Finish cutler_sale_display

This commit is contained in:
Roland Schneider 2016-02-21 22:07:19 +01:00
commit 59a7a3e95d
33 changed files with 1417 additions and 304 deletions

View File

@ -56,7 +56,13 @@ $this->params['breadcrumbs'][] = $this->title;
],
[
'attribute' => 'id_user',
'value' => 'userName'
'value' => 'userName' ,
'label' => 'Kiadta' ,
],
[
'attribute' => 'paid_by',
'value' => 'paidByName' ,
'label' => 'Fizette'
],
[
'attribute' => 'id_account',

View File

@ -1,3 +1,7 @@
-0.0.39
- add TransferPayout
- add ContractForm
-0.0.38
- add backend skin
- add import add/edit to key

View File

@ -0,0 +1,63 @@
<?php
namespace common\components;
class Azaz
{
public function __construct()
{
$this->EgyesStr = array('', 'egy', 'kettő', 'három', 'négy', 'öt', 'hat', 'hét', 'nyolc', 'kilenc');
$this->TizesStr = array('', 'tíz', 'húsz', 'harminc', 'negyven', 'ötven', 'hatvan', 'hetven', 'nyolcvan', 'kilencven');
$this->TizenStr = array('', 'tizen', 'huszon', 'harminc', 'negyven', 'ötven', 'hatvan', 'hetven', 'nyolcvan', 'kilencven');
}
public function toString($Mit)
{
$this->Mit = $Mit;
$this->Result = '';
if ($Mit == 0)
{
$this->Result = 'Nulla';
}
else
{
$this->Maradek = abs($this->Mit);
if ($this->Maradek > 999999999999)
{
throw new Exception('Túl nagy szám: '.$this->Maradek);
}
$this->Alakit($this->Maradek, 1000000000, 'milliárd');
$this->Alakit($this->Maradek, 1000000, 'millió');
$this->Alakit($this->Maradek, 1000, 'ezer');
$this->Alakit($this->Maradek, 1, '');
$this->Result = ucfirst($this->Result);
if ( $Mit < 0 )
$this->Result = 'Mínusz ' . $this->Result;
}
return $this->Result;
}
protected function Alakit($Maradek, $Oszto, $Osztonev)
{
if ( $Maradek >= $Oszto)
{
if ( mb_strlen($this->Result) > 0 )
$this->Result = $this->Result . '-';
$this->Mit = $Maradek / $Oszto;
if ( $this->Mit >= 100)
$this->Result = $this->Result . $this->EgyesStr[$this->Mit / 100] . 'száz';
$this->Mit = $this->Mit % 100;
if ($this->Mit % 10 !== 0)
$this->Result = $this->Result . $this->TizenStr[$this->Mit / 10] . $this->EgyesStr[$this->Mit % 10] . $Osztonev;
else
$this->Result = $this->Result . $this->TizesStr[$this->Mit / 10] . $Osztonev;
}
$this->Maradek = $this->Maradek % $Oszto;
}
}

View File

@ -255,6 +255,9 @@ class Helper {
public static function isUserCartVisibilityUser() {
return \Yii::$app->params ['user_cart_item_visibility'] == 'user';
}
public static function isUserCartVisibilityAll() {
return \Yii::$app->params ['user_cart_item_visibility'] == 'all';
}
public static function getBackendSkin() {
return \Yii::$app->params ['backend_skin'] ;

View File

@ -0,0 +1,118 @@
<?php
namespace common\components;
use common\models\Transfer;
use common\models\Account;
use yii\base\Exception;
use common\models\ShoppingCart;
use common\models\UserSoldItem;
class TransferPayout extends \yii\base\Object{
/**Current user*/
public $idUser = null;
/**id of transfers which we want to payout*/
public $idTransfers = [];
/** The loaded transfers*/
public $transfers = [];
/**valamilyen kosár kifizetés ( user|customer ) ? */
public $cartType;
/**Vásárló kosár kifizetése esetén a vásárló azonosító*/
public $idCustomer;
/**Az alapértelmezett kassza!*/
public $idAccount;
/**Ha a fizetési módot meg szeretnél változtatni*/
public $overridePaymentMethod = null;
public function payout(){
$this->readTransfers();
if ( count($this->transfers ) ==0 ){
\Yii::error("TransferPayout - üres lista kifizetés");
throw new Exception("Nem található kifizethető tranzakció a listában. ");
}
if ( !$this->isTransferCountMatchWithRequestesTransferCount() ){
\Yii::error("TransferPayout - input tranzakció azonosítók száma nem egyezik a betöltött tranzakciók számával");
throw new Exception("A kifizetni kívánt tranzakciók száma nem egyezik a kifizehtető tranzakciók számával. ");
}
foreach ($this->transfers as $transfer){
$this->payoutTransfer($transfer);
}
}
public function readTransfers(){
$query = Transfer::find();
$query->andWhere([ 'in' , 'transfer.id_transfer' , $this->idTransfers ]);
$query->andWhere( ['transfer.status' => Transfer::STATUS_NOT_PAID]) ;
if ( Helper::isUserCartVisibilityUser()){
$query->innerJoin("user" ,"user.id = transfer.id_user");
}
$this->transfers = $query->all();
\Yii::info("TransferPayout - betöltött tranzakciók száma:" . count($this->transfers) );
}
/**
* Ellenőrizzük, hogy annyi tranzakciót töltöttünk e be, mint amennyit parameterként kaptunkk
* */
public function isTransferCountMatchWithRequestesTransferCount(){
return count($this->transfers) == count($this->idTransfers);
}
/**
* @param common\models\Transfer $transfer the transfer to payout
* */
protected function payoutTransfer($transfer){
$transfer->paid_by = $this->idUser;
$transfer->status = Transfer::STATUS_PAID;
$transfer->paid_at = date('Y-m-d H:i:s' );
$account = $transfer->account;
if ( isset($account )){
/**Ha a tranzakció eredet kasszája látható típusu, akkor változtathatjuk az atuális kasszára. Különben nem*/
if ($account->type == Account::TYPE_ALL){
$transfer->id_account = Account::readDefault();
}
}
\Yii::info("fizetési mód: " . $this->overridePaymentMethod);
if ( isset($this->overridePaymentMethod ) && array_search($this->overridePaymentMethod, array_keys( Transfer::paymentMethods()) ) ){
\Yii::info("fizetési mód beállítva: " .$this->overridePaymentMethod );
$transfer->payment_method = $this->overridePaymentMethod;
}
if ( $transfer->save(false) == false ){
\Yii::error("Tranzakció kifizetése sikertelen volt: " . $transfer->id_transfer);
throw new Exception("Tranzakció fizetése sikertelen volt!");
}
try{
ShoppingCart::deleteAll( ['id_transfer' => $transfer->id_transfer] );
UserSoldItem::deleteAll( ['id_transfer' => $transfer->id_transfer] );
}catch (\Exception $e){
\Yii::error("TransferPayout - tranzakció törlése a kosarakból sikertelen volt. Tranzakció: " . $transfer->id_transfer);
throw new Exception("Tranzakció fizetése sikertelen volt!");
}
}
}

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.38',
'version' => 'v0.0.39',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
@ -12,9 +12,9 @@ return [
/**Kassza nyitáskor küldjünk email-t?*/
'mail_account_state_open' => true,
/**Kassza záráskor küldjünk email-t?*/
'mail_account_state_close' => true,
'login_reception_email' => true, //if reception login should send email
'login_admin_email' => true, //if admin login should send email
'mail_account_state_close' => false,
'login_reception_email' => false, //if reception login should send email
'login_admin_email' => false, //if admin login should send email
'account_state_close_preload_money' => 'true',//preload money wnen show account state close page
'ugiro_duplom_kod' => 1,
'ugiro_kezdemenyezo_szamlaszam' => '000000000000000',//5860025215371128
@ -22,10 +22,20 @@ return [
//a recepicó kosár csak az aktuális user által kiadott termékeket tartalmazza
//vagy mindent
//értékek user|all
// * - user: a felhasználó csak azokat a termékeket látja a kosrába, amiket ő rakott bele
// - all: a felhasználó minden kosrában lévő terméket lát, még azokat is , amiket nem ő rakott bele
'user_cart_item_visibility' => 'user',
/**
* Hány napig láthatják visszamenőleg a recepciósok az adatokat
* */
'reception_visibility_days' => 3,
'backend_skin' => 'skin-red', //skin-green
/**
* if products in carts are visible for everyone or only for the user
* possible values :
* - user: a felhasználó csak azokat a termékeket látja a kosrába, amiket ő rakott bele
* - global: a felhasználó minden kosrában lévő terméket lát, még azokat is , amiket nem ő rakott bele
*
**/
];

View File

@ -88,6 +88,9 @@ class Contract extends \yii\db\ActiveRecord
public function getTicketType(){
return $this->hasOne(TicketType::className(), ['id_ticket_type' => 'id_ticket_type']);
}
public function getTicket(){
return $this->hasOne(Ticket::className(), ['id_contract' => 'id_contract']);
}
public function getCustomer(){
return $this->hasOne(Customer::className(), ['id_customer' => 'id_customer']);
@ -179,4 +182,20 @@ class Contract extends \yii\db\ActiveRecord
public function isFlagActive() {
return $this->flag == static::$FLAG_ACTIVE;
}
public function getPriceMonthly(){
return $this->ticket->price_brutto;
}
public function getPartsTotal(){
$money = $this->getPriceMonthly();
$money = $money * $this->part_count;
return $money;
}
public function getPriceTotal(){
$money = $this->getPartsTotal();
$money = $money + $this->getPriceMonthly();
return $money;
}
}

View File

@ -96,6 +96,8 @@ class Customer extends \yii\db\ActiveRecord
'updated_at' => Yii::t('common/customer', 'Updated At'),
'customerCardNumber' => Yii::t('common/customer', 'Card number'),
'cardNumber' => Yii::t('common/customer', 'Card number'),
'mother_name' => Yii::t('common/customer', 'Anyja neve'),
'birth_place' => Yii::t('common/customer', 'Születési hely'),
];
}
@ -172,6 +174,16 @@ class Customer extends \yii\db\ActiveRecord
return $result;
}
public function getFullAddress(){
$zip = $this->zip;
$city = $this->city;
$address = $this->address;
$result = $zip . " " .$city . ", ". $address;
return $result;
}
}

