示例#1
0
 protected function insert()
 {
     $this->working_mode = 'insert_fail';
     if (!static::canInsert()) {
         $this->pushMsg('Permission: Could not Insert!', 'error');
         return false;
     }
     //insert
     $c = static::$model;
     //check manual mode
     if ($this->manual_no == true) {
         //get noseries
         $tmp = new $c();
         $tmp = QdNoSeries::GET($tmp->getNoSeries());
         if ($tmp != null && $tmp->manual_allowed == false) {
             $this->pushMsg('Manual No are not allowed for this Model', 'error');
             return false;
         }
     }
     //check duplicate id
     if ($c::GET($this->data['id'])) {
         $this->pushMsg(sprintf('Can not insert: Duplicate ID with record %s', $this->data['id']), 'error');
         return false;
     }
     $this->obj = $c::getInitObj();
     $this->obj->id = $this->data['id'];
     //force assign id while manual mode
     $this->beforeInsertAssign();
     $this->assign();
     if (!$this->checkPermission(__FUNCTION__)) {
         return false;
     }
     $class_name = $this->getCalledClassName();
     $location = "|{$class_name}|insert";
     if ($this->obj->save(true, $location)) {
         $this->pushMsg($this->obj->GETVALIDATION());
         $this->pushMsg(sprintf(Qdmvc_Message::getMsg('msg_insert_ok'), $this->obj->id));
         $this->working_mode = 'insert_ok';
         return true;
     } else {
         $this->pushMsg($this->obj->GETVALIDATION());
         return false;
     }
 }
示例#2
0
 private function getNoFromNoSeries($noseries_id)
 {
     $tmp = QdNoSeries::GET($noseries_id);
     if ($tmp != null) {
         $next_no = $tmp->getNextNo();
         if ($next_no === false) {
             $this->pushValidateError($tmp->GETVALIDATION());
             //$this->pushValidateError('', 'ERROR: getNoFromNoSeries', 'error');
             return false;
         } else {
             return $next_no;
         }
     } else {
         return false;
     }
 }