checkAlreadyPlanned() static public method

Check already planned user for a period
static public checkAlreadyPlanned ( $users_id, $begin, $end, $except = [] )
$users_id user id
$begin begin date
$end end date
$except array of items which not be into account array ('Reminder'=>array(1,2,id_of_items))
示例#1
0
 /**
  * @see CommonDBTM::post_updateItem()
  **/
 function post_updateItem($history = 1)
 {
     if (isset($this->fields["begin"]) && !empty($this->fields["begin"])) {
         Planning::checkAlreadyPlanned($this->fields["users_id"], $this->fields["begin"], $this->fields["end"], array('Reminder' => array($this->fields['id'])));
     }
     if (in_array("begin", $this->updates)) {
         PlanningRecall::managePlanningUpdates($this->getType(), $this->getID(), $this->fields["begin"]);
     }
 }
 function post_addItem()
 {
     global $CFG_GLPI;
     if (isset($this->input['_planningrecall'])) {
         $this->input['_planningrecall']['items_id'] = $this->fields['id'];
         PlanningRecall::manageDatas($this->input['_planningrecall']);
     }
     $donotif = $CFG_GLPI["use_mailing"];
     if (isset($this->fields["begin"]) && !empty($this->fields["begin"])) {
         Planning::checkAlreadyPlanned($this->fields["users_id_tech"], $this->fields["begin"], $this->fields["end"], array($this->getType() => array($this->fields["id"])));
         $calendars_id = Entity::getUsedConfig('calendars_id', $this->input["_job"]->fields['entities_id']);
         $calendar = new Calendar();
         // Using calendar
         if ($calendars_id > 0 && $calendar->getFromDB($calendars_id)) {
             if (!$calendar->isAWorkingHour(strtotime($this->fields["begin"]))) {
                 Session::addMessageAfterRedirect(__('Start of the selected timeframe is not a working hour.'), false, ERROR);
             }
             if (!$calendar->isAWorkingHour(strtotime($this->fields["end"]))) {
                 Session::addMessageAfterRedirect(__('End of the selected timeframe is not a working hour.'), false, ERROR);
             }
         }
     }
     $this->input["_job"]->updateDateMod($this->input[$this->input["_job"]->getForeignKeyField()]);
     if (isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
         $this->input["_job"]->updateActionTime($this->input[$this->input["_job"]->getForeignKeyField()]);
     }
     //change status only if input change
     if (isset($this->input['_status']) && $this->input['_status'] != $this->input['_job']->fields['status']) {
         $update['status'] = $this->input['_status'];
         $update['id'] = $this->input['_job']->fields['id'];
         $update['_disablenotif'] = true;
         $this->input['_job']->update($update);
     }
     if (!empty($this->fields['begin']) && $this->input["_job"]->isStatusExists(CommonITILObject::PLANNED) && ($this->input["_job"]->fields["status"] == CommonITILObject::INCOMING || $this->input["_job"]->fields["status"] == CommonITILObject::ASSIGNED)) {
         $input2['id'] = $this->input["_job"]->getID();
         $input2['status'] = CommonITILObject::PLANNED;
         $input2['_disablenotif'] = true;
         $this->input["_job"]->update($input2);
     }
     if ($donotif) {
         $options = array('task_id' => $this->fields["id"], 'is_private' => $this->isPrivate());
         NotificationEvent::raiseEvent('add_task', $this->input["_job"], $options);
     }
     // Add log entry in the ITIL object
     $changes[0] = 0;
     $changes[1] = '';
     $changes[2] = $this->fields['id'];
     Log::history($this->getField($this->input["_job"]->getForeignKeyField()), $this->input["_job"]->getTYpe(), $changes, $this->getType(), Log::HISTORY_ADD_SUBITEM);
 }
 function post_addItem()
 {
     global $CFG_GLPI;
     if (isset($this->input['_planningrecall'])) {
         $this->input['_planningrecall']['items_id'] = $this->fields['id'];
         PlanningRecall::manageDatas($this->input['_planningrecall']);
     }
     $donotif = $CFG_GLPI["use_mailing"];
     if (isset($this->fields["begin"]) && !empty($this->fields["begin"])) {
         Planning::checkAlreadyPlanned($this->fields["users_id_tech"], $this->fields["begin"], $this->fields["end"], array($this->getType() => array($this->fields["id"])));
     }
     if (isset($this->input["_no_notif"]) && $this->input["_no_notif"]) {
         $donotif = false;
     }
     $this->input["_job"]->updateDateMod($this->input[$this->input["_job"]->getForeignKeyField()]);
     if (isset($this->input["actiontime"]) && $this->input["actiontime"] > 0) {
         $this->input["_job"]->updateActionTime($this->input[$this->input["_job"]->getForeignKeyField()]);
     }
     if (!empty($this->fields['begin']) && ($this->input["_job"]->fields["status"] == CommonITILObject::INCOMING || $this->input["_job"]->fields["status"] == CommonITILObject::ASSIGNED)) {
         $input2['id'] = $this->input["_job"]->getID();
         $input2['status'] = CommonITILObject::PLANNED;
         $input2['_disablenotif'] = true;
         $this->input["_job"]->update($input2);
     }
     if ($donotif) {
         $options = array('task_id' => $this->fields["id"], 'is_private' => $this->isPrivate());
         NotificationEvent::raiseEvent('add_task', $this->input["_job"], $options);
     }
     // Add log entry in the ITIL object
     $changes[0] = 0;
     $changes[1] = '';
     $changes[2] = $this->fields['id'];
     Log::history($this->getField($this->input["_job"]->getForeignKeyField()), $this->input["_job"]->getTYpe(), $changes, $this->getType(), Log::HISTORY_ADD_SUBITEM);
 }
示例#4
0
 function prepareInputForUpdate($input)
 {
     global $CFG_GLPI;
     $this->getFromDB($input["id"]);
     // Save fields
     $oldfields = $this->fields;
     $this->fields["begin"] = $input["begin"];
     $this->fields["end"] = $input["end"];
     if (!$this->test_valid_date()) {
         $this->displayError("date");
         return false;
     }
     if (isset($fup->fields["users_id"])) {
         Planning::checkAlreadyPlanned($fup->fields["users_id"], $input["begin"], $input["end"], array('PluginProjetTask' => array($input["id"])));
     }
     // Restore fields
     $this->fields = $oldfields;
     return $input;
 }
 function post_updateItem($history = 1)
 {
     if ($this->fields["is_private"]) {
         Planning::checkAlreadyPlanned($this->fields["users_id"], $this->fields["begin"], $this->fields["end"], array('Reminder' => array($this->fields['id'])));
     }
 }
 function prepareInputForAdd($input)
 {
     if (!isset($input["begin"]) || !isset($input["end"])) {
         return false;
     }
     // Needed for test already planned
     $this->fields["users_id"] = $input["users_id"];
     $this->fields["begin"] = $input["begin"];
     $this->fields["end"] = $input["end"];
     if (!$this->test_valid_date()) {
         $this->displayError("date");
         return false;
     }
     Planning::checkAlreadyPlanned($input["users_id"], $input["begin"], $input["end"]);
     return $input;
 }