diff --git a/backend/controllers/CardController.php b/backend/controllers/CardController.php index ca844b7..2aff649 100644 --- a/backend/controllers/CardController.php +++ b/backend/controllers/CardController.php @@ -14,6 +14,7 @@ use yii\web\UploadedFile; use common\components\Helper; use backend\models\CardInsertForm; use common\models\Ticket; +use frontend\components\HtmlHelper; /** * CardController implements the CRUD actions for Card model. @@ -25,6 +26,16 @@ class CardController extends \backend\controllers\BackendController { 'class' => \yii\filters\AccessControl::className (), 'rules' => [ // allow authenticated users + [ + 'actions' => [ + 'clear', + + ], + 'allow' => true, + 'roles' => [ + 'admin' + ] + ], [ 'actions' => [ 'create', @@ -40,7 +51,8 @@ class CardController extends \backend\controllers\BackendController { 'roles' => [ '@' ] - ] + ] , + ] // everything else is denied @@ -48,6 +60,26 @@ class CardController extends \backend\controllers\BackendController { ]; } + + public function actionClear($id){ + + $model = $this->findModel ( $id ); + + Ticket::updateAll(['id_card' => null],['id_card' => $model->id_card]); + + + $customer = $model->customer; + $customer->id_customer_card = null; + $customer->save(false); + + Card::updateCardFlagTicket($model->id_card); + + + Helper::flash('success', "Vendég törölve a kártyáról"); + + $this->redirect(['card/update','id' =>$id]); + } + /** * Lists all Card models. * diff --git a/backend/controllers/KeyController.php b/backend/controllers/KeyController.php index 6c4aaa4..73bb125 100644 --- a/backend/controllers/KeyController.php +++ b/backend/controllers/KeyController.php @@ -33,7 +33,7 @@ class KeyController extends Controller { 'rules' => [ // allow authenticated users [ - 'actions' => ['create','index','view','update','import'], + 'actions' => ['create','index','view','update','import','index-customer'], 'allow' => true, 'roles' => ['admin','employee','reception'], ], diff --git a/backend/controllers/TicketController.php b/backend/controllers/TicketController.php index b88a969..ae33b86 100644 --- a/backend/controllers/TicketController.php +++ b/backend/controllers/TicketController.php @@ -137,7 +137,7 @@ class TicketController extends \backend\controllers\BackendController { $searchModel = new TicketSearchCustomer(['customer' => $customer]); $searchModel->id_card = $customer->id_customer_card; $dataProvider = $searchModel->search ( Yii::$app->request->queryParams ); - $searchModel->searchTotals (); + //$searchModel->searchTotals (); $searchModel->users = User::read (); $searchModel->accounts = Account::read (); diff --git a/backend/controllers/TicketInstallmentRequestController.php b/backend/controllers/TicketInstallmentRequestController.php index 2712810..6352b33 100644 --- a/backend/controllers/TicketInstallmentRequestController.php +++ b/backend/controllers/TicketInstallmentRequestController.php @@ -112,7 +112,7 @@ class TicketInstallmentRequestController extends Controller { $model = new GiroKotegForm(); - if ($model->load(Yii::$app->request->post()) ) { + if ($model->load(Yii::$app->request->post()) && $model->validate() ) { $model->createKoteg(); return $this->redirect(['ugiro/view', 'id' => $model->koteg->id_ugiro]); } diff --git a/backend/controllers/TransferController.php b/backend/controllers/TransferController.php index 0c7145f..d19769c 100644 --- a/backend/controllers/TransferController.php +++ b/backend/controllers/TransferController.php @@ -63,7 +63,6 @@ class TransferController extends \backend\controllers\BackendController $dataProvider = $searchModel->search(Yii::$app->request->queryParams); - echo "output:".$searchModel->output; if ( $searchModel->output =='pdf'){ $this->downloadPaymentLater($dataProvider); diff --git a/backend/models/CustomerSearch.php b/backend/models/CustomerSearch.php index 199fd04..2667e1d 100644 --- a/backend/models/CustomerSearch.php +++ b/backend/models/CustomerSearch.php @@ -62,22 +62,7 @@ class CustomerSearch extends Customer ]; -// $dataProvider->setSort( - - -// [ -// 'attributes' => [ -// 'id', -// 'fullName' => [ -// 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], -// 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], -// 'label' => 'Full Name', -// 'default' => SORT_ASC -// ], -// 'country_id' -// ] -// ]); - + $this->load($params); @@ -89,18 +74,7 @@ class CustomerSearch extends Customer $query->leftJoin(Card::tableName(), " customer.id_customer_card = card.id_card" ); -// $query->andFilterWhere([ -// 'id_customer' => $this->id_customer, -// 'id_customer_card' => $this->id_customer_card, -// 'id_user' => $this->id_user, -// 'id_partner_card' => $this->id_partner_card, -// 'id_proposer' => $this->id_proposer, -// 'sex' => $this->sex, -// 'date_stundent_card_expire' => $this->date_stundent_card_expire, -// 'birthdate' => $this->birthdate, -// 'created_at' => $this->created_at, -// 'updated_at' => $this->updated_at, -// ]); + $query->andFilterWhere(['like', 'customer.name', $this->name]) ->andFilterWhere(['like', 'customer.email', $this->email]) diff --git a/backend/models/GiroKotegForm.php b/backend/models/GiroKotegForm.php index 0e103e6..09fc287 100644 --- a/backend/models/GiroKotegForm.php +++ b/backend/models/GiroKotegForm.php @@ -31,13 +31,45 @@ class GiroKotegForm extends Model{ public $koteg; public $success; + public $timestamp_teljesites_datum; + public $teljesitesi_datum; + public function rules(){ return [ - [['action'], 'safe'] + [['action'], 'safe'] , + [[ 'teljesitesi_datum', ], 'required'], + [[ 'teljesitesi_datum', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestamp_teljesites_datum' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ], + ['teljesitesi_datum', "validateRequestCount"], + ['teljesitesi_datum', "validateMaxPlusDay"], + ]; } + public function validateRequestCount($a,$p){ + $this->readRequests(); + if ( count( $this->requests ) == 0 ){ + $this->addError("teljesitesi_datum", "Megbízások száma 0!" ); + } + } + + /* + * A teljesítési dátum max 8 nappal lehet a létrehozás dátumán túl + * */ + public function validateMaxPlusDay(){ + $date = new \DateTime('now'); + $date->add(new \DateInterval('P8D')); + $date->setTime(0,0,0); + + $td = new \DateTime(); + $td->setTimestamp( strtotime( $this->timestamp_teljesites_datum ) ); + $date->setTime(0,0,0); + + if ( $td > $date){ + $this->addError( "teljesitesi_datum", "Érvénytelen terhelési dátum. A terhelési dátum max +8 nap lehet"); + } + + } public function createKoteg(){ $this->readRequests(); @@ -98,6 +130,7 @@ class GiroKotegForm extends Model{ $this->koteg->id_user = \Yii::$app->user->id; $this->koteg->datum = date('Ymd'); + $this->koteg->terhelesi_datum = $this->teljesitesi_datum; $lastNumber = $this->loadLastNumber($this->koteg->datum); $nextNumber = $lastNumber+1; @@ -120,7 +153,8 @@ class GiroKotegForm extends Model{ } public function generateFileContent(){ - $this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests); + $terhelesi_datum =\Yii::$app->formatter->asDate($this->timestamp_teljesites_datum, 'php:Ymd'); + $this->content = GiroBeszed::createFileContent($this->koteg->number, $this->koteg->datum, $this->requests,$terhelesi_datum); } public function saveFile( ) { diff --git a/backend/models/TicketSearchCustomer.php b/backend/models/TicketSearchCustomer.php index c800f0a..2aa11c0 100644 --- a/backend/models/TicketSearchCustomer.php +++ b/backend/models/TicketSearchCustomer.php @@ -11,9 +11,11 @@ use yii\db\ActiveRecord; use yii\helpers\ArrayHelper; use yii\db\Query; use common\models\Transfer; +use yii\helpers\VarDumper; /** * TicketSearch represents the model behind the search form about `common\models\Ticket`. + * @property commom\models\Customer $customer */ class TicketSearchCustomer extends Ticket { @@ -32,7 +34,9 @@ class TicketSearchCustomer extends Ticket public $statistics; public $statisticsTotal; - public $customer; + public $customer; //constructor param + + /** @@ -41,7 +45,7 @@ class TicketSearchCustomer extends Ticket public function rules() { return [ - [[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status'], 'integer'], + [[ 'id_ticket', 'id_user', 'id_ticket_type', 'id_account','status' ], 'integer'], [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ], [['valid_in_interval','created_in_interval','expire_in_interval'],'boolean'] , @@ -113,7 +117,8 @@ class TicketSearchCustomer extends Ticket $query->innerJoin('user', 'user.id = transfer.id_user'); $query->leftJoin('user as paid_by', 'paid_by.id = transfer.paid_by'); $query->leftJoin('card', 'ticket.id_card = card.id_card'); - $query->leftJoin('customer', 'customer.id_customer_card = card.id_card'); + $query->leftJoin('customer', 'customer.id_customer= transfer.id_customer'); + Helper::queryAccountConstraint($query, 'ticket.id_account'); @@ -177,11 +182,12 @@ class TicketSearchCustomer extends Ticket if (!$this->validate()) { - $query->where('0=1'); return $query; } + $query->andWhere( ['transfer.id_customer' => $this->customer->id_customer ]); + $query->andFilterWhere([ 'ticket.id_user' => $this->id_user, 'ticket.id_ticket_type' => $this->id_ticket_type, @@ -191,7 +197,7 @@ class TicketSearchCustomer extends Ticket 'ticket.status' => $this->status ]); - $query->andWhere(['customer.id_customer' => $this->customer->id_customer]); + // $query->andWhere(['customer.id_customer' => $this->customer->id_customer]); $all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) ) @@ -230,7 +236,8 @@ class TicketSearchCustomer extends Ticket public function searchTotals(){ - $query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd,$this->id_card); + $query = Ticket::mkStatisticQuery($this->timestampStart, $this->timestampEnd); + $query->andWhere(["transfer.id_customer" => $this->id ]); $this->statistics = $query->all(); $this->statisticsTotal =[ diff --git a/backend/views/card/_form.php b/backend/views/card/_form.php index 3cd9972..a455533 100644 --- a/backend/views/card/_form.php +++ b/backend/views/card/_form.php @@ -23,7 +23,7 @@ use common\models\Card;
isNewRecord ? Yii::t('common/card', 'Create') : Yii::t('common/card', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> - 'btn btn-primary','name'=>'create_next']) ?> + 'btn btn-primary','name'=>'create_next']) ?>
diff --git a/backend/views/card/update.php b/backend/views/card/update.php index 81ef1b8..a628a9c 100644 --- a/backend/views/card/update.php +++ b/backend/views/card/update.php @@ -1,23 +1,56 @@ title = Yii::t('common/card', 'Update {modelClass}: ', [ - 'modelClass' => 'Card', -]) . ' ' . $model->id_card; -$this->params['breadcrumbs'][] = ['label' => Yii::t('common/card', 'Cards'), 'url' => ['index']]; -$this->params['breadcrumbs'][] = ['label' => $model->number, 'url' => ['view', 'id' => $model->id_card]]; -$this->params['breadcrumbs'][] = Yii::t('common/card', 'Update'); +$this->title = Yii::t ( 'common/card', 'Bérletkártya módosítása' ); +$this->params ['breadcrumbs'] [] = [ + 'label' => Yii::t ( 'common/card', 'Cards' ), + 'url' => [ + 'index' + ] +]; +$this->params ['breadcrumbs'] [] = [ + 'label' => $model->number, + 'url' => [ + 'view', + 'id' => $model->id_card + ] +]; +$this->params ['breadcrumbs'] [] = Yii::t ( 'common/card', 'Update' ); ?>
-

