Completed
Push — master ( 795753...9b7eb7 )
by Dmitry
10:52
created

PurseController::actions()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 31
ccs 20
cts 20
cp 1
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\controllers;
12
13
use hipanel\actions\IndexAction;
14
use hipanel\actions\RedirectAction;
15
use hipanel\actions\SmartPerformAction;
16
use hipanel\actions\SmartUpdateAction;
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
            'update' => [
34 1
                'class' => SmartUpdateAction::class,
35 1
            ],
36
            'update-contact' => [
37 1
                'class' => SmartUpdateAction::class,
38 1
            ],
39
            'update-requisite' => [
40 1
                'class' => SmartUpdateAction::class,
41 1
            ],
42
            'validate-form' => [
43 1
                'class' => ValidateFormAction::class,
44 1
            ],
45
            'invoice-archive' => [
46 1
                'class' => RedirectAction::class,
47 1
                'error' => Yii::t('hipanel', 'Under construction'),
48 1
            ],
49
            'update-monthly-document' => [
50 1
                'class'   => SmartPerformAction::class,
51 1
                'success' => Yii::t('hipanel:finance', 'Document updated'),
52 1
            ],
53 1
        ];
54
    }
55
56 View Code Duplication
    public function actionGenerateInvoice($id, $month = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
    {
58
        $content_type = 'application/pdf';
59
        $data = Purse::perform('generate-monthly-invoice', compact('id', 'month'));
60
        $response = Yii::$app->getResponse();
61
        $response->format = $response::FORMAT_RAW;
62
        $response->getHeaders()->add('content-type', $content_type);
63
64
        return $data;
65
    }
66
67 View Code Duplication
    public function actionGenerateMonthlyDocument($id, $type, $month = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
    {
69
        $content_type = 'application/pdf';
70
        $data = Purse::perform('generate-monthly-document', compact('id', 'type', 'month'));
71
        $response = Yii::$app->getResponse();
72
        $response->format = $response::FORMAT_RAW;
73
        $response->getHeaders()->add('content-type', $content_type);
74
75
        return $data;
76
    }
77
}
78