Add ContractForm, Add contract pdf, Add Display all Transfer option
This commit is contained in:
63
common/components/Azaz.php
Normal file
63
common/components/Azaz.php
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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'] ;
|
||||
|
||||
118
common/components/TransferPayout.php
Normal file
118
common/components/TransferPayout.php
Normal 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!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
*
|
||||
**/
|
||||
|
||||
];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user