示例#1
0
 public function transaction($in, $out, $model)
 {
     $account_id = DocchequesEav::findOne(array("doc_id" => $model->doc_id, "line" => $model->line, 'attribute' => 'account_id'));
     if ($account_id == NULL) {
         throw new Exception("NO out account was found for transaction", 401);
     }
     $out->account_id = $account_id->value;
 }
示例#2
0
 public function transaction($in, $out, $model)
 {
     $due_date = DocchequesEav::find()->where(array("doc_id" => $model->doc_id, "line" => $model->line, 'attribute' => 'cheque_date'))->one();
     if ($due_date == NULL) {
         $model->addError("cheque_date", \Yii::t('app', 'Not a valid doc cheque_date'));
         //throw new \Exception("NO due date was found for transaction", 401);
     } else {
         $valuedate = $due_date->value;
         $in->valuedate = $valuedate;
         $out->valuedate = $valuedate;
     }
 }
示例#3
0
 public function printDetails()
 {
     $model = PaymentType::findOne($this->type);
     $form = new $model->value();
     $attrs = DocchequesEav::find()->where(["doc_id" => $this->doc_id, "line" => $this->line])->All();
     //$text='';
     return $form->line($attrs);
 }
示例#4
0
文件: Docs.php 项目: chaimvaid/linet3
 private function saveCheq()
 {
     if (!is_null($this->docCheq)) {
         $line = 1;
         foreach ($this->docCheq as $key => $rcpt) {
             $submodel = Doccheques::findOne(array('doc_id' => $this->id, 'line' => $rcpt['line']));
             if ($submodel == null) {
                 //new line
                 $submodel = new Doccheques();
             }
             //go throw attr if no save new
             foreach ($rcpt as $key => $value) {
                 if ($submodel->hasAttribute($key)) {
                     $submodel->{$key} = $value;
                 } else {
                     $eav = new DocchequesEav();
                     $eav->line = $line;
                     $eav->doc_id = $this->id;
                     $eav->attribute = $key;
                     $eav->value = $value['value'];
                     $eav->save();
                 }
             }
             $submodel->line = $line;
             $submodel->doc_id = $this->id;
             //if ((int) $rcpt["type"] != 0) {
             if ($submodel->save()) {
                 //$saved = true;
                 $line++;
             } else {
                 $this->addError('docCheq', $submodel->errors);
                 Yii::error("fatel error cant save rcptdetial,doc_id:" . $submodel->line . "," . $submodel->doc_id);
                 //Yii::$app->end();
             }
             //}
             //Yii::$app->end();
         }
         if (count($this->docCheques) != $line) {
             //if more items in $docCheques delete them
             for ($curLine = $line; $curLine < count($this->docCheques); $curLine++) {
                 $this->docCheques[$curLine]->delete();
             }
         }
     }
     return true;
 }