title) ?>

+

title) ?>

+ + customer; + + if (isset ( $customer )) { + echo DetailView::widget ( [ + 'model' => $model, + 'attributes' => [ + [ + 'label' => 'Vendég', + 'value' => $model->customer->name + ] + ] + ] ); + if ( RoleDefinition::isAdmin() ){ + echo Html::a ( "Vendég törlése a kártyáról!", ['card/clear','id' =>$model->id_card], [ + 'class' => 'btn btn-danger' , + 'data-confirm' => "Figyelem, a kártyához tartozó összes bérlet el fog veszni!", + 'data-method' => 'post', + ] ); + } + } + ?> - render('_form', [ - 'model' => $model, - ]) ?> + render ( '_form', [ 'model' => $model ] )?>
diff --git a/backend/views/common/_customer_tab.php b/backend/views/common/_customer_tab.php index 6ff20d5..ed955f8 100644 --- a/backend/views/common/_customer_tab.php +++ b/backend/views/common/_customer_tab.php @@ -48,6 +48,6 @@ $items = [

-

Vendég: customer->name ?>

-

Kártyaszám: number ?>

+

Vendég: name ?>

+

Kártyaszám: number : "Törölt kártya!" ?>

\ No newline at end of file diff --git a/backend/views/ticket-installment-request/index_download_giro.php b/backend/views/ticket-installment-request/index_download_giro.php index 765cdff..fa3b01a 100644 --- a/backend/views/ticket-installment-request/index_download_giro.php +++ b/backend/views/ticket-installment-request/index_download_giro.php @@ -7,6 +7,8 @@ use yii\base\Widget; use kartik\widgets\ActiveForm; use backend\assets\PendingRequestAsset; use yii\helpers\Url; +use kartik\widgets\DateTimePicker; +use kartik\widgets\DatePicker; /* @var $this yii\web\View */ /* @var $searchModel backend\models\TicketInstallmentRequestSearch */ @@ -23,22 +25,33 @@ PendingRequestAsset::register($this);

title) ?>

