示例#1
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $this->_data, Fefop_Model_Mapper_Expense::CONFIG_PISE_FE_REGISTRATION);
         if (empty($this->_data['id_fe_registration'])) {
             $this->_data['fk_id_sysuser'] = Zend_Auth::getInstance()->getIdentity()->id_sysuser;
         }
         $dataForm = $this->_data;
         $dataForm['id_fe_registration'] = parent::_simpleSave();
         // Save Formation
         $this->_saveFormation($dataForm);
         // Save Entity
         $this->_saveEntity($dataForm);
         if (empty($this->_data['id_fe_contract'])) {
             $history = 'REJISTU FICHA INSKRISAUN FE: %s';
         } else {
             $history = 'ATUALIZA FICHA INSKRISAUN FE: %s';
         }
         $history = sprintf($history, $dataForm['id_fe_registration']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $dataForm['id_fe_registration'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#2
0
 /**
  * 
  */
 public function printAction()
 {
     $this->_helper->layout()->setLayout('print');
     $id = $this->_getParam('id');
     $mapperExpense = new Fefop_Model_Mapper_Expense();
     $itemsConfig = $mapperExpense->getItemsConfig();
     $this->view->identifier = $itemsConfig[$id];
     $this->view->rules = $this->_mapper->listRules($id);
     $this->view->rulesOptions = $this->_mapper->getOptionsRules();
     $this->view->user = Zend_Auth::getInstance()->getIdentity();
 }
示例#3
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dateStart = new Zend_Date($this->_data['date_start']);
         $dateFinish = new Zend_Date($this->_data['date_finish']);
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $this->_data, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_RI);
         // Check if the initial date is later than finish date
         if ($dateStart->isLater($dateFinish)) {
             $this->_message->addMessage('Data loron keta liu data remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => Fefop_Model_Mapper_Module::RI, 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $this->_data['date_start'] = $dateStart->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFinish->toString('yyyy-MM-dd');
         $dataForm = $this->_data;
         // Save the contract
         $dataForm['id_ri_contract'] = parent::_simpleSave();
         // Save budget category
         $this->_saveExpenses($dataForm);
         if (empty($this->_data['id_ri_contract'])) {
             $history = 'REJISTU KONTRAKTU RI: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU RI: %s';
         }
         $history = sprintf($history, $dataForm['id_ri_contract']);
         $this->_sysAudit($history);
         if ($this->_data['amount'] > self::LIMIT_AMOUNT) {
             $this->_sendWarningAmount($dataForm['id_ri_contract']);
         }
         $diff = $dateFinish->sub($dateStart);
         $measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::SECOND);
         $diffMonth = preg_replace('/[^0-9.]/i', '', $measure->convertTo(Zend_Measure_Time::MONTH, 0));
         if ((double) $diffMonth > self::MOUNTH_LIMIT) {
             $this->_sendWarningDuration($dataForm['id_ri_contract']);
         }
         $dbAdapter->commit();
         return $dataForm['id_ri_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#4
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dateStart = new Zend_Date($this->_data['date_start']);
         $dateFinish = new Zend_Date($this->_data['date_finish']);
         $mapperExpense = new Fefop_Model_Mapper_Expense();
         $item = $mapperExpense->getModuleToItem($this->_data['fk_id_fefop_modules']);
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $this->_data, $item);
         // Check if the initial date is later than finish date
         if ($dateStart->isLater($dateFinish)) {
             $this->_message->addMessage('Data loron keta liu data remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => $this->_data['fk_id_fefop_modules'], 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $this->_data['date_start'] = $dateStart->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFinish->toString('yyyy-MM-dd');
         $dataForm = $this->_data;
         // Save the contract
         $dataForm['id_per_contract'] = parent::_simpleSave();
         $dataForm['fk_id_per_contract'] = $dataForm['id_per_contract'];
         // Save budget category
         $this->_saveExpenses($dataForm);
         if (empty($this->_data['id_per_contract'])) {
             $history = 'REJISTU KONTRAKTU PER: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU PER: %s';
         }
         $history = sprintf($history, $dataForm['id_per_contract']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $dataForm['id_per_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#5
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $dataForm['client'] = array_keys($this->_data['cost_client']);
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $dataForm, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_FP);
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => Fefop_Model_Mapper_Module::FP, 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $date = new Zend_Date();
         $this->_data['date_start'] = $date->setDate($this->_data['start_date'])->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $date->setDate($this->_data['finish_date'])->toString('yyyy-MM-dd');
         $dataForm = $this->_data;
         // Save the contract
         $dataForm['id_fp_contract'] = parent::_simpleSave();
         // Set the class to the Planning Course
         $dbPlanningCourse = App_Model_DbTable_Factory::get('FPPlanningCourse');
         $row = $dbPlanningCourse->fetchRow(array('id_planning_course = ?' => $dataForm['fk_id_planning_course']));
         $row->fk_id_fefpstudentclass = $dataForm['fk_id_fefpstudentclass'];
         $row->save();
         // Save budget category
         $this->_saveBudgetCategory($dataForm);
         // Save the contract beneficiaries
         $this->_saveBeneficiaries($dataForm);
         if (empty($this->_data['id_fp_contract'])) {
             $history = 'REJISTU KONTRAKTU: %s BA ANNUAL PLANNING: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU: %s BA ANNUAL PLANNING: %s';
         }
         $history = sprintf($history, $dataForm['id_fp_contract'], $this->_data['fk_id_annual_planning']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $dataForm['id_fp_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#6
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         if (Fefop_Model_Mapper_Module::CED == $dataForm['fk_id_fefop_modules']) {
             if (!Client_Model_Mapper_Client::isHandicapped($dataForm['fk_id_perdata'])) {
                 $this->_message->addMessage('Kliente nee la iha defisiensia', App_Message::ERROR);
                 return false;
             }
         }
         $mapperRule = new Fefop_Model_Mapper_Rule();
         if (Fefop_Model_Mapper_Module::CEC == $dataForm['fk_id_fefop_modules']) {
             $itemConfig = Fefop_Model_Mapper_Expense::CONFIG_PCE_CEC_FASE_I;
         } else {
             $itemConfig = Fefop_Model_Mapper_Expense::CONFIG_PCE_CED_FASE_I;
         }
         $mapperRule->validate($this->_message, $dataForm, $itemConfig);
         // If there is no business plan yet
         if (empty($dataForm['id_pce_contract'])) {
             $dataContract = array('module' => $dataForm['fk_id_fefop_modules'], 'district' => $dataForm['fk_id_adddistrict'], 'status' => Fefop_Model_Mapper_Status::ANALYSIS);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $dataForm['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data = $dataForm;
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $id = parent::_simpleSave();
         $dataForm['fk_id_pce_contract'] = $id;
         // Save Expenses
         $this->_saveExpensesContract($dataForm);
         $history = "INSERE KONTRATU PCE FASE I: %s BA PROGRAMA PCE IHA MODULU: %s";
         $history = sprintf($history, $dataForm['fk_id_fefop_contract'], $dataForm['fk_id_fefop_modules']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $id;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#7
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $dataForm, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_DRH_PLAN);
         $dateIni = new Zend_Date($dataForm['date_start']);
         $dateFin = new Zend_Date($dataForm['date_finish']);
         // Check if the start date is later than finish date
         if ($dateIni->isLater($dateFin)) {
             $this->_message->addMessage('Loron inisiu la bele liu loron remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         $this->_data['date_start'] = $dateIni->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFin->toString('yyyy-MM-dd');
         $this->_data['amount'] = App_General_String::toFloat($this->_data['amount']);
         $this->_data['amount_expenses'] = App_General_String::toFloat($this->_data['amount_expenses']);
         // Save the training plan
         $dataForm['id_drh_trainingplan'] = parent::_simpleSave();
         //if ( $this->_data['amount'] > self::LIMIT_AMOUNT )
         //$this->_sendWarningAmount( $dataForm['id_drh_trainingplan'] );
         // Save beneficiaries
         $this->_saveBeneficiaries($dataForm);
         // Save Expenses
         $this->_saveExpenses($dataForm);
         $history = sprintf('REJISTU PLANU FORMASAUN DRH: %s', $dataForm['id_drh_trainingplan']);
         $this->_sysAudit($history);
         $this->_checkTravelInsurance($dataForm);
         $dbAdapter->commit();
         return $dataForm['id_drh_trainingplan'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#8
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $dataForm = $this->_data;
         $dataForm['amount'] = 0;
         foreach ($dataForm['expense'] as $costExpense) {
             $dataForm['amount'] += App_General_String::toFloat($costExpense);
         }
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $dataForm, Fefop_Model_Mapper_Expense::CONFIG_PFPCI_DRH);
         $idContract = $this->_saveContract($this->_data);
         $this->_message->addMessage($this->_config->messages->success, App_Message::SUCCESS);
         $dbAdapter->commit();
         return $idContract;
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }
示例#9
0
文件: Pce.php 项目: fredcido/simuweb
 /**
  * 
  * @param int $module
  * @return float
  */
 public function getTotalModule($module)
 {
     $mapperBudgetCategory = new Fefop_Model_Mapper_Expense();
     $identifier = $mapperBudgetCategory->getModuleToItem($module);
     $mapperRule = new Fefop_Model_Mapper_Rule();
     $ruleAmount = $mapperRule->getRuleIdentifier($identifier, Fefop_Model_Mapper_Rule::AMOUNT_MAX);
     if (empty($ruleAmount)) {
         return (double) $this->_limitAmounts[$module];
     } else {
         return (double) $ruleAmount->value;
     }
 }
示例#10
0
 /**
  * 
  * @return int|bool
  */
 public function save()
 {
     $dbAdapter = Zend_Db_Table_Abstract::getDefaultAdapter();
     $dbAdapter->beginTransaction();
     try {
         $this->_data['amount'] = 0;
         foreach ($this->_data['cost_expense'] as $cost) {
             $this->_data['amount'] += App_General_String::toFloat($cost);
         }
         $mapperRule = new Fefop_Model_Mapper_Rule();
         $mapperRule->validate($this->_message, $this->_data, Fefop_Model_Mapper_Expense::CONFIG_PISE_FE);
         $dateStart = new Zend_Date($this->_data['date_start']);
         $dateFinish = new Zend_Date($this->_data['date_finish']);
         //$dateFormation = new Zend_Date( $this->_data['date_formation'] );
         // Check if the initial date is later than finish date
         if ($dateStart->isLater($dateFinish)) {
             $this->_message->addMessage('Data loron keta liu data remata.');
             $this->addFieldError('date_start')->addFieldError('date_finish');
             return false;
         }
         // If there is no contract yet
         if (empty($this->_data['fk_id_fefop_contract'])) {
             $dataContract = array('module' => Fefop_Model_Mapper_Module::FE, 'district' => $this->_data['fk_id_adddistrict']);
             $mapperFefopContract = new Fefop_Model_Mapper_Contract();
             $this->_data['fk_id_fefop_contract'] = $mapperFefopContract->save($dataContract);
         }
         $this->_data['date_start'] = $dateStart->toString('yyyy-MM-dd');
         $this->_data['date_finish'] = $dateFinish->toString('yyyy-MM-dd');
         //$this->_data['date_formation'] = $dateFormation->toString( 'yyyy-MM-dd' );
         $dataForm = $this->_data;
         // If it has linkage with trainee
         if (!empty($dataForm['fk_id_trainee'])) {
             $dataTrainee = array('date_start' => $this->_data['date_start'], 'date_finish' => $this->_data['date_finish'], 'duration' => $this->_data['duration_month']);
             $where = array('id_trainee = ?' => $dataForm['fk_id_trainee']);
             $dbTrainee = App_Model_DbTable_Factory::get('JOBTrainingTrainee');
             $dbTrainee->update($dataTrainee, $where);
         }
         // Save the contract
         $dataForm['id_fe_contract'] = parent::_simpleSave();
         // Check if the duration is longer than 6 months
         $diff = $dateFinish->sub($dateStart);
         $measure = new Zend_Measure_Time($diff->toValue(), Zend_Measure_Time::SECOND);
         $diffMonth = preg_replace('/[^0-9.]/i', '', $measure->convertTo(Zend_Measure_Time::MONTH, 0));
         // If it is longer, send a warning
         //if ( (float)$diffMonth > self::MOUNTH_LIMIT )
         //$this->_sendWarningDuration( $dataForm['id_fe_contract'] );
         // Save budget category
         $this->_saveExpenses($dataForm);
         // Check the beneficiary graduation
         $this->_checkBeneficiaryGraduation($dataForm);
         if (empty($this->_data['id_fe_contract'])) {
             $history = 'REJISTU KONTRAKTU RI: %s';
         } else {
             $history = 'ATUALIZA KONTRAKTU RI: %s';
         }
         $history = sprintf($history, $dataForm['id_fe_contract']);
         $this->_sysAudit($history);
         $dbAdapter->commit();
         return $dataForm['id_fe_contract'];
     } catch (Exception $e) {
         $dbAdapter->rollBack();
         $this->_message->addMessage($this->_config->messages->error, App_Message::ERROR);
         return false;
     }
 }