Add ContractForm, Add contract pdf, Add Display all Transfer option
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user