View File

@ -3,6 +3,7 @@
namespace common\models;
use Yii;
use common\components\Helper;
/**
* This is the model class for table "shopping_cart".
@ -72,6 +73,8 @@ class ShoppingCart extends \yii\db\ActiveRecord
if ( isset($account)){
$sql .= " , id_account = " . $account;
} else if ( Helper::isUserCartVisibilityAll()){
$sql .= " , id_account = " . Account::readDefault();
}
$sql .= " WHERE t.status = " . Transfer::STATUS_NOT_PAID

View File

@ -223,9 +223,11 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
$ticketTypes = null;
if ( $forceIncludeObjectWithId == null){
$ticketTypes = TicketType::find()->andWhere(['status' => self::STATUS_ACTIVE])->andFilterWhere(['ticket_type.id_account' => $account])->all();
$ticketTypes = TicketType::find()->andWhere(['status' => self::STATUS_ACTIVE ])
->andWhere([ '<>', 'installment_enabled' , '1']) ->andFilterWhere(['ticket_type.id_account' => $account])->all();
}else{
$ticketTypes = TicketType::find()->andWhere( ['or', ['status' => self::STATUS_ACTIVE], ['id_ticket_type' => $forceIncludeObjectWithId ] ])->andFilterWhere(['ticket_type.id_account' => $account])->all();
$ticketTypes = TicketType::find()->andWhere( ['or', ['status' => self::STATUS_ACTIVE], ['id_ticket_type' => $forceIncludeObjectWithId ] ])
->andWhere([ '<>', 'installment_enabled' , '1'])->andFilterWhere(['ticket_type.id_account' => $account])->all();
}
return $ticketTypes;

View File

@ -488,8 +488,9 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
$transfers = [ ];
$query = Transfer::find ();
$query->innerJoin("user_sold_item","user_sold_item.id_transfer = transfer.id_transfer");
$query->innerJoinWith ( 'userSoldItem' );
// $query->innerJoinWith ( 'userSoldItem' );
if ( Helper::isUserCartVisibilityUser()){
$query->andWhere ( [
'user_sold_item.id_user' => $user->id
@ -942,6 +943,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
}
}
public function payout() {
if ($this->status != Transfer::STATUS_NOT_PAID) {
return false;
}
@ -949,14 +951,18 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
$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
if( Helper::isUserCartVisibilityAll() ){
$this->id_account = Account::readDefault();
}
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',
@ -968,24 +974,29 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
'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
]
]
] );
$updateConfig = null;
if ( Helper::isUserCartVisibilityUser() ){
$updateConfig = [
'status' => Transfer::STATUS_PAID,
'paid_at' => Helper::getDateTimeString (),
'paid_by' => $id_user
];
}else{
$updateConfig = [
'status' => Transfer::STATUS_PAID,
'paid_at' => Helper::getDateTimeString (),
'paid_by' => $id_user,
'id_account' => Account::readDefault(),
];
}
$updateConditions = [
[ 'in','id_transfer', $id_array ],
[ 'in', 'status', [ Transfer::STATUS_NOT_PAID ] ]
];
Transfer::updateAll ( $updateConfig , $updateConditions );
}
/**

View File

@ -99,8 +99,12 @@ class UserSoldItem extends \yii\db\ActiveRecord
if ( isset($account)){
$sql .= " , id_account = " . $account;
}else if ( Helper::isUserCartVisibilityAll() ){
$sql .= " , id_account = " . Account::readDefault();
}
$sql .= " WHERE t.status = " . Transfer::STATUS_NOT_PAID;
//we can see all transfer in cart, or just our

View File

@ -0,0 +1,31 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160221_132448_alter__table__customer__add__column_mother_name__birth_place extends Migration
{
public function up()
{
$this->addColumn("customer", "mother_name", "string");
$this->addColumn("customer", "birth_place", "string");
}
public function down()
{
echo "m160221_132448_alter__table__customer__add__column_mother_name__birth_place cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -17,6 +17,8 @@ use common\components\Helper;
use common\models\Sale;
use common\models\Product;
use common\models\ShoppingCart;
use common\models\Customer;
use frontend\models\ContractForm;
/**
* ContractController implements the CRUD actions for Contract model.
@ -32,10 +34,10 @@ class ContractController extends Controller {
],
'payout' => [
'post'
],
],
'cancel' => [
'post'
],
]
]
]
];
@ -43,7 +45,7 @@ class ContractController extends Controller {
/**
* Lists all Contract models.
*
*
* @return mixed
*/
public function actionIndex($id_card) {
@ -65,7 +67,7 @@ class ContractController extends Controller {
/**
* Displays a single Contract model.
*
*
* @param integer $id
* @return mixed
*/
@ -90,7 +92,7 @@ class ContractController extends Controller {
/**
* Creates a new Contract model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
*
* @return mixed
*/
public function actionCreate() {
@ -111,7 +113,7 @@ class ContractController extends Controller {
/**
* Updates an existing Contract model.
* If update is successful, the browser will be redirected to the 'view' page.
*
*
* @param integer $id
* @return mixed
*/
@ -133,7 +135,7 @@ class ContractController extends Controller {
/**
* Deletes an existing Contract model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
*
* @param integer $id
* @return mixed
*/
@ -160,21 +162,21 @@ class ContractController extends Controller {
$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;
$ticket = $result [1];
if ($part->status != TicketInstallmentRequest::$STATUS_REJECTED) {
$contract->part_required = $contract->part_required + 1;
}
$contract->part_paid = $contract->part_paid +1;
$contract->part_paid = $contract->part_paid + 1;
if ( $contract->part_paid >= $contract->part_required){
if ($contract->part_paid >= $contract->part_required) {
$contract->status = Contract::$STATUS_PAID;
}else{
} else {
$contract->status = Contract::$STATUS_NOT_PAID;
}
$contract->save(false);
$contract->save ( false );
$part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
$part->id_transfer = $transfer->id_transfer;
$part->request_processed_at = Helper::getDateTimeString ();
@ -258,16 +260,16 @@ class ContractController extends Controller {
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', "Szerződés felbontva!" );
return $this->redirect ( [
return $this->redirect ( [
'product/sale',
'number' => $card->number
'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!" );
} else {
\Yii::$app->session->setFlash ( 'danger', "Szerződést nem lehet felbontani!" );
}
return $this->redirect ( [
@ -275,11 +277,62 @@ class ContractController extends Controller {
'id' => $contract->id_contract
] );
}
public function actionMake($id) {
$customer = Customer::findOne ( $id );
if (! isset ( $customer )) {
throw new Exception ( "Az oldal nem található" );
}
$model = new ContractForm ( [
'customer' => $customer
] );
$model->fillOut ();
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
$model->make ();
$transaction->commit();
return $this->redirect ( [
'contract/view',
'id' => $model->contract->id_contract
] );
} catch ( \Exception $e ) {
$transaction->rollBack();
\Yii::$app->session->setFlash('danger', $e->getMessage());
}
}
return $this->render ( '_make_contract', [
'model' => $model
] );
}
public function actionContract($id){
$model = $this->findModel($id);
$mpdf=new \mPDF('utf-8', 'A4');
$mpdf->WriteHTML($this->renderPartial('_contract', [
'model' => $model,
]));
$fileName = "szerzodes";
$fileName .= "." . $model->customer->name;
$fileName .= "." .\Yii::$app->formatter->asDate( $model->created_at, "Y");
$fileName .=".pdf";
$mpdf->Output($fileName, 'D');//download file
// $mpdf->Output('szerzodes.pdf', 'I');//open in new tab
exit;
}
/**
* 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

View File

@ -14,6 +14,8 @@ use common\models\Card;
use frontend\models\CustomerUpdate;
use frontend\models\CustomerCreate;
use common\models\Image;
use frontend\models\ContractForm;
use yii\base\Exception;
/**
* CustomerController implements the CRUD actions for Customer model.
@ -205,16 +207,13 @@ 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;
}
// s
/**
* Deletes an existing Customer model.

View File

@ -100,6 +100,9 @@ class KeyController extends Controller
$model->toggleKey();
}
if ( isset($model->action ) && $model->action == 'unassign' ){
return $this->redirect(['product/sale', 'number' => $number ]);
}
return $this->redirect(['customer/reception', 'number' => $number ]);

View File

@ -28,6 +28,8 @@ use frontend\components\DefaultAccountBehavior;
use frontend\components\CassaOpenBehavior;
use common\components\ProductInventory;
use frontend\models\ProductInventorySearch;
use common\components\Helper;
use common\components\TransferPayout;
/**
* ProductController implements the CRUD actions for Product model.
@ -62,17 +64,17 @@ class ProductController extends Controller {
'@'
]
]
]
// everything else is denied
] ,
]
],
// everything else is denied
// named behavior, configuration array
'defaultAccount' => [
'class' => DefaultAccountBehavior::className(),
],
'cassaIsOpen' => [
'class' => CassaOpenBehavior::className(),
'defaultAccount' => [
'class' => DefaultAccountBehavior::className ()
],
'cassaIsOpen' => [
'class' => CassaOpenBehavior::className ()
]
];
}
public function actionSale($number = null) {
@ -156,100 +158,86 @@ class ProductController extends Controller {
}
}
public function actionPayoutUserCart() {
if (Yii::$app->request->isAjax) {
// $result = [ ];
// \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$model = new UserCartPayoutForm ();
$user = User::findOne ( Yii::$app->user->id );
if ($model->load ( Yii::$app->request->post () ) && $model->validate () && isset ( $user ) && count ( $model->transfers ) > 0) {
// $user = User::findOne ( Yii::$app->user->id );
// UserSoldItem::payout ( $user );
// $userTransfers = Transfer::modelsToArray ( Transfer::readUserSoldTransfers ( $user ) );
// $result ['transfers'] = $userTransfers;
// $result ['code'] = 'success';
return $result;
} else {
$model = new UserCartPayoutForm ();
$user = User::findOne ( Yii::$app->user->id );
if ( $model->load ( Yii::$app->request->post () ) && $model->validate () &&isset ( $user ) && count ( $model->transfers ) > 0) {
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
$tp = new TransferPayout ( [
'idUser' => \Yii::$app->user->id,
'idTransfers' => $model->transfers,
'cartType' => 'user',
'idAccount' => Account::readDefault ()
] );
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
UserSoldItem::payout ( $user, $model->transfers );
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'Recepicó kosár fizetve' );
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
} else {
Yii::error ( "faled to save : transfer" );
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
$tp->payout ();
// UserSoldItem::payout ( $user, $model->transfers );
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'Recepicó kosár fizetve' );
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
} catch ( \Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
} else {
Yii::error ( "faled to save : transfer" );
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
}
return $this->redirect ( Yii::$app->request->referrer );
}
public function actionPayoutCustomerCart($number) {
$cart = [ ];
$code = 'error';
$message = 'Hiba történt';
if (Yii::$app->request->isAjax) {
$result = [ ];
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
// post
$model = new CustomerCartPayoutForm ();
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
$this->findByNumber ( $number );
if (isset ( $this->customer )) {
if (isset ( $this->customer ) && count ( $model->transfers ) > 0) {
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
ShoppingCart::payout ( $this->customer );
$tp = new TransferPayout ( [
'idUser' => \Yii::$app->user->id,
'idTransfers' => $model->transfers,
'cartType' => 'customer',
'idAccount' => Account::readDefault (),
'idCustomer' => $this->customer->id_customer
] );
$tp->payout ();
// UserSoldItem::payout ( $user, $model->transfers );
$transaction->commit ();
$cart = Transfer::modelsToArray ( Transfer::readCustomerCart ( $this->customer ) );
$code = 'success';
$message = 'Bevásárlókosár fizetve: ' . $this->card->number;
\Yii::$app->session->setFlash ( 'success', 'Vendég kosár fizetve : ' . $this->customer->name );
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
} catch ( \Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
} else {
Yii::error ( "faled to save : no customer or transfer" );
\Yii::$app->session->setFlash ( 'warning', 'Nem történt kifizetés' );
}
$result ['customer_cart'] = $cart;
$result ['code'] = $code;
$result ['message'] = $message;
return $result;
} else {
// post
$model = new CustomerCartPayoutForm ();
if ($model->load ( Yii::$app->request->post () ) && $model->validate ()) {
$this->findByNumber ( $number );
if (isset ( $this->customer ) && count ( $model->transfers ) > 0) {
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction ();
try {
ShoppingCart::payout ( $this->customer, $model->transfers , Account::readDefault());
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'Vendég kosár kifizetve' );
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
\Yii::$app->session->setFlash ( 'danger', 'Hiba történt a mentés során' );
}
} else {
Yii::error ( "faled to save : no customer or transfer" );
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
}
}else{
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
}
return $this->redirect ( Yii::$app->request->referrer );
\Yii::$app->session->setFlash ( 'warning', 'Nem történt változás' );
}
return $this->redirect ( Yii::$app->request->referrer );
}
/**
@ -279,102 +267,84 @@ class ProductController extends Controller {
return $result;
}
public function actionInventory( ) {
public function actionInventory() {
$searchModel = new ProductInventorySearch ( [
'account' => Account::readDefaultObject ()
] );
$searchModel = new ProductInventorySearch(
['account' => Account::readDefaultObject()]
);
// $searchModel->search(\Yii::$app->request->params);
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
// $searchModel->search(\Yii::$app->request->params);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
// $inventory = new ProductInventory([
// ]);
// if ( $output == 'xls'){
// $inventory->pagination = false;
// }
// $inventory->createDataProvider();
// $dp = $inventory->dataProvider;
// $inventory = new ProductInventory([
// ]);
// if ( $output == 'xls'){
// $inventory->pagination = false;
// }
// $inventory->createDataProvider();
// $dp = $inventory->dataProvider;
if ( $searchModel->output == 'xls' ){
$models = $dataProvider->getModels();
$objPHPExcel = new \PHPExcel();
$sheet = $objPHPExcel->setActiveSheetIndex(0);
/**
*
Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
* */
if ($searchModel->output == 'xls') {
$models = $dataProvider->getModels ();
$objPHPExcel = new \PHPExcel ();
$sheet = $objPHPExcel->setActiveSheetIndex ( 0 );
/**
* Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktáron Termék eladva
*/
$row = 1;
$sheet
->setCellValue('A'.$row, "Termék azonosító")
->setCellValue('B'.$row, "Termék név")
->setCellValue('C'.$row, "Termék szám")
->setCellValue('D'.$row, "Termék vonalkód")
->setCellValue('E'.$row, "Termék raktáron");
// ->setCellValue('F'.$row, "Eladott mennyiség");
foreach ($models as $model ){
$row++;
$sheet->setCellValue('A'.$row, $model['product_id'])
->setCellValue('B'.$row, $model['product_name'])
->setCellValue('C'.$row, $model['product_number'])
->setCellValue('D'.$row, $model['product_barcode'])
->setCellValue('E'.$row, $model['product_stock']);
// ->setCellValue('F'.$row, $model['product_sold']);
$sheet->setCellValue ( 'A' . $row, "Termék azonosító" )->setCellValue ( 'B' . $row, "Termék név" )->setCellValue ( 'C' . $row, "Termék szám" )->setCellValue ( 'D' . $row, "Termék vonalkód" )->setCellValue ( 'E' . $row, "Termék raktáron" );
// ->setCellValue('F'.$row, "Eladott mennyiség");
foreach ( $models as $model ) {
$row ++;
$sheet->setCellValue ( 'A' . $row, $model ['product_id'] )->setCellValue ( 'B' . $row, $model ['product_name'] )->setCellValue ( 'C' . $row, $model ['product_number'] )->setCellValue ( 'D' . $row, $model ['product_barcode'] )->setCellValue ( 'E' . $row, $model ['product_stock'] );
// ->setCellValue('F'.$row, $model['product_sold']);
}
$styleArray = array(
'font' => array(
'bold' => true,
// 'color' => array('rgb' => 'FF0000'),
// 'size' => 15,
// 'name' => 'Verdana'
));
$styleArray = array (
'font' => array (
'bold' => true
)
);
// 'color' => array('rgb' => 'FF0000'),
// 'size' => 15,
// 'name' => 'Verdana'
foreach(range('A','E') as $columnID)
{
$sheet->getColumnDimension($columnID)->setAutoSize(true);
$sheet->getStyle($columnID.'1')->applyFromArray($styleArray);
foreach ( range ( 'A', 'E' ) as $columnID ) {
$sheet->getColumnDimension ( $columnID )->setAutoSize ( true );
$sheet->getStyle ( $columnID . '1' )->applyFromArray ( $styleArray );
}
// Redirect output to a clients web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="leltar.xls"');
header('Cache-Control: max-age=0');
header ( 'Content-Type: application/vnd.ms-excel' );
header ( 'Content-Disposition: attachment;filename="leltar.xls"' );
header ( 'Cache-Control: max-age=0' );
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
header ( 'Cache-Control: max-age=1' );
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); // Date in the past
header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ); // always modified
header ( 'Cache-Control: cache, must-revalidate' ); // HTTP/1.1
header ( 'Pragma: public' ); // HTTP/1.0
$objWriter = \PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel5' );
$objWriter->save ( 'php://output' );
exit ();
}
return $this->render('inventory',[ 'searchModel' =>$searchModel, 'dataProvider' => $dataProvider]);
return $this->render ( 'inventory', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider
] );
}
/**
* Finds the Product model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
*
*
* @param integer $id
* @return Product the loaded model
* @throws NotFoundHttpException if the model cannot be found
@ -398,12 +368,10 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
}
}
}
/**
* Lists all Product models.
*
*
* @return mixed
*/
/*
@ -420,7 +388,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
*/
/**
* Displays a single Product model.
*
*
* @param integer $id
* @return mixed
*/
@ -435,7 +403,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
/**
* Updates an existing Product model.
* If update is successful, the browser will be redirected to the 'view' page.
*
*
* @param integer $id
* @return mixed
*/
@ -456,7 +424,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
/**
* Deletes an existing Product model.
* If deletion is successful, the browser will be redirected to the 'index' page.
*
*
* @param integer $id
* @return mixed
*/
@ -471,7 +439,7 @@ Termék azonosító Termék neve Termék szám Termék vonalkód Termék raktár
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
*
* @return mixed
*/
/*

View File

@ -23,6 +23,9 @@ use frontend\models\UserCartForm;
use common\models\Customer;
use frontend\models\CustomerCartForm;
use common\models\Card;
use common\components\Helper;
use yii\base\Exception;
use common\components\TransferPayout;
/**
* TransferController implements the CRUD actions for Transfer model.
@ -190,26 +193,27 @@ class TransferController extends Controller
$transfer = $this->findModel($id);
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
$transfer->status = Transfer::STATUS_PAID;
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
$transfer->paid_by = \Yii::$app->user->id;
$transfer->id_account = Account::readDefault();
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
if ( $transfer->save() ){
\Yii::$app->session->setFlash( 'success','Tranzakció kifizetve!' );
$transaction->commit();
}else{
throw new \Exception("Failed to save");
}
} catch(Exception $e) {
$transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Tranzakció kifizetése nem sikerült' );
$tp = new TransferPayout( [
'idUser' => \Yii::$app->user->id,
'idTransfers' => [$transfer->id_transfer ],
'idAccount' => Account::readDefault (),
] );
$tp->payout ();
// UserSoldItem::payout ( $user, $model->transfers );
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'Tranzakció fizetve: ' . $transfer->count ." db " . $transfer->getObjectName() . " - " . $transfer->money);
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
} catch ( \Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
return $this->redirect(Yii::$app->request->referrer);
}
@ -359,6 +363,8 @@ class TransferController extends Controller
$model->run();
return $this->render("usercart",[ 'model' => $model]);
}
public function actionCustomerCart($id_card){
$defaultAccount = Account::readDefault();

View File

@ -56,4 +56,7 @@ class ContactForm extends Model
->setTextBody($this->body)
->send();
}
}

View File

@ -0,0 +1,307 @@
<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use yii\base\Exception;
use common\models\Ticket;
use common\models\Account;
use common\models\TicketType;
use common\models\Transfer;
use common\models\Contract;
use common\models\TicketInstallmentRequest;
use common\models\Discount;
use common\models\ShoppingCart;
/**
* ContactForm is the model behind the contact form.
*/
class ContractForm extends Model {
public $name;
public $birthdate;
public $birthplace;
public $mothername;
public $zip;
public $city;
public $address;
public $bank_account;
public $bank_name;
public $phone;
public $email;
public $ticket_type;
public $customer;
public $payment_method;
public $id_discount;
private $ticket;
private $transfer;
public $contract;
private $ticketType;
private $money;
private $discount;
/**
* @inheritdoc
*/
public function rules() {
return [
// name, email, subject and body are required
[
[
'ticket_type',
'name',
'birthdate',
'birthplace',
'mothername',
"zip",
"city",
"address",
"bank_account",
"bank_name",
'phone',
'email',
'payment_method'
],
'required'
],
// email has to be a valid email address
[
'email',
'email'
],
[
'ticket_type',
'integer'
],
[
[
'phone'
],
'string',
'max' => 20
],
[
[
'bank_account'
],
'string',
'max' => 24
],
[
[
'bank_name'
],
'string',
'max' => 100
],
[
[
'mothername',
'birthplace',
'name',
'zip',
'city',
'address'
],
'string',
'max' => 100
],
[
[
'birthdate'
],
'date'
],
[
[
'ticket_type',
'id_discount',
'payment_method'
],
'integer'
],
[
[
'ticket_type'
],
'validateTicketType'
]
];
}
public function validateTicketType($attribute, $params) {
$this->ticketType = TicketType::findOne ( $this->ticket_type );
if (! isset ( $this->ticketType )) {
$this->addError ( $attribute, "Bérlet típus nem található" );
}
}
/**
* @inheritdoc
*/
public function attributeLabels() {
return [
'name' => 'Név',
'birthdate' => 'Születési dátum',
'birthplace' => 'Születési hely',
'mothername' => 'Anyja neve',
'zip' => 'Irányítószám',
'city' => 'Város',
'address' => 'Cím',
'bank_account' => 'Bankszámlaszám',
'bank_name' => 'Bank neve',
'phone' => 'Telefonszám',
'email' => 'E-mail',
'ticket_type' => 'Bérlet típus' ,
'payment_method' => 'Fizetési mód' ,
'id_discount' => 'Kedvezmény' ,
];
}
public function fillOut() {
$this->name = $this->customer->name;
$this->birthdate = isset ( $this->customer->birthdate ) ? \Yii::$app->formatter->asDate ( $this->customer->birthdate ) : '';
$this->birthplace = $this->customer->birth_place;
$this->mothername = $this->customer->mother_name;
$this->zip = $this->customer->zip;
$this->city = $this->customer->city;
$this->address = $this->customer->address;
$this->bank_account = $this->customer->bank_account;
$this->bank_name = $this->customer->bank_name;
$this->phone = $this->customer->phone;
$this->email = $this->customer->email;
}
public function make() {
$this->money = $this->ticketType->price_brutto;
$this->discount = Discount::findOne($this->id_discount);
if ( isset($this->discount)){
$this->money = Discount::applyDiscount($this->ticketType->price_brutto, $this->discount);
}
$this->updateCustomer ();
$this->createTicket ();
$this->createTransfer ();
$this->appendToCustomerCart();
$this->addContract();
$this->ticket->id_contract = $this->contract->id_contract;
if ( !$this->ticket->update(false)){
\Yii::error("Nem sikerült a bérlethez hozzárendelni a szerződést");
throw new Exception("Hiba történt mentés közben!");
}
return true;
}
public function updateCustomer() {
$this->customer->name = $this->name;
$this->customer->birthdate = $this->birthdate;
$this->customer->birth_place = $this->birthplace;
$this->customer->mother_name = $this->mothername;
$this->customer->zip = $this->zip;
$this->customer->city = $this->city;
$this->customer->address = $this->address;
$this->customer->bank_account = $this->bank_account;
$this->customer->bank_name = $this->bank_name;
$this->customer->phone = $this->phone;
$this->customer->email = $this->email;
if (! $this->customer->save ( false )) {
throw new Exception ( 'nem sikerült a szerződés létrehozása' );
}
}
public function createTicket() {
$ticket = new Ticket ();
$ticket->id_user = \Yii::$app->user->id;
$ticket->id_account = Account::readDefault ();
$ticket->id_discount = $this->id_discount;
$ticket->start = date ( 'Y-m-d' );
$date = new \DateTime ();
$date->modify ( '+1 month' );
$date->modify ( '-1 day' );
$ticket->end = $date->format ( 'Y-m-d H:i:s' );
$ticket->id_ticket_type = $this->ticketType->id_ticket_type;
$ticket->price_brutto = $this->money;
$ticket->max_usage_count = $this->ticketType->max_usage_count;
$ticket->usage_count = 0;
$ticket->status = Ticket::STATUS_ACTIVE;
$ticket->comment = "Szerződéses bérlet";
$ticket->id_card = $this->customer->card->id_card;
$ticket->part = 0;
$ticket->part_paid = 0;
$ticket->part_count = $this->ticketType->installment_count;
if (! $ticket->save ( false )) {
\Yii::error ( "A bérlet mentése sikertelen volt" );
throw new Exception ( "Hiba történt mentés közben" );
}
$this->ticket = $ticket;
}
public function createTransfer() {
$transfer = new Transfer ();
$transfer->id_object = $this->ticket->id_ticket;
$transfer->status = Transfer::STATUS_NOT_PAID;
$transfer->type = Transfer::TYPE_TICKET;
$transfer->item_price = $this->money;
$transfer->count = 1;
$transfer->money = $this->money;
$transfer->id_user = \Yii::$app->user->id;
$transfer->comment = "Szerződéses bérlet";
$transfer->id_account = Account::readDefault ();
$transfer->direction = Transfer::DIRECTION_IN;
$transfer->id_customer = $this->customer->id_customer;
$transfer->payment_method = $this->payment_method;
$transfer->id_discount = $this->id_discount;
if (! $transfer->save ( false )) {
\Yii::error ( "A tranzakció mentése sikertelen volt" );
throw new Exception ( "Hiba történt mentés közben" );
}
$this->transfer = $transfer;
}
public function addContract() {
if (! $this->ticketType->isInstallment ()) {
\Yii::error ( "A bérlet típus nem tágmogatja a szerződés kötést!" );
throw new Exception ( "A bérlet típus nem tágmogatja a szerződés kötést!" );
}
$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 = $this->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->ticketType->id_ticket_type;
if (! $contract->save ( false )) {
\Yii::error ( "A szerződés mentése sikertelen volt" );
throw new Exception ( "Hiba történt mentés közben" );
}
$this->contract = $contract;
$requests = TicketInstallmentRequest::createInstallments ( $this->ticket, $this->ticketType, $this->customer, $contract );
foreach ( $requests as $request ) {
$request->save ( false );
if (! $request->save ( false )) {
\Yii::error ( "A szerződés részlet mentése sikertelen volt" );
throw new Exception ( "Hiba történt mentés közben" );
}
}
}
public function appendToCustomerCart(){
$item = new ShoppingCart();
$item->id_customer = $this->customer->id_customer;
$item->id_transfer = $this->transfer->id_transfer;
if ( !$item->save(false) ){
\Yii::error("Vendég kosár hozzárendelés sikertelen!");
throw new Exception ( "Hiba történt mentés közben" );
}
}
}

View File

@ -6,6 +6,7 @@ use Yii;
use yii\base\Model;
use common\models\Transfer;
use common\models\Account;
use common\components\TransferPayout;
/**
* ContactForm is the model behind the contact form.
@ -60,19 +61,34 @@ class CustomerCartForm extends Model
}
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->id_account = Account::readDefault();
$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;
}
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
$tp = new TransferPayout( [
'idUser' => \Yii::$app->user->id,
'idTransfers' => $this->selected,
'idAccount' => Account::readDefault (),
'cartType' => 'customer',
'overridePaymentMethod' => $this->payment_method,
'idCustomer' => $this->customer->id_customer
] );
$tp->payout ();
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'A vásárló kosár kiválasztott tranzakciói ki lettek kifizetve!');
return true;
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
} catch ( \Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
return false;
}else{
\Yii::$app->session->setFlash('danger', 'Nem választott ki terméket');
return false;

View File

@ -105,7 +105,9 @@ class CustomerCreate extends \common\models\Customer
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30],
[['photo_data'] ,'safe']
[['photo_data'] ,'safe'],
[['birth_place'] ,'safe'],
[['mother_name'] ,'safe'],
// [['email','phone'], 'validateEmailOrPhoneRequired' ],
];

View File

@ -115,7 +115,9 @@ class CustomerUpdate extends \common\models\Customer
[['zip'], 'string', 'max' => 8],
[['city'], 'string', 'max' => 30],
[['photo_data'] ,'safe']
[['photo_data'] ,'safe'],
[['birth_place'] ,'safe'],
[['mother_name'] ,'safe'],
];
}

View File

@ -17,7 +17,7 @@ class KeyToggleForm extends Model
public $card;
public $customer;
public $keyModel;
public $action;
@ -55,6 +55,7 @@ class KeyToggleForm extends Model
$assignments = CardKeyAssignment::find()->andWhere(['id_key' => $this->keyModel->id_key])->all();
if ( count($assignments) > 0){
$this->unassign();
$this->action = 'unassign';
}else{
$this->assign();
}

View File

@ -7,6 +7,7 @@ use yii\base\Model;
use common\models\Transfer;
use common\components\Helper;
use common\models\Account;
use common\components\TransferPayout;
/**
* ContactForm is the model behind the contact form.
@ -60,19 +61,48 @@ class UserCartForm extends Model
}
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->id_account = Account::readDefault();
$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;
}
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
try {
$tp = new TransferPayout( [
'idUser' => \Yii::$app->user->id,
'idTransfers' => $this->selected,
'idAccount' => Account::readDefault (),
'cartType' => 'user',
'overridePaymentMethod' => $this->payment_method
] );
$tp->payout ();
$transaction->commit ();
\Yii::$app->session->setFlash ( 'success', 'A recepció kosár kiválasztott tranzakciói ki lettek kifizetve!');
return true;
} catch ( Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
} catch ( \Exception $e ) {
$transaction->rollback ();
Yii::error ( "faled to save :" . $e->getMessage () );
}
return false;
// $items = $this->loadTransfers($this->selected);
// if ( count($items) == count($this->selected) ){
// foreach ($items as $item){
// $this->changePaymentMethod($item);
// if ( Helper::isUserCartVisibilityAll() ){
// $item->id_account = Account::readDefault();
// }
// $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;

View File

@ -0,0 +1,294 @@
<?php
use common\components\Azaz;
?>
<?php
$customer = $model->customer;
$customerName = $customer->name;
$customerAddress = $customer->getFullAddress();
$customerBirthInfo = $customer->birth_place . ", " . ( isset( $customer->birthdate ) ? \Yii::$app->formatter->asDate($customer->birthdate) : '');
$customerMotherName = $customer->mother_name;
$customerPhone = $customer->phone;
$customerEmail = $customer->email;
$customerBankAccount = $customer->bank_account;
$customerIdCustomer = $customer->id_customer;
$contractDate = date('Y.m.d');
$azaz = new Azaz();
$ticketMoneyYear = $model->getPriceTotal();
$ticketMoneyYearText = $azaz->toString($ticketMoneyYear);
$ticketMoneyMonth = $model->getPriceMonthly();
$ticketMoneyMonthText = $azaz->toString($ticketMoneyMonth);
$customerBankName = $customer->bank_name;
?>
<h1 style='text-align: center'>
TAGSÁGI SZERZŐDÉS
</h1>
<p>
Mely létrejött egyrészről:
<table>
<tbody>
<tr><td>
<b>Cutler-Four Kereskedelmi és Szolgáltató Korlátolt Felelősségű Társaság</b>
</td></tr>
<tr><td>
székhely: 9222 Hegyeshalom, Pozsonyi u. 11.
</td></tr>
<tr><td>
adószám: 25006285-2-08
</td></tr>
<tr><td>
cégjegyzékszám: 08-09-0260601
</td></tr>
<tr><td>
bankszámlaszám: 59500155-11109938
</td></tr>
<tr><td>
képviseli: Freimann Sándor ügyvezető
</td></tr>
<tr><td>
(a továbbiakban, mint Szolgáltató),
</td></tr>
</tbody>
</table>
</p>
<p>
másrészről:
<table>
<tbody>
<tr><td>
név: <?php echo $customerName ?>
</td></tr>
<tr><td>
lakcím: <?php echo $customerAddress?>
</td></tr>
<tr><td>
születési hely, idő: <?php echo $customerBirthInfo ?>
</td></tr>
<tr><td>
anyja neve: <?php echo $customerMotherName?>
</td></tr>
<tr><td>
telefonszám: <?php echo $customerPhone;?>
</td></tr>
<tr><td>
e-mail cím: <?php echo $customerEmail?>
</td></tr>
<tr><td>
bankszámlaszám: <?php echo $customerBankAccount; ?>
</td></tr>
</tbody>
</table>
</p>
<p>
(a továbbiakban, mint Tag) között alulírott helyen és időben az alábbi feltételekkel.
</p>
<ol>
<li>
A szerződő felek rögzítik, hogy a Tag igénybe kívánja venni a 9027 Győr, Nagysándor József utca 31. szám alatti CUTLER FITNESS Győr edzőterem szolgáltatásait az alábbiakban részletezett feltételek alapján.
</li>
<li>
A szerződő felek rögzítik, hogy jelen megállapodást 12 hónap határozott időtartamra kötik, melynek kezdő időpontja a jelen szerződés aláírásának a napja.
<p>
Felek megállapodnak abban is, hogy a jelen szerződés automatikusan további újabb és újabb 12 hónappal ráutaló magatartással meghosszabbodik mindaddig, ameddig bármelyik fél a szerződés, illetve a meghosszabbodott szerződés lejártát megelőző 30 napon belül a másik fél részére írásban a szerződés megszűntetésére vonatkozó szándékát nem közli.
</p>
<p>
A Szerződő Felek kijelentik, hogy a Tag a határozott időtartamú szerződés hatálya alatt, a CUTLER FITNESS Győr szolgáltatásait kedvezményesen veheti igénybe. Ezen kedvezményes éves tagsági díj összege <?php echo $ticketMoneyYear?> Ft, azaz <?php echo $ticketMoneyYearText?> forint, amely havi részletekben fizetendő meg. Így a havonta fizetendő tagsági díj összege havi <?php echo $ticketMoneyMonth?> Ft, azaz <?php echo $ticketMoneyMonthText?> forint, melynek első részletét a Tag jelen szerződés aláírásakor köteles megfizetni. Az első részlet megfizetéséig a Tag nem jogosult a szolgáltatások igénybe vételére.
</p>
<p>
A további részletek előre, a jelen szerződésmegkötését követő 30 naponta esedékesek. Ezen összegeket a Szolgáltató a Tag bankszámlájáról történő leemeléssel, úgy nevezett csoportos beszedési megbízással szedi be a Tag jelen szerződéssel egyidejűleg adott, aláírt felhatalmazása alapján.
</p>
<p>
Tag tudomásul veszi, hogy a Szolgáltató a bankszámláról történő beszedést az esedékességet megelőző 15 napon belül jogosult elindítani. Tag köteles a bankszámláján legalább a levonandó összegnek megfelelő egyenleget tartani, hogy a beszedés megtörténhessen.
</p>
</li>
<li>
Amennyiben a Szolgáltató részére az adott hónapban nem teljesül a bankszámláról történő beszedés, úgy azt Szolgáltató nem ismétli meg (aktuális időszakra). Amennyiben a Tag továbbra is igénybe kívánja venni a Szolgáltató szolgáltatását a díjfizetéssel nem rendezett időszakban, úgy köteles a hátralék egyéb úton történő megfizetésére.
</li>
<li>
Tag tudomásul veszi, hogy a Szolgáltató a szolgáltatási díjjal nem rendezett időszak alatt az elmaradás rendezéséig, az igénybe vehető szolgáltatások körét részben vagy egészben korlátozhatja, a Szolgáltató a belépést a területére megtilthatja.
</li>
<li>
Amennyiben Szolgáltató legalább 3 egymást követő hónapban sem tudja beszedni a bérlet összegét a bankszámlára indított csoportos beszedéssel, úgy Szolgáltató jogosult jelen Szerződés azonnali hatályú felmondására.
</li>
<li>
A Tag kijelenti, hogy a Szolgáltató recepciójánál kifüggesztett Házirendjét és jelen szerződést elolvasta, értelmezte és azt magára nézve kötelezőnek ismerte el.
</li>
<li>
7. Felmondási lehetőségek
<ol type="lower-alpha">
<li>
A Tag tudomásul veszi, hogy a határozott időtartam alatt nincs lehetőség a tagsági jogviszony felmondására. Indokolt esetben (pl. terhesség, sérülés, távoli helyre költözés, stb.) a Tag írásban kezdeményezheti a Szerződés közös megegyezéssel történő megszűntetését, amely kérelemről a Szolgáltató 15 napon belül saját belátása szerint dönt és döntéséről a kérelmezőt értesíti.
</li>
<li>
Jelen szerződés azonnali hatályú felmondására jogosult a Szolgáltató, amennyiben a Tag a bankszámlájára vonatkozó csoportos beszedési megbízásra vonatkozó felhatalmazást visszavonja a bankjánál, a bankszámláját megszünteti vagy a Házirendet súlyosan megszegi.
<p><b>
Ha Szolgáltató bármelyik fenti ok kapcsán él az azonnali hatályú felmondásra vonatkozó jogával, akkor a Tag köteles a szerződéséből hátralévő határozott időtartam alapulvételével havi 3.000,- Ft, azaz Háromezer forint kötbér megfizetésére, továbbá a felmondást követő 1 éven belül nem lesz jogosult újabb éves szerződés megkötésére.
</b></p>
</li>
<li>
Szolgáltató bármikor egyoldalúan jogosult arra, hogy a jelen Szerződést 30 napos felmondási idővel írásban felmondja, amennyiben a Tag a Házirendet bizonyíthatóan megsérti.
</li>
</ol>
</li>
<li>
Jelen szerződésben nem szabályozott kérdésekben a Ptk. rendelkezései az irányadóak.
</li>
</ol>
<p>
Kelt: Győr, <?php echo $contractDate ?>
</p>
<table style="width: 100%; margin-top: 30px;">
<tr>
<td style="width: 33%">
</td>
<td>
</td>
<td style="width: 33%; border-bottom: 1px dotted #000;">
</td>
</tr>
<tr>
<td style="text-align: center;">
Szolgáltató
</td>
<td>
</td>
<td style="text-align: center;">
Tag
</td>
</tr>
<tr>
<td style="text-align: center;">
Cutler-FourKft.
</td>
<td>
</td>
<td style="text-align: center;">
<?php echo $customerName?>
</td>
</tr>
<tr>
<td style="text-align: center;">
Freimann Sándor ügyvezető
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
<pagebreak />
<h2>Felhatalmazás csoportos beszedési megbízás teljesítésére</h2>
<ol>
<li>
<div>
Fizető fél adatai:
</div>
<div>
Fizető fél neve: <?php echo $customerName?>
</div>
<div>
Fizető fél bankszámlaszáma: <?php echo $customerBankAccount?>
</div>
</li>
<li>
<div>
Kedvezményezett adatai:
</div>
<div>
Kedvezményezett neve: <b>CUTLER-FOUR Kereskedelmi és Szolgáltató Kft.</b>
</div>
<div>
Kedvezményezett azonosítója: <b>A25006285</b>
</div>
</li>
<li>
<div>
Kedvezményezettel szerződéses viszonyban lévő személy adatai:
</div>
<div>
Szerződő fél neve: <?php echo $customerName?>
</div>
<div>
Szerződő fél címe: <?php echo $customerAddress?>
</div>
<div>
Szerződő fél azonosítója a Kedvezményezettnél: <?php echo $customerIdCustomer?>
</div>
</li>
<li>
<div>
Teljesítés adatai:
</div>
<div>
Érvényesség kezdete: <?php echo $contractDate?> lejárata:
</div>
<div>
Teljesítés felső értékhatára:
</div>
</li>
<li>
<div>
Felhatalmazás jellege: eredeti felhatalmazás
</div>
</li>
<li>
Nyilatkozat
<p>
Jelen nyomtatvány kitöltésével és aláírásával felhatalmazom <?php echo $customerBankName?> pénzforgalmi szolgáltatót arra, hogy a fentebb megjelölt Kedvezményezettet az általam benyújtott felhatalmazásról értesítse, és fizetési számlámat a Kedvezményezett által benyújtott beszedési megbízás alapján megbízásom keretei között megterhelje. Tudomásul veszem, hogy a beszedési megbízás teljesítésére szóló felhatalmazás elfogadásáról, a beszedés megkezdésének tényleges időpontjáról, illetve az elutasításáról és annak okáról a Kedvezményezettől a számlavezetőm és a szerződő fél értesítést kap.
</p>
</li>
</ol>
<table style="width: 100%; margin-top: 30px;">
<tr>
<td style="width: 33%; ">
Kelt: Győr, <?php echo $contractDate ?>
</td>
<td>
</td>
<td style="width: 33%; ">
Kelt: Győr, <?php echo $contractDate ?>
</td>
</tr>
</table>
<table style="width: 100%; margin-top: 30px;">
<tr>
<td style="width: 33%; border-bottom: 1px dotted #000;">
</td>
<td>
</td>
<td style="width: 33%; border-bottom: 1px dotted #000;">
</td>
</tr>
<tr>
<td style="text-align: center;">
Fizető fél aláírása
</td>
<td>
</td>
<td style="text-align: center;">
Átvevő aláírása
</td>
</tr>
</table>

View File

@ -0,0 +1,119 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\TicketType;
use common\components\Helper;
use frontend\components\HtmlHelper;
use kartik\widgets\DatePicker;
use common\models\Transfer;
use common\models\Discount;
/* @var $this yii\web\View */
/* @var $model common\models\Contract */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$types = TicketType::findAll(['status' => TicketType::STATUS_ACTIVE ,'installment_enabled' => '1']);
$types = HtmlHelper::mkTicketTypeOptions($types);
$discounts = Discount::read();
$discounts = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts);
?>
<h1>Szerződés létrehozása</h1>
<div class="contract-form">
<?php $form = ActiveForm::begin(); ?>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'name')->textInput() ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'mothername')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'birthplace')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'zip')->textInput() ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'city')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'address')->textInput() ?>
</div>
<div class="col-md-6">
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'bank_name')->textInput() ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'bank_account')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'phone')->textInput() ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'email')->textInput() ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'ticket_type')->dropDownList($types) ?>
</div>
<div class="col-md-6">
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'payment_method')->dropDownList(Transfer::paymentMethods()) ?>
</div>
<div class="col-md-6">
<?= $form->field($model, 'id_discount')->dropDownList( $discounts ) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton( Yii::t('common/contract', 'Szerződés és első bérlet létrehozása') , ['class' => 'btn btn-success' ]) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -19,6 +19,10 @@ $this->params['breadcrumbs'][] = $this->title;
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<?php
echo Html::a( "Új szerződés",['contract/make' , 'id' => $searchModel->customer->id_customer ], ['class' => 'btn btn-success'])
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,

