public static function newTransaction($doc_id, $account_id, $oppt_account_id, $item_id, $qty = 1, $serial = '') { $model = new stockAction(); $model->doc_id = $doc_id; $model->account_id = $account_id; $model->oppt_account_id = $oppt_account_id; $model->item_id = $item_id; $model->qty = $qty; $model->serial = $serial; $model->user_id = Yii::app()->user->id; if ($model->save()) { return $model->id; } else { return false; } }
public function actionStock() { $model = new stockAction('search'); $model->unsetAttributes(); $vl = 'stockAction-grid'; //echo Yii::app()->request->isAjaxRequest; //Yii::app()->end(); if (isset($_POST['stockAction'])) { $model->attributes = $_POST['stockAction']; } if (Yii::app()->request->isAjaxRequest || isset($_POST['ajax']) && $_POST['ajax'] === $vl) { // Render partial file created in Step 1 $this->renderPartial('stock', array('model' => $model)); Yii::app()->end(); } $this->render('stock', array('model' => $model)); }
private function stock($item_id, $qty) { if (Yii::app()->user->settings['company.stock']) { // remove from stock. $stockAction = $this->docType->stockAction; if ($stockAction) { if ($this->docType->stockSwitch) { //if has check box if (!$this->stockSwitch) { //if not checked return; } } $account_id = Yii::app()->user->warehouse; $oppt_account_id = $this->account_id; if ((int) $this->oppt_account_id != 0) { if ($this->doctype == 15) { //only if transfer //mybe shuld be only if oppt_account_type==8 wherehouse $account_id = $this->account_id; $oppt_account_id = $this->oppt_account_id; } } return stockAction::newTransaction($this->id, $account_id, $oppt_account_id, $item_id, $qty * $stockAction); } } return false; }