Exemplo n.º 1
0
 public function opname($id)
 {
     $entity = Entity::find($id);
     $entity->feasible = Input::get('feasible');
     $entity->infeasible = Input::get('infeasible');
     $entity->last_opname = date('Y-m-d H:i:s');
     $entity->employee_id = Input::get('employee');
     $entity->save();
     Session::flash('message', 'Info Opname telah diupdate');
 }
Exemplo n.º 2
0
 public function anyView()
 {
     $jobArray = explode(',', Input::get('jobs'));
     $colors = array();
     $jobsInfo = array();
     for ($iter = 0; $iter < count($jobArray); ++$iter) {
         $jobID = $jobArray[$iter];
         $jobsInfo[$jobID] = Entity::find($jobID);
         $color = AnalyticsController::$colorList[$iter % count(AnalyticsController::$colorList)];
         $jobsInfo[$jobID]['color'] = $color;
         $colors[$jobID] = $color;
     }
     return View::make('analytics.jobview')->with('jobConfigurations', $jobsInfo)->with('jobIDs', $jobArray)->with('jobColors', $colors);
 }
Exemplo n.º 3
0
 private function setOwnerData()
 {
     if (isset($this->phkRequestData['owner_id']) && !isset($this->phkRequestData['owner_text'])) {
         App::import("Model", "Entity");
         $entity = new Entity();
         $result = $entity->find("first", array('conditions' => array('Entity.id' => $this->phkRequestData['owner_id'])));
         if (count($result)) {
             $this->phkRequestData['owner_id'] = $result['Entity']['id'];
             $this->phkRequestData['owner_text'] = $result['Entity']['name'];
         }
     }
 }
Exemplo n.º 4
0
 public function getMail($id)
 {
     return Entity::find($id);
 }
 /**
  * import rules in glpi after user validation
  *
  * @since version 0.85
  *
  * @return true if all ok
  **/
 static function processImportRules()
 {
     global $DB;
     $ruleCriteria = new RuleCriteria();
     $ruleAction = new RuleAction();
     $entity = new Entity();
     //get session vars
     $rules = $_SESSION['glpi_import_rules'];
     $rules_refused = $_SESSION['glpi_import_rules_refused'];
     $rr_keys = array_keys($rules_refused);
     unset($_SESSION['glpi_import_rules']);
     unset($_SESSION['glpi_import_rules_refused']);
     // unset all refused rules
     foreach ($rules['rule'] as $k_rule => &$rule) {
         if (in_array($k_rule, $rr_keys)) {
             //Do not process rule with actions or criterias refused
             if (isset($rules_refused[$k_rule]['criterias']) || isset($rules_refused[$k_rule]['actions'])) {
                 unset($rules['rule'][$k_rule]);
             } else {
                 // accept rule with only entity not found (change entity)
                 $rule['entities_id'] = $_REQUEST['new_entities'][$rule['uuid']];
             }
         }
     }
     //import all right rules
     while (!empty($rules['rule'])) {
         $current_rule = array_shift($rules['rule']);
         $add_criteria_and_actions = false;
         $params = array();
         $itemtype = $current_rule['sub_type'];
         $item = new $itemtype();
         //Find a rule by it's uuid
         $found = $item->find("`uuid`='" . $current_rule['uuid'] . "'");
         $params = Toolbox::addslashes_deep($current_rule);
         unset($params['rulecriteria']);
         unset($params['ruleaction']);
         if (!$item->isEntityAssign()) {
             $params['entities_id'] = 0;
         } else {
             $entities_found = $entity->find("completename = '" . $rule['entities_id'] . "'");
             if (!empty($entities_found)) {
                 $entity_found = array_shift($entities_found);
                 $params['entities_id'] = $entity_found['id'];
             } else {
                 $params['entities_id'] = 0;
             }
         }
         foreach (array('is_recursive', 'is_active') as $field) {
             //Should not be necessary but without it there's an sql error...
             if (!isset($params[$field]) || $params[$field] == '') {
                 $params[$field] = 0;
             }
         }
         //if uuid not exist, create rule
         if (empty($found)) {
             //Manage entity
             $params['_add'] = true;
             $rules_id = $item->add($params);
             if ($rules_id) {
                 Event::log($rules_id, "rules", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $rules_id));
                 $add_criteria_and_actions = true;
             }
         } else {
             //if uuid exists, then update the rule
             $tmp = array_shift($found);
             $params['id'] = $tmp['id'];
             $params['_update'] = true;
             $rules_id = $tmp['id'];
             if ($item->update($params)) {
                 Event::log($rules_id, "rules", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
                 //remove all dependent criterias and action
                 $ruleCriteria->deleteByCriteria(array("rules_id" => $rules_id));
                 $ruleAction->deleteByCriteria(array("rules_id" => $rules_id));
                 $add_criteria_and_actions = true;
             }
         }
         if ($add_criteria_and_actions) {
             //Add criteria
             if (isset($current_rule['rulecriteria'])) {
                 foreach ($current_rule['rulecriteria'] as $criteria) {
                     $criteria['rules_id'] = $rules_id;
                     //fix array in value key
                     //(simplexml bug, empty xml node are converted in empty array instead of null)
                     if (is_array($criteria['pattern'])) {
                         $criteria['pattern'] = null;
                     }
                     $criteria = Toolbox::addslashes_deep($criteria);
                     $ruleCriteria->add($criteria);
                 }
             }
             //Add actions
             if (isset($current_rule['ruleaction'])) {
                 foreach ($current_rule['ruleaction'] as $action) {
                     $action['rules_id'] = $rules_id;
                     //fix array in value key
                     //(simplexml bug, empty xml node are converted in empty array instead of null)
                     if (is_array($action['value'])) {
                         $action['value'] = null;
                     }
                     $action = Toolbox::addslashes_deep($action);
                     $ruleAction->add($action);
                 }
             }
         }
     }
     Session::addMessageAfterRedirect(__('Successful importation'));
     return true;
 }
Exemplo n.º 6
0
 /**
  * Execute 1 task manage by the plugin
  *
  * @param CronTask $task Object of CronTask class for log / stat
  *
  * @return interger
  *    >0 : done
  *    <0 : to be run again (not finished)
  *     0 : nothing to do
  */
 static function cronSendNotifications($task)
 {
     global $LANG;
     $task->log($LANG['plugin_mreporting']['notification_log']);
     $entity = new Entity();
     $found_entities = $entity->find();
     foreach ($found_entities as $entity_data) {
         $params = $task->fields + array('entities_id' => $entity_data['id']);
         NotificationEvent::raiseEvent('sendReporting', new self(), $params);
     }
     return 1;
 }