Esempio n. 1
0
 /**
  * Check for duplicates and save the user alert
  * @param I2CE_User $user
  * @param boolean $transact
  * @return boolean
  */
 public function save($user, $transact = true)
 {
     if ($this->getId() === '0') {
         $find_duplicates = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'message', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->message))), array('operator' => 'FIELD_LIMIT', 'field' => 'time_ack', 'style' => 'null'), array('operator' => 'FIELD_LIMIT', 'field' => 'alert_type', 'style' => 'equals', 'data' => array('value' => $this->alert_type))));
         if ($this->link == '') {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'null');
         } else {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link', 'style' => 'equals', 'data' => array('value' => $this->link));
         }
         if ($this->link_text == '') {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'null');
         } else {
             $find_duplicates['operand'][] = array('operator' => 'FIELD_LIMIT', 'field' => 'link_text', 'style' => 'lowerequals', 'data' => array('value' => strtolower($this->link_text)));
         }
         $found = I2CE_FormStorage::search('user_alert', $this->getParent(), $find_duplicates, array("-time_sent"), 1);
         if ($found) {
             I2CE::raiseMessage("found duplicates so increasing repeats. {$found}");
             $duplicate = I2CE_FormFactory::instance()->createContainer("user_alert|" . $found);
             $duplicate->populate();
             $duplicate->repeated++;
             return $duplicate->save($user, $transact);
         }
     }
     return parent::save($user, $transact);
 }
 public function save($user, $transact = true)
 {
     if (!parent::save($user, $transact)) {
         return false;
     }
     if (!($parentObj = I2CE_FormFactory::instance()->createContainer($this->getParent())) instanceof iHRIS_Person_Scheduled_Training_Course) {
         //no parent form.
         return true;
     }
     $parentObj->populate();
     //this causes the average field in the person_scheduled_training_course to be calculate
     return $parentObj->save($user, $transact);
 }
Esempio n. 3
0
 /**
  * Save the training object.
  * 
  * Sets all the required fields for the training object based on the form data.
  * Since a training may be inside or outside the country certain fields may be required
  * depending on which case it is.
  * 
  * @param I2CE_User &$user The user saving this object.
  * @param boolean $transact
  */
 public function save(&$user, $transact = true)
 {
     if (I2CE_Validate::checkMap($this->training_program)) {
         $tp = I2CE_FormFactory::instance()->createContainer($this->getField("training_program")->getDBValue());
         $tp->populate();
         $this->in_cadre = $tp->cadre;
         $this->training_institution = $tp->training_institution;
         $this->trained_outside = false;
         $this->cadre = $this->in_cadre;
         unset($this->out_country);
         unset($this->out_institution);
     } else {
         $this->trained_outside = true;
         $this->cadre = $this->out_cadre;
         unset($this->training_institution);
     }
     parent::save($user, $transact);
 }