Esempio n. 1
0
 public function transaction($in, $out, $model)
 {
     $due_date = DocchequesEav::model()->findByPk(array("doc_id" => $model->doc_id, "line" => $model->line, 'attribute' => 'cheque_date'));
     if ($due_date == NULL) {
         throw new Exception("NO due date was found for transaction", 401);
     }
     $valuedate = date("Y-m-d H:m:s", CDateTimeParser::parse($due_date->value, Yii::app()->locale->getDateFormat('yiishort')));
     $in->valuedate = $valuedate;
     $out->valuedate = $valuedate;
 }
Esempio n. 2
0
 private function saveCheq()
 {
     if (!is_null($this->docCheq)) {
         $line = 0;
         foreach ($this->docCheq as $key => $rcpt) {
             $submodel = Doccheques::model()->findByPk(array('doc_id' => $this->id, 'line' => $rcpt['line']));
             if (!$submodel) {
                 //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 = $rcpt['line'];
                     $eav->doc_id = $this->id;
                     $eav->attribute = $key;
                     $eav->value = $value['value'];
                     $eav->save();
                 }
             }
             $submodel->doc_id = $this->id;
             if ((int) $rcpt["type"] != 0) {
                 if ($submodel->save()) {
                     $saved = true;
                     $line++;
                 } else {
                     Yii::log("fatel error cant save rcptdetial,doc_id:" . $submodel->line . "," . $submodel->doc_id, CLogger::LEVEL_ERROR, __METHOD__);
                     //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();
             }
         }
     }
 }
Esempio n. 3
0
 public function printDetails()
 {
     $model = PaymentType::model()->findByPk($this->type);
     $form = new $model->value();
     $attrs = DocchequesEav::model()->findAllByAttributes(array("doc_id" => $this->doc_id, "line" => $this->line));
     //$text='';
     return $form->line($attrs);
 }