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!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user