Example #1
0
 public function save($runValidation = true, $attributes = NULL)
 {
     if (isset($this->system_acc)) {
         if ($this->system_acc != 1) {
             return parent::save($runValidation, $attributes);
         }
     }
     //else
     //    parent::save($runValidation,$attributes);
     //else no save
     return false;
 }
Example #2
0
 public function save($runValidation = true, $attributes = NULL)
 {
     $this->owner = Yii::app()->user->id;
     if ($this->total == 0) {
         $this->total = $this->rcptsum;
     }
     $a = parent::save($runValidation, $attributes);
     if (!$a) {
         return $a;
     }
     if (!is_null($attributes)) {
         return $a;
     }
     //if ($a) { //if switch no save
     $this->saveRef();
     //load docs and re-save them
     if (!$this->action) {
         if ($this->status === null) {
             throw new CHttpException(500, Yii::t('app', 'No status recived'));
         }
         $this->docStatus = Docstatus::model()->findByPk(array('num' => $this->status, 'doc_type' => $this->doctype));
         if ($this->docStatus === null) {
             throw new CHttpException(500, Yii::t('app', 'Status is Invalid'));
         }
         $this->saveDet();
         $this->saveCheq();
         $this->calc();
         $this->validate();
         if (count($this->getErrors()) != 0) {
             return false;
         }
         if (isset($this->docStatus)) {
             if ($this->docStatus->action != 0) {
                 $this->docnum = $this->newNum();
                 //get num
                 $this->action = 1;
                 $a = parent::save($runValidation, $attributes);
                 $this->transaction((int) $this->docStatus->action);
                 if (is_null($this->docType->transactionType_id)) {
                     //only if !transaction stock
                     foreach ($this->docDetailes as $docdetail) {
                         $this->stock($docdetail->item_id, $docdetail->qty);
                     }
                 }
             }
         }
     }
     //} //else {
     // throw new CHttpException(500, Yii::t('app', 'Uneable to save document'));
     //}
     return $a;
 }