change procurement product selection, keytoggle redirect change

This commit is contained in:
2016-03-01 21:18:39 +01:00
parent b07bc4eca9
commit 80b8f5a238
12 changed files with 184 additions and 35 deletions

View File

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

View File

@@ -8,6 +8,7 @@ use common\models\CardKeyAssignment;
use common\models\Key;
use yii\helpers\ArrayHelper;
use common\components\Helper;
use common\models\Card;
/**
* ContactForm is the model behind the contact form.
@@ -19,7 +20,7 @@ class KeyToggleForm extends Model
public $customer;
public $keyModel;
public $action;
public $keyCard;
/**
@@ -55,6 +56,7 @@ class KeyToggleForm extends Model
$this->keyModel = $query->one();
if ( isset($this->keyModel) ){
$this->keyCard = Card::find()->innerJoin('card_key_assignment','card.id_card = card_key_assignment.id_card')->andWhere('card_key_assignment.id_key = ' .$this->keyModel->id_key)->one();
$assignments = CardKeyAssignment::find()->andWhere(['id_key' => $this->keyModel->id_key])->all();
if ( count($assignments) > 0){
$this->unassign();