diff --git a/backend/controllers/ProcurementController.php b/backend/controllers/ProcurementController.php
index 61b7114..eee905c 100644
--- a/backend/controllers/ProcurementController.php
+++ b/backend/controllers/ProcurementController.php
@@ -13,6 +13,7 @@ use common\models\Product;
use common\models\User;
use common\components\Helper;
use common\models\Account;
+use yii\helpers\Url;
/**
* ProcurementController implements the CRUD actions for Procurement model.
@@ -193,7 +194,15 @@ class ProcurementController extends \backend\controllers\BackendController
}
- return $this->redirect(['view', 'id' => $model->id_procurement]);
+// return $this->redirect(['view', 'id' => $model->id_procurement]);
+ $url = Url::previous("product_index");
+ if ( isset($url)){
+ return $this->redirect( $url );
+ }else{
+ return $this->redirect(['product/index']);
+ }
+
+// return $this->redirect(Yii::$app->request->referrer);
} else {
return $this->render('create_product', [
'model' => $model,
diff --git a/backend/controllers/ProductController.php b/backend/controllers/ProductController.php
index 333c9ea..6b13e6a 100644
--- a/backend/controllers/ProductController.php
+++ b/backend/controllers/ProductController.php
@@ -12,6 +12,7 @@ use common\models\Account;
use common\models\ProductCategory;
use backend\models\ProductStatisticsSearch;
use PHPExcel;
+use yii\helpers\Url;
/**
* ProductController implements the CRUD actions for Product model.
@@ -47,6 +48,8 @@ class ProductController extends \backend\controllers\BackendController
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+ Url::remember(Url::current(),"product_index");
+
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
diff --git a/backend/controllers/TicketController.php b/backend/controllers/TicketController.php
index a6b6c1b..b88a969 100644
--- a/backend/controllers/TicketController.php
+++ b/backend/controllers/TicketController.php
@@ -16,6 +16,10 @@ use common\models\Customer;
use common\models\Card;
use backend\models\TicketSearchStatisitcs;
use backend\models\TicketSearchCustomer;
+use common\components\TicketSale;
+use common\models\Contract;
+use common\components\giro\GiroDETSTATetel;
+use common\components\DetStatTetelProcessor;
/**
* TicketController implements the CRUD actions for Ticket model.
@@ -34,7 +38,8 @@ class TicketController extends \backend\controllers\BackendController {
'view',
'update',
'index-customer',
- 'statistics'
+ 'statistics' ,
+ 'test'
],
'allow' => true,
'roles' => [
@@ -223,6 +228,58 @@ class TicketController extends \backend\controllers\BackendController {
] );
}
+ public function actionTest(){
+
+// $this->doTestTicketSale();
+
+ $this->doTestDetstaProcess();
+
+ return $this->render('test');
+
+ }
+
+ protected function doTestDetstaProcess(){
+ $contract = Contract::findOne(19);
+ $megbizas = $contract->requests[0];
+
+ $tetel = new GiroDETSTATetel();
+ $tetel->visszajelzesInformacio = "02";
+
+ $tp = new DetStatTetelProcessor([
+ 'megbizas' => $megbizas,
+ 'tetel' => $tetel
+ ]);
+
+ $tp->run();
+
+ }
+
+ protected function doTestTicketSale(){
+ $ticketType = TicketType::findOne(1);
+ $customer = Customer::findOne(1);
+ $account = Account::findOne(1);
+ $card = $customer->card;
+ $discount = null;
+ $contract = Contract::findOne(19);
+ $megbizas = $contract->requests[0];
+
+
+
+ $ticketSale = new TicketSale(
+ [
+ 'ticketType'=> $ticketType,
+ 'customer'=> $customer,
+ 'account'=> $account,
+ 'card'=> $card,
+ 'discount'=> $discount,
+ 'contract'=> $contract,
+ 'ticketInstallmentRequest' => $megbizas
+ ]
+ );
+
+ $ticketSale->doSale();
+ }
+
/**
* Finds the Ticket model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
diff --git a/backend/models/DestaUploadForm.php b/backend/models/DestaUploadForm.php
index 11cd999..f9b3215 100644
--- a/backend/models/DestaUploadForm.php
+++ b/backend/models/DestaUploadForm.php
@@ -39,16 +39,17 @@ class DestaUploadForm extends Model
$datum = $destaUzenet->fej->csoportosUzenetSorszam->osszeallitasDatuma;
$koteg = Ugiro::find()->andWhere(['number' =>$number,'datum' => $datum ])->one();
$this->koteg = $koteg;
- $idKoteg = $this->koteg->id_ugiro;
if (!isset($koteg)){
$this->addError($attribute,"Nincs ilyen köteg! ( Datum: $datum, Sorszam: $number )");
}else{
if ( $koteg->status != Ugiro::$STATUS_SENT ){
+ $idKoteg = $this->koteg->id_ugiro;
$this->addError($attribute,"A köteg detsta fájl-ja már fel van töltve !( Köteg azonosító: $idKoteg )");
}
}
+
}
}
diff --git a/backend/views/procurement/_form_product.php b/backend/views/procurement/_form_product.php
index 725492d..c6aca77 100644
--- a/backend/views/procurement/_form_product.php
+++ b/backend/views/procurement/_form_product.php
@@ -17,21 +17,41 @@ $warehouseOptions = ArrayHelper::map($warehouses, 'id_warehouse', 'name') ;
?>
= Yii::t('common/product', 'Product') ?>
+
+
$product,
'attributes' =>[
- 'productCategoryName',
- 'accountName',
- 'product_number',
- 'barcode',
- 'stock',
+ [
+ 'attribute' => 'productCategoryName',
+ 'label' => 'Termék kategória'
+ ],
+ [
+ 'attribute' => 'accountName',
+ 'label' => 'Kassza'
+ ],
+ [
+ 'attribute' => 'product_number',
+ 'label' => 'Termék szám'
+ ],
+ [
+ 'attribute' => 'barcode',
+ 'label' => 'Vonalkód'
+ ],
+ [
+ 'attribute' => 'stock',
+ 'label' => 'Raktáron'
+ ],
]
]);
?>
-
+
+
+
+
@@ -52,3 +72,4 @@ echo DetailView::widget([
+
diff --git a/backend/views/ticket/test.php b/backend/views/ticket/test.php
new file mode 100644
index 0000000..30d74d2
--- /dev/null
+++ b/backend/views/ticket/test.php
@@ -0,0 +1 @@
+test
\ No newline at end of file
diff --git a/changelog.txt b/changelog.txt
index caf42e5..a555e74 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,6 @@
+-0.0.42
+ - add detsta import improvements
+ - add procurement/create-product , translations, redirects
-0.0.41
- add button kulcs "visszaad"
- fix ReceptionFomr#getFirstKey method
diff --git a/common/components/DetStatProcessor.php b/common/components/DetStatProcessor.php
index 35ce381..3c0bc5b 100644
--- a/common/components/DetStatProcessor.php
+++ b/common/components/DetStatProcessor.php
@@ -65,7 +65,7 @@ class DetStatProcessor extends Object{
]
);
$processor->run();
- $this->errors = $this->errors + $processor->errors;
+// $this->errors = $this->errors + $processor->errors;
}
}
@@ -129,21 +129,21 @@ class DetStatProcessor extends Object{
$this->megbizasok = $this->koteg->requests;
}
- public function applyNewMegbizasState(){
- $kod = $this->tetel->valaszHivatkozasiKod;
+// public function applyNewMegbizasState(){
+// $kod = $this->tetel->valaszHivatkozasiKod;
- if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
- $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
- }else{
- $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
- }
- $this->megbizas->save(false);
- }
+// if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
+// $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
+// }else{
+// $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
+// }
+// $this->megbizas->save(false);
+// }
- public function applyNewTicketState(){
- $this->ticket->applyTicketInstallmentRequest($this->megbizas);
- $this->ticket->save(false);
- }
+// public function applyNewTicketState(){
+// $this->ticket->applyTicketInstallmentRequest($this->megbizas);
+// $this->ticket->save(false);
+// }
public function hasError(){
diff --git a/common/components/DetStatTetelProcessor.php b/common/components/DetStatTetelProcessor.php
index e986bb3..bd09388 100644
--- a/common/components/DetStatTetelProcessor.php
+++ b/common/components/DetStatTetelProcessor.php
@@ -5,10 +5,8 @@ namespace common\components;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\components\giro\GiroDETSTATetel;
-use backend\models\TicketInstallmentMarkForSendForm;
-use common\models\Transfer;
use common\models\Account;
-use common\models\Discount;
+use common\models\Contract;
/**
* This is the model class for table "ticket".
@@ -16,114 +14,265 @@ use common\models\Discount;
* @property common\components\giro\GiroDETSTATetel $tetel
* @property common\models\TicketInstallmentRequest $megbizas
* @property common\models\Ticket $ticket
+ * @property common\models\Contract $contract
*
*
*/
class DetStatTetelProcessor extends Object {
+ /**
+ * A válasz tétel . Ha nincs megadva, automatikus visszautasítjuk a megbízást
+ * */
public $tetel; // config
+ /**
+ * A megbízás. Ha a megbízás már el van fogadva, megszakítjuk a feldolgozást
+ * */
public $megbizas; // config
- public $ticket;
- public $errors = [ ];
- public $dryRun = false; // for testing, to not to persist the changes
+ /**
+ * A szerződés. A megbízás hoz tartozó szerződés
+ * */
+ public $contract;
+ /**
+ * a tételből kiolvasott kód. Lásd extractKodAndStatus
+ * */
+ protected $kod;
+ /**
+ * Státusz. Az új státusza a megbízásnak a tétel alapján
+ * */
+ protected $status;
+ /**
+ * A komment. Lásd fillComment metódus
+ * */
+ protected $comment;
+ /**
+ * A bérlet objectkum, amit elmentettünk
+ * */
+ protected $ticket;
+ /**
+ * A tranzakció, amit mentettünk
+ * */
+ protected $transfer;
+
+ protected $eredetiMegbizasStatus;
+
public function run() {
- // $this->readMegbizas();
- if ($this->megbizas->isStatusAccepted()) {
+
+ \Yii::info('Megbízás feldolgozása: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
+
+ if ($this->isAlreadeyAccepted ()) {
+// \Yii::info('A megbízás feldolgozásának megszakítása. A megbízás már elfogadott: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
// return;
}
- $status = TicketInstallmentRequest::$STATUS_REJECTED;
- $kod = 'xx';
- $comment = "";
- if (isset ( $this->tetel )) {
- $kod = $this->tetel->visszajelzesInformacio;
+
+ $this->rememberEredetiMegbizasStatus();
+ $this->readContract();
+ $this->extractKodAndStatus ();
+ $this->fillComment();
+
+ if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED ){
+ $this->buyNewTicket();
+ }else{
+ $this->doRejectRequest();
}
- if ($kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
- $status = TicketInstallmentRequest::$STATUS_ACCEPTED;
- } else {
- $status = TicketInstallmentRequest::$STATUS_REJECTED;
-
- if ( $kod == "xx"){
- $comment = "Nem található a detsta fájlban a tétel válasza";
- }else{
- if ( array_key_exists($kod, GiroDETSTATetel::$INFORMACIOK)){
- $comment = "Hiba kód: ".$kod ." - " .GiroDETSTATetel::$INFORMACIOK[$kod];
- }else{
- $comment = "Ismeretlen hiba kód: " .$kod;
+ }
+
+
+ protected function rememberEredetiMegbizasStatus(){
+ $this->eredetiMegbizasStatus = $this->megbizas->status;
+ }
+
+ protected function isEredetiMegbizasStatusFinished(){
+ return $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED ||
+ $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ||
+ $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_REJECTED;
+ }
+
+ protected function buyNewTicket(){
+ \Yii::info('Új bérlet vásárlás folyamant indítása' );
+
+ $megbizas = $this->megbizas;
+ $customer = $this->contract->customer;
+ $card = $customer->card;
+ $account = Account::findOne(1);
+ $ticketType = $this->contract->ticketType;
+ $discount = $this->contract->discount;
+
+ $ticketSale = new TicketSale(
+ [
+ 'ticketType'=> $ticketType,
+ 'customer'=> $customer,
+ 'account'=> $account,
+ 'card'=> $card,
+ 'discount'=> $discount,
+ 'contract'=> $this->contract,
+ 'ticketInstallmentRequest' => $megbizas
+ ]
+ );
+
+ $ticketSale->doSale();
+ \Yii::info('Bérlet és tranzakció elmentve' );
+
+ $this->transfer = $ticketSale->transfer;
+ $this->ticket = $ticketSale->ticket;
+
+ $this->updateContractOnSuccess();
+ $this->updateMegbizasOnSuccess();
+
+ }
+
+ /**
+ * A szerződés betöltése
+ * */
+ protected function readContract(){
+ $this->contract = $this->megbizas->contract;
+ \Yii::info('Szerződés betöltve. Id:' .$this->contract->id_contract);
+ }
+
+
+ /**
+ * A megbízás módosítása sikeres detsta üzenet esetén
+ * */
+ protected function updateMegbizasOnSuccess(){
+
+ \Yii::info('Megbízás frissítése - megbizás elfogadva ' );
+
+ $this->megbizas->status = $this->status;
+ $this->megbizas->id_transfer = $this->transfer->id_transfer;
+ $this->megbizas->id_ticket = $this->ticket->id_ticket;
+ $this->megbizas->request_processed_at = Helper::getDateTimeString();
+ $this->megbizas->detsta_answer = $this->kod;
+ $this->megbizas->comment = $this->comment;
+
+ if ( !$this->megbizas->save(false) ){
+ \Yii::error("Nem sikerült menteni a megbízást!");
+ throw new \Exception("Nem sikerült menteni a megbízást!");
+ }
+ \Yii::info("A megbízás elmentve!");
+
+ }
+
+ /**
+ * Megbízás módosítása , ha a detsta üzenetben a megbízás vissza lett utasítva
+ * */
+ protected function updateMegbizasOnFail(){
+
+ \Yii::info('Megbázás frissítése - megbízás visszautasítva ' );
+
+ $this->megbizas->status = $this->status;
+ $this->megbizas->detsta_answer = $this->kod;
+ $this->megbizas->comment = $this->comment;
+ $this->megbizas->request_processed_at = Helper::getDateTimeString();
+
+ if ( !$this->megbizas->save(false) ){
+ \Yii::error("Nem sikerült menteni a megbízást!");
+ throw new \Exception("Nem sikerült menteni a megbízást!");
+ }
+ \Yii::info("A megbízás elmentve!");
+
+ }
+
+ /**
+ * Szerződés módosítása, ha a detsta üzenetben a megbízás el lett fogadva
+ * */
+ protected function updateContractOnSuccess(){
+ \Yii::info('Szerződés frissítése - megbizás elfogadva ' );
+ $this->incRequiredParts();
+ $this->contract->part_paid = $this->contract->part_paid +1;
+ $this->updateContractPaidStatus();
+
+ if ( !$this->contract->save(false) ){
+ \Yii::error("Nem sikerült menteni a szerződést!");
+ throw new \Exception("Nem sikerült menteni a szerződést!");
+ }
+ \Yii::info("A szerződés elmentve!");
+ }
+
+ protected function updateContractOnFail(){
+ \Yii::info('Szerződés frissítése - megbizás visszautasítva ' );
+ $this->incRequiredParts();
+ $this->updateContractPaidStatus();
+// $this->contract->status = Contract::$STATUS_NOT_PAID;
+ if ( !$this->contract->save(false) ){
+ \Yii::error("Nem sikerült menteni a szerződést!");
+ throw new \Exception("Nem sikerült menteni a szerződést!");
+ }
+ \Yii::info("A szerződés elmentve!");
+ }
+
+
+ /**
+ * Szerződés
+ * */
+ protected function incRequiredParts(){
+ if ( !$this->isEredetiMegbizasStatusFinished() ){
+ $this->contract->part_required = $this->contract->part_required +1;
+ \Yii::info("Szerződés szükséges megbizások száma növelve");
+ }else{
+ \Yii::info("Szerződés szükséges megbizások száma nem lett növelve az eredeti státusz miatt");
+ }
+ }
+
+ protected function updateContractPaidStatus(){
+ $required = $this->contract->part_required;
+ $paid = $this->contract->part_paid;
+ $ok = $required <= $paid;
+ if ($ok ){
+ $this->contract->status = Contract::$STATUS_PAID;
+ }else{
+ $this->contract->status = Contract::$STATUS_NOT_PAID;
+ }
+ \Yii::info("Szerződés új státusza id= " .$this->contract->id_contract . ", Státusz: " . $this->contract->status . " (" . Contract::toStatusName($this->contract->status) . ")");
+ }
+
+ /**
+ * Szerződés és megbízás frissítése , ha a detsta üzenet visszautásításra került
+ * */
+ protected function doRejectRequest(){
+ $this->updateContractOnFail();
+ $this->updateMegbizasOnFail();
+ }
+
+ /**
+ * Komment összeállítás a status mező alapján
+ * */
+ protected function fillComment() {
+ $this->comment = "Megbízás teljesítve";
+ if ($this->status != TicketInstallmentRequest::$STATUS_ACCEPTED) {
+ if ($this->kod == "xx") {
+ $this->comment = "Nem található a detsta fájlban a tétel válasza";
+ } else {
+ if (array_key_exists ( $this->kod, GiroDETSTATetel::$INFORMACIOK )) {
+ $this->comment = "Hiba kód: " . $this->kod . " - " . GiroDETSTATetel::$INFORMACIOK [$this->kod];
+ } else {
+ $this->comment = "Ismeretlen hiba kód: " . $this->kod;
}
}
}
-
- $this->megbizas->applyStatus($status,true,$kod,$comment);
-
-
- // $this->readTicket();
- // if ( !$this->hasError() ){
- // $this->applyNewMegbizasState();
- // $this->applyNewTicketState();
- // $this->addTransfer();
- // }
}
- // public function readMegbizas(){
- // $this->megbizas = TicketInstallmentRequest::findOne($this->tetel->ugyfelAzonosito);
- // if ( !isset($this->megbizas) ){
- // $this->errors [] = "Válaszban jelölt megbízás nem található! (".$this->tetel->ugyfelAzonosito." )";
- // }
- // }
- // public function readTicket(){
- // $this->ticket = $this->megbizas->ticket;
- // if ( !isset($this->ticket) ){
- // $this->errors [] = "Válaszban jelölt bérlet nem található! (".$this->megbizas->id_ticket." )";
- // }
- // }
-
- // public function applyNewMegbizasState(){
- // $kod = 'xx';
- // if ( isset($this->tetel ) ) {
- // $kod = $this->tetel->visszajelzesInformacio;
- // }
-
- // if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
- // $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
- // }else{
- // $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
- // }
- // if ( !$this->isDryRun() ){
- // $this->megbizas->save(false);
- // }
- // }
-
- // public function applyNewTicketState(){
- // $this->ticket->applyTicketInstallmentRequest($this->megbizas);
- // if ( !$this->isDryRun() ){
- // $this->ticket->save(false);
- // }
- // }
-
- // protected function addTransfer(){
-
- // $account = Account::findOne($this->ticket->id_account);
- // $discount = null;
- // if ( isset($this->ticket->id_account)){
- // $discount = Discount::findOne( $this->ticket->id_discount );
- // }
-
- // $transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket);
-
- // $transfer->status = Transfer::STATUS_PAID;
- // $transfer->paid_at = date('Y-m-d H:i:s' ) ;
- // $transfer->paid_by = \Yii::$app->user->id;
- // $transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
- // $transfer->money = $this->megbizas->money;
- // $transfer->comment = "Csoportos beszedes";
- // $transfer->id_user = \Yii::$app->user->id;
- // $transfer->id_customer = $this->ticket->id_customer;
- // $transfer->save(false);
- // }
+ /**
+ * Visszajelző kód kiolvasása a detsta tételből.
+ * Status beállítása a kód alapján
+ * */
+ protected function extractKodAndStatus() {
+ \Yii::info('Visszajelző kód kiolvasása' );
+ $this->status = TicketInstallmentRequest::$STATUS_REJECTED;
+ $this->kod = 'xx';
+ if (isset ( $this->tetel )) {
+ $this->kod = $this->tetel->visszajelzesInformacio;
+ }
+ if ($this->kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
+ $this->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
+ } else {
+ $this->status = TicketInstallmentRequest::$STATUS_REJECTED;
+ }
+ \Yii::info('Visszajelző kód kiolvasva: kod=' .$this->kod);
+ \Yii::info('Visszajelző kód kiolvasva: statusz=' .$this->status. " (" . TicketInstallmentRequest::toStatusName($this->status) .")");
+ }
+ protected function isAlreadeyAccepted() {
+ return $this->megbizas->isStatusAccepted ();
+ }
public function hasError() {
- return count ( $this->errors ) > 0;
- }
- public function isDryRun() {
- return $this->dryRun;
+ return false;
}
}
\ No newline at end of file
diff --git a/common/components/Helper.php b/common/components/Helper.php
index d25b481..ccdc969 100644
--- a/common/components/Helper.php
+++ b/common/components/Helper.php
@@ -92,6 +92,10 @@ class Helper {
return date("Y-m-d H:i:s");
}
+ public static function getDateString( ){
+
+ return date("Y-m-d");
+ }
public static function getArrayValue($arr,$key,$def){
$result = $def;
diff --git a/common/components/TicketSale.php b/common/components/TicketSale.php
new file mode 100644
index 0000000..27053c7
--- /dev/null
+++ b/common/components/TicketSale.php
@@ -0,0 +1,7 @@
+readMoney();
$this->readStartDate();
$this->readEndDate();
$this->mkTicket();
$this->mkTransfer();
$this->addToCustomerCart();
}
protected function mkTicket( ) {
$this->ticket = new Ticket ();
$this->ticket->id_user = \Yii::$app->user->id;
$this->ticket->id_ticket_type = $this->ticketType->id_ticket_type; // save to contract
$this->ticket->id_account = $this->account->id_account;
$this->ticket->id_discount = isset($this->discount) ? $this->discount->id_discount : null; // contract.id_discount
$this->ticket->start = $this->start;
$this->ticket->end = $this->end;
$this->ticket->max_usage_count = $this->ticketType->max_usage_count;
$this->ticket->usage_count = 0;
$this->ticket->status = Ticket::STATUS_ACTIVE;
$this->ticket->price_brutto = $this->money;
$this->ticket->id_card = $this->card->id_card;
if ( isset( $this->ticketInstallmentRequest ) ){
$this->ticket->part = $this->ticketInstallmentRequest->priority;
}
if (isset($this->contract)){
$this->ticket->id_contract = $this->contract->id_contract;
}
if ( !$this->ticket->save ( false ) ){
\Yii::error("Nem sikerült menteni a bérletet!");
throw new \Exception("Bérlet mentése nem sikerült");
}
\Yii::info("Bérlet elmentve: id=" . $this->ticket->id_ticket);
}
protected function mkTransfer( ) {
$this->transfer = new Transfer ();
$this->transfer->status = $this->transferStatus;
$this->transfer->type = Transfer::TYPE_TICKET;
$this->transfer->direction = Transfer::DIRECTION_IN;
$this->transfer->id_object = $this->ticket->id_ticket;
$this->transfer->item_price = $this->ticketType->price_brutto;
$this->transfer->money = $this->money;
$this->transfer->id_account = $this->account->id_account;
$this->transfer->count = 1;
if ($this->transferStatus == Transfer::STATUS_PAID) {
$this->transfer->paid_at = date ( 'Y-m-d H:i:s' );
$this->transfer->paid_by = \Yii::$app->user->id;
}
$this->transfer->payment_method = $this->paymentMethod;
$this->transfer->comment = "";
if ( isset($this->ticketInstallmentRequest)){
$this->transfer->comment = "Csoportos megbízással";
}
$this->transfer->id_user = \Yii::$app->user->id;
$this->transfer->id_customer = $this->customer->id_customer;
if ( !$this->transfer->save (false) ){
\Yii::error("Nem sikerült menteni a tranzakciót!");
throw new \Exception("Tranzakció mentése nem sikerült");
}
\Yii::info("tranzakció elmentve: id=" . $this->transfer->id_transfer);
}
protected function addToCustomerCart( ) {
}
protected function readMoney(){
if ( !isset($this->money)){
$this->money = $this->ticketType->price_brutto;
if (isset($this->discount)){
$this->money = Discount::applyDiscount($this->money, $this->discount);
}
if ( isset($this->ticketInstallmentRequest)){
$this->money = $this->ticketInstallmentRequest->money;
}
}
}
protected function readStartDate(){
if ( !isset($this->start)){
$this->start = Helper::getDateString();
if ( isset($this->ticketInstallmentRequest)){
$this->start = $this->ticketInstallmentRequest->request_target_time_at;
}
}
}
protected function readEndDate(){
if ( !isset($this->end)){
$unit = "month";
if ( $this->ticketType->time_unit_type == TicketType::TIME_UNIT_DAY ) {
$unit = "day";
}
$count = $this->ticketType->time_unit_count;
$this->end = date( 'Y-m-d', strtotime( $this->start . " +$count $unit -1 day"));
if ( isset($this->ticketInstallmentRequest)){
$this->end = date( 'Y-m-d', strtotime( $this->ticketInstallmentRequest->request_target_time_at . " +1 month -1 day"));
}
}
}
+
+}
\ No newline at end of file
diff --git a/common/components/giro/GiroBeszedFej.php b/common/components/giro/GiroBeszedFej.php
index a90fca4..15d5827 100644
--- a/common/components/giro/GiroBeszedFej.php
+++ b/common/components/giro/GiroBeszedFej.php
@@ -30,7 +30,7 @@ class GiroBeszedFej extends GiroBase{
return $this->recordTipus
.$this->uzenetTipus
. $this->duplumKod
- . $this->szamKitolt( $this->kezdemenyezoAzonosito , 13)
+ . $this->szovegKitolt( $this->kezdemenyezoAzonosito , 13)
. $this->uzenetSorszam->toString()
. $this->kezdemenyezoBankszamla->toString()
. $this->szamKitolt($this->ertesitesiHatarido,8)
diff --git a/common/config/params.php b/common/config/params.php
index 8d032d6..8003b7d 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.41',
+ 'version' => 'v0.0.42',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
@@ -18,7 +18,7 @@ return [
'account_state_close_preload_money' => 'true',//preload money wnen show account state close page
'ugiro_duplom_kod' => 1,
'ugiro_kezdemenyezo_szamlaszam' => '000000000000000',//5860025215371128
- 'ugiro_kezdemenyezo_azonosito' => 'A25366936T244',
+ 'ugiro_kezdemenyezo_azonosito' => 'A25006285',//
//a recepicó kosár csak az aktuális user által kiadott termékeket tartalmazza
//vagy mindent
//értékek user|all
diff --git a/common/models/Contract.php b/common/models/Contract.php
index 722ed80..728bd11 100644
--- a/common/models/Contract.php
+++ b/common/models/Contract.php
@@ -122,6 +122,11 @@ class Contract extends \yii\db\ActiveRecord
public function getRequests(){
return $this->hasMany(TicketInstallmentRequest::className(), ['id_contract' => 'id_contract']);
}
+
+ public function getDiscount(){
+ return $this->hasOne(Discount::className(), ['id_discount' => 'id_discount']);
+ }
+
// public static $STATUS_PAID = 10;
// public static $STATUS_NOT_PAID = 20;
diff --git a/common/models/TicketInstallmentRequest.php b/common/models/TicketInstallmentRequest.php
index fe166ec..3fb6a00 100644
--- a/common/models/TicketInstallmentRequest.php
+++ b/common/models/TicketInstallmentRequest.php
@@ -243,7 +243,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
$count = $type->installment_count;
$discount = $ticket->discount;
$money = $type->installment_money;
- if ( isset($discount ) ){
+ if ( isset( $discount ) ){
$money = Discount::applyDiscount($money, $discount);
}
$ticketCreatedAt = time();
diff --git a/common/models/Ugiro.php b/common/models/Ugiro.php
index 33ff63e..49b8823 100644
--- a/common/models/Ugiro.php
+++ b/common/models/Ugiro.php
@@ -23,8 +23,17 @@ class Ugiro extends \yii\db\ActiveRecord
public static $PATH_MEGBIZAS = "giro/megbizas";
public static $PATH_VALASZ = "giro/valasz";
+ /**
+ * beszed fájl kész
+ * */
public static $STATUS_SENT = 0;
+ /**
+ * detsta fájl felöltve
+ * */
public static $STATUS_RECIEVED = 10;
+ /**
+ * detsta fájl feldolgozva
+ * */
public static $STATUS_FINISHED = 20;
/**
diff --git a/console/migrations/m160131_102226_alter__table__contract__add__column__id_discount.php b/console/migrations/m160131_102226_alter__table__contract__add__column__id_discount.php
new file mode 100644
index 0000000..73f1d08
--- /dev/null
+++ b/console/migrations/m160131_102226_alter__table__contract__add__column__id_discount.php
@@ -0,0 +1,30 @@
+addColumn("contract", "id_discount", "int");
+ }
+
+ public function down()
+ {
+ echo "m160131_102226_alter__table__contract__add__column__id_discount 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/models/ContractForm.php b/frontend/models/ContractForm.php
index 6449b53..da434d9 100644
--- a/frontend/models/ContractForm.php
+++ b/frontend/models/ContractForm.php
@@ -157,7 +157,7 @@ class ContractForm extends Model {
'phone' => 'Telefonszám',
'email' => 'E-mail',
'ticket_type' => 'Bérlet típus' ,
- 'payment_method' => 'Fizetési mód' ,
+ 'payment_method' => 'Fizetési mód (első bérlet)' ,
'id_discount' => 'Kedvezmény' ,
];
}
diff --git a/frontend/models/TicketCreate.php b/frontend/models/TicketCreate.php
index fc9e61e..6d9cce2 100644
--- a/frontend/models/TicketCreate.php
+++ b/frontend/models/TicketCreate.php
@@ -176,6 +176,7 @@ class TicketCreate extends Ticket{
$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->id_discount = $this->id_discount;
$contract->save();
$requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);