1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Finance module for HiPanel |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
7
|
|
|
* @package hipanel-module-finance |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace hipanel\modules\finance\controllers; |
13
|
|
|
|
14
|
|
|
use hipanel\actions\IndexAction; |
15
|
|
|
use hipanel\actions\RedirectAction; |
16
|
|
|
use hipanel\actions\SmartPerformAction; |
17
|
|
|
use hipanel\actions\ValidateFormAction; |
18
|
|
|
use hipanel\actions\ViewAction; |
19
|
|
|
use hipanel\modules\finance\models\Purse; |
20
|
|
|
use Yii; |
21
|
|
|
|
22
|
|
|
class PurseController extends \hipanel\base\CrudController |
23
|
|
|
{ |
24
|
1 |
|
public function actions() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
'index' => [ |
28
|
1 |
|
'class' => IndexAction::class, |
29
|
1 |
|
], |
30
|
|
|
'view' => [ |
31
|
1 |
|
'class' => ViewAction::class, |
32
|
1 |
|
], |
33
|
|
|
'validate-form' => [ |
34
|
1 |
|
'class' => ValidateFormAction::class, |
35
|
1 |
|
], |
36
|
|
|
'invoice-archive' => [ |
37
|
1 |
|
'class' => RedirectAction::class, |
38
|
1 |
|
'error' => Yii::t('app', 'Under construction'), |
39
|
1 |
|
], |
40
|
|
|
'update-monthly-invoice' => [ |
41
|
1 |
|
'class' => SmartPerformAction::class, |
42
|
1 |
|
'success' => Yii::t('app', 'Invoice updated'), |
43
|
1 |
|
], |
44
|
1 |
|
]; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function actionGenerateInvoice($id, $month = null) |
48
|
|
|
{ |
49
|
|
|
$content_type = 'application/pdf'; |
50
|
|
|
$data = Purse::perform('GenerateMonthlyInvoice', compact('id', 'month')); |
51
|
|
|
$response = Yii::$app->getResponse(); |
52
|
|
|
$response->format = $response::FORMAT_RAW; |
53
|
|
|
$response->getHeaders()->add('content-type', $content_type); |
54
|
|
|
|
55
|
|
|
return $data; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|