Example #1
0
 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;
 }