diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php
index 62bfbdc..9119d51 100644
--- a/backend/components/AdminMenuStructure.php
+++ b/backend/components/AdminMenuStructure.php
@@ -122,6 +122,18 @@ class AdminMenuStructure{
'items' => $items
];
}
+ /////////////////////////////
+ // Kap lug megbízások
+ /////////////////////////////
+ $items = [];
+ $items[] = ['label' => 'Mozgások', 'url' => ['/door-log/index' , 'DoorLogSearch[start]' =>$today,'DoorLogSearch[end]' => $tomorrow ] ];
+// $items[] = ['label' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ];
+// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
+// $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
+// $items[] = ['label' => 'Kassza müveletek', 'url' => ['/account-state/index'] ];
+ $this->menuItems[] = ['label' => 'Forgóvilla', 'url' => $this->emptyUrl,
+ 'items' => $items
+ ];
}
diff --git a/backend/controllers/DoorLogController.php b/backend/controllers/DoorLogController.php
new file mode 100644
index 0000000..ed97c17
--- /dev/null
+++ b/backend/controllers/DoorLogController.php
@@ -0,0 +1,121 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['post'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all DoorLog models.
+ * @return mixed
+ */
+ public function actionIndex()
+ {
+ $searchModel = new DoorLogSearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single DoorLog model.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new DoorLog model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new DoorLog();
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id_door_log]);
+ } else {
+ return $this->render('create', [
+ 'model' => $model,
+ ]);
+ }
+ }
+
+ /**
+ * Updates an existing DoorLog model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionUpdate($id)
+ {
+ $model = $this->findModel($id);
+
+ if ($model->load(Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect(['view', 'id' => $model->id_door_log]);
+ } else {
+ return $this->render('update', [
+ 'model' => $model,
+ ]);
+ }
+ }
+
+ /**
+ * Deletes an existing DoorLog model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionDelete($id)
+ {
+ $this->findModel($id)->delete();
+
+ return $this->redirect(['index']);
+ }
+
+ /**
+ * Finds the DoorLog model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return DoorLog the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = DoorLog::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+}
diff --git a/backend/controllers/TestController.php b/backend/controllers/TestController.php
new file mode 100644
index 0000000..a2d33ef
--- /dev/null
+++ b/backend/controllers/TestController.php
@@ -0,0 +1,30 @@
+load(\Yii::$app->request->post()) ) {
+ $model->run();
+ }
+
+ return $this->render("_create_beszed",['model' => $model]);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/backend/controllers/UgiroController.php b/backend/controllers/UgiroController.php
index 444426e..e9aee21 100644
--- a/backend/controllers/UgiroController.php
+++ b/backend/controllers/UgiroController.php
@@ -184,6 +184,13 @@ class UgiroController extends Controller
}
+ public function actionGenerateDetsta(){
+
+
+
+ }
+
+
/**
* Finds the Ugiro model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
diff --git a/backend/detsta.txt b/backend/detsta.txt
index 20598c0..29269c8 100644
--- a/backend/detsta.txt
+++ b/backend/detsta.txt
@@ -1,4 +1,4 @@
-01DETSTA8A24237545 201501270001201502094542162957
+01DETSTA8A24237545 201601250001201601254542162957
020000010000014097201501270020150204201502031104 03916201502031001307001595 0015520150127321538700000000000000000000000340
020000020000015240201501275020150204 1117 73377201502033417908001595 0015520150127321538800000000000000000000000347
020000030000015240201501270020150204201502031120 94002201502030005151001595 0015520150127321538900000000000000000000000176
diff --git a/backend/models/DoorLogSearch.php b/backend/models/DoorLogSearch.php
new file mode 100644
index 0000000..6bad50b
--- /dev/null
+++ b/backend/models/DoorLogSearch.php
@@ -0,0 +1,147 @@
+ 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
+ [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
+
+ ];
+ }
+
+ public function attributeLabels(){
+ return [
+ 'searchCardNumber' => 'Kártya szám',
+ 'searchCustomerName' => 'Vendég',
+ 'searchKeyName' => 'Kulcs szám',
+ 'type' => 'Típus',
+ 'direction' => 'Irány',
+ 'start' => 'Időszak kezdete',
+ 'end' => 'Időszak vége'
+ ];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function scenarios()
+ {
+ // bypass scenarios() implementation in the parent class
+ return Model::scenarios();
+ }
+
+ /**
+ * Creates data provider instance with search query applied
+ *
+ * @param array $params
+ *
+ * @return ActiveDataProvider
+ */
+ public function search($params)
+ {
+ $query = DoorLog::find();
+
+ $dataProvider = new ActiveDataProvider([
+ 'query' => $query,
+ 'sort' =>[
+ 'attributes' => [
+// 'age',
+ 'id_card' => [
+ 'asc' => ['card.number' => SORT_ASC ],
+ 'desc' => ['card.number' => SORT_DESC],
+ ],
+ 'id_key' => [
+ 'asc' => ['key.number' => SORT_ASC ],
+ 'desc' => ['key.number' => SORT_DESC],
+ ],
+ 'id_customer' => [
+ 'asc' => ['customer.name' => SORT_ASC ],
+ 'desc' => ['customer.name' => SORT_DESC],
+ ],
+ 'direction' => [
+ 'asc' => ['door_log.direction' => SORT_ASC ],
+ 'desc' => ['door_log.direction' => SORT_DESC],
+ ],
+ 'created_at' => [
+ 'asc' => ['door_log.created_at' => SORT_ASC ],
+ 'desc' => ['door_log.created_at' => SORT_DESC],
+ ],
+ ],
+ ]
+ ]);
+
+ $this->load($params);
+
+ if (!$this->validate()) {
+ // uncomment the following line if you do not want to return any records when validation fails
+ // $query->where('0=1');
+ return $dataProvider;
+ }
+
+ $query->andFilterWhere([
+// 'id_door_log' => $this->id_door_log,
+// 'id_card' => $this->id_card,
+// 'id_customer' => $this->id_customer,
+// 'id_key' => $this->id_key,
+ 'direction' => $this->direction,
+// 'type' => $this->type,
+// 'created_at' => $this->created_at,
+ ]);
+
+ $query->andFilterWhere(['>=', 'door_log.created_at', $this->timestampStart]);
+ $query->andFilterWhere(['<', 'door_log.created_at', $this->timestampEnd]);
+
+ $query->innerJoin('card','card.id_card = door_log.id_card');
+ $query->leftJoin('key','key.id_key = door_log.id_key');
+ $query->leftJoin('customer','customer.id_customer = door_log.id_customer');
+
+ if ( !empty($this->searchCardNumber)){
+ $query->andWhere(['or',
+ ['and',[ 'in','card.number' , [$this->searchCardNumber]],"trim(coalesce(card.number, '')) <>'' " ],
+ ['and', ['in','card.rfid_key' ,[ $this->searchCardNumber] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
+
+ ]);
+ }
+
+ if ( !empty($this->searchKeyName)){
+ $query->andWhere(['or',
+ ['and',[ 'in','key.number' , [$this->searchKeyName]],"trim(coalesce(key.number, '')) <>'' " ],
+ ['and', ['in','key.rfid_key' ,[ $this->searchKeyName] ],"trim(coalesce(key.rfid_key, '')) <>'' "]
+
+ ]);
+ }
+
+ $query->andFilterWhere(['like', 'customer.name', $this->searchCustomerName]);
+
+ return $dataProvider;
+ }
+}
diff --git a/backend/models/GenerateDetstaForm.php b/backend/models/GenerateDetstaForm.php
new file mode 100644
index 0000000..8677c70
--- /dev/null
+++ b/backend/models/GenerateDetstaForm.php
@@ -0,0 +1,85 @@
+id_giro);
+ $requests = $ugiro->requests;
+
+ $this->detstatUzenet = new GiroDETSTA();
+
+ $fej = new GiroDETSTAFej();
+ $fej->csoportosUzenetSorszam->osszeallitasDatuma = $ugiro->datum;
+ $fej->csoportosUzenetSorszam->sorszam = $ugiro->number;
+ $fej->detstaUzenetSorszam->osszeallitasDatuma = $ugiro->datum;
+ $fej->detstaUzenetSorszam->sorszam = $ugiro->number;
+ $fej->ido = "141414";
+ $fej->jelentesJelzo = "8";
+ $fej->kezdemenyezoAzonosito = \Yii::$app->params['ugiro_kezdemenyezo_azonosito'];
+ $fej->kezdemenyezoBankszamla = \Yii::$app->params['ugiro_kezdemenyezo_szamlaszam'];
+
+ $this->detstatUzenet->fej = $fej;
+
+ foreach ($requests as $request){
+ $tetel = new GiroDETSTATetel();
+ $tetel->tetelSorszam = $request->number;
+ $tetel->osszeg = $request->money;
+ $tetel->eredetiTetelElszamolasiDatuma = date('Ymd');
+ $tetel->visszajelzesInformacio = "00";
+ $tetel->feldolgozasDatum = date('Ymd');
+ $tetel->terhelesiDatum = date('Ymd');
+ $tetel->eredetiHivatkozasiKod = "abc123";
+ $tetel->ugyfelAzonosito = $request->id_customer;
+
+ $this->detstatUzenet->tetelek[] = $tetel;
+ }
+
+ $lab = new GiroDETSTALab();
+ $lab->teljesitettTetelekSzama = 0;
+ $lab->teljesitettTetelekOsszerteke = 0;
+ $lab->megNemValaszoltTetelekOsszerteke = 0;
+ $lab->megNemValaszoltTetelekSzama = 0;
+ $lab->visszautasitottTetelekOsszerteke = 0;
+ $lab->visszautasitottTetelekSzama = 0;
+
+ $this->detstatUzenet->lab = $lab;
+
+
+ $this->uzenet = $this->detstatUzenet->toString();
+ }
+
+
+}
\ No newline at end of file
diff --git a/backend/models/GiroBeszedForm.php b/backend/models/GiroBeszedForm.php
new file mode 100644
index 0000000..89fc13e
--- /dev/null
+++ b/backend/models/GiroBeszedForm.php
@@ -0,0 +1,183 @@
+fej_osszeallitasDatuma = date('Ymd');
+ $this->ertesitesiHatarido = date('Ymd');
+ $this->terhelesiDatum = date('Ymd', strtotime('tomorrow'));
+ }
+
+
+ public function rules(){
+ return [
+ [ [ 'fej_recordTipus' ,
+ 'uzenetTipus' ,
+ 'duplumKod' ,
+ 'kezdemenyezoAzonosito' ,
+
+// 'uzenetSorszam' ,
+ 'fej_osszeallitasDatuma',
+ 'fej_sorszam',
+
+ 'kezdemenyezoBankszamla' ,
+
+ 'ertesitesiHatarido' ,
+ 'jogcim' ,
+ 'kezdemenyezoCegNeve' ,
+ 'kozlemeny' ,
+
+
+ 'rekordTipus' ,
+ 'tetelekSzama' ,
+ 'tetelekOsszerteke' ,
+
+ 'rekordTipus' ,
+ 'tetelSorszam' ,
+ 'terhelesiDatum' ,
+ 'osszeg' ,
+ 'kotelezettBankszamla' ,
+ 'ugyfelazonositoAKezdemenyezonel' ,
+ 'ugyfelNeve' ,
+ 'ugyfelCime' ,
+ 'szamlaTulajdonosNeve' ,
+ 'kozlemeny' ,] ,'string']
+ ];
+ }
+
+
+
+ public function run(){
+ $this->validate();
+ $uzenet = new GiroBeszed();
+ $fej = new GiroBeszedFej();
+ $lab = new GiroBeszedLab();
+ $tetel = new GiroBeszedTetel();
+
+
+ $fej->recordTipus = $this->fej_recordTipus;
+ $fej->uzenetTipus = $this->uzenetTipus;
+ $fej->duplumKod = $this->duplumKod;
+ $fej->kezdemenyezoAzonosito = $this->kezdemenyezoAzonosito;
+ $fej->uzenetSorszam->osszeallitasDatuma = $this->fej_osszeallitasDatuma;
+ $fej->uzenetSorszam->sorszam = $this->fej_sorszam;
+ $fej->kezdemenyezoBankszamla->szamlaszam = $this->kezdemenyezoBankszamla;
+ $fej->ertesitesiHatarido = $this->ertesitesiHatarido;
+ $fej->jogcim = $this->jogcim;
+ $fej->kezdemenyezoCegNeve = $this->kezdemenyezoCegNeve;
+ $fej->kozlemeny = $this->fej_kozlemeny;
+
+//
+ /***/
+
+ $lab->rekordTipus = $this->lab_rekordTipus;
+ $lab->tetelekSzama = $this->tetelekSzama;
+ $lab->tetelekOsszerteke = $this->tetelekOsszerteke;
+
+ //tetel
+
+
+ $tetel->rekordTipus = $this->rekordTipus;
+ $tetel->tetelSorszam = $this->tetelSorszam;
+ $tetel->terhelesiDatum = $this->terhelesiDatum;
+ $tetel->osszeg = $this->osszeg;
+ $tetel->kotelezettBankszamla->szamlaszam = $this->kotelezettBankszamla;
+ $tetel->ugyfelazonositoAKezdemenyezonel = $this->ugyfelazonositoAKezdemenyezonel;
+ $tetel->ugyfelNeve = $this->ugyfelNeve;
+ $tetel->ugyfelCime = $this->ugyfelCime;
+ $tetel->szamlaTulajdonosNeve = $this->szamlaTulajdonosNeve;
+ $tetel->kozlemeny = $this->kozlemeny;
+
+ $uzenet->fej = $fej;
+ $uzenet->tetelek[] = $tetel;
+ $uzenet->lab = $lab;
+
+ $this->uzenet_szoveg = $uzenet->toString();
+
+ }
+
+}
\ No newline at end of file
diff --git a/backend/models/GiroKotegForm.php b/backend/models/GiroKotegForm.php
index 400e236..4a2745c 100644
--- a/backend/models/GiroKotegForm.php
+++ b/backend/models/GiroKotegForm.php
@@ -80,7 +80,11 @@ class GiroKotegForm extends Model{
}
public function assignRequestsToUgiro(){
+ $i = 0;
foreach ($this->requests as $request){
+ $i++;
+ $request->number = $i;
+ $request->save(false);
$assignment = new UgiroRequestAssignment();
$assignment->id_request = $request->id_ticket_installment_request;
$assignment->id_ugiro = $this->koteg->id_ugiro;
diff --git a/backend/models/TicketInstallmentRequestSearch.php b/backend/models/TicketInstallmentRequestSearch.php
index 0d5ce27..b73cd39 100644
--- a/backend/models/TicketInstallmentRequestSearch.php
+++ b/backend/models/TicketInstallmentRequestSearch.php
@@ -38,7 +38,7 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
public function rules()
{
return [
- [['id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type','id_ugiro'], 'integer'],
+ [[ 'id_contract', 'id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type','id_ugiro'], 'integer'],
[['customer_name' ], 'safe'],
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
@@ -83,7 +83,9 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
'ticket_installment_request.status as request_status',//status
'ticket_installment_request.request_sent_at as request_sent_at',//sent_at
'ticket_installment_request.priority as request_priority',//sent_at
+ 'ticket_installment_request.number as request_number',//sent_at
'ticket_installment_request.request_processed_at as request_processed_at',//request_processed_at
+ 'ticket_installment_request.id_contract as request_id_contract',//request_processed_at
'customer.id_customer as customer_id_customer',//id_customer
'customer.name as customer_name',//customer_name
'ticket_type.name as ticket_type_name',//ticket_type_name
@@ -95,8 +97,8 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
]);
$query->from("ticket_installment_request");
$query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer");
- $query->innerJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
- $query->innerJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
+ $query->leftJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
+ $query->leftJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
$query->leftJoin("ugiro_request_assignment","ticket_installment_request.id_ticket_installment_request = ugiro_request_assignment.id_request");
$query->orderBy(["ticket_installment_request.request_target_time_at" => SORT_ASC]);
@@ -107,6 +109,7 @@ class TicketInstallmentRequestSearch extends TicketInstallmentRequest
'customer.id_customer' => $this->id_customer,
'ticket_installment_request.status' => $this->status,
'ticket_type.id_ticket_type' => $this->id_ticket_type,
+ 'ticket_installment_request.id_contract' => $this->id_contract,
]);
$query->andFilterWhere(['like', 'customer.name', $this->customer_name]);
//target time
diff --git a/backend/models/TicketInstallmentRequestSearchDownloadGiro.php b/backend/models/TicketInstallmentRequestSearchDownloadGiro.php
index 303d38b..b834383 100644
--- a/backend/models/TicketInstallmentRequestSearchDownloadGiro.php
+++ b/backend/models/TicketInstallmentRequestSearchDownloadGiro.php
@@ -80,8 +80,8 @@ class TicketInstallmentRequestSearchDownloadGiro extends TicketInstallmentReques
]);
$query->from("ticket_installment_request");
$query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer");
- $query->innerJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
- $query->innerJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
+ $query->leftJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
+ $query->leftJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
$query->andWhere(['ticket_installment_request.status' => TicketInstallmentRequest::$STATUS_MARKED_TO_SEND]);
diff --git a/backend/models/TicketInstallmentRequestSearchPending.php b/backend/models/TicketInstallmentRequestSearchPending.php
index 4a69ddd..dd25d74 100644
--- a/backend/models/TicketInstallmentRequestSearchPending.php
+++ b/backend/models/TicketInstallmentRequestSearchPending.php
@@ -28,7 +28,7 @@ class TicketInstallmentRequestSearchPending extends TicketInstallmentRequest
public function rules()
{
return [
- [['id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type'], 'integer'],
+ [[ 'id_contract', 'id_ticket_installment_request', 'id_ticket', 'id_customer', 'status' ,'id_ticket_type'], 'integer'],
[['customer_name' ], 'safe'],
[[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
@@ -69,6 +69,7 @@ class TicketInstallmentRequestSearchPending extends TicketInstallmentRequest
'ticket_installment_request.status as request_status',//status
'ticket_installment_request.request_sent_at as request_sent_at',//sent_at
'ticket_installment_request.priority as request_priority',//sent_at
+ 'ticket_installment_request.id_contract as request_id_contract',//sent_at
'ticket_installment_request.request_processed_at as request_processed_at',//request_processed_at
'customer.id_customer as customer_id_customer',//id_customer
'customer.name as customer_name',//customer_name
@@ -80,8 +81,8 @@ class TicketInstallmentRequestSearchPending extends TicketInstallmentRequest
]);
$query->from("ticket_installment_request");
$query->innerJoin("customer","customer.id_customer = ticket_installment_request.id_customer");
- $query->innerJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
- $query->innerJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
+ $query->leftJoin("ticket","ticket.id_ticket = ticket_installment_request.id_ticket");
+ $query->leftJoin("ticket_type","ticket.id_ticket_type = ticket_type.id_ticket_type");
$query->andWhere(['ticket_installment_request.status' => TicketInstallmentRequest::$STATUS_PENDING]);
@@ -93,6 +94,7 @@ class TicketInstallmentRequestSearchPending extends TicketInstallmentRequest
'customer.id_customer' => $this->id_customer,
'ticket_installment_request.status' => $this->status,
'ticket_type.id_ticket_type' => $this->id_ticket_type,
+ 'ticket_installment_request.id_contract' => $this->id_contract,
]);
$query->andFilterWhere(['like', 'customer.name', $this->customer_name]);
//target time
diff --git a/backend/views/customer/index.php b/backend/views/customer/index.php
index a4c7a25..8fdb96b 100644
--- a/backend/views/customer/index.php
+++ b/backend/views/customer/index.php
@@ -23,6 +23,7 @@ $this->params['breadcrumbs'][] = $this->title;
= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
+ 'id_customer',
[
'attribute' => 'customerCardNumber' ,
],
diff --git a/backend/views/door-log/_form.php b/backend/views/door-log/_form.php
new file mode 100644
index 0000000..7f13743
--- /dev/null
+++ b/backend/views/door-log/_form.php
@@ -0,0 +1,33 @@
+
+
+
diff --git a/backend/views/door-log/_search.php b/backend/views/door-log/_search.php
new file mode 100644
index 0000000..5313484
--- /dev/null
+++ b/backend/views/door-log/_search.php
@@ -0,0 +1,66 @@
+
+
+
+
+ ['index'],
+ 'method' => 'get',
+ ]); ?>
+
+
+
+ = $form->field($model, 'searchCardNumber') ?>
+
+
+
+ = $form->field($model, 'searchCustomerName') ?>
+
+
+
+ = $form->field($model, 'searchKeyName') ?>
+
+
+
+ = $form->field($model, 'direction')->dropDownList(['' => 'Mind' ] + []) ?>
+
+
+
+ field($model, 'type') ?>
+
+ field($model, 'created_at') ?>
+
+
+
+ = $form->field($model, 'start')->widget(DatePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd'
+ ]
+ ]) ?>
+
+
+ = $form->field($model, 'end') ->widget(DatePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd'
+ ]
+ ]) ?>
+
+
+
+
+ = Html::submitButton(Yii::t('common/door_log', 'Search'), ['class' => 'btn btn-primary']) ?>
+
+
+
+
+
diff --git a/backend/views/door-log/create.php b/backend/views/door-log/create.php
new file mode 100644
index 0000000..538a34e
--- /dev/null
+++ b/backend/views/door-log/create.php
@@ -0,0 +1,21 @@
+title = Yii::t('common/door_log', 'Create Door Log');
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/door_log', 'Door Logs'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/views/door-log/index.php b/backend/views/door-log/index.php
new file mode 100644
index 0000000..a1b0f01
--- /dev/null
+++ b/backend/views/door-log/index.php
@@ -0,0 +1,45 @@
+title = Yii::t('common/door_log', 'Mozgások');
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+ render('_search', ['model' => $searchModel]); ?>
+
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ ['class' => 'yii\grid\SerialColumn'],
+ [
+ 'attribute' => 'id_card',
+ 'value' => 'cardNumber'
+ ],
+ [
+ 'attribute' => 'id_key',
+ 'value' => 'keyNumber'
+ ],
+ [
+ 'attribute' => 'id_customer',
+ 'value' => 'customerName'
+ ],
+ [
+ 'attribute' => 'direction',
+ 'value' => 'directionName'
+ ],
+ // 'type',
+ 'created_at:datetime',
+
+ ],
+ ]); ?>
+
+
diff --git a/backend/views/door-log/update.php b/backend/views/door-log/update.php
new file mode 100644
index 0000000..752240f
--- /dev/null
+++ b/backend/views/door-log/update.php
@@ -0,0 +1,23 @@
+title = Yii::t('common/door_log', 'Update {modelClass}: ', [
+ 'modelClass' => 'Door Log',
+]) . ' ' . $model->id_door_log;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/door_log', 'Door Logs'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->id_door_log, 'url' => ['view', 'id' => $model->id_door_log]];
+$this->params['breadcrumbs'][] = Yii::t('common/door_log', 'Update');
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/backend/views/door-log/view.php b/backend/views/door-log/view.php
new file mode 100644
index 0000000..c1ccb50
--- /dev/null
+++ b/backend/views/door-log/view.php
@@ -0,0 +1,41 @@
+title = $model->id_door_log;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/door_log', 'Door Logs'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+
+ = Html::a(Yii::t('common/door_log', 'Update'), ['update', 'id' => $model->id_door_log], ['class' => 'btn btn-primary']) ?>
+ = Html::a(Yii::t('common/door_log', 'Delete'), ['delete', 'id' => $model->id_door_log], [
+ 'class' => 'btn btn-danger',
+ 'data' => [
+ 'confirm' => Yii::t('common/door_log', 'Are you sure you want to delete this item?'),
+ 'method' => 'post',
+ ],
+ ]) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id_door_log',
+ 'id_card',
+ 'id_customer',
+ 'id_key',
+ 'direction',
+ 'type',
+ 'created_at',
+ ],
+ ]) ?>
+
+
diff --git a/backend/views/test/_create_beszed.php b/backend/views/test/_create_beszed.php
new file mode 100644
index 0000000..13cc5f8
--- /dev/null
+++ b/backend/views/test/_create_beszed.php
@@ -0,0 +1,4 @@
+create beszed
+
+
+ render('beszed_form', ['model' => $model]); ?>
diff --git a/backend/views/test/beszed_form.php b/backend/views/test/beszed_form.php
new file mode 100644
index 0000000..2d8d5a3
--- /dev/null
+++ b/backend/views/test/beszed_form.php
@@ -0,0 +1,52 @@
+
+
diff --git a/backend/views/ticket-installment-request/_index_view.php b/backend/views/ticket-installment-request/_index_view.php
index f793404..ddd8adf 100644
--- a/backend/views/ticket-installment-request/_index_view.php
+++ b/backend/views/ticket-installment-request/_index_view.php
@@ -51,7 +51,7 @@ use yii\helpers\Html;
|
- Megbízás inditására irányzott dátum
+ Megbízás esedékességének dátuma
|
formatter->asDatetime( $model['request_request_target_time_at'] );?>
@@ -84,8 +84,10 @@ use yii\helpers\Html;
|
+ Szerződés azonosító
|
+
|
@@ -145,6 +147,22 @@ use yii\helpers\Html;
|
+
+ |
+ Sorszám a kötegben belül
+ |
+
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
$model['request_id_ticket_installment_request']] ,[ 'class' => 'btn btn-primary']);
if ( !empty( $model['ticket_id_ticket'] )){
- echo Html::a("Bérlet részletei",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ticket]' => $model['ticket_id_ticket']] ,[ 'class' => 'btn btn-primary']);
+ echo Html::a("Szerződés megbízásai",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_contract]' => $model['request_id_contract']] ,[ 'class' => 'btn btn-primary']);
}
?>
diff --git a/backend/views/ticket-installment-request/_pending_view.php b/backend/views/ticket-installment-request/_pending_view.php
index ab4ed8d..d69b0c9 100644
--- a/backend/views/ticket-installment-request/_pending_view.php
+++ b/backend/views/ticket-installment-request/_pending_view.php
@@ -47,10 +47,10 @@ use yii\helpers\Html;
|
- Megbízás inditására irányzott dátum
+ Megbízás esedékességének dátuma
|
- formatter->asDatetime( $model['request_request_target_time_at'] );?>
+ formatter->asDate( $model['request_request_target_time_at'] );?>
|
Megbízás elindításának ideje
@@ -78,8 +78,10 @@ use yii\helpers\Html;
|
|
+ Szerződés azonosíót
|
+
|
diff --git a/backend/views/ticket-installment-request/_search.php b/backend/views/ticket-installment-request/_search.php
index d4a7091..55fef46 100644
--- a/backend/views/ticket-installment-request/_search.php
+++ b/backend/views/ticket-installment-request/_search.php
@@ -39,6 +39,9 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
+
+ = $form->field($model, 'id_contract')->label("Szerződés azonosító") ?>
+
= $form->field($model, 'customer_name')->label("Vendég neve") ?>
@@ -56,7 +59,7 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
- ])->label('Megbízás inditására irányzott kezdete ( inklúzív )') ?>
+ ])->label('Megbízás esedékességének kezdete ( inklúzív )') ?>
= $form->field($model, 'end') ->widget(DatePicker::classname(), [
@@ -64,7 +67,7 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
- ])->label('Megbízás inditására irányzott dátum vége ( exklúzív )') ?>
+ ])->label('Megbízás esedékességének vége ( exklúzív )') ?>
diff --git a/backend/views/ticket-installment-request/_search_pending.php b/backend/views/ticket-installment-request/_search_pending.php
index c2443c9..a46d9b9 100644
--- a/backend/views/ticket-installment-request/_search_pending.php
+++ b/backend/views/ticket-installment-request/_search_pending.php
@@ -37,6 +37,9 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
+
+ = $form->field($model, 'id_contract')->label("Szerződés azonosító") ?>
+
= $form->field($model, 'customer_name')->label("Vendég neve") ?>
@@ -68,7 +71,6 @@ $ticketTypeOptions = ['' => 'Mind'] + ArrayHelper::map(TicketType::read(), 'i
= Html::submitButton(Yii::t('common/ticket_installment_request', 'Search'), ['class' => 'btn btn-primary']) ?>
- = Html::resetButton(Yii::t('common/ticket_installment_request', 'Reset'), ['class' => 'btn btn-default']) ?>
diff --git a/backend/views/ticket-installment-request/view.php b/backend/views/ticket-installment-request/view.php
index bf931e9..111e534 100644
--- a/backend/views/ticket-installment-request/view.php
+++ b/backend/views/ticket-installment-request/view.php
@@ -48,7 +48,9 @@ $this->params['breadcrumbs'][] = $this->title;
isStatusRejected()){
- echo Html::a("Teljesítettnek jelölés",['accept', 'id' => $model->id_ticket_installment_request] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
+ //echo Html::a("Teljesítettnek jelölés",['accept', 'id' => $model->id_ticket_installment_request] ,['data-method' =>'post', 'class' => 'btn btn-danger']);
+
+ echo "Teljesítettnek jelölés a recepciós felületen lehetséges!";
}
?>
@@ -132,6 +134,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
+ ticket)) {?>
|
Bérlet azonosító
@@ -170,24 +173,25 @@ $this->params['breadcrumbs'][] = $this->title;
|
|
+
|
- Bérlet részletek száma
+ Szerződés részletek száma
|
- ticket->part_count ;?>
+ contract->part_count ;?>
|
- Bérlet esedékes részlet
+ Szerződés esedékes részlet
|
- ticket->part ;?>
+ contract->part_required ;?>
|
- Bérlet utoljára fizetett részlet
+ Szerződés utoljára fizetett részlet
|
- ticket->part_paid ;?>
+ contract->part_paid ;?>
|
@@ -216,7 +220,7 @@ if ( !empty( $model->idGiro )){
echo Html::a("Köteg",['ugiro/view', 'id' => $model->idGiro] ,[ 'class' => 'btn btn-primary']);
echo Html::a("Részletek a kötegben",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ugiro]' => $model->idGiro] ,[ 'class' => 'btn btn-primary']);
}
-echo Html::a("Bérlet fizetési részletei",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_ticket]' => $model->id_ticket] ,[ 'class' => 'btn btn-primary']);
+echo Html::a("Szerzőés megbízásai",['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_contract]' => $model->id_contract] ,[ 'class' => 'btn btn-primary']);
?>
diff --git a/changelog.txt b/changelog.txt
index 219b59b..d22144b 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,6 @@
+-0.0.27
+ - Add contract (szerződés )
+ - Add door_log ( mozgások )
-0.0.26
- Fix GiroUzenetsorszam case sensitive class/file name match
-0.0.25
diff --git a/common/components/DetStatProcessor.php b/common/components/DetStatProcessor.php
index e9141fa..1bf782b 100644
--- a/common/components/DetStatProcessor.php
+++ b/common/components/DetStatProcessor.php
@@ -66,35 +66,43 @@ class DetStatProcessor extends Object{
-
+ /*
$this->detstatUzenet = new GiroDETSTA();
- $this->idKoteg = 33;
+ $this->idKoteg = 38;
$fej = new GiroDETSTAFej();
$this->detstatUzenet->fej = $fej;
$tetel = new GiroDETSTATetel();
- $tetel->ugyfelAzonosito = 12;
+ $tetel->tetelSorszam = 1;
$tetel->visszajelzesInformacio = "00";
- $tetel->visszajelzesInformacio = "02";
+// $tetel->visszajelzesInformacio = "02";
+
+ $this->detstatUzenet->tetelek[] = $tetel;
+
+ $tetel = new GiroDETSTATetel();
+ $tetel->tetelSorszam = 2;
+ $tetel->visszajelzesInformacio = "00";
+ $tetel->visszajelzesInformacio = "02";
$this->detstatUzenet->tetelek[] = $tetel;
$lab = new GiroDETSTALab();
$this->detstatUzenet->lab = $lab;
+ */
}
public function createMegbizasTetelHozzarendelesek(){
$mapTetel = [];
foreach ($this->detstatUzenet->tetelek as $tetel ){
- $mapTetel[$tetel->ugyfelAzonosito] = $tetel;
+ $mapTetel[$tetel->tetelSorszam] = $tetel;
}
foreach ($this->megbizasok as $megbizas){
- if ( array_key_exists($megbizas->id_ticket_installment_request, $mapTetel)){
- $megbizas->detstaTetel = $mapTetel[$megbizas->id_ticket_installment_request];
+ if ( array_key_exists($megbizas->number, $mapTetel)){
+ $megbizas->detstaTetel = $mapTetel[$megbizas->number];
}
}
diff --git a/common/components/Helper.php b/common/components/Helper.php
index 71a6fde..d47e876 100644
--- a/common/components/Helper.php
+++ b/common/components/Helper.php
@@ -6,10 +6,20 @@ use \Yii;
class Helper {
- public static function getDateTimeString(){
+ public static function getDateTimeString( ){
+
return date("Y-m-d H:i:s");
}
+ public static function getArrayValue($arr,$key,$def){
+ $result = $def;
+ if ( array_key_exists($key, $arr)){
+ $result = $arr[$key];
+ }
+ return $result;
+ }
+
+
public static function hufRound($m) {
$result = round ( $m / 5, 0 ) * 5;
return $result;
diff --git a/common/components/giro/GiroBeszed.php b/common/components/giro/GiroBeszed.php
index 3d3ba31..a3e6681 100644
--- a/common/components/giro/GiroBeszed.php
+++ b/common/components/giro/GiroBeszed.php
@@ -5,13 +5,16 @@ namespace common\components\giro;
use common\components\giro\GiroBase;
/**
- *
- * @property common\components\giro\GiroUzenetsorszam $uzenetSorszam
- * @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla
+ *@property common\components\giro\GiroBeszedFej $fej
+ *@property common\components\giro\GiroBeszedLab $lab
+ *@property common\components\giro\GiroBeszedTetel[] $tetelek
*
*/
class GiroBeszed extends GiroBase {
+ public $fej;
+ public $lab;
+ public $tetelek = [];
public function __construct() {
}
@@ -36,7 +39,7 @@ class GiroBeszed extends GiroBase {
$fej->kezdemenyezoBankszamla->szamlaszam = \Yii::$app->params['ugiro_kezdemenyezo_szamlaszam']; // "5860025215371128";
// $fej->kezdemenyezoBankszamla->bankszerv = "58600252"; // "TAKBHUHB";
$fej->ertesitesiHatarido = "";
- $fej->kezdemenyezoCegNeve = \Yii::$app->params['company'];
+ $fej->kezdemenyezoCegNeve = \Yii::$app->params['company_name'];
return $fej->toString ();
}
@@ -57,16 +60,16 @@ class GiroBeszed extends GiroBase {
public static function createTetel($request,$sorszam,$terhelesiDatum) {
$tetel = new GiroBeszedTetel ();
$customer = $request->customer;
- $tetel->tetelSorszam = $sorszam;
+ $tetel->tetelSorszam = $request->number;
$tetel->terhelesiDatum = $terhelesiDatum;
$tetel->osszeg = $request->money;
// $tetel->kotelezettBankszamla->bankszerv = "58600252";
$tetel->kotelezettBankszamla->szamlaszam = $customer->bank_account;
- $tetel->ugyfelazonositoAKezdemenyezonel = $request->id_ticket_installment_request;
+ $tetel->ugyfelazonositoAKezdemenyezonel = $customer->id_customer;
// $tetel->ugyfelNeve = "Schneider Roland";
// $tetel->ugyfelCime = "Mosonmagyarovar, Gardonyi 31";
$tetel->szamlaTulajdonosNeve = $customer->name;
- $tetel->kozlemeny = "Berlet:" . $request->id_ticket .";MegbizasAzo:" . $request->id_ticket_installment_request;
+ $tetel->kozlemeny = "Fitness berlet. Megbizas azon: " . $request->id_ticket_installment_request;
return $tetel->toString();
}
@@ -84,4 +87,18 @@ class GiroBeszed extends GiroBase {
return $lab->toString ();
}
+
+
+ public function toString( ) {
+ $s = "";
+ $s .= $this->fej->toString();
+
+ foreach ($this->tetelek as $tetel ){
+ $s .= $tetel->toString();
+ }
+
+ $s .= $this->lab->toString();
+ return $s;
+ }
+
}
\ No newline at end of file
diff --git a/common/components/giro/GiroBeszedTetel.php b/common/components/giro/GiroBeszedTetel.php
index b4fa234..002bee3 100644
--- a/common/components/giro/GiroBeszedTetel.php
+++ b/common/components/giro/GiroBeszedTetel.php
@@ -9,7 +9,38 @@ use common\components\giro\GiroBase;
class GiroBeszedTetel extends GiroBase{
public $rekordTipus = "02";
+ /**
+ * 3 – 8
+ T211
+ tételsorszám
+ N
+ 6
+ K
+ * */
public $tetelSorszam = 0;
+ /**
+ * @var string $terhelesiDatum
+ * 9 – 16
+ T212
+ terhelési / esedékességi dátum
+ N
+ 8
+ ééééhhnn
+ K
+ ezen a dátumon (év, hó, nap) kell megterhelni a kötelezett számláját a beszedendő összeggel
+ * Ellenőrzés
+ * 9 – 16
+ T212
+ terhelési / esedékességi dátum 1
+ érvényes / időhatáron belüli
+ dátum?
+ E <= D <= E + 8 ?
+ 33 T
+ érvénytelen terhelési dátum
+ *
+ * A ’D’ terhelési dátumnak érvényes naptári napnak kell lennie, valamint nem lehet kisebb
+ és legfeljebb 8 munka- / elszámolási nappal lehet későbbi, mint az ’E’ elszámolási dátum.
+ * */
public $terhelesiDatum = "";
public $osszeg;
public $kotelezettBankszamla;
diff --git a/common/components/giro/GiroDETSTA.php b/common/components/giro/GiroDETSTA.php
index 3dab266..488d3e7 100644
--- a/common/components/giro/GiroDETSTA.php
+++ b/common/components/giro/GiroDETSTA.php
@@ -47,4 +47,24 @@ class GiroDETSTA extends GiroBase {
return $detsta;
}
+ /**
+ * @param common\components\giro\GiroBeszed $beszed
+ * */
+ public static function createBeszedAnswer($beszed){
+// /**@var common\components\giro\GiroBeszed $beszed*/
+ $beszed = new GiroBeszed();
+ $detsta = new GiroDETSTA();
+ $detsta->fej = new GiroDETSTAFej();
+
+ $detsta->fej->jelentesJelzo = 8;
+ $detsta->fej->kezdemenyezoAzonosito = $beszed->fej->kezdemenyezoAzonosito;
+ $detsta->fej->csoportosUzenetSorszam->osszeallitasDatuma = $beszed->fej->uzenetSorszam->osszeallitasDatuma;
+ $detsta->fej->csoportosUzenetSorszam->sorszam = $beszed->fej->uzenetSorszam->sorszam;
+ $detsta->fej->detstaUzenetSorszam->osszeallitasDatuma = $beszed->fej->uzenetSorszam->osszeallitasDatuma;
+ $detsta->fej->detstaUzenetSorszam = $beszed->fej->uzenetSorszam->sorszam;
+
+
+ $detsta->lab = new GiroDETSTALab();
+ }
+
}
\ No newline at end of file
diff --git a/common/components/giro/GiroDETSTALab.php b/common/components/giro/GiroDETSTALab.php
index d015963..44c211d 100644
--- a/common/components/giro/GiroDETSTALab.php
+++ b/common/components/giro/GiroDETSTALab.php
@@ -4,8 +4,13 @@ namespace common\components\giro;
/**
*
- * @property common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam
- * @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla
+ * @property string $recordTipus
+ * @property string $teljesitettTetelekSzama
+ * @property string $teljesitettTetelekOsszerteke
+ * @property string $visszautasitottTetelekSzama
+ * @property string $visszautasitottTetelekSzama
+ * @property string $megNemValaszoltTetelekSzama
+ * @property string $megNemValaszoltTetelekOsszerteke
*
*/
class GiroDETSTALab extends GiroBase {
diff --git a/common/config/params.php b/common/config/params.php
index 01154ac..5de3f85 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.26',
+ 'version' => 'v0.0.27',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
diff --git a/common/models/Card.php b/common/models/Card.php
index fda6585..acf7a55 100644
--- a/common/models/Card.php
+++ b/common/models/Card.php
@@ -25,6 +25,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
const TYPE_QRCODE = 20;
const TYPE_BARCODE = 30;
const TYPE_OLD = 40;
+ const TYPE_EMPLOYEE = 50;
/**
* @inheritdoc
@@ -95,6 +96,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
self::TYPE_QRCODE => Yii::t('common/card', 'QRCODE'),
self::TYPE_BARCODE => Yii::t('common/card', 'BARCODE'),
self::TYPE_OLD => Yii::t('common/card', 'OLD'),
+ self::TYPE_EMPLOYEE => Yii::t('common/card', 'Munkatárs'),
];
}
diff --git a/common/models/Contract.php b/common/models/Contract.php
new file mode 100644
index 0000000..16aedad
--- /dev/null
+++ b/common/models/Contract.php
@@ -0,0 +1,182 @@
+ TimestampBehavior::className(),
+ 'value' => function(){ return Helper::getDateTimeString(); }
+ ],
+ ], parent::behaviors());
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public static function tableName()
+ {
+ return 'contract';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function rules()
+ {
+ return [
+// [['id_user', 'id_customer', 'status', 'flag', 'part_paid', 'part_count', 'part_required'], 'integer'],
+// [['expired_at', 'created_at', 'updated_at'], 'required'],
+// [['expired_at', 'created_at', 'updated_at'], 'safe']
+ ];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id_contract' => Yii::t('common/contract', 'Szerződés azonosító'),
+ 'id_user' => Yii::t('common/contract', 'Felhasználó'),
+ 'id_customer' => Yii::t('common/contract', 'Vendég'),
+ 'status' => Yii::t('common/contract', 'Státusz'),
+ 'flag' => Yii::t('common/contract', 'Állapot'),
+ 'part_count' => Yii::t('common/contract', 'Részletek száma'),
+ 'part_paid' => Yii::t('common/contract', 'Fizetett részletek'),
+ 'part_required' => Yii::t('common/contract', 'Esedékes részlet'),
+ 'expired_at' => Yii::t('common/contract', 'Lejárati dátum'),
+ 'created_at' => Yii::t('common/contract', 'Létrehozva'),
+ 'updated_at' => Yii::t('common/contract', 'Módosítva'),
+ ];
+ }
+
+ public function getTicketType(){
+ return $this->hasOne(TicketType::className(), ['id_ticket_type' => 'id_ticket_type']);
+ }
+
+ public function getCustomer(){
+ return $this->hasOne(Customer::className(), ['id_customer' => 'id_customer']);
+ }
+ public function getCustomerName(){
+ $customer = $this->customer;
+ $result = "";
+
+ if ( isset($customer)){
+ $result = $customer->name;
+ }
+
+ return $result;
+ }
+ public function getUser(){
+ return $this->hasOne(User::className(), ['id' => 'id_user']);
+ }
+ public function getUserName(){
+ $user = $this->user;
+ $result = "";
+
+ if ( isset($user)){
+ $result = $user->username;
+ }
+
+ return $result;
+ }
+
+ public function getRequests(){
+ return $this->hasMany(TicketInstallmentRequest::className(), ['id_contract' => 'id_contract']);
+ }
+// public static $STATUS_PAID = 10;
+// public static $STATUS_NOT_PAID = 20;
+
+// public static $FLAG_DELETED = 10;
+// public static $FLAG_CANCELED = 20;
+// public static $FLAG_ACTIVE= 30;
+// public static $FLAG_EXPIRED = 40;
+
+
+ public static function statuses(){
+ return [
+ static::$STATUS_NOT_PAID => "Nincs fizetve",
+ static::$STATUS_PAID => "Fizetve",
+ ];
+ }
+
+
+ public static function flags(){
+ return [
+ static::$FLAG_ACTIVE => "Aktív",
+ static::$FLAG_CANCELED => "Felbontva",
+ static::$FLAG_DELETED => "Törölve",
+ static::$FLAG_EXPIRED => "Lejárt",
+ ];
+ }
+
+ public static function toStatusName($status){
+ return Helper::getArrayValue(self::statuses(), $status, "");
+ }
+
+ public static function toFlangName($flag){
+ return Helper::getArrayValue(self::flags(), $flag, "");
+ }
+
+ public function getStatusName() {
+ return self::toStatusName($this->status);
+ }
+
+ public function getFlagName() {
+ return self::toFlangName($this->flag);
+ }
+
+
+ public function isStatusNotPaid(){
+ return $this->status == static::$STATUS_NOT_PAID;
+ }
+
+ public function canCancel() {
+ return $this->flag == static::$FLAG_ACTIVE;
+ }
+ public function isFlagCanceled() {
+ return $this->flag == static::$FLAG_CANCELED;
+ }
+ public function isFlagDeleted() {
+ return $this->flag == static::$FLAG_DELETED;
+ }
+
+ public function isFlagActive() {
+ return $this->flag == static::$FLAG_ACTIVE;
+ }
+}
diff --git a/common/models/DoorLog.php b/common/models/DoorLog.php
new file mode 100644
index 0000000..d17a128
--- /dev/null
+++ b/common/models/DoorLog.php
@@ -0,0 +1,96 @@
+ Yii::t('common/door_log', 'Id Door Log'),
+ 'id_card' => Yii::t('common/door_log', 'Bérlet kártya'),
+ 'id_customer' => Yii::t('common/door_log', 'Vendég'),
+ 'id_key' => Yii::t('common/door_log', 'Kulcs'),
+ 'direction' => Yii::t('common/door_log', 'Irány'),
+ 'type' => Yii::t('common/door_log', 'Típus'),
+ 'created_at' => Yii::t('common/door_log', 'Időpont'),
+ ];
+ }
+
+ public function getCustomer(){
+ return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
+ }
+
+ public function getCustomerName(){
+ $result = "";
+ if (isset($this->customer)){
+ $result = $this->customer->name;
+ }
+ return $result;
+ }
+ public function getCard(){
+ return $this->hasOne( Card::className(), ["id_card" =>"id_card" ] );
+ }
+
+ public function getCardNumber(){
+ $result = "";
+ if (isset($this->card)){
+ $result = $this->card->number;
+ }
+ return $result;
+ }
+ public function getKey(){
+ return $this->hasOne( Key::className(), ["id_key" =>"id_key" ] );
+ }
+
+ public function getKeyNumber(){
+ $result = "";
+ if (isset($this->key)){
+ $result = $this->key->number;
+ }
+ return $result;
+ }
+ public function getDirectionName(){
+ $result = "";
+ if (isset($this->direction)){
+ $result = $this->direction;
+ }
+ return $result;
+ }
+}
diff --git a/common/models/Product.php b/common/models/Product.php
index 56c4b53..928a5b8 100644
--- a/common/models/Product.php
+++ b/common/models/Product.php
@@ -29,6 +29,8 @@ class Product extends \common\models\BaseFitnessActiveRecord {
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
+ public static $BUNTETES = "buntetes3000";
+
/**
* @inheritdoc
*/
diff --git a/common/models/TicketInstallmentRequest.php b/common/models/TicketInstallmentRequest.php
index f331594..fe166ec 100644
--- a/common/models/TicketInstallmentRequest.php
+++ b/common/models/TicketInstallmentRequest.php
@@ -108,6 +108,9 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
public function getCustomer(){
return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
}
+ public function getContract(){
+ return $this->hasOne( Contract::className(), ["id_contract" =>"id_contract" ] );
+ }
public function getTicket(){
return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_ticket", ] ) ;
@@ -119,13 +122,27 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
->viaTable('ugiro_request_assignment', [ 'id_request' => 'id_ticket_installment_request' ]);
}
+ public function getTicketExpirationDate(){
+ return strtotime( $this->request_target_time_at . " +1 month -1 day") ;
+ }
+
+
public function isStatusAccepted(){
return $this->status == static::$STATUS_ACCEPTED || $this->status == static::$STATUS_ACCEPTED_MANUAL;
}
+
public function isStatusRejected(){
return $this->status == static::$STATUS_REJECTED ;
}
+ public function isStatusCanceled(){
+ return $this->status == static::$STATUS_CANCELED ;
+ }
+
+ public function isStatusPending(){
+ return $this->status == static::$STATUS_PENDING ;
+ }
+
public function getIdGiro(){
$result = null;
$giro = $this->ugiro;
@@ -143,36 +160,54 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
* @param boolean $partRequired ha igaz, a bérleten a part mezőt változtatjuk
* */
public function applyStatus($status, $partRequired = false, $visszajelzes = "", $comment = ""){
+ $contract = $this->contract;
+ $contract->part_required = $contract->part_required +1;
if ( $status == static::$STATUS_ACCEPTED || $status == static::$STATUS_ACCEPTED_MANUAL){
if ( !$this->isStatusAccepted() ){
+ $contract->part_paid = $contract->part_paid +1;
+// $tranfer = $this->addTransfer();
+ $result = Transfer::sellContractTicket($contract, $this, Account::findOne(1), Transfer::STATUS_PAID, Transfer::PAYMENT_METHOD_TRANSFER);
+ $transfer = $result[0];
+ $ticket = $result[1];
$this->status = $status;
- $tranfer = $this->addTransfer();
- $this->id_transfer = $tranfer->id_transfer;
+ $this->id_transfer = $transfer->id_transfer;
+ $this->id_ticket = $ticket->id_ticket;
+
$this->request_processed_at = Helper::getDateTimeString();
$this->save(false);
- $this->applyNewTicketState($partRequired);
+
+ $contract->save(false);
+
+ \Yii::info("Megbízás kifizetve: " . $this->id_ticket_installment_request);
+// $this->applyNewTicketState($partRequired);
return true;
}else{
+ \Yii::info("Megbízás már ki volt fizetve: " . $this->id_ticket_installment_request);
return false;
}
}else{
+
$this->status = $status;
$this->detsta_answer = $visszajelzes;
$this->comment = $comment;
$this->request_processed_at = Helper::getDateTimeString();
$this->save(false);
- $this->applyNewTicketState($partRequired);
+ $contract->status = Contract::$STATUS_NOT_PAID;
+ $contract->save(false);
+// $this->applyNewTicketState($partRequired);
+ \Yii::info("Megbízás visszautasítva: " . $this->id_ticket_installment_request);
return true;
}
}
- protected function applyNewTicketState($partRequired = false){
- if ( $partRequired ){
- $this->ticket->setPartRequired($this);
- }
- $this->ticket->applyTicketInstallmentRequest($this);
- $this->ticket->save(false);
- }
+// protected function applyNewTicketState($partRequired = false){
+// if ( $partRequired ){
+// $this->ticket->setPartRequired($this);
+// }
+// $this->ticket->applyTicketInstallmentRequest($this);
+// $this->ticket->save(false);
+// }
+
protected function addTransfer(){
@@ -202,18 +237,18 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
* @param common\models\TicketType $type
* @return common\models\TicketInstallmentRequest[]
* */
- public static function createInstallments($ticket,$type,$customer){
+ public static function createInstallments($ticket,$type,$customer,$contract){
$result = [];
if ( $type->isInstallment() ){
$count = $type->installment_count;
$discount = $ticket->discount;
- $money = $type->price_brutto;
+ $money = $type->installment_money;
if ( isset($discount ) ){
$money = Discount::applyDiscount($money, $discount);
}
$ticketCreatedAt = time();
for ( $i = 1; $i <= $count; $i++){
- $request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $money, $ticketCreatedAt, $i);
+ $request = TicketInstallmentRequest::createInstallment($ticket, $type, $customer, $contract, $money, $ticketCreatedAt, $i);
$result[] = $request;
}
@@ -221,9 +256,9 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
return $result;
}
- public static function createInstallment($ticket,$type,$customer,$money,$ticketCreated,$index){
+ public static function createInstallment($ticket,$type,$customer,$contract,$money,$ticketCreated,$index){
$request = new TicketInstallmentRequest();
- $request->id_ticket = $ticket->id_ticket;
+// $request->id_ticket = $ticket->id_ticket;
$request->id_customer = $customer->id_customer;
$request->status = TicketInstallmentRequest::$STATUS_PENDING;
$request->priority = $index;
@@ -231,6 +266,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
$request->request_processed_at = null;
$request->request_sent_at = null;
$request->money = $money;
+ $request->id_contract = $contract->id_contract;
return $request;
}
@@ -242,8 +278,8 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
TicketInstallmentRequest::$STATUS_SENT=> 'Beküldve',
TicketInstallmentRequest::$STATUS_CANCELED=> 'Törölve',
TicketInstallmentRequest::$STATUS_REJECTED=> 'Visszautasítva',
- TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen végrehajtva',
- TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL=> 'Manuálisan elfogadva',
+ TicketInstallmentRequest::$STATUS_ACCEPTED=> 'Sikeresen beszedés',
+ TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL=> 'Személyesen fizetve',
];
}
@@ -257,4 +293,8 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
return $result;
}
+ public function getStatusName(){
+ return static::toStatusName($this->status);
+ }
+
}
diff --git a/common/models/Transfer.php b/common/models/Transfer.php
index 2b15e93..082b0b4 100644
--- a/common/models/Transfer.php
+++ b/common/models/Transfer.php
@@ -13,6 +13,7 @@ use common\components\CustomerAwareBehavior;
use yii\db\Query;
use yii\db\Expression;
use common\components\RoleDefinition;
+use common\components\Helper;
/**
* This is the model class for table "transfer".
@@ -37,746 +38,979 @@ use common\components\RoleDefinition;
* @property string $paid_at
* @property integer $id_customer
*/
-class Transfer extends \common\models\BaseFitnessActiveRecord
-{
-
+class Transfer extends \common\models\BaseFitnessActiveRecord {
const TYPE_PRODUCT = 10;
- const TYPE_TICKET = 20;
- const TYPE_MONEY_MOVEMENT_OUT = 30; //MONEY OUT FROM ACCOUNT
-
+ const TYPE_TICKET = 20;
+ const TYPE_MONEY_MOVEMENT_OUT = 30; // MONEY OUT FROM ACCOUNT
const STATUS_NOT_PAID = 10;
const STATUS_PAID = 20;
const STATUS_STORNO = 30;
-
- const DIRECTION_OUT = 10;// MONEY GOES OUT FROM ACCOUNT ( COMPANY LOST MONEY )
- const DIRECTION_IN = 20;//MONEY GOES IN TO THE ACCOUNT ( COMPANY EARN MONEY )
-
+ const DIRECTION_OUT = 10; // MONEY GOES OUT FROM ACCOUNT ( COMPANY LOST MONEY )
+ const DIRECTION_IN = 20; // MONEY GOES IN TO THE ACCOUNT ( COMPANY EARN MONEY )
const PAYMENT_METHOD_CASH = 10;
- const PAYMENT_METHOD_BANCCARD = 20; //BANKKÁRTYA
- const PAYMENT_METHOD_TRANSFER= 30; // ÁTUTALÁS
- const PAYMENT_METHOD_CAFETERY = 40;//SZÉCHENYI KÁRTYA
-// const PAYMENT_METHOD_DEBIT_MANDATE = 50;//CSOPORTOS BESZEDÉSI MEGBÍZÁS
+ const PAYMENT_METHOD_BANCCARD = 20; // BANKKÁRTYA
+ const PAYMENT_METHOD_TRANSFER = 30; // ÁTUTALÁS
+ const PAYMENT_METHOD_CAFETERY = 40; // SZÉCHENYI KÁRTYA
+ // const PAYMENT_METHOD_DEBIT_MANDATE = 50;//CSOPORTOS BESZEDÉSI MEGBÍZÁS
/**
* @inheritdoc
*/
- public function behaviors()
- {
- return ArrayHelper::merge( [
- [
- 'class' => TimestampBehavior::className(),
- 'value' => function(){ return date('Y-m-d H:i:s' ,\Yii::$app->formatter->asTimestamp(date('Y-d-m h:i:s')) ); }
- ],
- [
- 'class' => DiscountAwareBehavior::className(),
- ],
- [
- 'class' => CustomerAwareBehavior::className(),
- ],
- ], parent::behaviors());
+ public function behaviors() {
+ return ArrayHelper::merge ( [
+ [
+ 'class' => TimestampBehavior::className (),
+ 'value' => function () {
+ return date ( 'Y-m-d H:i:s', \Yii::$app->formatter->asTimestamp ( date ( 'Y-d-m h:i:s' ) ) );
+ }
+ ],
+ [
+ 'class' => DiscountAwareBehavior::className ()
+ ],
+ [
+ 'class' => CustomerAwareBehavior::className ()
+ ]
+ ], parent::behaviors () );
}
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'transfer';
- }
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
- [['created_at', 'updated_at'], 'safe'],
- [['comment'], 'string', 'max' => 255]
- ];
- }
-
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id_transfer' => Yii::t('common/transfer', 'Id Transfer'),
- 'id_account' => Yii::t('common/transfer', 'Account'),
- 'id_discount' => Yii::t('common/transfer', 'Id Discount'),
- 'id_currency' => Yii::t('common/transfer', 'Id Currency'),
- 'id_object' => Yii::t('common/transfer', 'Id Object'),
- 'objectName' => Yii::t('common/transfer', 'Id Object'),
- 'status' => Yii::t('common/transfer', 'Status'),
- 'type' => Yii::t('common/transfer', 'Type'),
- 'item_price' => Yii::t('common/transfer', 'Item Price'),
- 'count' => Yii::t('common/transfer', 'Count'),
- 'money' => Yii::t('common/transfer', 'Money'),
- 'money_currency' => Yii::t('common/transfer', 'Money Currency'),
- 'rate' => Yii::t('common/transfer', 'Rate'),
- 'id_user' => Yii::t('common/transfer', 'Id User'),
- 'id_customer' => Yii::t('common/transfer', 'Customer'),
- 'comment' => Yii::t('common/transfer', 'Comment'),
- 'created_at' => Yii::t('common/transfer', 'Created At'),
- 'updated_at' => Yii::t('common/transfer', 'Updated At'),
- 'paid_at' => Yii::t('common/transfer', 'Paid At'),
- 'types' => Yii::t('common/transfer', 'Types'),
- 'start' => Yii::t('common/transfer', 'Start'),
- 'end' => Yii::t('common/transfer', 'End'),
- 'payment_method' => Yii::t('common/transfer', 'Fizetési mód'),
- ];
- }
-
- public function getUser(){
- return $this->hasOne( User::className(), ["id" =>"id_user" ] );
- }
-
- public function getProduct(){
- return $this->hasOne( Product::className(), ["id_product" =>"id_product" ] )->via('sale');
- }
- public function getMoneyMovement(){
- return $this->hasOne( MoneyMovement::className(), ["id_money_movement" =>"id_object" ] );
- }
-
- public function getTicket(){
- return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_object", ] ) ;
- }
-
- public function getTicketType(){
- return $this->hasOne( TicketType::className(), ["id_ticket_type" =>"id_ticket_type" ] )->via('ticket') ;
- }
-
- public function getAccount(){
- return $this->hasOne( Account::className(), ["id_account" =>"id_account" ] ) ;
- }
-
- public function getCurrency(){
- return $this->hasOne( Currency::className(), ["id_currency" =>"id_currency" ] );
- }
-
-
- public function getUserSoldItem(){
- return $this->hasOne( UserSoldItem::className(), ["id_transfer" =>"id_transfer" ] );
- }
-
- public function getCustomerCart(){
- return $this->hasOne( ShoppingCart::className(), ["id_transfer" =>"id_transfer" ] );
- }
-
- public function getSale(){
- return $this->hasOne( Sale::className(), ["id_sale" =>"id_object" ] ) ;
- }
-
- public function getObjectName(){
- $result = "";
- if ( $this->type == Transfer::TYPE_TICKET ){
- $result = $this->ticketName;
- }else if ( $this->type == Transfer::TYPE_PRODUCT ){
- $result = $this->productName;
- }else if ( $this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT ){
- $result = $this->moneyMovement->humanType;
- }
- return $result;
- }
- public function getUserName(){
- $result = "";
- $user = $this->user;
- if (isset($this->user)){
- $result = $user->username;
- }
-
- return $result;
- }
-
- public function getProductName(){
- $result = "";
- $product = $this->product;
- if (isset($product)){
- $result = $product->name;
- }
-
- return $result;
- }
-
- public function getTicketName(){
- $result = "";
- $ticket = $this->ticket;
- if (isset($ticket)){
- $result = $this->ticket->ticketTypeName;
- }
-
- return $result;
- }
- public function getAccountName(){
- $result = "";
- $account = $this->account;
- if (isset($account)){
- $result = $account->name;
- }
-
- return $result;
- }
-
- public function getTransferTypeName(){
- $result = "";
- if ( $this->type == Transfer::TYPE_TICKET ){
- $result = Yii::t('common/transfer','Ticket');
- }else if ( $this->type == Transfer::TYPE_PRODUCT ){
- $result = Yii::t('common/transfer','Product');
- }else if ( $this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT ){
- $result = Yii::t('common/transfer','Money movement');
- }
- return $result;
- }
-
-
- public function getSaleName(){
- $result = "";
- $sale = $this->sale;
- if (isset($sale)){
- $result = $sale->name;
- }
- return $result;
- }
-
-
-
- public function getSignedMoney(){
- $m = 1;
- $result = $this->money;
- if ( $this->direction == self::DIRECTION_OUT ){
- $m = -1;
- }
-
- $result = $result * $m;
-
- return $result;
-
- }
-
- public static function toSignedMoney($dir,$money){
- $m = 1;
- $result = $money;
- if ( $dir == Transfer::DIRECTION_OUT ){
- $m = -1;
- }
-
- $result = $result * $m;
-
- return $result;
-
- }
+ /**
+ * @inheritdoc
+ */
+ public static function tableName() {
+ return 'transfer';
+ }
- public function toProductSoldString(){
- $s = "";
-
- $s .= $this->count;
- $s .= " " . Yii::t('frontend/transfer', 'pieces') . " ";
- $s .= $this->product->name;
- $s .= " - ";
- $s .= $this->account->name;
-
- return $s;
- }
-
- /**
- * @param $account common\models\Account
- * @param $discount common\models\Discount
- * @param $currency common\models\Currency
- * @param $product common\models\Product
- * @param $customer common\models\Customer
- * */
- public static function createProductTransfer($sale,$account, $discount, $currency, $count,$product , $status = Transfer::STATUS_PAID,$customer = null){
- $transfer = new Transfer();
-
- $transfer->type = Transfer::TYPE_PRODUCT;
-
- $transfer->id_object = $sale->id_sale;
-
- $transfer->item_price = $product->sale_price;
- $totalPrice = $transfer->item_price;
-
- $transfer->count = $count;
- $totalPrice = $totalPrice * $count;
-
- if ( isset( $discount ) ){
- $transfer->id_discount = $discount->id_discount;
- $totalPrice = Discount::applyDiscount( $totalPrice, $discount);
- }
-
- $transfer->money = $totalPrice;
-
- if ( isset( $currency ) ){
- $transfer->rate = $currency->rate;
- $transfer->money_currency = Currency::applyCurrency($totalPrice, $currency);
- }
-
- $transfer->direction = Transfer::DIRECTION_IN;
- $transfer->status = $status;
-
- $transfer->id_account = $account->id_account;
-
- if ( isset( $customer ) ){
- $transfer->id_customer = $customer->id_customer;
- }
-
- return $transfer;
- }
-
- /**
- * @param $account common\models\Account
- * @param $discount common\models\Discount
- * @param $currency common\models\Currency
- * @param $moneyMovement common\models\MoneyMovement
- * */
- public static function createMoneyMovementOutTransfer($account , $moneyMovement ){
- $transfer = new Transfer();
- $transfer->payment_method = Transfer::PAYMENT_METHOD_CASH;
- $transfer->type = Transfer::TYPE_MONEY_MOVEMENT_OUT;
- $transfer->status = Transfer::STATUS_PAID;
- if ( $moneyMovement->type == MoneyMovement::TYPE_OUT){
- $transfer->direction = Transfer::DIRECTION_OUT;
- }else if ( $moneyMovement->type == MoneyMovement::TYPE_IN ){
- $transfer->direction = Transfer::DIRECTION_IN;
- }
- $transfer->count = null;
-
- $transfer->id_object = $moneyMovement->id_money_movement;
- $transfer->money = $moneyMovement->money;
-
- $transfer->id_account = $account->id_account;
-
- $transfer->paid_at = date('Y-m-d H:i:s' ) ;
- $transfer->paid_by = \Yii::$app->user->id;
-
- return $transfer;
- }
- /**
- * @param $account common\models\Account
- * @param $discount common\models\Discount
- * @param $currency common\models\Currency
- * @param $ticket common\models\Ticket
- * */
- public static function createTicketTransfer($account, $discount, $currency, $count,$ticket ,$status = Transfer::STATUS_NOT_PAID){
- $transfer = new Transfer();
-
- $transfer->status = $status;
- $transfer->type = Transfer::TYPE_TICKET;
- $transfer->direction = Transfer::DIRECTION_IN;
-
- $transfer->id_object = $ticket->id_ticket;
-
- $transfer->item_price = $ticket->price_brutto;
- $totalPrice = $transfer->item_price;
-
- $transfer->count = $count;
- $totalPrice = $totalPrice * $count;
-
- if ( isset( $discount ) ){
- $transfer->id_discount = $discount->id_discount;
- $totalPrice = Discount::applyDiscount( $totalPrice, $discount);
- }
-
- $transfer->money = $totalPrice;
-
- if ( isset( $currency ) ){
- $transfer->rate = $currency->rate;
- $transfer->money_currency = Currency::applyCurrency($totalPrice, $currency);
- }
-
- $transfer->id_account = $account->id_account;
-
- return $transfer;
- }
-
- public static function modelsToArray($transfers,$default = []){
-
- if ( $transfers == null ){
- return $default;
- }
-
- return ArrayHelper::toArray($transfers, [
- 'common\models\Transfer' => [
- 'id_transfer',
- 'item_price',
- 'count',
- 'money',
- 'money_currency',
- 'time' => function ($transfer){
- return Yii::$app->formatter->asDatetime($transfer->created_at);
- },
- 'account_name' => function ($transfer) {
- return $transfer->account->name;
- },
- 'product_name' => function ($transfer) {
- $result = "";
- if ( $transfer->type == Transfer::TYPE_TICKET ){
- $result = $transfer->ticket->ticketTypeName;
- }else if ( $transfer->type == Transfer::TYPE_PRODUCT ){
- $result = $transfer->product->name;
- }else if ( $transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT ){
- $result = "Pénzmozgás";
- }
- return $result;
- },
- 'category' => function ($transfer) {
- if ( $transfer->type == Transfer::TYPE_TICKET ){
- return Yii::t('frontend/transfer','Ticket');
- }else if ( $transfer->type == Transfer::TYPE_PRODUCT ){
- return $transfer->product->productCategoryName;
- }else if ( $transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT ){
- return "Pénzmozgás";
- }
- },
- ],
- ]);
- }
-
-
- public static function readUserSoldTransfers($user){
- $transfers = [];
-
- $query = Transfer::find();
-
- $query->innerJoinWith('userSoldItem');
- $query->andWhere(['user_sold_item.id_user' => $user->id ]);
- $transfers = $query->all();
-
- return $transfers;
- }
- public static function readCustomerCart($customer){
- $transfers = [];
-
- if ( isset($customer) ){
- $query = Transfer::find();
- $query->innerJoinWith('customerCart');
- $query->andWhere(['shopping_cart.id_customer' => $customer->id_customer ]);
- $transfers = $query->all();
- }
-
- return $transfers;
- }
-
- public static function types( ) {
- return [
- self::TYPE_MONEY_MOVEMENT_OUT => Yii::t('common/transfer','Pénzmozgás'),
- self::TYPE_PRODUCT => Yii::t('common/transfer','Product'),
- self::TYPE_TICKET => Yii::t('common/transfer','Ticket'),
- ];
- }
- public static function paymentMethods( ) {
- return [
- self::PAYMENT_METHOD_CASH=> Yii::t('common/transfer','Készpénz'),
- self::PAYMENT_METHOD_BANCCARD => Yii::t('common/transfer','Bankkártyás fizetés'),
- self::PAYMENT_METHOD_TRANSFER => Yii::t('common/transfer','Átutalás'),
- self::PAYMENT_METHOD_CAFETERY => Yii::t('common/transfer','Széchenyi kártya'),
-// self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
- ];
- }
- public static function statuses( ) {
- return [
- self::STATUS_NOT_PAID => Yii::t('common/transfer','Nincs fizetve'),
- self::STATUS_PAID => Yii::t('common/transfer','Fizetve'),
- self::STATUS_STORNO => Yii::t('common/transfer','Törölve'),
- ];
- }
- public function getStatusName( ) {
- $status = null;
- $statuses = self::statuses();
- if ( array_key_exists($this->status, $statuses)){
- $status = $statuses[$this->status];
- }
- return $status;
- }
- public function getPaymentMethodName( ) {
- $status = null;
- $statuses = self::paymentMethods();
- if ( array_key_exists($this->payment_method, $statuses)){
- $status = $statuses[$this->payment_method];
- }
- return $status;
- }
-
- public function beforeDelete(){
- parent::beforeDelete();
- if ( $this->type == Transfer::TYPE_TICKET){
- $ticket = $this->ticket;
- if ( $ticket != null ){
- $ticket->delete();
- }
- }else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT){
- $mm = $this->moneyMovement;
- $mm->delete();
- }else if ($this->type == Transfer::TYPE_PRODUCT){
- $sale = $this->sale;
- $product = $this->product;
-
- $product->stock = $product->stock + $this->count;
-
- $product->save();
- $sale->delete();
- }
-
- ShoppingCart::deleteAll(['id_transfer' =>$this->id_transfer]);
- UserSoldItem::deleteAll(['id_transfer' =>$this->id_transfer]);
-
- return true;
- }
-
- /**
- * @param string $mode The mode to load
- * Available modes
- *
- * -
- *
created_at
- * Load all transfer which were created
- *
- * -
- *
paid_at
- * Load all transfer which were paid
- *
- * -
- *
created_at_paid
- * Load all transfer which were created and paid
- *
- * -
- *
created_at_not_paid
- * Load all transfer which were created but not paid
- *
- * -
- *
paid_at_not_created_at
- * Load all transfer which were not created but paid . Works correctly only,
- * when start and end date given
- *
- *
- *
- *
- * */
- public static function mkTotalQuery($mode,$start,$end,$idUser,$types,$idAccount){
-
- $query = new Query();
-
- $query->addSelect( [
- new Expression( 'transfer.id_account as account'),
- new Expression( ' COALESCE(sum( ( case when direction = '.Transfer::DIRECTION_OUT.' then -1 else 1 end )* transfer.money ),0) as money /** --'. $mode.'*/' )
-
- ]);
- $query->from('transfer');
-
- if ( !RoleDefinition::isAdmin() ){
- $query->innerJoin("user_account_assignment", 'transfer.id_account = user_account_assignment.id_account' );
- $query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id ]);
-
- }
- $query->innerJoin("account", 'transfer.id_account = account.id_account' );
- $query->andWhere(['account.type' => Account::TYPE_ALL]);
-
- $query->andFilterWhere([
- 'transfer.id_account' => $idAccount,
- ]);
-
- $query->andFilterWhere(['transfer.id_user' => $idUser]);
-
- $query->andFilterWhere(['in' ,'transfer.type', $types]);
-
- $query->andWhere(['not in','transfer.status', Transfer::STATUS_STORNO]);
-
-
- if ( $mode == 'created_at'){
- self::inInterval($query, 'transfer.created_at', $start, $end);
- }else if ( $mode == 'paid_at'){
- self::inInterval($query, 'transfer.paid_at' , $start, $end);
- }else if ( $mode == 'created_at_not_paid'){
- self::notPaid($query, 'transfer.paid_at', $start, $end);
- self::inInterval($query, 'transfer.created_at', $start, $end);
- }else if ( $mode == 'created_at_paid'){
- self::inInterval($query, 'transfer.created_at', $start, $end);
- self::inInterval($query, 'transfer.paid_at', $start, $end);
- }else if ( $mode == 'paid_at_not_created_at'){
- self::inInterval($query, 'transfer.paid_at' , $start, $end);
- self::notInInterval($query, 'transfer.created_at', $start, $end);
- }
-
- $query->groupBy('transfer.id_account');
-
- return $query;
-
-
- }
-
- public static function notInInterval($query ,$field , $start,$end ){
- $query->andFilterWhere( ['or', [ '<', $field , isset( $start ) ? $start : '1900-01-01' ] ,[ '>=' , $field , isset($end) ? $end : '3000-01-01' ] ] );
- }
-
- public static function notPaid($query ,$field , $start,$end ){
- $query->andFilterWhere( ['or', [ '<', $field , isset( $start ) ? $start : '1900-01-01' ] ,[ '>=' , $field , isset($end) ? $end : '3000-01-01' ] ,[ "transfer.status" => Transfer::STATUS_NOT_PAID ] ] );
- }
- public static function inInterval($query ,$field , $start,$end ){
- $query->andFilterWhere([ '>=', $field , $start ] );
- $query->andFilterWhere([ '<' , $field , $end ] );
- }
-
-
-
-
- /**
- *
- * Parse query results so, that all available account will be display, even then , if $queryResult does not contain any result for the given account
- *
- * @param mixed $queryResult an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ]
- * */
- public static function mkTotalsResultWithAllAvailableAccount($queryResult,$accounts,$accountMap,$idAccount){
-
- $totals = [];
- $totals['total'] = 0;
-
- $totals['accounts'] = [];
-
- foreach ($accounts as $account){
- if ( isset($idAccount) && is_numeric($idAccount) && $idAccount != $account->id_account ){
- continue ;
- }
-
- $accountTotal = [
- 'id_account' => $account->id_account,
- 'label' => $account->name,
- 'money' => 0,
- ];
-
- $item = self::findByAccountInQueryResult($queryResult, $account);
-
- if ( isset($item)){
- $accountTotal['money'] = $item['money'];
- }
-
- $totals['accounts'][] = $accountTotal;
- $totals['total'] += $accountTotal['money'];
- }
- return $totals;
- }
-
- public static function findByAccountInQueryResult( $queryResult, $account ){
- $result = null;
- foreach ($queryResult as $item){
- if( $item['account'] == $account->id_account ){
- $result = $item;
- }
- }
- return $result;
- }
-
-
- /**create and execute a "total" query*/
- public static function exTotalQuery($mode,$start,$end,$idUser,$types,$idAccount){
- $query = self::mkTotalQuery($mode, $start, $end, $idUser, $types, $idAccount );
- $command = $query->createCommand();
- $result = $command->queryAll();
- return $result;
- }
-
- /**
- *find all transfers which were paid in the period
- * */
- public static function mkPaidAtTotals( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
- $result = [];
- $queryResult = self::exTotalQuery('paid_at', $start, $end, $idUser, $types, $idAccount );
- $result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount);
- return $result;
- }
-
- /**find all transfers in the period ( doesn't matter if paid or not )*/
- public static function mkCreatedAtTotals( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
- $result = [];
- $queryResult = self::exTotalQuery('created_at', $start, $end, $idUser, $types, $idAccount );
- $result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount);
- return $result;
- }
-
- /**find transfers which were created but not paid in the period*/
- public static function mkCreatedAtNotPaidTotals( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
- $result = [];
- $queryResult = self::exTotalQuery('created_at_not_paid', $start, $end, $idUser, $types, $idAccount );
- $result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount);
- return $result;
- }
-
- /**
- * find transfers which were created and paid in the period
- *
- * */
- public static function mkCreatedAtPaidTotals( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
- $result = [];
- $queryResult = self::exTotalQuery('created_at_paid', $start, $end, $idUser, $types, $idAccount );
- $result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount);
- return $result;
- }
-
- /**
- *
- * find transfers, where depth was paid
- * */
- public static function mkPaidAtNotCreatedAtPaidTotals( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
- $result = [];
- $queryResult = self::exTotalQuery('paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount );
- $result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount);
- return $result;
- }
-
-
- public static function mkTotals( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap ){
- $result = [];
-
- $result['paid_at'] = self::mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap);
- $result['created_at'] = self::mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap);
- $result['created_at_not_paid'] = self::mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap);
- $result['created_at_paid'] = self::mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap);
- $result['paid_at_not_created_at'] = self::mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap);
-
- return $result;
- }
-
- public static function readPaid($start,$end,$idUser){
- $query = (new \yii\db\Query());
- $query->select(['coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN. ' then transfer.money else -1 * transfer.money end ),0) AS transfer_money']);
- $query->from('transfer');
- $query->innerJoin("account","account.id_account = transfer.id_account");
- $query->andWhere(['transfer.id_user' => $idUser ]);
-
- $created_condition = ['and',[ '>=', 'transfer.created_at', $start ] ,[ '<', 'transfer.created_at', $end ] ];
- $paid_condition = ['and',[ '>=', 'transfer.paid_at', $start] ,[ '<', 'transfer.paid_at', $end ] ];
-
- $query->andFilterWhere(['or' , $created_condition , $paid_condition]);
- $query->andWhere(['transfer.status' => Transfer::STATUS_PAID]);
- $query->andWhere(['account.type' => Account::TYPE_ALL]);
- $query->andWhere(['transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH]);
-
- return $query->scalar();
- }
-
-
- public function storno(){
- $this->status = Transfer::STATUS_STORNO;
- $this->save(false);
- if ( $this->type == Transfer::TYPE_TICKET){
- $ticket = $this->ticket;
- $ticket->status = Ticket::STATUS_DELETED;
- $ticket->save(false);
-
- TicketInstallmentRequest::updateAll(
- ['status' => TicketInstallmentRequest::$STATUS_CANCELED ],
- ['id_ticket' => $this->ticket->id_ticket ]
- );
-
- }else if ( $this->type == Transfer::TYPE_PRODUCT ){
- $sale = $this->sale;
- $sale->status = Sale::STATUS_DELETED;
- $sale->save(false);
- }else if ( $this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT ){
- $mm = $this->moneyMovement;
- $mm->status = MoneyMovement::STATUS_STORNO;
- $mm->save(false);
- }
- }
-
+ /**
+ * @inheritdoc
+ */
+ public function rules() {
+ return [
+ [
+ [
+ 'id_discount',
+ 'id_currency',
+ 'id_object',
+ 'status',
+ 'type',
+ 'item_price',
+ 'count',
+ 'money',
+ 'money_currency',
+ 'rate',
+ 'id_user'
+ ],
+ 'integer'
+ ],
+ [
+ [
+ 'created_at',
+ 'updated_at'
+ ],
+ 'safe'
+ ],
+ [
+ [
+ 'comment'
+ ],
+ 'string',
+ 'max' => 255
+ ]
+ ];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function attributeLabels() {
+ return [
+ 'id_transfer' => Yii::t ( 'common/transfer', 'Id Transfer' ),
+ 'id_account' => Yii::t ( 'common/transfer', 'Account' ),
+ 'id_discount' => Yii::t ( 'common/transfer', 'Id Discount' ),
+ 'id_currency' => Yii::t ( 'common/transfer', 'Id Currency' ),
+ 'id_object' => Yii::t ( 'common/transfer', 'Id Object' ),
+ 'objectName' => Yii::t ( 'common/transfer', 'Id Object' ),
+ 'status' => Yii::t ( 'common/transfer', 'Status' ),
+ 'type' => Yii::t ( 'common/transfer', 'Type' ),
+ 'item_price' => Yii::t ( 'common/transfer', 'Item Price' ),
+ 'count' => Yii::t ( 'common/transfer', 'Count' ),
+ 'money' => Yii::t ( 'common/transfer', 'Money' ),
+ 'money_currency' => Yii::t ( 'common/transfer', 'Money Currency' ),
+ 'rate' => Yii::t ( 'common/transfer', 'Rate' ),
+ 'id_user' => Yii::t ( 'common/transfer', 'Id User' ),
+ 'id_customer' => Yii::t ( 'common/transfer', 'Customer' ),
+ 'comment' => Yii::t ( 'common/transfer', 'Comment' ),
+ 'created_at' => Yii::t ( 'common/transfer', 'Created At' ),
+ 'updated_at' => Yii::t ( 'common/transfer', 'Updated At' ),
+ 'paid_at' => Yii::t ( 'common/transfer', 'Paid At' ),
+ 'types' => Yii::t ( 'common/transfer', 'Types' ),
+ 'start' => Yii::t ( 'common/transfer', 'Start' ),
+ 'end' => Yii::t ( 'common/transfer', 'End' ),
+ 'payment_method' => Yii::t ( 'common/transfer', 'Fizetési mód' )
+ ];
+ }
+ public function getUser() {
+ return $this->hasOne ( User::className (), [
+ "id" => "id_user"
+ ] );
+ }
+ public function getProduct() {
+ return $this->hasOne ( Product::className (), [
+ "id_product" => "id_product"
+ ] )->via ( 'sale' );
+ }
+ public function getMoneyMovement() {
+ return $this->hasOne ( MoneyMovement::className (), [
+ "id_money_movement" => "id_object"
+ ] );
+ }
+ public function getTicket() {
+ return $this->hasOne ( Ticket::className (), [
+ "id_ticket" => "id_object"
+ ] );
+ }
+ public function getTicketType() {
+ return $this->hasOne ( TicketType::className (), [
+ "id_ticket_type" => "id_ticket_type"
+ ] )->via ( 'ticket' );
+ }
+ public function getAccount() {
+ return $this->hasOne ( Account::className (), [
+ "id_account" => "id_account"
+ ] );
+ }
+ public function getCurrency() {
+ return $this->hasOne ( Currency::className (), [
+ "id_currency" => "id_currency"
+ ] );
+ }
+ public function getUserSoldItem() {
+ return $this->hasOne ( UserSoldItem::className (), [
+ "id_transfer" => "id_transfer"
+ ] );
+ }
+ public function getCustomerCart() {
+ return $this->hasOne ( ShoppingCart::className (), [
+ "id_transfer" => "id_transfer"
+ ] );
+ }
+ public function getSale() {
+ return $this->hasOne ( Sale::className (), [
+ "id_sale" => "id_object"
+ ] );
+ }
+ public function getObjectName() {
+ $result = "";
+ if ($this->type == Transfer::TYPE_TICKET) {
+ $result = $this->ticketName;
+ } else if ($this->type == Transfer::TYPE_PRODUCT) {
+ $result = $this->productName;
+ } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
+ $result = $this->moneyMovement->humanType;
+ }
+ return $result;
+ }
+ public function getUserName() {
+ $result = "";
+ $user = $this->user;
+ if (isset ( $this->user )) {
+ $result = $user->username;
+ }
+
+ return $result;
+ }
+ public function getProductName() {
+ $result = "";
+ $product = $this->product;
+ if (isset ( $product )) {
+ $result = $product->name;
+ }
+
+ return $result;
+ }
+ public function getTicketName() {
+ $result = "";
+ $ticket = $this->ticket;
+ if (isset ( $ticket )) {
+ $result = $this->ticket->ticketTypeName;
+ }
+
+ return $result;
+ }
+ public function getAccountName() {
+ $result = "";
+ $account = $this->account;
+ if (isset ( $account )) {
+ $result = $account->name;
+ }
+
+ return $result;
+ }
+ public function getTransferTypeName() {
+ $result = "";
+ if ($this->type == Transfer::TYPE_TICKET) {
+ $result = Yii::t ( 'common/transfer', 'Ticket' );
+ } else if ($this->type == Transfer::TYPE_PRODUCT) {
+ $result = Yii::t ( 'common/transfer', 'Product' );
+ } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
+ $result = Yii::t ( 'common/transfer', 'Money movement' );
+ }
+ return $result;
+ }
+ public function getSaleName() {
+ $result = "";
+ $sale = $this->sale;
+ if (isset ( $sale )) {
+ $result = $sale->name;
+ }
+ return $result;
+ }
+ public function getSignedMoney() {
+ $m = 1;
+ $result = $this->money;
+ if ($this->direction == self::DIRECTION_OUT) {
+ $m = - 1;
+ }
+
+ $result = $result * $m;
+
+ return $result;
+ }
+ public static function toSignedMoney($dir, $money) {
+ $m = 1;
+ $result = $money;
+ if ($dir == Transfer::DIRECTION_OUT) {
+ $m = - 1;
+ }
+
+ $result = $result * $m;
+
+ return $result;
+ }
+ public function toProductSoldString() {
+ $s = "";
+
+ $s .= $this->count;
+ $s .= " " . Yii::t ( 'frontend/transfer', 'pieces' ) . " ";
+ $s .= $this->product->name;
+ $s .= " - ";
+ $s .= $this->account->name;
+
+ return $s;
+ }
+
+ /**
+ *
+ * @param $account common\models\Account
+ * @param $discount common\models\Discount
+ * @param $currency common\models\Currency
+ * @param $product common\models\Product
+ * @param $customer common\models\Customer
+ *
+ */
+ public static function createProductTransfer($sale, $account, $discount, $currency, $count, $product, $status = Transfer::STATUS_PAID, $customer = null) {
+ $transfer = new Transfer ();
+
+ $transfer->type = Transfer::TYPE_PRODUCT;
+
+ $transfer->id_object = $sale->id_sale;
+
+ $transfer->item_price = $product->sale_price;
+ $totalPrice = $transfer->item_price;
+
+ $transfer->count = $count;
+ $totalPrice = $totalPrice * $count;
+
+ if (isset ( $discount )) {
+ $transfer->id_discount = $discount->id_discount;
+ $totalPrice = Discount::applyDiscount ( $totalPrice, $discount );
+ }
+
+ $transfer->money = $totalPrice;
+
+ if (isset ( $currency )) {
+ $transfer->rate = $currency->rate;
+ $transfer->money_currency = Currency::applyCurrency ( $totalPrice, $currency );
+ }
+
+ $transfer->direction = Transfer::DIRECTION_IN;
+ $transfer->status = $status;
+
+ $transfer->id_account = $account->id_account;
+
+ if (isset ( $customer )) {
+ $transfer->id_customer = $customer->id_customer;
+ }
+
+ return $transfer;
+ }
+
+ /**
+ *
+ * @param $account common\models\Account
+ * @param $discount common\models\Discount
+ * @param $currency common\models\Currency
+ * @param $moneyMovement common\models\MoneyMovement
+ *
+ */
+ public static function createMoneyMovementOutTransfer($account, $moneyMovement) {
+ $transfer = new Transfer ();
+ $transfer->payment_method = Transfer::PAYMENT_METHOD_CASH;
+ $transfer->type = Transfer::TYPE_MONEY_MOVEMENT_OUT;
+ $transfer->status = Transfer::STATUS_PAID;
+ if ($moneyMovement->type == MoneyMovement::TYPE_OUT) {
+ $transfer->direction = Transfer::DIRECTION_OUT;
+ } else if ($moneyMovement->type == MoneyMovement::TYPE_IN) {
+ $transfer->direction = Transfer::DIRECTION_IN;
+ }
+ $transfer->count = null;
+
+ $transfer->id_object = $moneyMovement->id_money_movement;
+ $transfer->money = $moneyMovement->money;
+
+ $transfer->id_account = $account->id_account;
+
+ $transfer->paid_at = date ( 'Y-m-d H:i:s' );
+ $transfer->paid_by = \Yii::$app->user->id;
+
+ return $transfer;
+ }
+ /**
+ *
+ * @param $account common\models\Account
+ * @param $discount common\models\Discount
+ * @param $currency common\models\Currency
+ * @param $ticket common\models\Ticket
+ *
+ */
+ public static function createTicketTransfer($account, $discount, $currency, $count, $ticket, $status = Transfer::STATUS_NOT_PAID) {
+ $transfer = new Transfer ();
+
+ $transfer->status = $status;
+ $transfer->type = Transfer::TYPE_TICKET;
+ $transfer->direction = Transfer::DIRECTION_IN;
+
+ $transfer->id_object = $ticket->id_ticket;
+
+ $transfer->item_price = $ticket->price_brutto;
+ $totalPrice = $transfer->item_price;
+
+ $transfer->count = $count;
+ $totalPrice = $totalPrice * $count;
+
+ if (isset ( $discount )) {
+ $transfer->id_discount = $discount->id_discount;
+ $totalPrice = Discount::applyDiscount ( $totalPrice, $discount );
+ }
+
+ $transfer->money = $totalPrice;
+
+ if (isset ( $currency )) {
+ $transfer->rate = $currency->rate;
+ $transfer->money_currency = Currency::applyCurrency ( $totalPrice, $currency );
+ }
+
+ $transfer->id_account = $account->id_account;
+
+ return $transfer;
+ }
+ public static function modelsToArray($transfers, $default = []) {
+ if ($transfers == null) {
+ return $default;
+ }
+
+ return ArrayHelper::toArray ( $transfers, [
+ 'common\models\Transfer' => [
+ 'id_transfer',
+ 'item_price',
+ 'count',
+ 'money',
+ 'money_currency',
+ 'time' => function ($transfer) {
+ return Yii::$app->formatter->asDatetime ( $transfer->created_at );
+ },
+ 'account_name' => function ($transfer) {
+ return $transfer->account->name;
+ },
+ 'product_name' => function ($transfer) {
+ $result = "";
+ if ($transfer->type == Transfer::TYPE_TICKET) {
+ $result = $transfer->ticket->ticketTypeName;
+ } else if ($transfer->type == Transfer::TYPE_PRODUCT) {
+ $result = $transfer->product->name;
+ } else if ($transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
+ $result = "Pénzmozgás";
+ }
+ return $result;
+ },
+ 'category' => function ($transfer) {
+ if ($transfer->type == Transfer::TYPE_TICKET) {
+ return Yii::t ( 'frontend/transfer', 'Ticket' );
+ } else if ($transfer->type == Transfer::TYPE_PRODUCT) {
+ return $transfer->product->productCategoryName;
+ } else if ($transfer->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
+ return "Pénzmozgás";
+ }
+ }
+ ]
+ ] );
+ }
+ public static function toPaymentMethodName($id) {
+ $result = "";
+ $arr = static::paymentMethods ();
+
+ if (array_key_exists ( $id, $arr )) {
+ $result = $arr [$id];
+ }
+
+ return $result;
+ }
+ public static function readUserSoldTransfers($user) {
+ $transfers = [ ];
+
+ $query = Transfer::find ();
+
+ $query->innerJoinWith ( 'userSoldItem' );
+ $query->andWhere ( [
+ 'user_sold_item.id_user' => $user->id
+ ] );
+ $transfers = $query->all ();
+
+ return $transfers;
+ }
+ public static function readCustomerCart($customer) {
+ $transfers = [ ];
+
+ if (isset ( $customer )) {
+ $query = Transfer::find ();
+ $query->innerJoinWith ( 'customerCart' );
+ $query->andWhere ( [
+ 'shopping_cart.id_customer' => $customer->id_customer
+ ] );
+ $transfers = $query->all ();
+ }
+
+ return $transfers;
+ }
+ public static function types() {
+ return [
+ self::TYPE_MONEY_MOVEMENT_OUT => Yii::t ( 'common/transfer', 'Pénzmozgás' ),
+ self::TYPE_PRODUCT => Yii::t ( 'common/transfer', 'Product' ),
+ self::TYPE_TICKET => Yii::t ( 'common/transfer', 'Ticket' )
+ ];
+ }
+ public static function paymentMethods() {
+ return [
+ self::PAYMENT_METHOD_CASH => Yii::t ( 'common/transfer', 'Készpénz' ),
+ self::PAYMENT_METHOD_BANCCARD => Yii::t ( 'common/transfer', 'Bankkártyás fizetés' ),
+ self::PAYMENT_METHOD_TRANSFER => Yii::t ( 'common/transfer', 'Átutalás' ),
+ self::PAYMENT_METHOD_CAFETERY => Yii::t ( 'common/transfer', 'Széchenyi kártya' )
+ ]
+ // self::PAYMENT_METHOD_DEBIT_MANDATE => Yii::t('common/transfer','Csoportos beszedési megbízás'),
+ ;
+ }
+ public static function statuses() {
+ return [
+ self::STATUS_NOT_PAID => Yii::t ( 'common/transfer', 'Nincs fizetve' ),
+ self::STATUS_PAID => Yii::t ( 'common/transfer', 'Fizetve' ),
+ self::STATUS_STORNO => Yii::t ( 'common/transfer', 'Törölve' )
+ ];
+ }
+ public function getStatusName() {
+ $status = null;
+ $statuses = self::statuses ();
+ if (array_key_exists ( $this->status, $statuses )) {
+ $status = $statuses [$this->status];
+ }
+ return $status;
+ }
+ public function getPaymentMethodName() {
+ $status = null;
+ $statuses = self::paymentMethods ();
+ if (array_key_exists ( $this->payment_method, $statuses )) {
+ $status = $statuses [$this->payment_method];
+ }
+ return $status;
+ }
+ public function beforeDelete() {
+ parent::beforeDelete ();
+ if ($this->type == Transfer::TYPE_TICKET) {
+ $ticket = $this->ticket;
+ if ($ticket != null) {
+ $ticket->delete ();
+ }
+ } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
+ $mm = $this->moneyMovement;
+ $mm->delete ();
+ } else if ($this->type == Transfer::TYPE_PRODUCT) {
+ $sale = $this->sale;
+ $product = $this->product;
+
+ $product->stock = $product->stock + $this->count;
+
+ $product->save ();
+ $sale->delete ();
+ }
+
+ ShoppingCart::deleteAll ( [
+ 'id_transfer' => $this->id_transfer
+ ] );
+ UserSoldItem::deleteAll ( [
+ 'id_transfer' => $this->id_transfer
+ ] );
+
+ return true;
+ }
+
+ /**
+ *
+ * @param string $mode
+ * The mode to load
+ * Available modes
+ *
+ * -
+ *
created_at
+ * Load all transfer which were created
+ *
+ * -
+ *
paid_at
+ * Load all transfer which were paid
+ *
+ * -
+ *
created_at_paid
+ * Load all transfer which were created and paid
+ *
+ * -
+ *
created_at_not_paid
+ * Load all transfer which were created but not paid
+ *
+ * -
+ *
paid_at_not_created_at
+ * Load all transfer which were not created but paid . Works correctly only,
+ * when start and end date given
+ *
+ *
+ *
+ *
+ *
+ */
+ public static function mkTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
+ $query = new Query ();
+
+ $query->addSelect ( [
+ new Expression ( 'transfer.id_account as account' ),
+ new Expression ( ' COALESCE(sum( ( case when direction = ' . Transfer::DIRECTION_OUT . ' then -1 else 1 end )* transfer.money ),0) as money /** --' . $mode . '*/' )
+ ]
+ );
+ $query->from ( 'transfer' );
+
+ if (! RoleDefinition::isAdmin ()) {
+ $query->innerJoin ( "user_account_assignment", 'transfer.id_account = user_account_assignment.id_account' );
+ $query->andWhere ( [
+ 'user_account_assignment.id_user' => Yii::$app->user->id
+ ] );
+ }
+ $query->innerJoin ( "account", 'transfer.id_account = account.id_account' );
+ $query->andWhere ( [
+ 'account.type' => Account::TYPE_ALL
+ ] );
+
+ $query->andFilterWhere ( [
+ 'transfer.id_account' => $idAccount
+ ] );
+
+ $query->andFilterWhere ( [
+ 'transfer.id_user' => $idUser
+ ] );
+
+ $query->andFilterWhere ( [
+ 'in',
+ 'transfer.type',
+ $types
+ ] );
+
+ $query->andWhere ( [
+ 'not in',
+ 'transfer.status',
+ Transfer::STATUS_STORNO
+ ] );
+
+ if ($mode == 'created_at') {
+ self::inInterval ( $query, 'transfer.created_at', $start, $end );
+ } else if ($mode == 'paid_at') {
+ self::inInterval ( $query, 'transfer.paid_at', $start, $end );
+ } else if ($mode == 'created_at_not_paid') {
+ self::notPaid ( $query, 'transfer.paid_at', $start, $end );
+ self::inInterval ( $query, 'transfer.created_at', $start, $end );
+ } else if ($mode == 'created_at_paid') {
+ self::inInterval ( $query, 'transfer.created_at', $start, $end );
+ self::inInterval ( $query, 'transfer.paid_at', $start, $end );
+ } else if ($mode == 'paid_at_not_created_at') {
+ self::inInterval ( $query, 'transfer.paid_at', $start, $end );
+ self::notInInterval ( $query, 'transfer.created_at', $start, $end );
+ }
+
+ $query->groupBy ( 'transfer.id_account' );
+
+ return $query;
+ }
+ public static function notInInterval($query, $field, $start, $end) {
+ $query->andFilterWhere ( [
+ 'or',
+ [
+ '<',
+ $field,
+ isset ( $start ) ? $start : '1900-01-01'
+ ],
+ [
+ '>=',
+ $field,
+ isset ( $end ) ? $end : '3000-01-01'
+ ]
+ ] );
+ }
+ public static function notPaid($query, $field, $start, $end) {
+ $query->andFilterWhere ( [
+ 'or',
+ [
+ '<',
+ $field,
+ isset ( $start ) ? $start : '1900-01-01'
+ ],
+ [
+ '>=',
+ $field,
+ isset ( $end ) ? $end : '3000-01-01'
+ ],
+ [
+ "transfer.status" => Transfer::STATUS_NOT_PAID
+ ]
+ ] );
+ }
+ public static function inInterval($query, $field, $start, $end) {
+ $query->andFilterWhere ( [
+ '>=',
+ $field,
+ $start
+ ] );
+ $query->andFilterWhere ( [
+ '<',
+ $field,
+ $end
+ ] );
+ }
+
+ /**
+ *
+ * Parse query results so, that all available account will be display, even then , if $queryResult does not contain any result for the given account
+ *
+ * @param mixed $queryResult
+ * an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ]
+ *
+ */
+ public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount) {
+ $totals = [ ];
+ $totals ['total'] = 0;
+
+ $totals ['accounts'] = [ ];
+
+ foreach ( $accounts as $account ) {
+ if (isset ( $idAccount ) && is_numeric ( $idAccount ) && $idAccount != $account->id_account) {
+ continue;
+ }
+
+ $accountTotal = [
+ 'id_account' => $account->id_account,
+ 'label' => $account->name,
+ 'money' => 0
+ ];
+
+ $item = self::findByAccountInQueryResult ( $queryResult, $account );
+
+ if (isset ( $item )) {
+ $accountTotal ['money'] = $item ['money'];
+ }
+
+ $totals ['accounts'] [] = $accountTotal;
+ $totals ['total'] += $accountTotal ['money'];
+ }
+ return $totals;
+ }
+ public static function findByAccountInQueryResult($queryResult, $account) {
+ $result = null;
+ foreach ( $queryResult as $item ) {
+ if ($item ['account'] == $account->id_account) {
+ $result = $item;
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * create and execute a "total" query
+ */
+ public static function exTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
+ $query = self::mkTotalQuery ( $mode, $start, $end, $idUser, $types, $idAccount );
+ $command = $query->createCommand ();
+ $result = $command->queryAll ();
+ return $result;
+ }
+
+ /**
+ * find all transfers which were paid in the period
+ */
+ public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
+ $result = [ ];
+ $queryResult = self::exTotalQuery ( 'paid_at', $start, $end, $idUser, $types, $idAccount );
+ $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
+ return $result;
+ }
+
+ /**
+ * find all transfers in the period ( doesn't matter if paid or not )
+ */
+ public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
+ $result = [ ];
+ $queryResult = self::exTotalQuery ( 'created_at', $start, $end, $idUser, $types, $idAccount );
+ $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
+ return $result;
+ }
+
+ /**
+ * find transfers which were created but not paid in the period
+ */
+ public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
+ $result = [ ];
+ $queryResult = self::exTotalQuery ( 'created_at_not_paid', $start, $end, $idUser, $types, $idAccount );
+ $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
+ return $result;
+ }
+
+ /**
+ * find transfers which were created and paid in the period
+ */
+ public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
+ $result = [ ];
+ $queryResult = self::exTotalQuery ( 'created_at_paid', $start, $end, $idUser, $types, $idAccount );
+ $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
+ return $result;
+ }
+
+ /**
+ * find transfers, where depth was paid
+ */
+ public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
+ $result = [ ];
+ $queryResult = self::exTotalQuery ( 'paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount );
+ $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount );
+ return $result;
+ }
+ public static function mkTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
+ $result = [ ];
+
+ $result ['paid_at'] = self::mkPaidAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
+ $result ['created_at'] = self::mkCreatedAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
+ $result ['created_at_not_paid'] = self::mkCreatedAtNotPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
+ $result ['created_at_paid'] = self::mkCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
+ $result ['paid_at_not_created_at'] = self::mkPaidAtNotCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap );
+
+ return $result;
+ }
+ public static function readPaid($start, $end, $idUser) {
+ $query = (new \yii\db\Query ());
+ $query->select ( [
+ 'coalesce(sum( case when transfer.direction = ' . Transfer::DIRECTION_IN . ' then transfer.money else -1 * transfer.money end ),0) AS transfer_money'
+ ] );
+ $query->from ( 'transfer' );
+ $query->innerJoin ( "account", "account.id_account = transfer.id_account" );
+ $query->andWhere ( [
+ 'transfer.id_user' => $idUser
+ ] );
+
+ $created_condition = [
+ 'and',
+ [
+ '>=',
+ 'transfer.created_at',
+ $start
+ ],
+ [
+ '<',
+ 'transfer.created_at',
+ $end
+ ]
+ ];
+ $paid_condition = [
+ 'and',
+ [
+ '>=',
+ 'transfer.paid_at',
+ $start
+ ],
+ [
+ '<',
+ 'transfer.paid_at',
+ $end
+ ]
+ ];
+
+ $query->andFilterWhere ( [
+ 'or',
+ $created_condition,
+ $paid_condition
+ ] );
+ $query->andWhere ( [
+ 'transfer.status' => Transfer::STATUS_PAID
+ ] );
+ $query->andWhere ( [
+ 'account.type' => Account::TYPE_ALL
+ ] );
+ $query->andWhere ( [
+ 'transfer.payment_method' => Transfer::PAYMENT_METHOD_CASH
+ ] );
+
+ return $query->scalar ();
+ }
+ public function storno() {
+ $this->status = Transfer::STATUS_STORNO;
+ $this->save ( false );
+ if ($this->type == Transfer::TYPE_TICKET) {
+ $ticket = $this->ticket;
+ $ticket->status = Ticket::STATUS_DELETED;
+
+ $ticket->save ( false );
+
+ if ( $ticket->part == 0 ){
+ TicketInstallmentRequest::updateAll ( [
+ 'status' => TicketInstallmentRequest::$STATUS_CANCELED
+ ], [
+ 'id_ticket' => $this->ticket->id_ticket
+ ] );
+ }
+
+ // storno contract
+
+ } else if ($this->type == Transfer::TYPE_PRODUCT) {
+ $sale = $this->sale;
+ $product = $this->sale->product;
+ $product->stock = $product->stock + $this->count;
+ $product->save ( false );
+ $sale->status = Sale::STATUS_DELETED;
+ $sale->save ( false );
+ } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
+ $mm = $this->moneyMovement;
+ $mm->status = MoneyMovement::STATUS_STORNO;
+ $mm->save ( false );
+ }
+ }
+ public function payout() {
+ if ($this->status != Transfer::STATUS_NOT_PAID) {
+ return false;
+ }
+
+ $this->status = Transfer::STATUS_PAID;
+ $this->paid_at = Helper::getDateTimeString ();
+ $this->paid_by = \Yii::$app->user->id;
+ ShoppingCart::deleteAll ( [
+ 'id_transfer' => $this->id_transfer
+ ] );
+ UserSoldItem::deleteAll ( [
+ 'id_transfer' => $this->id_transfer
+ ] );
+ return $this->save ();
+ }
+ public static function payoutAll($id_user, $id_array) {
+ ShoppingCart::deleteAll ( [
+ 'in',
+ 'id_transfer',
+ $id_array
+ ] );
+ UserSoldItem::deleteAll ( [
+ 'in',
+ 'id_transfer',
+ $id_array
+ ] );
+ Transfer::updateAll ( [
+ 'status' => Transfer::STATUS_PAID,
+ 'paid_at' => Helper::getDateTimeString (),
+ 'paid_by' => $id_user
+ ], [
+ [
+ 'in',
+ 'id_transfer',
+ $id_array
+ ],
+ [
+ 'in',
+ 'status',
+ [
+ Transfer::STATUS_NOT_PAID
+ ]
+ ]
+ ] );
+ }
+
+ /**
+ *
+ * @param common\models\Contract $contract
+ * @param common\models\TicketInstallmentRequest $request
+ * @param common\models\Account $account
+ * @param int $transferStatus
+ *
+ *
+ */
+ public static function sellContractTicket($contract, $request, $account, $transferStatus, $paymentMethod, $addToCustomerCart = false) {
+ $ticketType = $contract->ticketType;
+ $customer = $contract->customer;
+ $card = $customer->card;
+
+ $ticket = new Ticket ();
+
+ $ticket->id_user = \Yii::$app->user->id;
+ $ticket->id_ticket_type = $ticketType->id_ticket_type; // save to contract
+ $ticket->id_account = $account->id_account;
+ $ticket->id_discount = null; // contract.id_discount
+ $ticket->start = $request->request_target_time_at;
+ $ticket->end = date( 'Y-m-d', strtotime( $request->request_target_time_at . " +1 month -1 day"));
+ $ticket->max_usage_count = $ticketType->max_usage_count;
+ $ticket->usage_count = 0;
+ $ticket->status = Ticket::STATUS_ACTIVE;
+ $ticket->price_brutto = $request->money;
+ $ticket->id_card = $card->id_card;
+ $ticket->part = $request->priority;
+ $ticket->id_contract = $contract->id_contract;
+ $ticket->save ( false );
+
+ $transfer = new Transfer ();
+
+ $transfer->status = $transferStatus;
+ $transfer->type = Transfer::TYPE_TICKET;
+ $transfer->direction = Transfer::DIRECTION_IN;
+ $transfer->id_object = $ticket->id_ticket;
+ $transfer->item_price = $ticketType->price_brutto;
+ $transfer->money = $request->money;
+ $transfer->id_account = $account->id_account;
+ $transfer->count = 1;
+
+ if ($transferStatus == Transfer::STATUS_PAID) {
+ $transfer->paid_at = date ( 'Y-m-d H:i:s' );
+ $transfer->paid_by = \Yii::$app->user->id;
+ }
+
+ $transfer->payment_method = $paymentMethod;
+
+ $transfer->comment = "Szerződéses bérlet létrehozás";
+ $transfer->id_user = \Yii::$app->user->id;
+ $transfer->id_customer = $customer->id_customer;
+ $transfer->save (false);
+
+
+ if ( $addToCustomerCart == true ){
+ $cart = new ShoppingCart();
+ $cart->id_customer = $customer->id_customer;
+ $cart->id_transfer = $transfer->id_transfer;
+ $cart->save(false);
+ }
+
+ return [$transfer,$ticket];
+ }
}
diff --git a/common/models/TransferSaleSearch.php b/common/models/TransferSaleSearch.php
index a478630..72c7a79 100644
--- a/common/models/TransferSaleSearch.php
+++ b/common/models/TransferSaleSearch.php
@@ -271,7 +271,7 @@ class TransferSaleSearch extends Transfer
protected function readProducts(){
$query = (new \yii\db\Query());
- $query->select([ 'transfer.id_transfer as id_transfer', 'customer.name as customer_name' ,'user.username as user_name','account.name as account_name' , 'product_category.name as product_category_name', 'product.name as product_name', 'transfer.money AS product_money', 'transfer.count AS product_count', 'transfer.money AS product_money','transfer.item_price AS product_item_price', 'transfer.created_at as product_created_at','transfer.paid_at as product_paid_at']);
+ $query->select([ 'transfer.payment_method as transfer_payment_method', 'transfer.id_transfer as id_transfer', 'customer.name as customer_name' ,'user.username as user_name','account.name as account_name' , 'product_category.name as product_category_name', 'product.name as product_name', 'transfer.money AS product_money', 'transfer.count AS product_count', 'transfer.money AS product_money','transfer.item_price AS product_item_price', 'transfer.created_at as product_created_at','transfer.paid_at as product_paid_at']);
$query->from('transfer');
$query->andWhere(['transfer.type' => Transfer::TYPE_PRODUCT]);
$query->innerJoin("sale", "sale.id_sale = transfer.id_object");
diff --git a/console/migrations/m160123_222804_alter__table__ticket_installment_request__add__column__ugiro__number.php b/console/migrations/m160123_222804_alter__table__ticket_installment_request__add__column__ugiro__number.php
new file mode 100644
index 0000000..e487993
--- /dev/null
+++ b/console/migrations/m160123_222804_alter__table__ticket_installment_request__add__column__ugiro__number.php
@@ -0,0 +1,30 @@
+addColumn("ticket_installment_request", "number", "int");
+ }
+
+ public function down()
+ {
+ echo "m160123_222804_alter__table__ticket_installment_request__add__column__ugiro__number cannot be reverted.\n";
+
+ return false;
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/console/migrations/m160124_135213_add__table__contract.php b/console/migrations/m160124_135213_add__table__contract.php
new file mode 100644
index 0000000..0a13e82
--- /dev/null
+++ b/console/migrations/m160124_135213_add__table__contract.php
@@ -0,0 +1,50 @@
+db->driverName === 'mysql') {
+ // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
+ $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
+ }
+
+ $this->createTable('{{%contract}}', [
+ 'id_contract' => $this->primaryKey(),
+ 'id_user' => $this->integer(11),
+ 'id_customer' => $this->integer(11),
+ 'status' => $this->integer(11),
+ 'flag' => $this->integer(11),
+ 'part_paid' => $this->integer(11),
+ 'part_count' => $this->integer(11),
+ 'part_required' => $this->integer(11),
+ 'expired_at' => $this->dateTime()->notNull(),
+ 'created_at' => $this->dateTime()->notNull(),
+ 'updated_at' => $this->dateTime()->notNull(),
+ ], $tableOptions);
+
+ $this->addColumn("ticket", "id_contract", "int");
+ $this->addColumn("ticket_installment_request", "id_contract", "int");
+
+
+ }
+
+ public function down()
+ {
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/console/migrations/m160124_204003_alter__table__contract__add__field__ticket_type.php b/console/migrations/m160124_204003_alter__table__contract__add__field__ticket_type.php
new file mode 100644
index 0000000..644ba2f
--- /dev/null
+++ b/console/migrations/m160124_204003_alter__table__contract__add__field__ticket_type.php
@@ -0,0 +1,30 @@
+addColumn("contract", "id_ticket_type", "int");
+ }
+
+ public function down()
+ {
+ echo "m160124_204003_alter__table__contract__add__field__ticket_type cannot be reverted.\n";
+
+ return false;
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/console/migrations/m160124_235346_add_product_buntetes.php b/console/migrations/m160124_235346_add_product_buntetes.php
new file mode 100644
index 0000000..f87b849
--- /dev/null
+++ b/console/migrations/m160124_235346_add_product_buntetes.php
@@ -0,0 +1,44 @@
+name = "Büntetések";
+ $productCategory->status = ProductCategory::STATUS_ACTIVE;
+
+ $productCategory->save(false);
+
+ $product = new Product();
+ $product->name = "Büntetés Szerződés 3000 ft";
+ $product->product_number = "buntetes3000";
+ $product->id_account = 1;
+ $product->purchase_price = 0;
+ $product->sale_price = 3000;
+ $product->id_product_category = $productCategory->id_product_category;
+ $product->save(false);
+
+
+ }
+
+ public function down()
+ {
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/console/migrations/m160125_094224_add__table__door_log.php b/console/migrations/m160125_094224_add__table__door_log.php
new file mode 100644
index 0000000..fe76b80
--- /dev/null
+++ b/console/migrations/m160125_094224_add__table__door_log.php
@@ -0,0 +1,44 @@
+db->driverName === 'mysql') {
+ // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
+ $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
+ }
+
+ $this->createTable('{{%door_log}}', [
+ 'id_door_log' => $this->primaryKey(),
+ 'id_card' => $this->integer(11),
+ 'id_customer' => $this->integer(11),
+ 'id_key' => $this->integer(11),
+ 'direction' => $this->integer(11),
+ 'type' => $this->integer(11),
+ 'created_at' => $this->dateTime()->notNull(),
+ ], $tableOptions);
+ }
+
+ public function down()
+ {
+ echo "m160125_094224_add__table__door_log cannot be reverted.\n";
+
+ return false;
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/frontend/assets/TransferUserCartAsset.php b/frontend/assets/TransferUserCartAsset.php
new file mode 100644
index 0000000..ffe4db2
--- /dev/null
+++ b/frontend/assets/TransferUserCartAsset.php
@@ -0,0 +1,28 @@
+
+ * @since 2.0
+ */
+class TransferUserCartAsset extends AssetBundle
+{
+ public $basePath = '@webroot';
+ public $baseUrl = '@web';
+ public $css = [
+ ];
+ public $js = [
+ 'js/transfer.usercart.js',
+ ];
+ public $depends = [
+ 'frontend\assets\AppAsset',
+ ];
+}
diff --git a/frontend/controllers/ContractController.php b/frontend/controllers/ContractController.php
new file mode 100644
index 0000000..bd6a4ef
--- /dev/null
+++ b/frontend/controllers/ContractController.php
@@ -0,0 +1,294 @@
+ [
+ 'class' => VerbFilter::className (),
+ 'actions' => [
+ 'delete' => [
+ 'post'
+ ],
+ 'payout' => [
+ 'post'
+ ],
+ 'cancel' => [
+ 'post'
+ ],
+ ]
+ ]
+ ];
+ }
+
+ /**
+ * Lists all Contract models.
+ *
+ * @return mixed
+ */
+ public function actionIndex($id_card) {
+ $card = Card::findOne ( $id_card );
+
+ if (! isset ( $card ))
+ throw new NotFoundHttpException ( 'A bérlet nem található' );
+
+ $searchModel = new ContractSearch ();
+ $searchModel->card = $card;
+ $searchModel->customer = $card->customer;
+ $dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
+
+ return $this->render ( 'index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider
+ ] );
+ }
+
+ /**
+ * Displays a single Contract model.
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionView($id) {
+ $model = $this->findModel ( $id );
+ $customer = $model->customer;
+ $card = $customer->card;
+
+ $installments = TicketInstallmentRequest::find ()->andWhere ( [
+ 'id_contract' => $model->id_contract
+ ] )->orderBy ( [
+ 'ticket_installment_request.priority' => SORT_ASC
+ ] )->all ();
+
+ return $this->render ( 'view', [
+ 'model' => $model,
+ 'intstallments' => $installments,
+ 'card' => $card
+ ] );
+ }
+
+ /**
+ * Creates a new Contract model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ *
+ * @return mixed
+ */
+ public function actionCreate() {
+ $model = new Contract ();
+
+ if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
+ return $this->redirect ( [
+ 'view',
+ 'id' => $model->id_contract
+ ] );
+ } else {
+ return $this->render ( 'create', [
+ 'model' => $model
+ ] );
+ }
+ }
+
+ /**
+ * Updates an existing Contract model.
+ * If update is successful, the browser will be redirected to the 'view' page.
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionUpdate($id) {
+ $model = $this->findModel ( $id );
+
+ if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
+ return $this->redirect ( [
+ 'view',
+ 'id' => $model->id_contract
+ ] );
+ } else {
+ return $this->render ( 'update', [
+ 'model' => $model
+ ] );
+ }
+ }
+
+ /**
+ * Deletes an existing Contract model.
+ * If deletion is successful, the browser will be redirected to the 'index' page.
+ *
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionDelete($id) {
+ $this->findModel ( $id )->delete ();
+
+ return $this->redirect ( [
+ 'index'
+ ] );
+ }
+
+ /**
+ * EGY RÉSZLET KIFIZETÉSE
+ */
+ public function actionPayout($id) {
+ $part = TicketInstallmentRequest::findOne ( $id );
+ $contract = $part->contract;
+ $customer = $contract->customer;
+ $card = $customer->card;
+
+ $connection = \Yii::$app->db;
+ $transaction = $connection->beginTransaction ();
+ try {
+
+ $result = Transfer::sellContractTicket ( $contract, $part, Account::readDefaultObject (), Transfer::STATUS_NOT_PAID, Transfer::PAYMENT_METHOD_CASH, true );
+ $transfer = $result [0];
+ $ticket = $result[1];
+ if ( $part->status != TicketInstallmentRequest::$STATUS_REJECTED ){
+ $contract->part_required = $contract->part_required +1;
+ }
+
+ $contract->part_paid = $contract->part_paid +1;
+
+ if ( $contract->part_paid >= $contract->part_required){
+ $contract->status = Contract::$STATUS_PAID;
+ }else{
+ $contract->status = Contract::$STATUS_NOT_PAID;
+ }
+
+ $contract->save(false);
+
+ $part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
+ $part->id_transfer = $transfer->id_transfer;
+ $part->request_processed_at = Helper::getDateTimeString ();
+ $part->id_ticket = $ticket->id_ticket;
+
+ $part->save ( false );
+ $transaction->commit ();
+ \Yii::$app->session->setFlash ( 'success', "Részlet a bevásárló kosárba helyezve!" );
+ } catch ( Exception $e ) {
+ $transaction->rollback ();
+ Yii::error ( "Nem sikerült a kifizetés." );
+ }
+
+ return $this->redirect ( [
+ 'view',
+ 'id' => $contract->id_contract
+ ] );
+ }
+
+ /**
+ * EGY RÉSZLET KIFIZETÉSE
+ */
+ public function actionCancel($id) {
+ $contract = $this->findModel ( $id );
+ $customer = $contract->customer;
+ $card = $customer->card;
+
+ if ($contract->canCancel ()) {
+ $connection = \Yii::$app->db;
+ $transaction = $connection->beginTransaction ();
+ try {
+
+ $contract->flag = Contract::$FLAG_CANCELED;
+ $contract->save ();
+ $requests = $contract->requests;
+ $buntetes = 0;
+
+ foreach ( $requests as $request ) {
+ /** @var common\models\TicketInstallmentRequest $request*/
+ if ($request->isStatusAccepted ()) {
+ $buntetes = $buntetes + 1;
+ } else {
+ $request->status = TicketInstallmentRequest::$STATUS_CANCELED;
+ $request->save ( false );
+ }
+ }
+
+ $productBuntetes = Product::find ()->andWhere ( [
+ 'product_number' => Product::$BUNTETES
+ ] )->one ();
+
+ if (isset ( $productBuntetes )) {
+ if ($buntetes > 0) {
+
+ $sale = new Sale ();
+ $sale->id_account = Account::readDefault ();
+ $sale->id_product = $productBuntetes->id_product;
+ $sale->status = Sale::STATUS_NOT_PAID;
+ $sale->type = Sale::TYPE_PRODUCT;
+ $sale->item_price = $productBuntetes->sale_price;
+ $sale->count = $buntetes;
+ $sale->money = $buntetes * $sale->item_price;
+ $sale->id_user = \Yii::$app->user->id;
+
+ $sale->save ( false );
+
+ $transfer = Transfer::createProductTransfer ( $sale, Account::readDefaultObject (), null, null, $sale->count, $productBuntetes, Transfer::STATUS_NOT_PAID, $customer );
+ $transfer->payment_method = Transfer::PAYMENT_METHOD_CASH;
+
+ $transfer->id_user = Yii::$app->user->id;
+
+ $transfer->save ( false );
+
+ $cart = new ShoppingCart ();
+ $cart->id_customer = $customer->id_customer;
+ $cart->id_transfer = $transfer->id_transfer;
+ $cart->save ( false );
+ }
+ }
+
+ $transaction->commit ();
+ \Yii::$app->session->setFlash ( 'success', "Szerződés felbontva!" );
+
+ return $this->redirect ( [
+ 'product/sale',
+ 'number' => $card->number
+ ] );
+ } catch ( Exception $e ) {
+ $transaction->rollback ();
+ Yii::error ( "Szerződés felbontása nem sikerült!" );
+ }
+ }else{
+ \Yii::$app->session->setFlash ( 'danger', "Szerződést nem lehet felbontani!" );
+ }
+
+ return $this->redirect ( [
+ 'view',
+ 'id' => $contract->id_contract
+ ] );
+ }
+
+ /**
+ * Finds the Contract model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ *
+ * @param integer $id
+ * @return Contract the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id) {
+ if (($model = Contract::findOne ( $id )) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException ( 'The requested page does not exist.' );
+ }
+ }
+}
diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php
index 8ba9b92..61458a0 100644
--- a/frontend/controllers/CustomerController.php
+++ b/frontend/controllers/CustomerController.php
@@ -34,7 +34,7 @@ class CustomerController extends Controller
],
'access' => [
'class' => \yii\filters\AccessControl::className(),
- 'only' => ['create', 'update','reception'],
+ 'only' => ['create', 'update','reception','contract'],
'rules' => [
// allow authenticated users
[
@@ -199,6 +199,18 @@ class CustomerController extends Controller
}
}
+
+ public function actionContract($id){
+ $model = $this->findModel($id);
+
+ $mpdf=new \mPDF('utf-8', 'A4-L');
+ $mpdf->WriteHTML($this->renderPartial('_contract', [
+ 'model' => $model,
+ ]));
+ $mpdf->Output('szerzodes.pdf', 'D');
+ exit;
+ }
+
/**
* Deletes an existing Customer model.
* If deletion is successful, the browser will be redirected to the 'index' page.
diff --git a/frontend/controllers/TransferController.php b/frontend/controllers/TransferController.php
index 14729b8..f17128b 100644
--- a/frontend/controllers/TransferController.php
+++ b/frontend/controllers/TransferController.php
@@ -19,6 +19,7 @@ use common\models\ProductCategory;
use common\models\Product;
use common\models\TransferTicketSearch;
use common\models\TicketType;
+use frontend\models\UserCartForm;
/**
* TransferController implements the CRUD actions for Transfer model.
@@ -337,4 +338,15 @@ class TransferController extends Controller
exit;
}
+
+
+ public function actionUserCart(){
+
+ $model = new UserCartForm();
+ if ($model->load(Yii::$app->request->post()) && $model->payout()) {
+ return $this->redirect(['user-cart']);
+ }
+ $model->run();
+ return $this->render("usercart",[ 'model' => $model]);
+ }
}
diff --git a/frontend/models/ContractSearch.php b/frontend/models/ContractSearch.php
new file mode 100644
index 0000000..f19c4e0
--- /dev/null
+++ b/frontend/models/ContractSearch.php
@@ -0,0 +1,88 @@
+ $query,
+ ]);
+
+ $this->load($params);
+
+ if (!$this->validate()) {
+ // uncomment the following line if you do not want to return any records when validation fails
+ // $query->where('0=1');
+ return $dataProvider;
+ }
+
+ $query->andWhere([
+ 'id_customer' => $this->customer->id_customer
+ ]);
+
+ $query->andFilterWhere([
+// 'id_contract' => $this->id_contract,
+// 'id_user' => $this->id_user,
+// 'id_customer' => $this->id_customer,
+// 'status' => $this->status,
+// 'flag' => $this->flag,
+// 'part_paid' => $this->part_paid,
+// 'part_count' => $this->part_count,
+// 'part_required' => $this->part_required,
+// 'expired_at' => $this->expired_at,
+// 'created_at' => $this->created_at,
+// 'updated_at' => $this->updated_at,
+ ]);
+
+
+
+
+ return $dataProvider;
+ }
+}
diff --git a/frontend/models/KeyToggleForm.php b/frontend/models/KeyToggleForm.php
index a8df8d4..2b845d2 100644
--- a/frontend/models/KeyToggleForm.php
+++ b/frontend/models/KeyToggleForm.php
@@ -56,12 +56,17 @@ class KeyToggleForm extends Model
public function assign(){
if ( isset($this->card) && isset($this->customer) ){
- $assignment = new CardKeyAssignment();
- $assignment->id_card = $this->card->id_card;
- $assignment->id_key = $this->keyModel->id_key;
- $assignment->id_user = \Yii::$app->user->id;
- $assignment->save(false);
- \Yii::$app->session->setFlash ( 'success', 'Kulcs kiadva!' );
+ $assignments = CardKeyAssignment::find()->andWhere(['id_card' => $this->card->id_card])->all();
+ if ( count($assignments) > 0 ){
+ \Yii::$app->session->setFlash ( 'danger', 'A vendégnél egyszerre csak egy kulcs lehet' );
+ }else{
+ $assignment = new CardKeyAssignment();
+ $assignment->id_card = $this->card->id_card;
+ $assignment->id_key = $this->keyModel->id_key;
+ $assignment->id_user = \Yii::$app->user->id;
+ $assignment->save(false);
+ \Yii::$app->session->setFlash ( 'success', 'Kulcs kiadva!' );
+ }
}else{
\Yii::$app->session->setFlash ( 'danger', 'Nincs vendég kiválasztva vagy érvénytelen kártya!' );
}
diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php
index 1f62bf5..b6f7c68 100644
--- a/frontend/models/ReceptionForm.php
+++ b/frontend/models/ReceptionForm.php
@@ -12,6 +12,8 @@ use common\models\CardSearch;
use common\models\AccountState;
use common\models\Key;
use common\models\CardKeyAssignment;
+use common\models\Contract;
+use yii\db\Expression;
/**
* ContactForm is the model behind the contact form.
@@ -26,6 +28,7 @@ class ReceptionForm extends Model
public $cardSearchModel;
public $lastCassaState;
public $keys;
+ public $contract;
/**
* @inheritdoc
*/
@@ -73,6 +76,7 @@ class ReceptionForm extends Model
$this->customer = $this->card->customer;
$this->readValidTickets();
$this->readAssignedKeys();
+ $this->readContract();
}
$defaultAccount = Account::readDefault();
@@ -104,6 +108,18 @@ class ReceptionForm extends Model
}
}
+ public function readContract(){
+ if ($this->isCardWithCustomer()){
+
+ $query = Contract::find();
+ $query->andWhere(['id_customer' => $this->customer->id_customer ]);
+ $query->andWhere([ '>=' ,'expired_at' , new Expression("now()") ]);
+ $query->andWhere(["not in" , 'flag' , [Contract::$FLAG_DELETED ]]);
+ $this->contract = $query->one();
+ }
+
+ }
+
public function hasCassa(){
return isset($this->lastCassaState) ;
}
diff --git a/frontend/models/TicketCreate.php b/frontend/models/TicketCreate.php
index 3c6e33d..610cbf6 100644
--- a/frontend/models/TicketCreate.php
+++ b/frontend/models/TicketCreate.php
@@ -10,6 +10,8 @@ use common\models\UserSoldItem;
use common\models\ShoppingCart;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
+use common\models\Contract;
+use common\components\Helper;
/**
* @property $cart string name of cart, into we put the ticket
@@ -103,6 +105,17 @@ class TicketCreate extends Ticket{
$this->addError($attribute,"Vendég bankszámlaszáma nem 16 vagy 24 hosszú");
return;
}
+ //find
+ $query = Contract::find();
+ $query->andWhere( [ 'id_customer' => $this->customer->id_customer ]);
+ $query->andWhere( [ '>', 'expired_at' , Helper::getDateTimeString() ]);
+ $query->andWhere( [ 'not in', 'flag', [Contract::$FLAG_DELETED ] ]);
+ $contracts = $query->all();
+
+ if ( count($contracts) > 0 ){
+ $this->addError($attribute,"A vendégnek már van érvényes vagy felbontott szerződése!");
+ }
+
}
}
}
@@ -142,15 +155,28 @@ class TicketCreate extends Ticket{
$this->addTransfer();
$this->appendToUserCart();
$this->appendToCustomerCart();
- $this->addTicketInstallmentRequests($insert);
+ $this->addContract($insert);
}
- public function addTicketInstallmentRequests($insert){
+ public function addContract($insert){
if ($insert){
$ticketType = TicketType::findOne($this->id_ticket_type);
if ( isset($ticketType) && $ticketType->isInstallment() ){
- $requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer);
+
+ $contract = new Contract();
+ $contract->id_customer = $this->customer->id_customer;
+ $contract->id_user = \Yii::$app->user->id;
+ $contract->status = Contract::$STATUS_PAID;
+ $contract->flag = Contract::$FLAG_ACTIVE;
+ $contract->part_count = $ticketType->installment_count;
+ $contract->part_paid = 0;
+ $contract->part_required = 0;
+ $contract->expired_at = date('Y-m-d', strtotime("today +12 month -1 day"));
+ $contract->id_ticket_type = $this->id_ticket_type;
+ $contract->save();
+
+ $requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);
foreach ($requests as $request){
$request->save(false);
}
diff --git a/frontend/models/UserCartForm.php b/frontend/models/UserCartForm.php
new file mode 100644
index 0000000..2b8c785
--- /dev/null
+++ b/frontend/models/UserCartForm.php
@@ -0,0 +1,103 @@
+ ['integer']],
+ [['money' ,'payment_method'],'integer'],
+ [['payment_method'],'validatePaymentMethod'],
+ ];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function attributeLabels()
+ {
+ return [
+ ];
+ }
+
+ public function validatePaymentMethod( $attribute, $params ){
+ if ( !empty($this->payment_method)){
+// echo $this->payment_method;
+ $arr = Transfer::paymentMethods();
+ if ( !array_key_exists($this->payment_method, $arr) ){
+ $this->addError($attribute, "Érvénytelen fizetési mód");
+ }
+ }
+ }
+
+
+ public function payout(){
+ $valid = $this->validate();
+
+ if ( !$valid ){
+ return false;
+ }
+
+ if ( isset($this->selected) && count($this->selected) > 0 ){
+ $items = $this->loadTransfers($this->selected);
+ if ( count($items) == count($this->selected) ){
+ foreach ($items as $item){
+ $this->changePaymentMethod($item);
+ $item->payout();
+ }
+ \Yii::$app->session->setFlash('success', 'Kifizetve');
+ return true;
+ }else{
+ \Yii::$app->session->setFlash('danger', 'Időközben változtak a kosrában található tételek');
+ return false;
+ }
+ }else{
+ \Yii::$app->session->setFlash('danger', 'Nem választott ki terméket');
+ return false;
+ }
+ }
+
+ public function changePaymentMethod($item){
+ if ( !empty($this->payment_method)){
+ $item->payment_method = $this->payment_method;
+ }
+ }
+
+ public function run(){
+ $this->readTransfers();
+ }
+
+ public function readTransfers( ) {
+ $this->transfers = $this->loadTransfers();
+ }
+
+ public function loadTransfers($id_tranfer_array = null){
+ $query = Transfer::find();
+ $query->innerJoin("user_sold_item", "user_sold_item.id_transfer = transfer.id_transfer");
+ $query->andWhere(["user_sold_item.id_user" => \Yii::$app->user->id]);
+ if (isset($id_tranfer_array)){
+ $query->andWhere(["in", "transfer.id_transfer" , $id_tranfer_array ]);
+ }
+ return $query->all();
+ }
+
+}
diff --git a/frontend/views/card/index.php b/frontend/views/card/index.php
index 8ab0e9b..fca56fa 100644
--- a/frontend/views/card/index.php
+++ b/frontend/views/card/index.php
@@ -45,7 +45,7 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\ActionColumn',
- 'template' => '{ticket} {ticket_history} {keys}',
+ 'template' => '{ticket} {ticket_history} {keys} {contract}',
'buttons' => [
'ticket' => function ($url, $model, $key) {
return Html::a('Új bérlet', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
@@ -56,6 +56,9 @@ $this->params['breadcrumbs'][] = $this->title;
'keys' => function ($url, $model, $key) {
return Html::a('Kulcsok', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
},
+ 'contract' => function ($url, $model, $key) {
+ return Html::a('Szerződések', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
+ },
],
'urlCreator' => function ($action, $model, $key, $index){
$url = "";
@@ -65,6 +68,8 @@ $this->params['breadcrumbs'][] = $this->title;
$url = Url::to(['ticket/index','number' => $model['card_number']]);
}else if ( 'keys' == $action ){
$url = Url::to(['key/index','id_card' => $model['card_id_card']]);
+ }else if ( 'contract' == $action ){
+ $url = Url::to(['contract/index','id_card' => $model['card_id_card']]);
}
return $url;
}
diff --git a/frontend/views/common/_reception_menu.php b/frontend/views/common/_reception_menu.php
index e1c9f1b..588a555 100644
--- a/frontend/views/common/_reception_menu.php
+++ b/frontend/views/common/_reception_menu.php
@@ -54,6 +54,20 @@ $card = $model->card;
+
+ isCustomerWithTicket() ){
+ ?>
+
+
+ $model->customer->id_customer ]);?>
+
+
+
+
diff --git a/frontend/views/common/_reception_ticket.php b/frontend/views/common/_reception_ticket.php
index dfb9655..816f0a6 100644
--- a/frontend/views/common/_reception_ticket.php
+++ b/frontend/views/common/_reception_ticket.php
@@ -3,6 +3,8 @@ use yii\base\Object;
use common\models\Ticket;
use frontend\model\ReceptionForm;
use yii\helpers\Html;
+use yii\helpers\Url;
+use common\models\Contract;
/* @var $this yii\web\View */
/* @var $model frontend\model\ReceptionForm */
@@ -57,4 +59,37 @@ if ( isset($model->card)){
echo Html::endTag("div");
}
+
+if ( isset($model->contract)){
+ /** @var common\models\Contract $contract*/
+ $contract = $model->contract;
+ if ( $contract->isFlagActive() ){
+ if ( $model->contract->isStatusNotPaid() ){
+ echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]);
+ echo Html::beginTag("strong",[ ]);
+ echo "Szerződés részlete nincs fizetve!";
+ echo Html::a("Szerződés részletei",Url::toRoute(['contract/view','id' => $model->contract->id_contract]));
+ echo Html::endTag("strong");
+ echo Html::endTag("div");
+ }else{
+ echo Html::beginTag("div",['class'=>"alert alert-success", "role"=>"alert"]);
+ echo Html::beginTag("strong",[ ]);
+ echo "Érvényes szerződés!";
+ echo Html::a("Szerződés részletei",Url::toRoute(['contract/view','id' => $model->contract->id_contract]));
+ echo Html::endTag("strong");
+ echo Html::endTag("div");
+ }
+ }else{
+
+ if ( $contract->isFlagCanceled() ){
+ echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]);
+ echo Html::beginTag("strong",[ ]);
+ echo "Szerződés felbontva !";
+ echo Html::a("Szerződés részletei",Url::toRoute(['contract/view','id' => $model->contract->id_contract]));
+ echo Html::endTag("strong");
+ echo Html::endTag("div");
+ }
+ }
+}
+
?>
\ No newline at end of file
diff --git a/frontend/views/contract/_form.php b/frontend/views/contract/_form.php
new file mode 100644
index 0000000..65e0cce
--- /dev/null
+++ b/frontend/views/contract/_form.php
@@ -0,0 +1,43 @@
+
+
+
diff --git a/frontend/views/contract/_search.php b/frontend/views/contract/_search.php
new file mode 100644
index 0000000..dfd32a0
--- /dev/null
+++ b/frontend/views/contract/_search.php
@@ -0,0 +1,47 @@
+
+
+
+
+ ['index'],
+ 'method' => 'get',
+ ]); ?>
+
+ = $form->field($model, 'id_contract') ?>
+
+ = $form->field($model, 'id_user') ?>
+
+ = $form->field($model, 'id_customer') ?>
+
+ = $form->field($model, 'status') ?>
+
+ = $form->field($model, 'flag') ?>
+
+ field($model, 'part_paid') ?>
+
+ field($model, 'part_count') ?>
+
+ field($model, 'part_required') ?>
+
+ field($model, 'expired_at') ?>
+
+ field($model, 'created_at') ?>
+
+ field($model, 'updated_at') ?>
+
+
+ = Html::submitButton(Yii::t('common/contract', 'Search'), ['class' => 'btn btn-primary']) ?>
+ = Html::resetButton(Yii::t('common/contract', 'Reset'), ['class' => 'btn btn-default']) ?>
+
+
+
+
+
diff --git a/frontend/views/contract/create.php b/frontend/views/contract/create.php
new file mode 100644
index 0000000..a745b74
--- /dev/null
+++ b/frontend/views/contract/create.php
@@ -0,0 +1,21 @@
+title = Yii::t('common/contract', 'Create Contract');
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/contract', 'Contracts'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/frontend/views/contract/index.php b/frontend/views/contract/index.php
new file mode 100644
index 0000000..04c3609
--- /dev/null
+++ b/frontend/views/contract/index.php
@@ -0,0 +1,58 @@
+title = $searchModel->customer->name . " szerződései";
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+ render('_search', ['model' => $searchModel]); ?>
+
+
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => [
+ 'id_contract',
+ [
+ 'attribute' => 'id_customer',
+ 'value' => 'customerName'
+ ],
+ [
+ 'attribute' => 'id_user',
+ 'value' => 'userName'
+ ],
+ // 'part_paid',
+ // 'part_count',
+ // 'part_required',
+ 'expired_at:datetime',
+ 'created_at:datetime',
+ // 'updated_at',
+
+ ['class' => 'yii\grid\ActionColumn',
+ 'template' => '{details}',
+ 'buttons' => [
+ 'details' => function ($url, $model, $key) {
+ return Html::a('Fizetési részletek', $url, ['class'=> 'btn btn-xs btn-success' ]) ;
+ },
+ ],
+ 'urlCreator' => function ($action, $model, $key, $index){
+ $url = "";
+ if ( 'details' == $action ){
+ $url = Url::to(['contract/view','id' => $model->id_contract]);
+ }
+ return $url;
+ }
+
+ ],
+ ],
+ ]); ?>
+
+
diff --git a/frontend/views/contract/update.php b/frontend/views/contract/update.php
new file mode 100644
index 0000000..514a0c0
--- /dev/null
+++ b/frontend/views/contract/update.php
@@ -0,0 +1,23 @@
+title = Yii::t('common/contract', 'Update {modelClass}: ', [
+ 'modelClass' => 'Contract',
+]) . ' ' . $model->id_contract;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/contract', 'Contracts'), 'url' => ['index']];
+$this->params['breadcrumbs'][] = ['label' => $model->id_contract, 'url' => ['view', 'id' => $model->id_contract]];
+$this->params['breadcrumbs'][] = Yii::t('common/contract', 'Update');
+?>
+
+
+
= Html::encode($this->title) ?>
+
+ = $this->render('_form', [
+ 'model' => $model,
+ ]) ?>
+
+
diff --git a/frontend/views/contract/view.php b/frontend/views/contract/view.php
new file mode 100644
index 0000000..1002213
--- /dev/null
+++ b/frontend/views/contract/view.php
@@ -0,0 +1,100 @@
+title = "Szerződés részletek" ;
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/contract', 'Szerződések'), 'url' => ['index', 'id_card' => $card->id_card]];
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+
+
= Html::encode($this->title) ?>
+
+
+ = DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
+ 'id_contract',
+ [
+ 'attribute' => 'id_user',
+ 'value' => $model->userName
+ ],
+ [
+ 'attribute' => 'id_customer',
+ 'value' => $model->customerName
+ ],
+ [
+ 'attribute' => 'flag',
+ 'value' => $model->flagName
+ ],
+ [
+ 'attribute' => 'status',
+ 'value' => $model->statusName
+ ],
+ 'part_paid',
+ 'part_required',
+ 'part_count',
+ 'expired_at:datetime',
+ 'created_at:datetime',
+ 'updated_at:datetime',
+ ],
+ ]) ?>
+ canCancel() ){?>
+
+
+ $model->id_contract], [ 'data-method' => 'post', 'class' => 'btn btn-danger']);
+ ?>
+ Szerződés felbontása esetén a már megkezdett hónapokra hónaponként 3000 Ft büntetést írunk fel a vásárló kosarába
+
+
+
+
+
+ isStatusAccepted() ){
+ $panelClass = "panel-success";
+ }else if ( $inst->isStatusRejected() ){
+ $panelClass = "panel-danger";
+ }
+ ?>
+
+
+
Bérlet priority?>
+
+
+
+ | Esedékességi dátum |
+ formatter->asDate($inst->request_target_time_at)?> |
+
+
+ | Fizetendő |
+ money)?> |
+
+
+ | Státusz |
+ statusName)?> |
+
+
+ | Bérlet vége |
+ formatter->asDate($inst->ticketExpirationDate)?> |
+
+
+
+ isStatusPending() || $inst->isStatusRejected() ){
+ echo Html::a("Fizetettnek jelölés és bérlet vásárló kásrba helyezése",['contract/payout' , 'id' => $inst->id_ticket_installment_request], [ 'data-method' => 'post', 'class' => 'btn btn-danger']);
+ }
+ ?>
+
+
+
+
+
diff --git a/frontend/views/customer/_contract.php b/frontend/views/customer/_contract.php
new file mode 100644
index 0000000..08b2be7
--- /dev/null
+++ b/frontend/views/customer/_contract.php
@@ -0,0 +1,24 @@
+
+ Éves szerződés
+
+
+
+
+ Ez az éves szerződés szövege
+
+
+ Kövektező bekezdés
+
+
+ A szerződő fél neve:
+
+name
+?>
+
+
+
+
+ A cég neve:
+ params['company_name']?>
+
\ No newline at end of file
diff --git a/frontend/views/product/_user_cart.php b/frontend/views/product/_user_cart.php
index c80866a..c2d99b7 100644
--- a/frontend/views/product/_user_cart.php
+++ b/frontend/views/product/_user_cart.php
@@ -44,4 +44,7 @@ use kartik\widgets\ActiveForm;
'btn btn-primary btn-block' , 'onclick' => 'location.reload();']) ?>
+
+ 'btn btn-primary btn-block' ]) ?>
+
\ No newline at end of file
diff --git a/frontend/views/transfer/_result_sale.php b/frontend/views/transfer/_result_sale.php
index 33f7002..fe28fb3 100644
--- a/frontend/views/transfer/_result_sale.php
+++ b/frontend/views/transfer/_result_sale.php
@@ -101,6 +101,7 @@ td,th{
| T |
Kiadva |
+ F. mód |
Fizetve |
Kassza |
Felhasználó |
@@ -117,6 +118,7 @@ td,th{
| |
|
+ |
|
|
|
diff --git a/frontend/views/transfer/_user_cart_item.php b/frontend/views/transfer/_user_cart_item.php
new file mode 100644
index 0000000..11fdc68
--- /dev/null
+++ b/frontend/views/transfer/_user_cart_item.php
@@ -0,0 +1,13 @@
+
+
+
+
+
+ transferTypeName;?>
+
+
+
\ No newline at end of file
diff --git a/frontend/views/transfer/sale.php b/frontend/views/transfer/sale.php
index 34ad890..f059cdb 100644
--- a/frontend/views/transfer/sale.php
+++ b/frontend/views/transfer/sale.php
@@ -3,6 +3,7 @@ use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\ListView;
use yii\base\Widget;
+use common\models\Transfer;
/* @var $this yii\web\View */
/* @var $searchModel common\models\TransferSearch */
@@ -66,8 +67,9 @@ td.name {
- | Tranzakció |
+ ID |
Kiadva |
+ F. mód |
Fizetve |
Kassza |
Felhasználó |
@@ -84,6 +86,7 @@ td.name {
| |
|
+ |
|
|
|
diff --git a/frontend/views/transfer/usercart.php b/frontend/views/transfer/usercart.php
new file mode 100644
index 0000000..881e826
--- /dev/null
+++ b/frontend/views/transfer/usercart.php
@@ -0,0 +1,90 @@
+
+registerJs ( 'new TransferUserCart( '. json_encode($options).');' );
+ $dp = new ArrayDataProvider(
+ [
+ 'allModels' => $model->transfers,
+ 'pagination' => false
+
+ ]
+ );
+
+?>
+Kosár
+
\ No newline at end of file
diff --git a/frontend/web/js/transfer.usercart.js b/frontend/web/js/transfer.usercart.js
new file mode 100644
index 0000000..c5264e2
--- /dev/null
+++ b/frontend/web/js/transfer.usercart.js
@@ -0,0 +1,26 @@
+function TransferUserCart(o){
+
+ var defaults = {};
+
+ init();
+
+ function init(){
+ defaults = $.extend(defaults,o);
+ $('.select-on-check-all').click(recalculate);
+ $('.cart-item').click(recalculate);
+ }
+
+ function recalculate(){
+ var items = $('.cart-item');
+ var money = 0;
+ items.each(function(i,e){
+ if ( $(e).is(':checked')){
+ money += $(e).data('money');
+ }
+ });
+ $('#usercartform-money').val(money);
+ $('.selected-money').html(money);
+ }
+
+
+}
\ No newline at end of file