Completed
Push — master ( 8c1c91...aeff30 )
by Dmitry
05:55
created

PurseController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 74.07%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 45
ccs 20
cts 27
cp 0.7407
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B actions() 0 31 1
A actionGenerateInvoice() 0 10 1
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\SmartUpdateAction;
18
use hipanel\actions\ValidateFormAction;
19
use hipanel\actions\ViewAction;
20
use hipanel\modules\finance\models\Purse;
21
use Yii;
22
23
class PurseController extends \hipanel\base\CrudController
24 1
{
25
    public function actions()
26
    {
27
        return [
28 1
            'index' => [
29 1
                'class' => IndexAction::class,
30
            ],
31 1
            'view' => [
32 1
                'class' => ViewAction::class,
33
            ],
34 1
            'update' => [
35 1
                'class' => SmartUpdateAction::class,
36
            ],
37 1
            'update-contact' => [
38 1
                'class' => SmartUpdateAction::class,
39
            ],
40 1
            'update-requisite' => [
41 1
                'class' => SmartUpdateAction::class,
42
            ],
43 1
            'validate-form' => [
44 1
                'class' => ValidateFormAction::class,
45
            ],
46 1
            'invoice-archive' => [
47 1
                'class' => RedirectAction::class,
48 1
                'error' => Yii::t('hipanel', 'Under construction'),
49
            ],
50 1
            'update-monthly-invoice' => [
51 1
                'class'   => SmartPerformAction::class,
52 1
                'success' => Yii::t('hipanel:finance', 'Invoice updated'),
53 1
            ],
54
        ];
55
    }
56
57
    public function actionGenerateInvoice($id, $month = null)
58
    {
59
        $content_type = 'application/pdf';
60
        $data = Purse::perform('GenerateMonthlyInvoice', compact('id', 'month'));
61
        $response = Yii::$app->getResponse();
62
        $response->format = $response::FORMAT_RAW;
63
        $response->getHeaders()->add('content-type', $content_type);
64
65
        return $data;
66
    }
67
}
68