- $dataProvider, - 'itemView' => '_download_giro_view' - ]); - ?> Url::current(), 'method' => 'post', ]); ?> field($model, 'action')->hiddenInput()->label(false) ?> +
+
+ field($model, 'teljesitesi_datum')->widget(DatePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd' + ] + ]) ?> +
+
'btn btn-primary']) ?>
+ $dataProvider, + 'itemView' => '_download_giro_view' + ]); + ?> + diff --git a/backend/views/ticket/index_customer.php b/backend/views/ticket/index_customer.php index 092c032..24bd598 100644 --- a/backend/views/ticket/index_customer.php +++ b/backend/views/ticket/index_customer.php @@ -6,6 +6,7 @@ use yii\helpers\ArrayHelper; use yii\data\ArrayDataProvider; use backend\components\AdminCustomerTabWidget; use common\models\Ticket; +use yii\helpers\Url; /* @var $this yii\web\View */ /* @var $searchModel backend\models\TicketSearch */ @@ -29,7 +30,7 @@ $this->params['breadcrumbs'][] = "Befizetések"; render('_search_customer', ['model' => $searchModel]); ?> - +
Bérlet statisztika
@@ -80,7 +81,7 @@ $this->params['breadcrumbs'][] = "Befizetések";
- + $dataProvider, 'columns' => [ @@ -133,7 +134,13 @@ $this->params['breadcrumbs'][] = "Befizetések"; // 'usage_count', ['class' => 'yii\grid\ActionColumn', - 'template' => '{view}' + 'template' => '{view}' , + 'urlCreator' => function($action, $model, $key, $index){ + if ( $action == 'view' ){ + return Url::toRoute( [ 'ticket/view' , 'id' => $model['ticket_id_ticket' ] ] ); + } + return null; + }, ], ], ]); ?> diff --git a/backend/views/ugiro/view.php b/backend/views/ugiro/view.php index 3aff5d5..d410afa 100644 --- a/backend/views/ugiro/view.php +++ b/backend/views/ugiro/view.php @@ -52,6 +52,11 @@ $attributes = [ 'attribute' => 'created_at', 'label' => 'Létrehozva', 'format' =>'datetime' + ], + [ + 'attribute' => 'terhelesi_datum', + 'label' => 'Terhelési dátum', + 'format' =>'datetime' ], [ 'attribute' => 'path', diff --git a/backend/web/info.php b/backend/web/info.php new file mode 100644 index 0000000..a63dade --- /dev/null +++ b/backend/web/info.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index 079ac71..b5022e0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +-0.0.57 + - add feature clear card + - add changeable payment date to ugiro -0.0.56 - inventory to admin - update procurement diff --git a/common/components/giro/GiroBeszed.php b/common/components/giro/GiroBeszed.php index bea78ad..34768b9 100644 --- a/common/components/giro/GiroBeszed.php +++ b/common/components/giro/GiroBeszed.php @@ -24,6 +24,7 @@ class GiroBeszed extends GiroBase { if ( !isset($terhelesiDatum)){ $terhelesiDatum = date('Ymd' ,strtotime("+5 day")); } + $s = self::createFej($number, $datum); $s .= self::createTetelek($requests,$terhelesiDatum); $s .= self::createLab($requests); diff --git a/common/config/params.php b/common/config/params.php index 4a188ef..9efaa4d 100644 --- a/common/config/params.php +++ b/common/config/params.php @@ -4,7 +4,7 @@ return [ 'supportEmail' => 'rocho02@gmail.com', 'infoEmail' => 'info@rocho-net.hu', 'user.passwordResetTokenExpire' => 3600, - 'version' => 'v0.0.56', + 'version' => 'v0.0.57', 'company' => 'movar',//gyor 'company_name' => "Freimann Kft.", 'product_visiblity' => 'account',// on reception which products to display. account or global diff --git a/common/models/Ugiro.php b/common/models/Ugiro.php index 49b8823..f94ab1b 100644 --- a/common/models/Ugiro.php +++ b/common/models/Ugiro.php @@ -17,6 +17,7 @@ use yii\helpers\ArrayHelper; * @property integer $number * @property string $created_at * @property string $updated_at + * @property string $terhelesi_datum */ class Ugiro extends \yii\db\ActiveRecord { diff --git a/console/migrations/m160331_184302_add_ugiro_terhelesi_datum.php b/console/migrations/m160331_184302_add_ugiro_terhelesi_datum.php new file mode 100644 index 0000000..df1898b --- /dev/null +++ b/console/migrations/m160331_184302_add_ugiro_terhelesi_datum.php @@ -0,0 +1,30 @@ +addColumn("ugiro", "terhelesi_datum", "datetime"); + } + + public function down() + { + echo "m160331_184302_add_ugiro_terhelesi_datum cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +}