add editable account on reception/customer-cart, add towel handling
This commit is contained in:
@@ -20,7 +20,8 @@ class CustomerCartForm extends Model
|
||||
public $money = 0;
|
||||
public $selected = [];
|
||||
public $customer;
|
||||
|
||||
public $hiddenAccounts;
|
||||
public $id_account;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -28,7 +29,7 @@ class CustomerCartForm extends Model
|
||||
{
|
||||
return [
|
||||
['selected', 'each', 'rule' => ['integer']],
|
||||
[['money' ,'payment_method'],'integer'],
|
||||
[['money' ,'payment_method' ,'id_account' ],'integer'],
|
||||
[['payment_method'],'validatePaymentMethod'],
|
||||
];
|
||||
}
|
||||
@@ -44,15 +45,45 @@ class CustomerCartForm extends Model
|
||||
|
||||
public function validatePaymentMethod( $attribute, $params ){
|
||||
if ( !empty($this->payment_method)){
|
||||
// echo $this->payment_method;
|
||||
$arr = Transfer::paymentMethods();
|
||||
if ( !array_key_exists($this->payment_method, $arr) ){
|
||||
$this->addError($attribute, "Érvénytelen fizetési mód");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function validateIdAccount( $attribute, $params ){
|
||||
if ( !empty($this->id_account)){
|
||||
$account = $this->loadAvailableOverrideAccounts($this->id_account);
|
||||
if ( !isset($account) ){
|
||||
$this->addError($attribute, "Érvénytelen kassza");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function loadAvailableOverrideAccounts($id_account = null){
|
||||
$accounts = null;
|
||||
$query = Account::find();
|
||||
|
||||
$query->innerJoinWith('userAccountAssignments');
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||
$query->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
|
||||
if ( isset($id_account)){
|
||||
$query->andWhere(['account.id_account' => $id_account]);
|
||||
}
|
||||
|
||||
|
||||
$query->orderBy( ['name' => SORT_ASC]);
|
||||
|
||||
|
||||
$accounts = $query->all();
|
||||
return $accounts;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function payout(){
|
||||
$valid = $this->validate();
|
||||
|
||||
@@ -71,6 +102,7 @@ class CustomerCartForm extends Model
|
||||
'idAccount' => Account::readDefault (),
|
||||
'cartType' => 'customer',
|
||||
'overridePaymentMethod' => $this->payment_method,
|
||||
'overrideIdAccount' => $this->id_account,
|
||||
'idCustomer' => $this->customer->id_customer
|
||||
] );
|
||||
|
||||
@@ -82,10 +114,10 @@ class CustomerCartForm extends Model
|
||||
|
||||
} catch ( Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
Yii::error ( "failed to save :" . $e->getMessage () );
|
||||
} catch ( \Exception $e ) {
|
||||
$transaction->rollback ();
|
||||
Yii::error ( "faled to save :" . $e->getMessage () );
|
||||
Yii::error ( "failed to save :" . $e->getMessage () );
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -100,7 +132,13 @@ class CustomerCartForm extends Model
|
||||
$item->payment_method = $this->payment_method;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function changeAccount($item){
|
||||
if ( !empty($this->id_account)){
|
||||
$item->id_account = $this->id_account;
|
||||
}
|
||||
}
|
||||
|
||||
public function run(){
|
||||
$this->readTransfers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user