View File

@ -14,6 +14,8 @@ $this->params['breadcrumbs'][] = $this->title;
?>
<?php echo CustomerTabWidget::widget(['card' => $model->customer->card,'title' => 'Szerződés részletek'])?>
<div class="contract-view">
<?= DetailView::widget([
@ -52,6 +54,14 @@ $this->params['breadcrumbs'][] = $this->title;
?>
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
</div>
</div>
<br>
<div class="row">
<div class="col-md-12">
<?php
echo Html::a("Szerződés letöltése ",['contract/contract' , 'id' => $model->id_contract], [ 'class' => 'btn btn-success']);
?>
</div>
</div>
<br>
<?php }?>
@ -90,7 +100,7 @@ $this->params['breadcrumbs'][] = $this->title;
<?php
if ( $inst->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']);
echo Html::a("Fizetettnek jelölés és bérlet vásárló kosarába helyezése",['contract/payout' , 'id' => $inst->id_ticket_installment_request], [ 'data-method' => 'post', 'class' => 'btn btn-danger']);
}
?>
</div>

View File

@ -1,24 +0,0 @@
<h1>
Éves szerződés
</h1>
<p>
Ez az éves szerződés szövege
</p>
<p>
Kövektező bekezdés
</p>
<p>
A szerződő fél neve:
<span>
<?php
echo $model->name
?>
</span>
</p>
<p>
<span>A cég neve:</span>
<span><?php echo \Yii::$app->params['company_name']?></span>
</p>

View File

@ -54,6 +54,20 @@ use kartik\widgets\DatePicker;
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
</div>
<div class='col-md-3'>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'mother_name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'birth_place')->textInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
@ -78,6 +92,8 @@ use kartik\widgets\DatePicker;
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>

View File

@ -44,20 +44,34 @@ use yii\base\Widget;
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'mother_name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-3'>
<?php echo $form->field($model, 'birthdate',[ ] )->widget(DatePicker::classname(), [
<?= $form->field($model, 'birth_place')->textInput(['maxlength' => true]) ?>
</div>
<div class='col-md-3'>
<?= $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
]) ?>
</div>
</div>
</div>
<div class='row'>
<div class='col-md-3'>

View File

@ -68,17 +68,21 @@ AppAsset::register($this);
</div>
</div>
<footer class="footer">
<footer class="footer" style="min-height: 60px; height: auto;">
<div class="container">
<div class="row">
<div class="col-md-12">
<p class="pull-left">&copy; <?= Yii::$app->name ?> <?= Yii::$app->params['version'] ?> Fitness - WebAdmin <?= date('Y') ?></p>
</div>
</div>
</div>
<div class="container">
<div>
Az oldalon szereplő adatok csak tájékoztató jellegűek.<br>
Az adatok helyességéért és igazságtartalmáért felelősséget nem vállalunk.<br>
Az oldal nem használható hivatalos adatforrásként.<br>
<div class="row">
<div class="col-md-12">
Ingyenesen használható alkalmazás.
Az oldalon szereplő adatok csak tájékoztató jellegűek.<br>
Az adatok helyességéért és igazságtartalmáért felelősséget nem vállalunk.<br>
Az oldal nem használható hivatalos adatforrásként.<br>
</div>
</div>
</div>
</footer>