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;
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);