示例#1
0
 /**
  * 
  * @return int|bool
  */
 public function save($dataExternal)
 {
     try {
         // Get the Module
         $mapperModule = new Fefop_Model_Mapper_Module();
         $module = $mapperModule->fetchModule($dataExternal['module']);
         // Get the District
         $mapperDistrict = new Register_Model_Mapper_AddDistrict();
         $district = $mapperDistrict->fetchRow($dataExternal['district']);
         $data = array('fk_id_fefop_modules' => $module->id_fefop_modules, 'fk_id_fefop_programs' => $module->id_fefop_programs, 'fk_id_sysuser' => Zend_Auth::getInstance()->getIdentity()->id_sysuser, 'num_district' => $district->acronym, 'num_program' => $module->num_program, 'num_module' => $module->num_module, 'num_year' => date('y'));
         $data['num_sequence'] = str_pad($this->_getNumSequence($data), 4, '0', STR_PAD_LEFT);
         $this->_data = $data;
         $id = parent::_simpleSave($this->_dbTable, false);
         $dataStatus = array('contract' => $id, 'status' => !empty($dataExternal['status']) ? $dataExternal['status'] : Fefop_Model_Mapper_Status::ANALYSIS, 'description' => 'Kontraktu rejistu');
         $mapperStatus = new Fefop_Model_Mapper_Status();
         $mapperStatus->setData($dataStatus)->save();
         return $id;
     } catch (Exception $ex) {
         throw $ex;
     }
 }
示例#2
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $id = $this->saveFollowUp($this->_data['fk_id_fefop_contract'], $this->_data['description']);
         // If the status was changed
         if (!empty($dataForm['fk_id_fefop_status'])) {
             $dataStatus = array('contract' => $dataForm['fk_id_fefop_contract'], 'status' => $dataForm['fk_id_fefop_status'], 'id_fefop_followup' => $id);
             // Save the new Status
             $mapperStatus = new Fefop_Model_Mapper_Status();
             $mapperStatus->setData($dataStatus)->save();
         }
         $dbAdapter->commit();
         return true;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#3
0
 /**
  * 
  * @param int $idContract
  * @return boolean
  */
 protected function _tryUpdateStatusContract($idContract)
 {
     $mapperContract = new Fefop_Model_Mapper_Contract();
     $contract = $mapperContract->detail($idContract);
     if (Fefop_Model_Mapper_Status::INITIAL != $contract->id_fefop_status) {
         return false;
     }
     $mapperStatus = new Fefop_Model_Mapper_Status();
     $dataStatus = array('id_fefop_followup' => null, 'contract' => $idContract, 'status' => Fefop_Model_Mapper_Status::PROGRESS, 'description' => 'PRIMEIRO LANSAMENTU FINANSEIRU');
     $mapperStatus->setData($dataStatus)->save();
 }