showTimeStamp() static public méthode

Dropdown integers
static public showTimeStamp ( $myname, $options = [] )
$myname select name
$options array of options - value : default value - min : min value : default 0 - max : max value : default DAY_TIMESTAMP - value : default value - addfirstminutes : add first minutes before first step (default false) - toadd : array of values to add - inhours : only show timestamp in hours not in days - display : boolean / display or return string - width : string / display width of the item
Exemple #1
0
 /**
  * @see CommonDropdown::displaySpecificTypeField()
  **/
 function displaySpecificTypeField($ID, $field = array())
 {
     switch ($field['type']) {
         case 'actiontime':
             $toadd = array();
             for ($i = 9; $i <= 100; $i++) {
                 $toadd[] = $i * HOUR_TIMESTAMP;
             }
             Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
             break;
     }
 }
Exemple #2
0
 /**
  * Clone of Ticket::showForm()
  * Change '$this' by '$ticket', 'self' by 'Ticket' and 'parent' by 'Ticket'
  */
 static function getCentral($ID = 0, $options = array())
 {
     global $CFG_GLPI;
     // * Added by plugin survey ticket
     $ticket = new Ticket();
     // * End of adding
     $default_values = Ticket::getDefaultValues();
     // Get default values from posted values on reload form
     if (!isset($options['template_preview'])) {
         if (isset($_POST)) {
             $values = $_POST;
         }
     }
     // Restore saved value or override with page parameter
     $saved = $ticket->restoreInput();
     foreach ($default_values as $name => $value) {
         if (!isset($values[$name])) {
             if (isset($saved[$name])) {
                 $values[$name] = $saved[$name];
             } else {
                 $values[$name] = $value;
             }
         }
     }
     // Default check
     if ($ID > 0) {
         $ticket->check($ID, 'r');
     } else {
         // Create item
         $ticket->check(-1, 'w', $values);
     }
     if (!$ID) {
         $ticket->userentities = array();
         if ($values["_users_id_requester"]) {
             //Get all the user's entities
             $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
             //For each user's entity, check if the technician which creates the ticket have access to it
             foreach ($all_entities as $tmp => $ID_entity) {
                 if (Session::haveAccessToEntity($ID_entity)) {
                     $ticket->userentities[] = $ID_entity;
                 }
             }
         }
         $ticket->countentitiesforuser = count($ticket->userentities);
         if ($ticket->countentitiesforuser > 0 && !in_array($ticket->fields["entities_id"], $ticket->userentities)) {
             // If entity is not in the list of user's entities,
             // then use as default value the first value of the user's entites list
             $ticket->fields["entities_id"] = $ticket->userentities[0];
             // Pass to values
             $values['entities_id'] = $ticket->userentities[0];
         }
     }
     if ($values['type'] <= 0) {
         $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE);
     }
     if (!isset($options['template_preview'])) {
         $options['template_preview'] = 0;
     }
     // Load ticket template if available :
     $tt = $ticket->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']);
     // Predefined fields from template : reset them
     if (isset($values['_predefined_fields'])) {
         $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
     } else {
         $values['_predefined_fields'] = array();
     }
     // Store predefined fields to be able not to take into account on change template
     // Only manage predefined values on ticket creation
     $predefined_fields = array();
     if (!$ID) {
         if (isset($tt->predefined) && count($tt->predefined)) {
             foreach ($tt->predefined as $predeffield => $predefvalue) {
                 if (isset($default_values[$predeffield])) {
                     // Is always default value : not set
                     // Set if already predefined field
                     // Set if ticket template change
                     if ($values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID()) {
                         // Load template data
                         $values[$predeffield] = $predefvalue;
                         $ticket->fields[$predeffield] = $predefvalue;
                         $predefined_fields[$predeffield] = $predefvalue;
                     }
                 }
             }
         } else {
             // No template load : reset predefined values
             if (count($values['_predefined_fields'])) {
                 foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
                     if ($values[$predeffield] == $predefvalue) {
                         $values[$predeffield] = $default_values[$predeffield];
                     }
                 }
             }
         }
     }
     // Put ticket template on $values for actors
     $values['_tickettemplate'] = $tt;
     $canupdate = Session::haveRight('update_ticket', '1');
     $canpriority = Session::haveRight('update_priority', '1');
     $canstatus = $canupdate;
     if (in_array($ticket->fields['status'], $ticket->getClosedStatusArray())) {
         $canupdate = false;
     }
     $showuserlink = 0;
     if (Session::haveRight('user', 'r')) {
         $showuserlink = 1;
     }
     if (!$options['template_preview']) {
         $ticket->showTabs($options);
     } else {
         // Add all values to fields of tickets for template preview
         foreach ($values as $key => $val) {
             if (!isset($ticket->fields[$key])) {
                 $ticket->fields[$key] = $val;
             }
         }
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '29';
     $colsize3 = '13';
     $colsize4 = '45';
     $canupdate_descr = $canupdate || $ticket->fields['status'] == Ticket::INCOMING && $ticket->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $ticket->numberOfFollowups() == 0 && $ticket->numberOfTasks() == 0;
     if (!$options['template_preview']) {
         echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>";
     }
     echo "<div class='spaced' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe' id='mainformtable'>";
     // Optional line
     $ismultientities = Session::isMultiEntitiesMode();
     echo "<tr class='headerRow'>";
     echo "<th colspan='4'>";
     if ($ID) {
         $text = sprintf(__('%1$s - %2$s'), $ticket->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID));
         if ($ismultientities) {
             $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $ticket->fields['entities_id']));
         }
         echo $text;
     } else {
         if ($ismultientities) {
             printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $ticket->fields['entities_id']));
         } else {
             _e('New ticket');
         }
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date'));
     } else {
         _e('Opening date');
     }
     echo $tt->getEndHiddenFieldText('date');
     echo "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('date');
     $date = $ticket->fields["date"];
     if ($canupdate) {
         Html::showDateTimeFormItem("date", $date, 1, false);
     } else {
         echo Html::convDateTime($date);
     }
     echo $tt->getEndHiddenFieldValue('date', $ticket);
     echo "</td>";
     // SLA
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Due date'), $tt->getMandatoryMark('due_date'));
     } else {
         _e('Due date');
     }
     echo $tt->getEndHiddenFieldText('due_date');
     echo "</th>";
     echo "<td width='{$colsize4}%' class='nopadding'>";
     if ($ID) {
         if ($ticket->fields["slas_id"] > 0) {
             echo "<table width='100%'><tr><td class='nopadding'>";
             echo Html::convDateTime($ticket->fields["due_date"]);
             echo "</td><td class='b'>" . __('SLA') . "</td>";
             echo "<td class='nopadding'>";
             echo Dropdown::getDropdownName("glpi_slas", $ticket->fields["slas_id"]);
             $commentsla = "";
             $slalevel = new SlaLevel();
             if ($slalevel->getFromDB($ticket->fields['slalevels_id'])) {
                 $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span><br>';
             }
             $nextaction = new SlaLevel_Ticket();
             if ($nextaction->getFromDBForTicket($ticket->fields["id"])) {
                 $commentsla .= '<span class="b spaced">' . sprintf(__('Next escalation: %s'), Html::convDateTime($nextaction->fields['date'])) . '</span>';
                 if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) {
                     $commentsla .= '<span class="b spaced">' . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName()) . '</span>';
                 }
             }
             $slaoptions = array();
             if (Session::haveRight('config', 'r')) {
                 $slaoptions['link'] = Toolbox::getItemTypeFormURL('SLA') . "?id=" . $ticket->fields["slas_id"];
             }
             Html::showToolTip($commentsla, $slaoptions);
             if ($canupdate) {
                 echo "&nbsp;<input type='submit' class='submit' name='sla_delete' value='" . _sx('button', 'Delete permanently') . "'>";
             }
             echo "</td>";
             echo "</tr></table>";
         } else {
             echo "<table><tr><td class='nopadding'>";
             echo $tt->getBeginHiddenFieldValue('due_date');
             Html::showDateTimeFormItem("due_date", $ticket->fields["due_date"], 1, true, $canupdate);
             echo $tt->getEndHiddenFieldValue('due_date', $ticket);
             echo "</td>";
             if ($canupdate) {
                 echo "<td>";
                 echo $tt->getBeginHiddenFieldText('slas_id');
                 echo "<span id='sla_action'>";
                 echo "<a class='vsubmit' " . Html::addConfirmationOnAction(array(__('The assignment of a SLA to a ticket causes the recalculation of the due date.'), __("Escalations defined in the SLA will be triggered under this new date.")), "cleanhide('sla_action');cleandisplay('sla_choice');") . ">" . __('Assign a SLA') . '</a>';
                 echo "</span>";
                 echo "<span id='sla_choice' style='display:none'>";
                 echo "<span  class='b'>" . __('SLA') . "</span>&nbsp;";
                 Sla::dropdown(array('entity' => $ticket->fields["entities_id"], 'value' => $ticket->fields["slas_id"]));
                 echo "</span>";
                 echo $tt->getEndHiddenFieldText('slas_id');
                 echo "</td>";
             }
             echo "</tr></table>";
         }
     } else {
         // New Ticket
         echo "<table><tr><td class='nopadding'>";
         if ($ticket->fields["due_date"] == 'NULL') {
             $ticket->fields["due_date"] = '';
         }
         echo $tt->getBeginHiddenFieldValue('due_date');
         Html::showDateTimeFormItem("due_date", $ticket->fields["due_date"], 1, false, $canupdate);
         echo $tt->getEndHiddenFieldValue('due_date', $ticket);
         echo "</td>";
         if ($canupdate) {
             echo "<td class='nopadding b'>" . $tt->getBeginHiddenFieldText('slas_id');
             printf(__('%1$s%2$s'), __('SLA'), $tt->getMandatoryMark('slas_id'));
             echo $tt->getEndHiddenFieldText('slas_id') . "</td>";
             echo "<td class='nopadding'>" . $tt->getBeginHiddenFieldValue('slas_id');
             Sla::dropdown(array('entity' => $ticket->fields["entities_id"], 'value' => $ticket->fields["slas_id"]));
             echo $tt->getEndHiddenFieldValue('slas_id', $ticket);
             echo "</td>";
         }
         echo "</tr></table>";
     }
     echo "</td></tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('By') . "</th>";
         echo "<td width='{$colsize2}%'>";
         if ($canupdate) {
             User::dropdown(array('name' => 'users_id_recipient', 'value' => $ticket->fields["users_id_recipient"], 'entity' => $ticket->fields["entities_id"], 'right' => 'all'));
         } else {
             echo getUserName($ticket->fields["users_id_recipient"], $showuserlink);
         }
         echo "</td>";
         echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>";
         echo "<td width='{$colsize4}%'>";
         if ($ticket->fields['users_id_lastupdater'] > 0) {
             //TRANS: %1$s is the update date, %2$s is the last updater name
             printf(__('%1$s by %2$s'), Html::convDateTime($ticket->fields["date_mod"]), getUserName($ticket->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td>";
         echo "</tr>";
     }
     if ($ID && (in_array($ticket->fields["status"], $ticket->getSolvedStatusArray()) || in_array($ticket->fields["status"], $ticket->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>";
         echo "<td width='{$colsize2}%'>";
         Html::showDateTimeFormItem("solvedate", $ticket->fields["solvedate"], 1, false, $canupdate);
         echo "</td>";
         if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) {
             echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>";
             echo "<td width='{$colsize4}%'>";
             Html::showDateTimeFormItem("closedate", $ticket->fields["closedate"], 1, false, $canupdate);
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     if ($ID) {
         echo "</table>";
         echo "<table  class='tab_cadre_fixe' id='mainformtable2'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Permit to set type when creating ticket without update right
     if ($canupdate || !$ID) {
         $opt = array('value' => $ticket->fields["type"]);
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'submit()';
         }
         $rand = Ticket::dropdownType('type', $opt);
         if ($ID) {
             $params = array('type' => '__VALUE__', 'entity_restrict' => $ticket->fields['entities_id'], 'value' => $ticket->fields['itilcategories_id'], 'currenttype' => $ticket->fields['type']);
             Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params);
         }
     } else {
         echo Ticket::getTicketTypeName($ticket->fields["type"]);
     }
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>";
     echo "<td width='{$colsize4}%'>";
     // Permit to set category when creating ticket without update right
     if ($canupdate || !$ID || $canupdate_descr) {
         $opt = array('value' => $ticket->fields["itilcategories_id"], 'entity' => $ticket->fields["entities_id"]);
         if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
             $opt['condition'] = "`is_helpdeskvisible`='1' AND ";
         } else {
             $opt['condition'] = '';
         }
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'submit()';
         }
         /// if category mandatory, no empty choice
         /// no empty choice is default value set on ticket creation, else yes
         if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $ticket->fields["itilcategories_id"] > 0) {
             $opt['display_emptychoice'] = false;
         }
         switch ($ticket->fields["type"]) {
             case Ticket::INCIDENT_TYPE:
                 $opt['condition'] .= "`is_incident`='1'";
                 break;
             case Ticket::DEMAND_TYPE:
                 $opt['condition'] .= "`is_request`='1'";
                 break;
             default:
                 break;
         }
         echo "<span id='show_category_by_type'>";
         ITILCategory::dropdown($opt);
         echo "</span>";
     } else {
         echo Dropdown::getDropdownName("glpi_itilcategories", $ticket->fields["itilcategories_id"]);
     }
     echo "</td>";
     echo "</tr>";
     if (!$ID) {
         echo "</table>";
         $ticket->showActorsPartForm($ID, $values);
         echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status');
     printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status'));
     echo $tt->getEndHiddenFieldText('status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('status');
     if ($canstatus) {
         Ticket::dropdownStatus(array('value' => $ticket->fields["status"], 'showtype' => 'allowed'));
     } else {
         echo Ticket::getStatus($ticket->fields["status"]);
     }
     echo $tt->getEndHiddenFieldValue('status', $ticket);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id');
     printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id'));
     echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>";
     echo "<td width='{$colsize4}%'>";
     echo $tt->getBeginHiddenFieldValue('requesttypes_id');
     if ($canupdate) {
         RequestType::dropdown(array('value' => $ticket->fields["requesttypes_id"]));
     } else {
         echo Dropdown::getDropdownName('glpi_requesttypes', $ticket->fields["requesttypes_id"]);
     }
     echo $tt->getEndHiddenFieldValue('requesttypes_id', $ticket);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('urgency');
     printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency'));
     echo $tt->getEndHiddenFieldText('urgency') . "</th>";
     echo "<td>";
     if ($canupdate && $canpriority || !$ID || $canupdate_descr) {
         // Only change during creation OR when allowed to change priority OR when user is the creator
         echo $tt->getBeginHiddenFieldValue('urgency');
         $idurgency = Ticket::dropdownUrgency(array('value' => $ticket->fields["urgency"]));
         echo $tt->getEndHiddenFieldValue('urgency', $ticket);
     } else {
         $idurgency = "value_urgency" . mt_rand();
         echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $ticket->fields["urgency"] . "'>";
         echo Ticket::getUrgencyName($ticket->fields["urgency"]);
     }
     echo "</td>";
     // Display validation state
     echo "<th>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldText('_add_validation');
         printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation'));
         echo $tt->getEndHiddenFieldText('_add_validation');
     } else {
         echo $tt->getBeginHiddenFieldText('global_validation');
         _e('Approval');
         echo $tt->getEndHiddenFieldText('global_validation');
     }
     echo "</th>";
     echo "<td>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldValue('_add_validation');
         $validation_right = '';
         if ($values['type'] == Ticket::INCIDENT_TYPE && Session::haveRight('create_incident_validation', 1)) {
             $validation_right = 'validate_incident';
         }
         if ($values['type'] == Ticket::DEMAND_TYPE && Session::haveRight('create_request_validation', 1)) {
             $validation_right = 'validate_request';
         }
         if (!empty($validation_right)) {
             User::dropdown(array('name' => "_add_validation", 'entity' => $ticket->fields['entities_id'], 'right' => $validation_right, 'value' => $values['_add_validation']));
         }
         echo $tt->getEndHiddenFieldValue('_add_validation', $ticket);
         if ($tt->isPredefinedField('global_validation')) {
             echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>";
         }
     } else {
         echo $tt->getBeginHiddenFieldValue('global_validation');
         if ($canupdate) {
             TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $ticket->fields['global_validation']));
         } else {
             echo TicketValidation::getStatus($ticket->fields['global_validation']);
         }
         echo $tt->getEndHiddenFieldValue('global_validation', $ticket);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('impact');
     printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact'));
     echo $tt->getEndHiddenFieldText('impact') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('impact');
     if ($canupdate) {
         $idimpact = Ticket::dropdownImpact(array('value' => $ticket->fields["impact"]));
     } else {
         $idimpact = "value_impact" . mt_rand();
         echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $ticket->fields["impact"] . "'>";
         echo Ticket::getImpactName($ticket->fields["impact"]);
     }
     echo $tt->getEndHiddenFieldValue('impact', $ticket);
     echo "</td>";
     echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('itemtype');
     printf(__('%1$s%2$s'), __('Associated element'), $tt->getMandatoryMark('itemtype'));
     if ($ID && $canupdate) {
         echo "&nbsp;<img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n                      onClick=\"Ext.get('tickethardwareselection{$ID}').setDisplayed('block')\"\n                      class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'>";
     }
     echo $tt->getEndHiddenFieldText('itemtype');
     echo "</th>";
     echo "<td rowspan='2'>";
     echo $tt->getBeginHiddenFieldValue('itemtype');
     // Select hardware on creation or if have update right
     if ($canupdate || !$ID || $canupdate_descr) {
         if ($ID) {
             if ($ticket->fields['itemtype'] && ($item = getItemForItemtype($ticket->fields['itemtype'])) && $ticket->fields["items_id"]) {
                 if ($item->can($ticket->fields["items_id"], 'r')) {
                     printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getLink(array('comments' => true)));
                 } else {
                     printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID());
                 }
             }
         }
         $dev_user_id = 0;
         $dev_itemtype = $ticket->fields["itemtype"];
         $dev_items_id = $ticket->fields["items_id"];
         if (!$ID) {
             $dev_user_id = $values['_users_id_requester'];
             $dev_itemtype = $values["itemtype"];
             $dev_items_id = $values["items_id"];
         } else {
             if (isset($ticket->users[CommonITILActor::REQUESTER]) && count($ticket->users[CommonITILActor::REQUESTER]) == 1) {
                 foreach ($ticket->users[CommonITILActor::REQUESTER] as $user_id_single) {
                     $dev_user_id = $user_id_single['users_id'];
                 }
             }
         }
         if ($ID) {
             echo "<div id='tickethardwareselection{$ID}' style='display:none'>";
         }
         if ($dev_user_id > 0) {
             Ticket::dropdownMyDevices($dev_user_id, $ticket->fields["entities_id"], $dev_itemtype, $dev_items_id);
         }
         Ticket::dropdownAllDevices("itemtype", $dev_itemtype, $dev_items_id, 1, $dev_user_id, $ticket->fields["entities_id"]);
         if ($ID) {
             echo "</div>";
         }
         echo "<span id='item_ticket_selection_information'></span>";
     } else {
         if ($ID && $ticket->fields['itemtype'] && ($item = getItemForItemtype($ticket->fields['itemtype']))) {
             $item->getFromDB($ticket->fields['items_id']);
             printf(__('%1$s - %2$s'), $item->getTypeName(), $item->getNameID());
         } else {
             _e('General');
         }
     }
     echo $tt->getEndHiddenFieldValue('itemtype', $ticket);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . sprintf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority')) . "</th>";
     echo "<td>";
     $idajax = 'change_priority_' . mt_rand();
     if ($canupdate && $canpriority && !$tt->isHiddenField('priority')) {
         $idpriority = Ticket::dropdownPriority(array('value' => $ticket->fields["priority"], 'withmajor' => true));
         echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     } else {
         $idpriority = 0;
         echo "<span id='{$idajax}'>" . Ticket::getPriorityName($ticket->fields["priority"]) . "</span>";
     }
     if ($canupdate || $canupdate_descr) {
         $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority);
         Ajax::updateItemOnSelectEvent(array($idurgency, $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     // Need comment right to add a followup with the actiontime
     if (!$ID && Session::haveRight("global_add_followups", "1")) {
         echo "<th>" . $tt->getBeginHiddenFieldText('actiontime');
         printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime'));
         echo $tt->getEndHiddenFieldText('actiontime') . "</th>";
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('actiontime');
         Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true));
         echo $tt->getEndHiddenFieldValue('actiontime', $ticket);
         echo "</td>";
     } else {
         echo "<th></th><td></td>";
     }
     echo "<th>" . $tt->getBeginHiddenFieldText('locations_id');
     printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
     echo $tt->getEndHiddenFieldText('locations_id') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('locations_id');
     if ($canupdate) {
         Location::dropdown(array('value' => $ticket->fields['locations_id'], 'entity' => $ticket->fields['entities_id']));
     } else {
         echo Dropdown::getDropdownName('glpi_locations', $ticket->fields["locations_id"]);
     }
     echo $tt->getEndHiddenFieldValue('locations_id', $ticket);
     echo "</td></tr>";
     echo "</table>";
     if ($ID) {
         $values['canupdate'] = $canupdate;
         $ticket->showActorsPartForm($ID, $values);
     }
     $view_linked_tickets = $ID || $canupdate;
     echo "<table class='tab_cadre_fixe' id='mainformtable4'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name');
     printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name'));
     echo $tt->getEndHiddenFieldText('name') . "</th>";
     echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>";
     if (!$ID || $canupdate_descr) {
         echo $tt->getBeginHiddenFieldValue('name');
         $rand = mt_rand();
         echo "<script type='text/javascript' >\n";
         echo "function showName{$rand}() {\n";
         echo "Ext.get('name{$rand}').setDisplayed('none');";
         $params = array('maxlength' => 250, 'size' => 90, 'name' => 'name', 'data' => rawurlencode($ticket->fields["name"]));
         Ajax::updateItemJsCode("viewname{$rand}", $CFG_GLPI["root_doc"] . "/ajax/inputtext.php", $params);
         echo "}";
         echo "</script>\n";
         echo "<div id='name{$rand}' class='tracking left' onClick='showName{$rand}()'>\n";
         if (empty($ticket->fields["name"])) {
             _e('Without title');
         } else {
             echo $ticket->fields["name"];
         }
         echo "</div>\n";
         echo "<div id='viewname{$rand}'>\n";
         echo "</div>\n";
         if (!$ID) {
             echo "<script type='text/javascript' >\n\n            showName{$rand}();\n            </script>";
         }
         echo $tt->getEndHiddenFieldValue('name', $ticket);
     } else {
         if (empty($ticket->fields["name"])) {
             _e('Without title');
         } else {
             echo $ticket->fields["name"];
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content');
     printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content'));
     echo $tt->getEndHiddenFieldText('content') . "</th>";
     echo "<td width='" . (100 - $colsize1) . "%' colspan='3'>";
     // * Added by plugin surveyticket
     $psTicketTemplate = new PluginSurveyticketTicketTemplate();
     $psSurvey = new PluginSurveyticketSurvey();
     $plugin_surveyticket_surveys_id = 0;
     $a_tickettemplates = current($psTicketTemplate->find("`tickettemplates_id`='" . $tt->fields['id'] . "'\n                                                      AND `type`='" . $values['type'] . "'\n                                                      AND `is_central`='1'"));
     if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) {
         $psSurvey = new PluginSurveyticketSurvey();
         $psSurvey->getFromDB($a_tickettemplates['plugin_surveyticket_surveys_id']);
         if ($psSurvey->fields['is_active'] == 1) {
             $plugin_surveyticket_surveys_id = $a_tickettemplates['plugin_surveyticket_surveys_id'];
             $psSurvey = new PluginSurveyticketSurvey();
             $psSurvey->startSurvey($plugin_surveyticket_surveys_id);
         }
     } else {
         // End of adding by plugin
         if (!$ID || $canupdate_descr) {
             // Admin =oui on autorise la modification de la description
             echo $tt->getBeginHiddenFieldValue('content');
             $rand = mt_rand();
             echo "<script type='text/javascript' >\n";
             echo "function showDesc{$rand}() {\n";
             echo "Ext.get('desc{$rand}').setDisplayed('none');";
             $params = array('rows' => 6, 'cols' => 90, 'name' => 'content', 'data' => rawurlencode($ticket->fields["content"]));
             Ajax::updateItemJsCode("viewdesc{$rand}", $CFG_GLPI["root_doc"] . "/ajax/textarea.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='desc{$rand}' class='tracking' onClick='showDesc{$rand}()'>\n";
             if (!empty($ticket->fields["content"])) {
                 echo nl2br($ticket->fields["content"]);
             } else {
                 _e('Empty description');
             }
             echo "</div>\n";
             echo "<div id='viewdesc{$rand}'></div>\n";
             if (!$ID) {
                 echo "<script type='text/javascript' >\n\n            showDesc{$rand}();\n            </script>";
             }
             echo $tt->getEndHiddenFieldValue('content', $ticket);
         } else {
             echo nl2br($ticket->fields["content"]);
         }
         // * Added by plugin surveyticket
     }
     // End of adding by plugin
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     // Permit to add doc when creating a ticket
     if (!$ID) {
         echo "<th width='{$colsize1}%'>" . sprintf(__('File (%s)'), Document::getMaxUploadSize());
         echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt=\"" . __s('Help') . "\" onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000," . "height=800')\">";
         echo "&nbsp;";
         Ticket::showDocumentAddButton();
         echo "</th>";
         echo "<td width='{$colsize2}%'>";
         echo "<div id='uploadfiles'><input type='file' name='filename[]' size='20'></div></td>";
     } else {
         echo "<th colspan='2'>";
         $docnb = Document_Item::countForItem($ticket);
         echo "<a href=\"" . $ticket->getLinkURL() . "&amp;forcetab=Document_Item\$1\">";
         //TRANS: %d is the document number
         echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb);
         echo "</a></th>";
     }
     if ($view_linked_tickets) {
         echo "<th width='{$colsize3}%'>" . _n('Linked ticket', 'Linked tickets', 2);
         $rand_linked_ticket = mt_rand();
         if ($canupdate) {
             echo "&nbsp;";
             echo "<img onClick=\"Ext.get('linkedticket{$rand_linked_ticket}').setDisplayed('block')\"\n                   title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                   class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo '</th>';
         echo "<td width='{$colsize4}%'>";
         if ($canupdate) {
             echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>";
             Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
             printf(__('%1$s: %2$s'), __('Ticket'), __('ID'));
             echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n";
             echo "<input type='text' name='_link[tickets_id_2]'\n                   value='" . (isset($values["_link"]) ? $values["_link"]['tickets_id_2'] : '') . "'\n                   size='10'>\n";
             echo "&nbsp;";
             echo "</div>";
             if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) {
                 echo "<script language='javascript'>Ext.get('linkedticket{$rand_linked_ticket}').\n                      setDisplayed('block');</script>";
             }
         }
         Ticket_Ticket::displayLinkedTicketsTo($ID);
         echo "</td>";
     } else {
         echo "<td></td>";
     }
     echo "</tr>";
     if ((!$ID || $canupdate || $canupdate_descr || Session::haveRight("assign_ticket", "1") || Session::haveRight("steal_ticket", "1")) && !$options['template_preview']) {
         echo "<tr class='tab_bg_1'>";
         if ($ID) {
             if (Session::haveRight('delete_ticket', 1)) {
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 if ($ticket->fields["is_deleted"] == 1) {
                     echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'></td>";
                 } else {
                     echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'></td>";
                 }
                 echo "<td class='tab_bg_2 center' colspan='2'>";
                 if ($ticket->fields["is_deleted"] == 1) {
                     echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
                 } else {
                     echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'></td>";
                 }
             } else {
                 echo "<td class='tab_bg_2 center' colspan='4'>";
                 echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>";
             }
             echo "<input type='hidden' name='_read_date_mod' value='" . $ticket->getField('date_mod') . "'>";
         } else {
             echo "<td class='tab_bg_2 center' colspan='4'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             if ($tt->isField('id') && $tt->fields['id'] > 0) {
                 echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
                 echo "<input type='hidden' name='_predefined_fields'\n                      value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
             }
         }
     }
     echo "</table>";
     echo "<input type='hidden' name='id' value='{$ID}'>";
     echo "</div>";
     if (!$options['template_preview']) {
         Html::closeForm();
         $ticket->addDivForTabs();
     }
     return true;
 }
Exemple #3
0
 /**
  * Print the rssfeed form
  *
  * @param $ID        integer  Id of the item to print
  * @param $options   array    of possible options:
  *     - target filename : where to go when done.
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     // Test _rss cache directory. I permission trouble : unable to edit
     if (Toolbox::testWriteAccessToDirectory(GLPI_RSS_DIR) > 0) {
         echo "<div class='center'>";
         printf(__('Check permissions to the directory: %s'), GLPI_RSS_DIR);
         echo "<p class='red b'>" . __('Error') . "</p>";
         echo "</div>";
         return false;
     }
     $this->initForm($ID, $options);
     $canedit = $this->can($ID, UPDATE);
     $this->showFormHeader($options);
     $rowspan = 4;
     if (!$this->isNewID($ID)) {
         // Force getting feed :
         $feed = self::getRSSFeed($this->fields['url'], $this->fields['refresh_rate']);
         if (!$feed || $feed->error()) {
             $this->setError(true);
         } else {
             $this->setError(false);
         }
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Name') . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, "name", array('entity' => -1, 'user' => $this->fields["users_id"]));
         echo "</td><td colspan ='2'>&nbsp;</td></tr>\n";
     }
     echo "<tr class='tab_bg_1'><td>" . __('URL') . "</td>";
     echo "<td colspan='3'>";
     echo "<input type='text' name='url' size='100' value='" . $this->fields["url"] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('By') . "</td>";
     echo "<td>";
     echo getUserName($this->fields["users_id"]);
     echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "'>\n";
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Refresh rate') . "</td>";
     echo "<td>";
     Dropdown::showTimeStamp("refresh_rate", array('value' => $this->fields["refresh_rate"], 'min' => HOUR_TIMESTAMP, 'max' => DAY_TIMESTAMP, 'step' => HOUR_TIMESTAMP, 'display_emptychoice' => false, 'toadd' => array(5 * MINUTE_TIMESTAMP, 15 * MINUTE_TIMESTAMP, 30 * MINUTE_TIMESTAMP, 45 * MINUTE_TIMESTAMP)));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Number of items displayed') . "</td>";
     echo "<td>";
     Dropdown::showNumber("max_items", array('value' => $this->fields["max_items"], 'min' => 5, 'max' => 100, 'step' => 5, 'toadd' => array(1), 'display_emptychoice' => false));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Error retrieving RSS feed') . "</td>";
     echo "<td>";
     echo Dropdown::getYesNo($this->fields['have_error']);
     echo "</td>";
     if ($this->fields['have_error']) {
         echo "<td>" . __('RSS feeds found');
         echo "</td><td>";
         $this->showDiscoveredFeeds();
         echo "</td>\n";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
Exemple #4
0
 /**
  * Display for reservation
  *
  * @param $ID              ID of the reservation (empty for create new)
  * @param $options   array of possibles options:
  *     - item  reservation items ID for creation process
  *     - date date for creation process
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
         return false;
     }
     $resa = new self();
     if (!empty($ID)) {
         if (!$resa->getFromDB($ID)) {
             return false;
         }
         if (!$resa->can($ID, UPDATE)) {
             return false;
         }
         // Set item if not set
         if ((!isset($options['item']) || count($options['item']) == 0) && ($itemid = $resa->getField('reservationitems_id'))) {
             $options['item'][$itemid] = $itemid;
         }
     } else {
         $resa->getEmpty();
         $resa->fields["begin"] = $options['begin'];
         if (!isset($options['end'])) {
             $resa->fields["end"] = date("Y-m-d H:00:00", strtotime($resa->fields["begin"]) + HOUR_TIMESTAMP);
         } else {
             $resa->fields["end"] = $options['end'];
         }
     }
     // No item : problem
     if (!isset($options['item']) || count($options['item']) == 0) {
         return false;
     }
     echo "<div class='center'><form method='post' name=form action='reservation.form.php'>";
     if (!empty($ID)) {
         echo "<input type='hidden' name='id' value='{$ID}'>";
     }
     echo "<table class='tab_cadre' width='700px'>";
     echo "<tr><th colspan='2'>" . __('Reserve an item') . "</th></tr>\n";
     // Add Hardware name
     $r = new ReservationItem();
     echo "<tr class='tab_bg_1'><td>" . __('Item') . "</td>";
     echo "<td>";
     foreach ($options['item'] as $itemID) {
         $r->getFromDB($itemID);
         $type = $r->fields["itemtype"];
         $name = NOT_AVAILABLE;
         $item = NULL;
         if ($item = getItemForItemtype($r->fields["itemtype"])) {
             $type = $item->getTypeName();
             if ($item->getFromDB($r->fields["items_id"])) {
                 $name = $item->getName();
             } else {
                 $item = NULL;
             }
         }
         echo "<span class='b'>" . sprintf(__('%1$s - %2$s'), $type, $name) . "</span><br>";
         echo "<input type='hidden' name='items[{$itemID}]' value='{$itemID}'>";
     }
     echo "</td></tr>\n";
     if (!Session::haveRight("reservation", UPDATE) || is_null($item) || !Session::haveAccessToEntity($item->fields["entities_id"])) {
         echo "<input type='hidden' name='users_id' value='" . Session::getLoginUserID() . "'>";
     } else {
         echo "<tr class='tab_bg_2'><td>" . __('By') . "</td>";
         echo "<td>";
         if (empty($ID)) {
             User::dropdown(array('value' => Session::getLoginUserID(), 'entity' => $item->getEntityID(), 'right' => 'all'));
         } else {
             User::dropdown(array('value' => $resa->fields["users_id"], 'entity' => $item->getEntityID(), 'right' => 'all'));
         }
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     $rand_begin = Html::showDateTimeField("resa[begin]", array('value' => $resa->fields["begin"], 'timestep' => -1, 'maybeempty' => false));
     echo "</td></tr>\n";
     $default_delay = floor((strtotime($resa->fields["end"]) - strtotime($resa->fields["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
     echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
     $rand = Dropdown::showTimeStamp("resa[_duration]", array('min' => 0, 'max' => 24 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $params = array('duration' => '__VALUE__', 'end' => $resa->fields["end"], 'name' => "resa[end]");
     Ajax::updateItemOnSelectEvent("dropdown_resa[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     if ($default_delay == 0) {
         $params['duration'] = 0;
         Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     }
     Alert::displayLastAlert('Reservation', $ID);
     echo "</td></tr>\n";
     if (empty($ID)) {
         echo "<tr class='tab_bg_2'><td>" . __('Rehearsal') . "</td>";
         echo "<td>";
         $values = array('' => _x('periodicity', 'None'), 'day' => _x('periodicity', 'Daily'), 'week' => _x('periodicity', 'Weekly'), 'month' => _x('periodicity', 'Monthly'));
         $rand = Dropdown::showFromArray('periodicity[type]', $values);
         $field_id = Html::cleanId("dropdown_periodicity[type]{$rand}");
         $params = array('type' => '__VALUE__', 'end' => $resa->fields["end"]);
         Ajax::updateItemOnSelectEvent($field_id, "resaperiodcontent{$rand}", $CFG_GLPI["root_doc"] . "/ajax/resaperiod.php", $params);
         echo "<br><div id='resaperiodcontent{$rand}'></div>";
         echo "</td></tr>\n";
     }
     echo "<tr class='tab_bg_2'><td>" . __('Comments') . "</td>";
     echo "<td><textarea name='comment' rows='8' cols='60'>" . $resa->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     if (empty($ID)) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='2' class='top center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
     } else {
         if ($resa->fields["users_id"] == Session::getLoginUserID() || Session::haveRightsOr(static::$rightname, array(PURGE, UPDATE))) {
             echo "<tr class='tab_bg_2'>";
             if ($resa->fields["users_id"] == Session::getLoginUserID() || Session::haveRight(static::$rightname, PURGE)) {
                 echo "<td class='top center'>";
                 echo "<input type='submit' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\"\n                      class='submit'>";
                 if ($resa->fields["group"] > 0) {
                     echo "<br><input type='checkbox' name='_delete_group'>&nbsp;" . __s('Delete all rehearsals');
                 }
                 echo "</td>";
             }
             if ($resa->fields["users_id"] == Session::getLoginUserID() || Session::haveRight(static::$rightname, UPDATE)) {
                 echo "<td class='top center'>";
                 echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\"\n                     class='submit'>";
                 echo "</td>";
             }
             echo "</tr>\n";
         }
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
 }
 /**
  * Form for Ticket or Problem Task on Massive action
  **/
 function showFormMassiveAction()
 {
     echo "&nbsp;" . __('Category') . "&nbsp;";
     TaskCategory::dropdown(array('condition' => "`is_active`= '1'"));
     echo "<br>" . __('Description') . " ";
     echo "<textarea name='content' cols='50' rows='6'></textarea>&nbsp;";
     if ($this->maybePrivate()) {
         echo "<input type='hidden' name='is_private' value='" . $_SESSION['glpitask_private'] . "'>";
     }
     echo "<br>" . __('Duration');
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
 }
Exemple #6
0
 public function showFormBadgeReturn($target, $ID)
 {
     $this->getFromDB($ID);
     echo "<div align='center'>";
     echo "<form method='post' action=\"{$target}\">";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='4'>";
     _e('Time of checking of validity of the badges', 'badges');
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     _e('Badge return delay', 'badges') . "&nbsp;";
     echo "</td>";
     echo "<td>";
     Dropdown::showTimeStamp("delay_returnexpire", array('min' => DAY_TIMESTAMP, 'max' => 52 * WEEK_TIMESTAMP, 'step' => DAY_TIMESTAMP, 'value' => $this->fields["delay_returnexpire"], 'addfirstminutes' => true, 'inhours' => false));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='center' colspan='4'>";
     echo "<input type='hidden' name='id' value='" . $ID . "'>";
     echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit' >";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Exemple #7
0
 function showForm($ID, $options = array())
 {
     if (!$this->canView()) {
         return false;
     }
     $plugin_resources_resources_id = -1;
     if (isset($options['plugin_resources_resources_id'])) {
         $plugin_resources_resources_id = $options['plugin_resources_resources_id'];
     }
     $item = new PluginResourcesResource();
     if ($item->getFromDB($plugin_resources_resources_id)) {
         $entities_id = $item->fields["entities_id"];
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
         $plugin_resources_resources_id = $this->fields["plugin_resources_resources_id"];
     } else {
         // Create item
         $input = array('plugin_resources_resources_id' => $plugin_resources_resources_id, 'entities_id' => $entities_id);
         $this->check(-1, 'w', $input);
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<input type='hidden' name='plugin_resources_resources_id' value='{$plugin_resources_resources_id}'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . PluginResourcesResource::getTypeName(2) . "&nbsp;</td><td>";
     $user = PluginResourcesResource::getResourceName($plugin_resources_resources_id, 2);
     $out = "<a href='" . $user['link'] . "'>";
     $out .= $user["name"];
     if ($_SESSION["glpiis_ids_visible"]) {
         $out .= " (" . $plugin_resources_resources_id . ")";
     }
     $out .= "</a>";
     echo $out;
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name", array('size' => "50"));
     echo "</td>";
     echo "<td>" . PluginResourcesTaskType::getTypeName(1) . "</td><td>";
     Dropdown::show('PluginResourcesTaskType', array('value' => $this->fields["plugin_resources_tasktypes_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician') . "</td><td>";
     User::dropdown(array('name' => "users_id", 'value' => $this->fields["users_id"], 'right' => 'interface'));
     echo "</td>";
     echo "<td>" . __('Planning') . "</td>";
     echo "<td>";
     $plan = new PluginResourcesTaskPlanning();
     $plan->showFormForTask($plugin_resources_resources_id, $this);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td><td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"]));
     echo "</td>";
     echo "<td>" . __('Carried out task', 'resources') . "</td><td>";
     Dropdown::showYesNo("is_finished", $this->fields["is_finished"]);
     echo "</td>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Effective duration', 'resources') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td><td colspan='2'></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4'>" . __('Comments') . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     echo "<textarea cols='130' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "<input type='hidden' name='withtemplate' value=\"" . $options['withtemplate'] . "\" >";
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Exemple #8
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . _n('Context', 'Contexts', 1, 'tasklists') . "</td><td>";
     Dropdown::show('PluginTasklistsTaskType', array('name' => "plugin_tasklists_tasktypes_id", 'value' => $this->fields["plugin_tasklists_tasktypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Priority') . "</td>";
     echo "<td>";
     CommonITILObject::dropdownPriority(array('value' => $this->fields['priority'], 'withmajor' => 1));
     echo "</td>";
     echo "<td>" . __('Planned duration') . "</td>";
     echo "<td>";
     $toadd = array();
     //for ($i=9 ; $i<=100 ; $i++) {
     //   $toadd[] = $i*HOUR_TIMESTAMP;
     //}
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 50 * DAY_TIMESTAMP, 'step' => DAY_TIMESTAMP, 'value' => $this->fields["actiontime"], 'toadd' => $toadd));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Visibility') . "</td>";
     echo "<td>";
     self::dropdownVisibility(array('value' => $this->fields['visibility']));
     echo "</td>";
     echo "<td>" . __('Due date');
     echo "&nbsp;";
     Html::showToolTip(nl2br(__('Empty for infinite', 'tasklists')));
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("due_date", $this->fields["due_date"], true, true);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td><td>";
     User::dropdown(array('name' => "users_id", 'value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Percent done') . "</td>";
     echo "<td>";
     Dropdown::showNumber("percent_done", array('value' => $this->fields['percent_done'], 'min' => 0, 'max' => 100, 'step' => 20, 'unit' => '%'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Dropdown::show('Group', array('name' => "groups_id", 'value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Status') . "</td><td>";
     Planning::dropdownState("state", $this->fields["state"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Description') . "</td>";
     echo "<td colspan = '3' class='center'>";
     echo "<textarea cols='100' rows='15' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Print the item cost form
  *
  * @param $ID        integer  ID of the item
  * @param $options   array    options used
  **/
 function showForm($ID, $options = array())
 {
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options[static::$items_id] = $item->getField('id');
         $this->check(-1, CREATE, $options);
         $this->initBasedOnPrevious();
     }
     if ($ID > 0) {
         $items_id = $this->fields[static::$items_id];
     } else {
         $items_id = $options['parent']->fields["id"];
     }
     $item = new static::$itemtype();
     if (!$item->getFromDB($items_id)) {
         return false;
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     echo "<input type='hidden' name='" . static::$items_id . "' value='" . $item->fields['id'] . "'>";
     Html::autocompletionTextField($this, 'name');
     echo "</td>";
     echo "<td>" . __('Begin date') . "</td>";
     echo "<td>";
     Html::showDateField("begin_date", array('value' => $this->fields['begin_date']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td>";
     echo "<td>";
     Dropdown::showTimeStamp('actiontime', array('value' => $this->fields['actiontime'], 'addfirstminutes' => true));
     echo "</td>";
     echo "<td>" . __('End date') . "</td>";
     echo "<td>";
     Html::showDateField("end_date", array('value' => $this->fields['end_date']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Time cost') . "</td><td>";
     echo "<input type='text' size='15' name='cost_time' value='" . Html::formatNumber($this->fields["cost_time"], true) . "'>";
     echo "</td>";
     $rowspan = 4;
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Fixed cost') . "</td><td>";
     echo "<input type='text' size='15' name='cost_fixed' value='" . Html::formatNumber($this->fields["cost_fixed"], true) . "'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Material cost') . "</td><td>";
     echo "<input type='text' size='15' name='cost_material' value='" . Html::formatNumber($this->fields["cost_material"], true) . "'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Budget') . "</td>";
     echo "<td>";
     Budget::dropdown(array('value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
Exemple #10
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     $opt = array();
     if (isset($options['helpdesk_id']) && !empty($options['helpdesk_id'])) {
         $help = new $options['helpdesk_itemtype']();
         if ($help->getFromDB($options['helpdesk_id'])) {
             $opt['value'] = $help->fields["name"];
             echo "<input type='hidden' name='helpdesk_id' value='" . $options['helpdesk_id'] . "'>";
             echo "<input type='hidden' name='helpdesk_itemtype' value='" . $options['helpdesk_itemtype'] . "'>";
         }
     }
     Html::autocompletionTextField($this, "name", $opt);
     echo "</td>";
     //Projet parent
     echo "<td>" . __('Parent project', 'projet') . "</td>";
     echo "<td>";
     PluginProjetProjet_Projet::displayLinkedProjetsTo($ID, $options['withtemplate']);
     if ($this->canCreate() && $options['withtemplate'] < 2) {
         $rand_linked_projet = mt_rand();
         echo "&nbsp;";
         if (!PluginProjetProjet_Projet::getParentProjetsTo($ID)) {
             echo "<img onClick=\"Ext.get('linkedprojet{$rand_linked_projet}').setDisplayed('block')\"\n                       title=\"" . _x('button', 'Add') . "\" alt=\"" . _x('button', 'Add') . "\"\n                       class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo "<div style='display:none' id='linkedprojet{$rand_linked_projet}'>";
         PluginProjetProjet_Projet::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
         echo "&nbsp;";
         PluginProjetProjet_Projet::dropdownParent("_link[plugin_projet_projets_id_2]", isset($values["_link"]) ? $values["_link"]['plugin_projet_projets_id_2'] : '', array('id' => $this->fields["id"], 'entities_id' => $this->fields["entities_id"]));
         echo "<input type='hidden' name='_link[plugin_projet_projets_id_1]' value='{$ID}'>\n";
         echo "&nbsp;";
         echo "</div>";
         if (isset($values["_link"]) && !empty($values["_link"]['plugin_projet_projets_id_2'])) {
             echo "<script language='javascript'>Ext.get('linkedprojet{$rand_linked_projet}').\n                   setDisplayed('block');</script>";
         }
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td colspan='2'>" . _n('Responsible', 'Responsibles', 2, 'projet') . "</td>";
     echo "<td colspan='2'>" . __('Planification', 'projet') . "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('User') . "</td><td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Start date') . "</td><td>";
     Html::showDateFormItem("date_begin", $this->fields["date_begin"], true, true);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Group') . "</td><td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('End date') . "</td><td>";
     Html::showDateFormItem("date_end", $this->fields["date_end"], true, true);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Estimated duration', 'projet');
     echo "</td>";
     echo "<td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * DAY_TIMESTAMP;
     }
     Dropdown::showTimeStamp("estimatedtime", array('min' => 0, 'max' => 8 * DAY_TIMESTAMP, 'value' => $this->fields["estimatedtime"], 'addfirstminutes' => false, 'inhours' => false, 'toadd' => $toadd));
     echo "</td>\n";
     echo "<td>" . __('Effective duration', 'projet') . "&nbsp;";
     Html::showToolTip(nl2br(__('Total of effective duration of project tasks', 'projet')));
     echo "</td>";
     echo "<td>" . self::getProjectForecast($ID) . "</td></tr>";
     echo "<tr class='tab_bg_2'><td>";
     echo __('Estimated duration', 'projet') . "&nbsp;" . __('in hours', 'projet');
     echo "</td><td>";
     $time = floor($this->fields["estimatedtime"]);
     $out = Html::formatNumber($time / HOUR_TIMESTAMP, 2);
     echo sprintf(_n('%s hour', '%s hours', $out), $out);
     echo "</td><td>" . __('Linked tickets duration', 'projet') . "&nbsp;";
     Html::showToolTip(nl2br(__('Total of duration of linked tickets for project', 'projet')));
     echo "</td>";
     echo "<td>" . self::getProjectDuration($ID) . "</td></tr>";
     //status
     echo "<tr class='tab_bg_1'><td>" . __('State') . "</td><td>";
     Dropdown::show('PluginProjetProjetState', array('value' => $this->fields["plugin_projet_projetstates_id"]));
     echo "</td>";
     echo "<td>" . __('Display on the global Gantt', 'projet') . "</td><td>";
     Dropdown::showYesNo("show_gantt", $this->fields["show_gantt"]);
     echo "</td></tr>";
     //advance
     echo "<tr class='tab_bg_1'><td>" . __('Progress') . "</td><td>";
     $advance = floor($this->fields["advance"]);
     echo "<select name='advance'>";
     for ($i = 0; $i < 101; $i += 5) {
         echo "<option value='{$i}' ";
         if ($advance == $i) {
             echo "selected";
         }
         echo " >{$i}</option>";
     }
     echo "</select> %";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>" . __('Comments') . "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     $value = $this->fields["comment"];
     if (isset($options['helpdesk_id']) && !empty($options['helpdesk_id'])) {
         $help = new $options['helpdesk_itemtype']();
         if ($help->getFromDB($options['helpdesk_id'])) {
             $value = $help->fields["content"];
         }
     }
     echo "<textarea cols='130' rows='4' name='comment' >" . $value . "</textarea>";
     echo "<input type='hidden' name='withtemplate' value='" . $options['withtemplate'] . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>" . __('Description') . "</td></tr>";
     echo "<tr class='tab_bg_1'><td colspan='4'>";
     echo "<textarea cols='130' rows='4' name='description' >" . $this->fields["description"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . __('Send email', 'projet') . "</td><td>";
     echo "<input type='checkbox' name='send_notification' checked = true";
     echo " value='1'>";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td colspan='4'>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of update
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 /** form for Task
  *
  * @param $ID        Integer : Id of the task
  * @param $options   array
  *     -  parent Object : the object
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     $fkfield = $item->getForeignKeyField();
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $options[$fkfield] = $item->getField('id');
         $this->check(-1, 'w', $options);
     }
     $canplan = Session::haveRight("show_planning", "1");
     $this->showFormHeader($options);
     $rowspan = 5;
     if ($this->maybePrivate()) {
         $rowspan++;
     }
     // Recall
     if (!empty($this->fields["begin"])) {
         $rowspan++;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='{$rowspan}' class='middle right'>" . __('Description') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea name='content' cols='50' rows='{$rowspan}'>" . $this->fields["content"] . "</textarea></td>";
     if ($ID > 0) {
         echo "<td>" . __('Date') . "</td>";
         echo "<td>";
         Html::showDateTimeFormItem("date", $this->fields["date"], 1, false);
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Category') . "</td><td>";
     TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"]));
     echo "</td></tr>\n";
     if (isset($this->fields["state"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Status') . "</td><td>";
         Planning::dropdownState("state", $this->fields["state"]);
         echo "</td></tr>\n";
     }
     if ($this->maybePrivate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Private') . "</td>";
         echo "<td>";
         Dropdown::showYesNo('is_private', $this->fields["is_private"]);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Planning') . "</td>";
     echo "<td>";
     if (!empty($this->fields["begin"])) {
         if (Session::haveRight('show_planning', 1)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $ID . "() {\n";
             echo "Ext.get('plan').setDisplayed('none');";
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n";
             echo "<span class='showplan'>";
         }
         if (isset($this->fields["state"])) {
             echo Planning::getState($this->fields["state"]) . "<br>";
         }
         printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
         echo "<br>" . getUserName($this->fields["users_id_tech"]);
         if (Session::haveRight('show_planning', 1)) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if (Session::haveRight('show_planning', 1)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo "Ext.get('plan').setDisplayed('none');";
             $params = array('form' => 'followups', 'users_id' => Session::getLoginUserID(), 'entity' => $_SESSION["glpiactive_entity"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
             echo "<span class='showplan'>" . __('Plan this task') . "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         } else {
             _e('None');
         }
     }
     echo "</td></tr>";
     if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td>";
         PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!$this->isNewID($ID)) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE);
     }
     $this->showFormHeader($options);
     $fields = $this->getAdditionalFields();
     $nb = count($fields);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     if ($this instanceof CommonDevice) {
         // Awfull hack for CommonDevice where name is designation
         Html::autocompletionTextField($this, "designation");
     } else {
         Html::autocompletionTextField($this, "name");
     }
     echo "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>" . __('Comments') . "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>\n            <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     foreach ($fields as $field) {
         if ($field['name'] == 'entities_id' && $ID == 0 && !$this->isNewID($ID)) {
             // No display for root entity
             echo "<tr class='tab_bg_1'><td colspan='2'>&nbsp;</td></tr>";
             break;
         }
         if (!isset($field['type'])) {
             $field['type'] = '';
         }
         if ($field['name'] == 'header') {
             echo "<tr class='tab_bg_1'><th colspan='2'>" . $field['label'] . "</th></tr>";
             continue;
         }
         echo "<tr class='tab_bg_1'><td>" . $field['label'];
         if (isset($field['comment']) && !empty($field['comment'])) {
             echo "&nbsp;";
             Html::showToolTip($field['comment']);
         }
         echo "</td><td>";
         switch ($field['type']) {
             case 'UserDropdown':
                 $param = array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"]);
                 if (isset($field['right'])) {
                     $params['right'] = $field['right'];
                 }
                 User::dropdown($param);
                 break;
             case 'dropdownValue':
                 $params = array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID());
                 if (isset($field['condition'])) {
                     $params['condition'] = $field['condition'];
                 }
                 Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), $params);
                 break;
             case 'text':
                 Html::autocompletionTextField($this, $field['name']);
                 break;
             case 'textarea':
                 $cols = 40;
                 $rows = 3;
                 if (isset($field['rows'])) {
                     $rows = $field['rows'];
                 }
                 if (isset($field['cols'])) {
                     $cols = $field['cols'];
                 }
                 echo "<textarea name='" . $field['name'] . "' cols='{$cols}' rows='{$rows}'>" . $this->fields[$field['name']] . "</textarea >";
                 break;
             case 'integer':
                 Dropdown::showNumber($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'timestamp':
                 $param = array('value' => $this->fields[$field['name']]);
                 if (isset($field['min'])) {
                     $param['min'] = $field['min'];
                 }
                 if (isset($field['max'])) {
                     $param['max'] = $field['max'];
                 }
                 if (isset($field['step'])) {
                     $param['step'] = $field['step'];
                 }
                 Dropdown::showTimeStamp($field['name'], $param);
                 break;
             case 'parent':
                 if ($field['name'] == 'entities_id') {
                     $restrict = -1;
                 } else {
                     $restrict = $this->getEntityID();
                 }
                 Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array()));
                 break;
             case 'icon':
                 Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones");
                 if (!empty($this->fields[$field['name']])) {
                     echo "&nbsp;<img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>";
                 }
                 break;
             case 'bool':
                 Dropdown::showYesNo($field['name'], $this->fields[$field['name']]);
                 break;
             case 'color':
                 Html::showColorField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'date':
                 Html::showDateField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'datetime':
                 Html::showDateTimeField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'password':
                 echo "<input type='password' name='password' value='' size='20' autocomplete='off'>";
                 break;
             default:
                 $this->displaySpecificTypeField($ID, $field);
                 break;
         }
         if (isset($field['unit'])) {
             echo "&nbsp;" . $field['unit'];
         }
         echo "</td></tr>\n";
     }
     if (isset($this->fields['is_protected']) && $this->fields['is_protected']) {
         $options['candel'] = false;
     }
     if (isset($_REQUEST['_in_modal'])) {
         echo "<input type='hidden' name='_in_modal' value='1'>";
     }
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Select a field using standard system
  *
  * @since version 0.83
  *
  * @param $field_id_or_search_options  integer/string/array id of the search option field
  *                                                             or field name
  *                                                             or search option array
  * @param $name                        string               name of the select (if empty use linkfield)
  *                                                          (default '')
  * @param $values                                           mixed default value to display
  *                                                          (default '')
  * @param $options                     array                of possible options:
  * Parameters which could be used in options array :
  *    - comments : boolean / is the comments displayed near the value (default false)
  *    - any others options passed to specific display method
  *
  * @return return the string to display
  **/
 function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = array())
 {
     global $CFG_GLPI;
     $param['comments'] = false;
     $param['html'] = false;
     foreach ($param as $key => $val) {
         if (!isset($options[$key])) {
             $options[$key] = $val;
         }
     }
     $searchoptions = array();
     if (is_array($field_id_or_search_options)) {
         $searchoptions = $field_id_or_search_options;
     } else {
         $searchopt = $this->getSearchOptions();
         // Get if id of search option is passed
         if (is_numeric($field_id_or_search_options)) {
             if (isset($searchopt[$field_id_or_search_options])) {
                 $searchoptions = $searchopt[$field_id_or_search_options];
             }
         } else {
             // Get if field name is passed
             $searchoptions = $this->getSearchOptionByField('field', $field_id_or_search_options, $this->getTable());
         }
     }
     if (count($searchoptions)) {
         $field = $searchoptions['field'];
         // Normalize option
         if (is_array($values)) {
             $value = $values[$field];
         } else {
             $value = $values;
             $values = array($field => $value);
         }
         if (empty($name)) {
             $name = $searchoptions['linkfield'];
         }
         // If not set : set to specific
         if (!isset($searchoptions['datatype'])) {
             $searchoptions['datatype'] = 'specific';
         }
         $options['display'] = false;
         $unit = '';
         if (isset($searchoptions['unit'])) {
             $unit = $searchoptions['unit'];
         }
         if (isset($options[$searchoptions['table'] . '.' . $searchoptions['field']])) {
             $options = array_merge($options, $options[$searchoptions['table'] . '.' . $searchoptions['field']]);
         }
         switch ($searchoptions['datatype']) {
             case "count":
             case "number":
             case "integer":
                 $copytooption = array('min', 'max', 'step', 'toadd', 'unit');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showNumber($name, $options);
             case "decimal":
             case "mac":
             case "ip":
             case "string":
             case "email":
             case "weblink":
                 $this->fields[$name] = $value;
                 return Html::autocompletionTextField($this, $name, $options);
             case "text":
                 $out = '';
                 if (isset($searchoptions['htmltext']) && $searchoptions['htmltext']) {
                     $out = Html::initEditorSystem($name, '', false);
                 }
                 return $out . "<textarea cols='45' rows='5' name='{$name}'>{$value}</textarea>";
             case "bool":
                 return Dropdown::showYesNo($name, $value, -1, $options);
             case "color":
                 return Html::showColorField($name, $options);
             case "date":
             case "date_delay":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('min', 'max', 'maybeempty', 'showyear');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateField($name, $options);
             case "datetime":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     $options['with_time'] = true;
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('mindate', 'maxdate', 'mintime', 'maxtime', 'maybeempty', 'timestep');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateTimeField($name, $options);
             case "timestamp":
                 $copytooption = array('addfirstminutes', 'emptylabel', 'inhours', 'max', 'min', 'step', 'toadd', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showTimeStamp($name, $options);
             case "itemlink":
                 // Do not use dropdown if wanted to select string value instead of ID
                 if (isset($options['itemlink_as_string']) && $options['itemlink_as_string']) {
                     break;
                 }
             case "dropdown":
                 $copytooption = array('condition', 'displaywith', 'emptylabel', 'right', 'toadd');
                 $options['name'] = $name;
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (!isset($options['entity'])) {
                     $options['entity'] = $_SESSION['glpiactiveentities'];
                 }
                 $itemtype = getItemTypeForTable($searchoptions['table']);
                 return $itemtype::dropdown($options);
             case "right":
                 return Profile::dropdownRights(Profile::getRightsFor($searchoptions['rightclass']), $name, $value, array('multiple' => false, 'display' => false));
             case "itemtypename":
                 if (isset($searchoptions['itemtype_list'])) {
                     $options['types'] = $CFG_GLPI[$searchoptions['itemtype_list']];
                 }
                 $copytooption = array('types');
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (isset($options['types'])) {
                     return Dropdown::showItemTypes($name, $options['types'], $options);
                 }
                 return false;
             case "language":
                 $copytooption = array('emptylabel', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showLanguages($name, $options);
         }
         // Get specific display if available
         $itemtype = getItemTypeForTable($searchoptions['table']);
         if ($item = getItemForItemtype($itemtype)) {
             $specific = $item->getSpecificValueToSelect($searchoptions['field'], $name, $values, $options);
             if (strlen($specific)) {
                 return $specific;
             }
         }
     }
     // default case field text
     $this->fields[$name] = $value;
     return Html::autocompletionTextField($this, $name, $options);
 }
 /** form for Task
  *
  * @param $ID        Integer : Id of the task
  * @param $options   array
  *     -  parent Object : the object
  **/
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     if (isset($options['parent']) && !empty($options['parent'])) {
         $item = $options['parent'];
     }
     $fkfield = $item->getForeignKeyField();
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $options[$fkfield] = $item->getField('id');
         $this->check(-1, CREATE, $options);
     }
     $rand = mt_rand();
     $this->showFormHeader($options);
     $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED);
     $rowspan = 3;
     if ($this->maybePrivate()) {
         $rowspan++;
     }
     if (isset($this->fields["state"])) {
         $rowspan++;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td rowspan='{$rowspan}' class='middle'>" . __('Description') . "</td>";
     echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea name='content' cols='50' rows='{$rowspan}' class='form-control'>" . $this->fields["content"] . "</textarea></td>";
     if ($ID > 0) {
         echo "<td>" . __('Date') . "</td>";
         echo "<td>";
         Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo "<td colspan='2'>&nbsp;";
     }
     echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Category') . "</td><td>";
     TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"]));
     echo "</td></tr>\n";
     if (isset($this->fields["state"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Status') . "</td><td>";
         Planning::dropdownState("state", $this->fields["state"]);
         echo "</td></tr>\n";
     }
     if ($this->maybePrivate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Private') . "</td>";
         echo "<td>";
         Dropdown::showYesNo('is_private', $this->fields["is_private"]);
         echo "</td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Duration') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('By');
     echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n             title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n             class='calendrier'>";
     echo "</a>";
     Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
     echo "</td>";
     echo "<td class='center'>";
     $rand_user = mt_rand();
     $params = array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"], 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"]);
     $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
     User::dropdown($params);
     echo "</td>\n";
     if ($canplan) {
         echo "<td>" . __('Planning') . "</td>";
     }
     echo "<td>";
     if (!empty($this->fields["begin"])) {
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $ID . "() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n";
             echo "<span class='showplan'>";
         }
         if (isset($this->fields["state"])) {
             echo Planning::getState($this->fields["state"]) . "<br>";
         }
         printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
         echo "<br>" . getUserName($this->fields["users_id_tech"]);
         if (Session::haveRight('planning', Planning::READMY)) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if ($canplan) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo Html::jsHide('plan');
             $params = array('form' => 'followups', 'entity' => $_SESSION["glpiactive_entity"], 'rand_user' => $rand_user, 'itemtype' => $this->getType(), 'items_id' => $this->getID());
             Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             if ($canplan) {
                 echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
                 echo "<span class='vsubmit'>" . __('Plan this task') . "</span>";
                 echo "</div>\n";
                 echo "<div id='viewplan'></div>\n";
             }
         } else {
             _e('None');
         }
     }
     echo "</td></tr>";
     if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>";
         PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID()));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
Exemple #15
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!$this->canView()) {
         return false;
     }
     $plugin_projet_projets_id = -1;
     if (isset($options['plugin_projet_projets_id'])) {
         $plugin_projet_projets_id = $options['plugin_projet_projets_id'];
     }
     $item = new PluginProjetProjet();
     if ($item->getFromDB($plugin_projet_projets_id)) {
         $entities_id = $item->fields["entities_id"];
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
         $plugin_projet_projets_id = $this->fields["plugin_projet_projets_id"];
     } else {
         // Create item
         $input = array('plugin_projet_projets_id' => $plugin_projet_projets_id, 'entities_id' => $entities_id);
         $this->check(-1, 'w', $input);
     }
     $options["colspan"] = 4;
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<input type='hidden' name='plugin_projet_projets_id' value='{$plugin_projet_projets_id}'>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='2'>" . PluginProjetProjet::getTypeName(2) . "</td><td colspan='2'>";
     $link = NOT_AVAILABLE;
     if ($item->getFromDB($plugin_projet_projets_id)) {
         $link = $item->getLink();
     }
     echo $link;
     echo "</td>";
     echo "<td>";
     echo __('Parent task', 'projet') . "</td><td>";
     PluginProjetTask_Task::displayLinkedProjetTasksTo($ID);
     if ($this->canCreate()) {
         $rand_linked_projettask = mt_rand();
         echo "&nbsp;";
         if (!PluginProjetTask_Task::getParentProjetTasksTo($ID)) {
             echo "<img onClick=\"Ext.get('linkedprojettask{$rand_linked_projettask}').setDisplayed('block')\"\n                       title=\"" . __('Add') . "\" alt=\"" . __('Add') . "\"\n                       class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo "<div style='display:none' id='linkedprojettask{$rand_linked_projettask}'>";
         PluginProjetTask_Task::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
         echo "&nbsp;";
         PluginProjetTask_Task::dropdownParent("_link[plugin_projet_tasks_id_2]", isset($values["_link"]) ? $values["_link"]['plugin_projet_tasks_id_2'] : '', array('id' => $this->fields["id"], 'entities_id' => $this->fields["entities_id"], 'plugin_projet_projets_id' => $plugin_projet_projets_id));
         echo "<input type='hidden' name='_link[plugin_projet_tasks_id_1]' value='{$ID}'>\n";
         echo "&nbsp;";
         echo "</div>";
         if (isset($values["_link"]) && !empty($values["_link"]['plugin_projet_tasks_id_2'])) {
             echo "<script language='javascript'>Ext.get('linkedprojettask{$rand_linked_projettask}').\n                   setDisplayed('block');</script>";
         }
     }
     echo "</td>";
     echo "<td>";
     echo __('Dependent', 'projet') . "</td><td>";
     Dropdown::showYesNo("depends", $this->fields["depends"]);
     echo "&nbsp;";
     echo " <img alt='' src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' onmouseout=\"cleanhide('commentsup')\" onmouseover=\"cleandisplay('commentsup')\">";
     echo "<span class='over_link' id='commentsup'>" . nl2br(__('Depends on the tasks children', 'projet')) . "</span>";
     echo "</td>";
     echo "</tr>";
     $width_left = $width_right = "50%";
     $cols = 60;
     $rows = 4;
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'>";
     echo __('Name') . "</td><td  colspan='2'>";
     Html::autocompletionTextField($this, "name", array('size' => "30"));
     echo "<td >";
     echo _n('Type', 'Types', 1) . "</td><td>";
     Dropdown::show('PluginProjetTaskType', array('value' => $this->fields["plugin_projet_tasktypes_id"]));
     echo "</td>";
     echo "<td>";
     echo __('State') . "</td><td>";
     if ($ID > 0) {
         $this->dropdownState("plugin_projet_taskstates_id", $this->fields["plugin_projet_taskstates_id"], array('depends' => $this->fields["depends"], 'id' => $this->fields["id"], 'plugin_projet_projets_id' => $plugin_projet_projets_id));
     } else {
         Dropdown::show('PluginProjetTaskState', array('value' => $this->fields["plugin_projet_taskstates_id"]));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'>";
     echo _n('Location', 'Locations', 1) . "</td><td  colspan='2'>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"]));
     echo "</td>";
     echo "<td>";
     echo __('Priority') . "</td><td>";
     Ticket::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
     echo "</td>";
     echo "<td>" . __('Progress') . "</td><td>";
     $advance = floor($this->fields["advance"]);
     echo "<select name='advance'>";
     if (empty($ID) || $this->fields["depends"] == 0) {
         for ($i = 0; $i < 101; $i += 5) {
             echo "<option value='{$i}' ";
             if ($advance == $i) {
                 echo "selected";
             }
             echo " >{$i}</option>";
         }
     } else {
         if ($this->fields["depends"] != 0) {
             for ($i = 0; $i < 100; $i += 5) {
                 echo "<option value='{$i}' ";
                 if ($advance == $i) {
                     echo "selected";
                 }
                 echo " >{$i}</option>";
             }
         }
     }
     echo "</select> %";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_3'>";
     echo "<td colspan='4'>" . __('Assigned to') . "</td>";
     echo "<td colspan='4'>" . __('Planification', 'projet') . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4' width='{$width_left}'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td>" . _n('User', 'Users', 1) . "</td><td>";
     $this->dropdownItems($this->fields["plugin_projet_projets_id"], "users_id", array(), $this->fields["users_id"], 'User');
     echo "</td></tr>";
     echo "<tr><td>" . _n('Group', 'Groups', 1) . "</td><td>";
     $this->dropdownItems($this->fields["plugin_projet_projets_id"], "groups_id", array(), $this->fields["groups_id"], 'Group');
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>" . _n('Supplier', 'Suppliers', 1) . "</td><td>";
     $this->dropdownItems($this->fields["plugin_projet_projets_id"], "contacts_id", array(), $this->fields["contacts_id"], 'Supplier');
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "<td colspan='4' width='{$width_right}' valign='top'>";
     echo "<table width='100%'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Effective duration', 'projet') . "</td><td>";
     $toadd = array();
     for ($i = 9; $i <= 100; $i++) {
         $toadd[] = $i * HOUR_TIMESTAMP;
     }
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Planning') . "</td>";
     echo "<td>";
     $plan = new PluginProjetTaskPlanning();
     $plan->showFormForTask($plugin_projet_projets_id, $this);
     echo "</td></tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_3'>";
     $colspan = '8';
     if (!empty($ID)) {
         $colspan = '4';
     }
     echo "<td colspan='" . $colspan . "'>" . __('Description') . "</td>";
     if (!empty($ID)) {
         echo "<td colspan='4'>" . __('Results') . "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='" . $colspan . "' width='{$width_left}'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td>";
     echo "<textarea name='comment' cols='{$cols}' rows='{$rows}'>" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "</table>";
     if (!empty($ID)) {
         echo "</td>";
         echo "<td colspan='4' width='{$width_left}'>";
         echo "<table width='100%'>";
         echo "<tr>";
         echo "<td>";
         echo "<textarea name='sub' cols='{$cols}' rows='{$rows}'>" . $this->fields["sub"] . "</textarea>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_3'>";
     echo "<td colspan='4'>" . __('Others participants', 'projet') . "</td>";
     echo "<td colspan='4'>" . __('Affected people', 'projet') . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='4' width='{$width_left}'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td>";
     echo "<textarea name='others' cols='{$cols}' rows='2'>" . $this->fields["others"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "<td colspan='4' width='{$width_right}' valign='top'>";
     echo "<table width='100%'>";
     echo "<tr>";
     echo "<td>";
     echo "<textarea name='affect' cols='{$cols}' rows='2'>" . $this->fields["affect"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td  colspan='2'>" . __('Send email', 'projet') . "</td><td colspan='2'>";
     echo "<input type='checkbox' name='send_notification'";
     echo " value='1'>";
     echo "</td>";
     echo "<td colspan='4' align='center'>" . __('Display on the Gantt', 'projet') . " ";
     Dropdown::showYesNo("show_gantt", $this->fields["show_gantt"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='8' align='center'>";
     $datestring = __('Last update') . ": ";
     $date = Html::convDateTime($this->fields["date_mod"]);
     echo $datestring . $date . "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
Exemple #16
0
 function showForm($ID, $options = array())
 {
     global $DB, $CFG_GLPI;
     $default_values = self::getDefaultValues();
     // Get default values from posted values on reload form
     // On get because of tabs
     // we use REQUEST because method differ with layout (lefttab : GET, vsplit: POST)
     if (!isset($options['template_preview'])) {
         if (isset($_REQUEST)) {
             $values = Html::cleanPostForTextArea($_REQUEST);
         }
     }
     // Restore saved value or override with page parameter
     $saved = $this->restoreInput();
     foreach ($default_values as $name => $value) {
         if (!isset($values[$name])) {
             if (isset($saved[$name])) {
                 $values[$name] = $saved[$name];
             } else {
                 $values[$name] = $value;
             }
         }
     }
     if (isset($values['content'])) {
         // Clean new lines to be fix encoding
         $order = array('\\r', '\\n', "\\");
         $replace = array("", "", "");
         $values['content'] = str_replace($order, $replace, $values['content']);
     }
     if (isset($values['name'])) {
         $values['name'] = str_replace("\\", "", $values['name']);
     }
     if (!$ID) {
         // Override defaut values from projecttask if needed
         if (isset($options['_projecttasks_id'])) {
             $pt = new ProjectTask();
             if ($pt->getFromDB($options['_projecttasks_id'])) {
                 $values['name'] = $pt->getField('name');
                 $values['content'] = $pt->getField('name');
             }
         }
     }
     // Check category / type validity
     if ($values['itilcategories_id']) {
         $cat = new ITILCategory();
         if ($cat->getFromDB($values['itilcategories_id'])) {
             switch ($values['type']) {
                 case self::INCIDENT_TYPE:
                     if (!$cat->getField('is_incident')) {
                         $values['itilcategories_id'] = 0;
                     }
                     break;
                 case self::DEMAND_TYPE:
                     if (!$cat->getField('is_request')) {
                         $values['itilcategories_id'] = 0;
                     }
                     break;
                 default:
                     break;
             }
         }
     }
     // Default check
     if ($ID > 0) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE, $values);
     }
     if (!$ID) {
         $this->userentities = array();
         if ($values["_users_id_requester"]) {
             //Get all the user's entities
             $all_entities = Profile_User::getUserEntities($values["_users_id_requester"], true, true);
             //For each user's entity, check if the technician which creates the ticket have access to it
             foreach ($all_entities as $tmp => $ID_entity) {
                 if (Session::haveAccessToEntity($ID_entity)) {
                     $this->userentities[] = $ID_entity;
                 }
             }
         }
         $this->countentitiesforuser = count($this->userentities);
         if ($this->countentitiesforuser > 0 && !in_array($this->fields["entities_id"], $this->userentities)) {
             // If entity is not in the list of user's entities,
             // then use as default value the first value of the user's entites list
             $this->fields["entities_id"] = $this->userentities[0];
             // Pass to values
             $values['entities_id'] = $this->userentities[0];
         }
     }
     if ($values['type'] <= 0) {
         $values['type'] = Entity::getUsedConfig('tickettype', $values['entities_id'], '', Ticket::INCIDENT_TYPE);
     }
     if (!isset($options['template_preview'])) {
         $options['template_preview'] = 0;
     }
     // Load ticket template if available :
     if ($ID) {
         $tt = $this->getTicketTemplateToUse($options['template_preview'], $this->fields['type'], $this->fields['itilcategories_id'], $this->fields['entities_id']);
     } else {
         $tt = $this->getTicketTemplateToUse($options['template_preview'], $values['type'], $values['itilcategories_id'], $values['entities_id']);
     }
     // Predefined fields from template : reset them
     if (isset($values['_predefined_fields'])) {
         $values['_predefined_fields'] = Toolbox::decodeArrayFromInput($values['_predefined_fields']);
     } else {
         $values['_predefined_fields'] = array();
     }
     // Store predefined fields to be able not to take into account on change template
     // Only manage predefined values on ticket creation
     $predefined_fields = array();
     if (!$ID) {
         if (isset($tt->predefined) && count($tt->predefined)) {
             foreach ($tt->predefined as $predeffield => $predefvalue) {
                 if (isset($default_values[$predeffield])) {
                     // Is always default value : not set
                     // Set if already predefined field
                     // Set if ticket template change
                     if (count($values['_predefined_fields']) == 0 && $values[$predeffield] == $default_values[$predeffield] || isset($values['_predefined_fields'][$predeffield]) && $values[$predeffield] == $values['_predefined_fields'][$predeffield] || isset($values['_tickettemplates_id']) && $values['_tickettemplates_id'] != $tt->getID() || $predeffield == 'requesttypes_id' && empty($saved)) {
                         // Load template data
                         $values[$predeffield] = $predefvalue;
                         $this->fields[$predeffield] = $predefvalue;
                         $predefined_fields[$predeffield] = $predefvalue;
                     }
                 }
             }
             // All predefined override : add option to say predifined exists
             if (count($predefined_fields) == 0) {
                 $predefined_fields['_all_predefined_override'] = 1;
             }
         } else {
             // No template load : reset predefined values
             if (count($values['_predefined_fields'])) {
                 foreach ($values['_predefined_fields'] as $predeffield => $predefvalue) {
                     if ($values[$predeffield] == $predefvalue) {
                         $values[$predeffield] = $default_values[$predeffield];
                     }
                 }
             }
         }
     }
     // Put ticket template on $values for actors
     $values['_tickettemplate'] = $tt;
     $canupdate = Session::haveRight(self::$rightname, UPDATE);
     $canpriority = Session::haveRight(self::$rightname, self::CHANGEPRIORITY);
     $canstatus = $canupdate;
     if ($ID && in_array($this->fields['status'], $this->getClosedStatusArray())) {
         $canupdate = false;
         // No update for actors
         $values['_noupdate'] = true;
     }
     $showuserlink = 0;
     if (Session::haveRight('user', READ)) {
         $showuserlink = 1;
     }
     if ($options['template_preview']) {
         // Add all values to fields of tickets for template preview
         foreach ($values as $key => $val) {
             if (!isset($this->fields[$key])) {
                 $this->fields[$key] = $val;
             }
         }
     }
     // In percent
     $colsize1 = '13';
     $colsize2 = '29';
     $colsize3 = '13';
     $colsize4 = '45';
     $canupdate_descr = $canupdate || $this->fields['status'] == self::INCOMING && $this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) && $this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0;
     if (!$options['template_preview']) {
         echo "<form method='post' name='form_ticket' enctype='multipart/form-data' action='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php'>";
         if (isset($options['_projecttasks_id'])) {
             echo "<input type='hidden' name='_projecttasks_id' value='" . $options['_projecttasks_id'] . "'>";
         }
     }
     echo "<div class='spaced' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe' id='mainformtable'>";
     // Optional line
     $ismultientities = Session::isMultiEntitiesMode();
     echo "<tr class='headerRow responsive_hidden'>";
     echo "<th colspan='4'>";
     if ($ID) {
         $text = sprintf(__('%1$s - %2$s'), $this->getTypeName(1), sprintf(__('%1$s: %2$s'), __('ID'), $ID));
         if ($ismultientities) {
             $text = sprintf(__('%1$s (%2$s)'), $text, Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']));
         }
         echo $text;
     } else {
         if ($ismultientities) {
             printf(__('The ticket will be added in the entity %s'), Dropdown::getDropdownName("glpi_entities", $this->fields['entities_id']));
         } else {
             _e('New ticket');
         }
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Opening date'), $tt->getMandatoryMark('date'));
     } else {
         _e('Opening date');
     }
     echo $tt->getEndHiddenFieldText('date');
     echo "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('date');
     $date = $this->fields["date"];
     if ($canupdate) {
         Html::showDateTimeField("date", array('value' => $date, 'timestep' => 1, 'maybeempty' => false));
     } else {
         echo Html::convDateTime($date);
     }
     echo $tt->getEndHiddenFieldValue('date', $this);
     echo "</td><td colspan='2'></td></tr>";
     // SLTs
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('time_to_own');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Time to own'), $tt->getMandatoryMark('time_to_own'));
     } else {
         _e('Time to own');
     }
     echo $tt->getEndHiddenFieldText('time_to_own');
     echo "</th>";
     echo "<td width='{$colsize2}%' class='nopadding'>";
     $slt = new SLT();
     $slt->showSltForTicket($this, SLT::TTO, $tt, $canupdate);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('due_date');
     if (!$ID) {
         printf(__('%1$s%2$s'), __('Time to resolve'), $tt->getMandatoryMark('due_date'));
     } else {
         _e('Time to resolve');
     }
     echo $tt->getEndHiddenFieldText('due_date');
     echo "</th>";
     echo "<td width='{$colsize4}%' class='nopadding'>";
     $slt->showSltForTicket($this, SLT::TTR, $tt, $canupdate);
     echo "</td>";
     echo "</tr>";
     if ($ID) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('By') . "</th>";
         echo "<td width='{$colsize2}%'>";
         if ($canupdate) {
             User::dropdown(array('name' => 'users_id_recipient', 'value' => $this->fields["users_id_recipient"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
         } else {
             echo getUserName($this->fields["users_id_recipient"], $showuserlink);
         }
         echo "</td>";
         echo "<th width='{$colsize3}%'>" . __('Last update') . "</th>";
         echo "<td width='{$colsize4}%'>";
         if ($this->fields['users_id_lastupdater'] > 0) {
             //TRANS: %1$s is the update date, %2$s is the last updater name
             printf(__('%1$s by %2$s'), Html::convDateTime($this->fields["date_mod"]), getUserName($this->fields["users_id_lastupdater"], $showuserlink));
         }
         echo "</td>";
         echo "</tr>";
     }
     if ($ID && (in_array($this->fields["status"], $this->getSolvedStatusArray()) || in_array($this->fields["status"], $this->getClosedStatusArray()))) {
         echo "<tr class='tab_bg_1'>";
         echo "<th width='{$colsize1}%'>" . __('Resolution date') . "</th>";
         echo "<td width='{$colsize2}%'>";
         Html::showDateTimeField("solvedate", array('value' => $this->fields["solvedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
         echo "</td>";
         if (in_array($this->fields["status"], $this->getClosedStatusArray())) {
             echo "<th width='{$colsize3}%'>" . __('Close date') . "</th>";
             echo "<td width='{$colsize4}%'>";
             Html::showDateTimeField("closedate", array('value' => $this->fields["closedate"], 'timestep' => 1, 'maybeempty' => false, 'canedit' => $canupdate));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
     }
     if ($ID) {
         echo "</table>";
         echo "<table  class='tab_cadre_fixe' id='mainformtable2'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . sprintf(__('%1$s%2$s'), __('Type'), $tt->getMandatoryMark('type')) . "</th>";
     echo "<td width='{$colsize2}%'>";
     // Permit to set type when creating ticket without update right
     if ($canupdate || !$ID) {
         $opt = array('value' => $this->fields["type"]);
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'this.form.submit()';
         }
         $rand = self::dropdownType('type', $opt);
         if ($ID) {
             $params = array('type' => '__VALUE__', 'entity_restrict' => $this->fields['entities_id'], 'value' => $this->fields['itilcategories_id'], 'currenttype' => $this->fields['type']);
             Ajax::updateItemOnSelectEvent("dropdown_type{$rand}", "show_category_by_type", $CFG_GLPI["root_doc"] . "/ajax/dropdownTicketCategories.php", $params);
         }
     } else {
         echo self::getTicketTypeName($this->fields["type"]);
     }
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . sprintf(__('%1$s%2$s'), __('Category'), $tt->getMandatoryMark('itilcategories_id')) . "</th>";
     echo "<td width='{$colsize4}%'>";
     // Permit to set category when creating ticket without update right
     if ($canupdate || !$ID || $canupdate_descr) {
         $opt = array('value' => $this->fields["itilcategories_id"], 'entity' => $this->fields["entities_id"]);
         if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
             $opt['condition'] = "`is_helpdeskvisible`='1' AND ";
         } else {
             $opt['condition'] = '';
         }
         /// Auto submit to load template
         if (!$ID) {
             $opt['on_change'] = 'this.form.submit()';
         }
         /// if category mandatory, no empty choice
         /// no empty choice is default value set on ticket creation, else yes
         if (($ID || $values['itilcategories_id']) && $tt->isMandatoryField("itilcategories_id") && $this->fields["itilcategories_id"] > 0) {
             $opt['display_emptychoice'] = false;
         }
         switch ($this->fields["type"]) {
             case self::INCIDENT_TYPE:
                 $opt['condition'] .= "`is_incident`='1'";
                 break;
             case self::DEMAND_TYPE:
                 $opt['condition'] .= "`is_request`='1'";
                 break;
             default:
                 break;
         }
         echo "<span id='show_category_by_type'>";
         ITILCategory::dropdown($opt);
         echo "</span>";
     } else {
         echo Dropdown::getDropdownName("glpi_itilcategories", $this->fields["itilcategories_id"]);
     }
     echo "</td>";
     echo "</tr>";
     if (!$ID) {
         echo "</table>";
         $this->showActorsPartForm($ID, $values);
         echo "<table class='tab_cadre_fixe' id='mainformtable3'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<th width='{$colsize1}%'>" . $tt->getBeginHiddenFieldText('status');
     printf(__('%1$s%2$s'), __('Status'), $tt->getMandatoryMark('status'));
     echo $tt->getEndHiddenFieldText('status') . "</th>";
     echo "<td width='{$colsize2}%'>";
     echo $tt->getBeginHiddenFieldValue('status');
     if ($canstatus) {
         self::dropdownStatus(array('value' => $this->fields["status"], 'showtype' => 'allowed'));
         TicketValidation::alertValidation($this, 'status');
     } else {
         echo self::getStatus($this->fields["status"]);
         if (in_array($this->fields["status"], $this->getClosedStatusArray()) && $this->isAllowedStatus($this->fields['status'], Ticket::INCOMING)) {
             echo "&nbsp;<a class='vsubmit' href='" . $this->getLinkURL() . "&amp;forcetab=TicketFollowup\$1&amp;_openfollowup=1'>" . __('Reopen') . "</a>";
         }
     }
     echo $tt->getEndHiddenFieldValue('status', $this);
     echo "</td>";
     echo "<th width='{$colsize3}%'>" . $tt->getBeginHiddenFieldText('requesttypes_id');
     printf(__('%1$s%2$s'), __('Request source'), $tt->getMandatoryMark('requesttypes_id'));
     echo $tt->getEndHiddenFieldText('requesttypes_id') . "</th>";
     echo "<td width='{$colsize4}%'>";
     echo $tt->getBeginHiddenFieldValue('requesttypes_id');
     if ($canupdate) {
         RequestType::dropdown(array('value' => $this->fields["requesttypes_id"], 'condition' => 'is_active = 1 AND is_ticketheader = 1'));
     } else {
         echo Dropdown::getDropdownName('glpi_requesttypes', $this->fields["requesttypes_id"]);
         echo Html::hidden('requesttypes_id', array('value' => $this->fields["requesttypes_id"]));
     }
     echo $tt->getEndHiddenFieldValue('requesttypes_id', $this);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('urgency');
     printf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency'));
     echo $tt->getEndHiddenFieldText('urgency') . "</th>";
     echo "<td>";
     if ($canupdate && $canpriority || !$ID || $canupdate_descr) {
         // Only change during creation OR when allowed to change priority OR when user is the creator
         echo $tt->getBeginHiddenFieldValue('urgency');
         $idurgency = self::dropdownUrgency(array('value' => $this->fields["urgency"]));
         echo $tt->getEndHiddenFieldValue('urgency', $this);
     } else {
         $idurgency = "value_urgency" . mt_rand();
         echo "<input id='{$idurgency}' type='hidden' name='urgency' value='" . $this->fields["urgency"] . "'>";
         echo $tt->getBeginHiddenFieldValue('urgency');
         echo parent::getUrgencyName($this->fields["urgency"]);
         echo $tt->getEndHiddenFieldValue('urgency', $this);
     }
     echo "</td>";
     // Display validation state
     echo "<th>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldText('_add_validation');
         printf(__('%1$s%2$s'), __('Approval request'), $tt->getMandatoryMark('_add_validation'));
         echo $tt->getEndHiddenFieldText('_add_validation');
     } else {
         echo $tt->getBeginHiddenFieldText('global_validation');
         _e('Approval');
         echo $tt->getEndHiddenFieldText('global_validation');
     }
     echo "</th>";
     echo "<td>";
     if (!$ID) {
         echo $tt->getBeginHiddenFieldValue('_add_validation');
         $validation_right = '';
         if ($values['type'] == self::INCIDENT_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT)) {
             $validation_right = 'validate_incident';
         }
         if ($values['type'] == self::DEMAND_TYPE && Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) {
             $validation_right = 'validate_request';
         }
         if (!empty($validation_right)) {
             echo "<input type='hidden' name='_add_validation' value='" . $values['_add_validation'] . "'>";
             $params = array('name' => "users_id_validate", 'entity' => $this->fields['entities_id'], 'right' => $validation_right, 'users_id_validate' => $values['users_id_validate']);
             TicketValidation::dropdownValidator($params);
         }
         echo $tt->getEndHiddenFieldValue('_add_validation', $this);
         if ($tt->isPredefinedField('global_validation')) {
             echo "<input type='hidden' name='global_validation' value='" . $tt->predefined['global_validation'] . "'>";
         }
     } else {
         echo $tt->getBeginHiddenFieldValue('global_validation');
         if (Session::haveRightsOr('ticketvalidation', TicketValidation::getCreateRights()) && $canupdate) {
             TicketValidation::dropdownStatus('global_validation', array('global' => true, 'value' => $this->fields['global_validation']));
         } else {
             echo TicketValidation::getStatus($this->fields['global_validation']);
         }
         echo $tt->getEndHiddenFieldValue('global_validation', $this);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('impact');
     printf(__('%1$s%2$s'), __('Impact'), $tt->getMandatoryMark('impact'));
     echo $tt->getEndHiddenFieldText('impact') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('impact');
     if ($canupdate) {
         $idimpact = self::dropdownImpact(array('value' => $this->fields["impact"]));
     } else {
         $idimpact = "value_impact" . mt_rand();
         echo "<input id='{$idimpact}' type='hidden' name='impact' value='" . $this->fields["impact"] . "'>";
         echo parent::getImpactName($this->fields["impact"]);
     }
     echo $tt->getEndHiddenFieldValue('impact', $this);
     echo "</td>";
     echo "<th>" . $tt->getBeginHiddenFieldText('locations_id');
     printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
     echo $tt->getEndHiddenFieldText('locations_id') . "</th>";
     echo "<td>";
     echo $tt->getBeginHiddenFieldValue('locations_id');
     if ($canupdate || !$ID) {
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $this->fields['entities_id']));
     } else {
         echo Dropdown::getDropdownName('glpi_locations', $this->fields["locations_id"]);
     }
     echo $tt->getEndHiddenFieldValue('locations_id', $this);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th>" . $tt->getBeginHiddenFieldText('priority');
     printf(__('%1$s%2$s'), __('Priority'), $tt->getMandatoryMark('priority'));
     echo $tt->getEndHiddenFieldText('priority') . "</th>";
     echo "<td>";
     $idajax = 'change_priority_' . mt_rand();
     if ($canpriority && !$tt->isHiddenField('priority')) {
         $idpriority = parent::dropdownPriority(array('value' => $this->fields["priority"], 'withmajor' => true));
         $idpriority = 'dropdown_priority' . $idpriority;
         echo "&nbsp;<span id='{$idajax}' style='display:none'></span>";
     } else {
         $idpriority = 0;
         echo $tt->getBeginHiddenFieldValue('priority');
         echo "<span id='{$idajax}'>" . parent::getPriorityName($this->fields["priority"]) . "</span>";
         echo $tt->getEndHiddenFieldValue('priority', $this);
     }
     if ($canupdate || $canupdate_descr) {
         $params = array('urgency' => '__VALUE0__', 'impact' => '__VALUE1__', 'priority' => $idpriority);
         Ajax::updateItemOnSelectEvent(array('dropdown_urgency' . $idurgency, 'dropdown_impact' . $idimpact), $idajax, $CFG_GLPI["root_doc"] . "/ajax/priority.php", $params);
     }
     echo "</td>";
     echo "<th rowspan='2'>" . $tt->getBeginHiddenFieldText('items_id');
     printf(__('%1$s%2$s'), _n('Associated element', 'Associated elements', Session::getPluralNumber()), $tt->getMandatoryMark('items_id'));
     if ($ID && $canupdate) {
         echo "&nbsp;<a  href='" . $this->getFormURL() . "?id=" . $ID . "&amp;forcetab=Item_Ticket\$1'><img title='" . __s('Update') . "' alt='" . __s('Update') . "'\n                      class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/showselect.png'></a>";
     }
     echo $tt->getEndHiddenFieldText('items_id');
     echo "</th>";
     if (!$ID) {
         echo "<td rowspan='2'>";
         echo $tt->getBeginHiddenFieldValue('items_id');
         $values['_canupdate'] = Session::haveRight('ticket', CREATE);
         if ($values['_canupdate']) {
             Item_Ticket::itemAddForm($this, $values);
         }
         echo $tt->getEndHiddenFieldValue('items_id', $this);
         echo "</td>";
     } else {
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('items_id');
         $values['_canupdate'] = $canupdate || $canupdate_descr;
         Item_Ticket::itemAddForm($this, $values);
         echo $tt->getEndHiddenFieldValue('items_id', $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     // Need comment right to add a followup with the actiontime
     if (!$ID && Session::haveRight('followup', TicketFollowup::ADDALLTICKET)) {
         echo "<th>" . $tt->getBeginHiddenFieldText('actiontime');
         printf(__('%1$s%2$s'), __('Total duration'), $tt->getMandatoryMark('actiontime'));
         echo $tt->getEndHiddenFieldText('actiontime') . "</th>";
         echo "<td>";
         echo $tt->getBeginHiddenFieldValue('actiontime');
         Dropdown::showTimeStamp('actiontime', array('value' => $values['actiontime'], 'addfirstminutes' => true));
         echo $tt->getEndHiddenFieldValue('actiontime', $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "</table>";
     if ($ID) {
         $this->showActorsPartForm($ID, $values);
     }
     $view_linked_tickets = $ID || $canupdate;
     echo "<table class='tab_cadre_fixe' id='mainformtable4'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('name');
     printf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name'));
     echo $tt->getEndHiddenFieldText('name') . "</th>";
     echo "<td colspan='3'>";
     if (!$ID || $canupdate_descr) {
         echo $tt->getBeginHiddenFieldValue('name');
         echo "<input type='text' style='width:98%' maxlength=250 name='name' " . " value=\"" . Html::cleanInputText($this->fields["name"]) . "\">";
         echo $tt->getEndHiddenFieldValue('name', $this);
     } else {
         if (empty($this->fields["name"])) {
             _e('Without title');
         } else {
             echo $this->fields["name"];
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th style='width:{$colsize1}%'>" . $tt->getBeginHiddenFieldText('content');
     printf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content'));
     if (!$ID || $canupdate_descr) {
         $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         Html::showTooltip(nl2br(Html::Clean($content)));
     }
     echo $tt->getEndHiddenFieldText('content') . "</th>";
     echo "<td colspan='3'>";
     if (!$ID || $canupdate_descr) {
         // Admin =oui on autorise la modification de la description
         echo $tt->getBeginHiddenFieldValue('content');
         $rand = mt_rand();
         $rand_text = mt_rand();
         $rows = 6;
         $content_id = "content{$rand}";
         if ($CFG_GLPI["use_rich_text"]) {
             $this->fields["content"] = $this->setRichTextContent($content_id, $this->fields["content"], $rand);
             $rows = 10;
         } else {
             $this->fields["content"] = $this->setSimpleTextContent($this->fields["content"]);
         }
         echo "<div id='content{$rand_text}'>";
         echo "<textarea id='{$content_id}' name='content' style='width:100%' rows='{$rows}'>" . $this->fields["content"] . "</textarea></div>";
         echo Html::scriptBlock("\$(document).ready(function() { \$('#{$content_id}').autogrow(); });");
         echo $tt->getEndHiddenFieldValue('content', $this);
     } else {
         $content = Toolbox::unclean_cross_side_scripting_deep(Html::entity_decode_deep($this->fields['content']));
         echo nl2br(Html::Clean($content));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     if ($view_linked_tickets) {
         echo "<th style='width:{$colsize1}%'>" . _n('Linked ticket', 'Linked tickets', Session::getPluralNumber());
         $rand_linked_ticket = mt_rand();
         if ($canupdate) {
             echo "&nbsp;";
             echo "<img onClick=\"" . Html::jsShow("linkedticket{$rand_linked_ticket}") . "\"\n                   title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                   class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         }
         echo '</th>';
         echo "<td colspan='3'>";
         if ($canupdate) {
             echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>";
             echo "<table class='tab_format' width='100%'><tr><td width='30%'>";
             Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
             echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n";
             echo "</td><td width='70%'>";
             $linkparam = array('name' => '_link[tickets_id_2]', 'displaywith' => array('id'));
             if (isset($values["_link"])) {
                 $linkparam['value'] = $values["_link"]['tickets_id_2'];
             }
             Ticket::dropdown($linkparam);
             echo "</td></tr></table>";
             echo "</div>";
             if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) {
                 echo "<script language='javascript'>";
                 echo Html::jsShow("linkedticket{$rand_linked_ticket}");
                 echo "</script>";
             }
         }
         Ticket_Ticket::displayLinkedTicketsTo($ID);
         echo "</td>";
     }
     echo "</tr>";
     // View files added
     echo "<tr class='tab_bg_1'>";
     // Permit to add doc when creating a ticket
     echo "<th style='width:{$colsize1}%'>";
     echo $tt->getBeginHiddenFieldText('_documents_id');
     $doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize());
     printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id'));
     // Do not show if hidden.
     if (!$tt->isHiddenField('_documents_id')) {
         DocumentType::showAvailableTypesLink();
     }
     echo $tt->getEndHiddenFieldText('_documents_id');
     echo "</th>";
     echo "<td colspan='3'>";
     // Do not set values
     echo $tt->getEndHiddenFieldValue('_documents_id');
     if ($tt->isPredefinedField('_documents_id')) {
         if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) {
             echo "<span class='b'>" . __('Default documents:') . '</span>';
             echo "<br>";
             $doc = new Document();
             foreach ($values['_documents_id'] as $key => $val) {
                 if ($doc->getFromDB($val)) {
                     echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>";
                     echo "- " . $doc->getNameID() . "<br>";
                 }
             }
         }
     }
     echo "<div id='fileupload_info'></div>";
     echo "</td>";
     echo "</tr>";
     if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) {
         echo "<tr class='tab_bg_1'>";
         if ($ID) {
             if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) {
                 echo "<td class='tab_bg_2 center' colspan='4'>";
                 if ($this->fields["is_deleted"] == 1) {
                     if (self::canPurge()) {
                         echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 } else {
                     if (self::canUpdate()) {
                         echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                     }
                 }
                 if ($this->fields["is_deleted"] == 1) {
                     if (self::canPurge()) {
                         echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
                     }
                 } else {
                     if ($this->canDeleteItem()) {
                         echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>";
                     }
                 }
                 echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
                 echo "</td>";
             }
         } else {
             echo "<td class='tab_bg_2 center' colspan='4'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             if ($tt->isField('id') && $tt->fields['id'] > 0) {
                 echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
                 echo "<input type='hidden' name='_predefined_fields'\n                      value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
             }
         }
     }
     // File upload system
     $colspan = 3;
     if (!$CFG_GLPI['use_rich_text']) {
         $colspan = 4;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='{$colspan}'>";
     echo $tt->getBeginHiddenFieldValue('_documents_id');
     echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename'])));
     echo "</td>";
     if ($CFG_GLPI['use_rich_text']) {
         echo "</tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='{$colspan}'>";
         if (!isset($rand)) {
             $rand = mt_rand();
         }
         if ($canupdate_descr) {
             echo Html::initImagePasteSystem($content_id, $rand);
         }
         echo "</td>";
     }
     echo "</tr>";
     echo "</table>";
     echo "<input type='hidden' name='id' value='{$ID}'>";
     echo "</div>";
     if (!$options['template_preview']) {
         Html::closeForm();
     }
     return true;
 }
Exemple #17
0
 /**
  * Former front/planning.php before 9.1.
  * Display a classic form to plan an event (with begin fiel and duration)
  *
  * @since 9.1
  *
  * @param $params (array): array of parameters whou should contain :
  *   - id (integer): id of item who receive the planification
  *   - itemtype (string): itemtype of item who receive the planification
  *   - begin (string) : start date of event
  *   - end (optionnal) (string) : end date of event. Ifg missing, it will computerd from begin+1hour
  *   - rand_user (integer) : users_id to check planning avaibility
  */
 static function showAddEventClassicForm($params = array())
 {
     global $CFG_GLPI;
     if (isset($params["id"]) && $params["id"] > 0) {
         echo "<input type='hidden' name='plan[id]' value='" . $params["id"] . "'>";
     }
     $mintime = $CFG_GLPI["planning_begin"];
     if (isset($params["begin"]) && !empty($params["begin"])) {
         $begin = $params["begin"];
         $begintime = date("H:i:s", strtotime($begin));
         if ($begintime < $mintime) {
             $mintime = $begintime;
         }
     } else {
         $ts = $CFG_GLPI['time_step'] * 60;
         // passage en minutes
         $time = time() + $ts - 60;
         $time = floor($time / $ts) * $ts;
         $begin = date("Y-m-d H:i", $time);
     }
     if (isset($params["end"]) && !empty($params["end"])) {
         $end = $params["end"];
     } else {
         $end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP);
     }
     echo "<table class='tab_cadre'>";
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     $rand_begin = Html::showDateTimeField("plan[begin]", array('value' => $begin, 'timestep' => -1, 'maybeempty' => false, 'canedit' => true, 'mindate' => '', 'maxdate' => '', 'mintime' => $mintime, 'maxtime' => $CFG_GLPI["planning_end"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_2'><td>" . __('Period') . "&nbsp;";
     if (isset($params["rand_user"])) {
         echo "<span id='user_available" . $params["rand_user"] . "'>";
         include_once GLPI_ROOT . '/ajax/planningcheck.php';
         echo "</span>";
     }
     echo "</td><td>";
     $default_delay = floor((strtotime($end) - strtotime($begin)) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP;
     $rand = Dropdown::showTimeStamp("plan[_duration]", array('min' => 0, 'max' => 50 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $event_options = array('duration' => '__VALUE__', 'end' => $end, 'name' => "plan[end]", 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]);
     Ajax::updateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $event_options);
     if ($default_delay == 0) {
         $params['duration'] = 0;
         Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     }
     echo "</td></tr>\n";
     if ((!isset($params["id"]) || $params["id"] == 0) && isset($params['itemtype']) && PlanningRecall::isAvailable()) {
         echo "<tr class='tab_bg_2'><td>" . _x('Planning', 'Reminder') . "</td><td>";
         PlanningRecall::dropdown(array('itemtype' => $params['itemtype'], 'items_id' => $params['items_id']));
         echo "</td></tr>";
     }
     echo "</table>\n";
 }
} else {
    $end = date("Y-m-d H:i:s", strtotime($begin) + HOUR_TIMESTAMP);
}
echo "<table class='tab_cadre'>";
echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
$rand_begin = Html::showDateTimeField("plan[begin]", array('value' => $begin, 'timestep' => -1, 'maybeempty' => false, 'canedit' => true, 'mindate' => '', 'maxdate' => '', 'mintime' => $CFG_GLPI["planning_begin"], 'maxtime' => $CFG_GLPI["planning_end"]));
echo "</td></tr>\n";
echo "<tr class='tab_bg_2'><td>" . __('Period') . "&nbsp;";
if (isset($_POST["rand_user"])) {
    echo "<span id='user_available" . $_POST["rand_user"] . "'>";
    include_once GLPI_ROOT . '/ajax/planningcheck.php';
    echo "</span>";
}
echo "</td><td>";
$default_delay = floor((strtotime($end) - strtotime($begin)) / 15 / MINUTE_TIMESTAMP) * 15 * MINUTE_TIMESTAMP;
$rand = Dropdown::showTimeStamp("plan[_duration]", array('min' => 0, 'max' => 50 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
echo "<br><div id='date_end{$rand}'></div>";
$params = array('duration' => '__VALUE__', 'end' => $end, 'name' => "plan[end]", 'global_begin' => $CFG_GLPI["planning_begin"], 'global_end' => $CFG_GLPI["planning_end"]);
Ajax::updateItemOnSelectEvent("dropdown_plan[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
if ($default_delay == 0) {
    $params['duration'] = 0;
    Ajax::updateItem("date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
}
echo "</td></tr>\n";
if ((!isset($_POST["id"]) || $_POST["id"] == 0) && isset($_POST['itemtype']) && PlanningRecall::isAvailable()) {
    echo "<tr class='tab_bg_2'><td>" . _x('Planning', 'Reminder') . "</td><td>";
    PlanningRecall::dropdown(array('itemtype' => $_POST['itemtype'], 'items_id' => $_POST['items_id']));
    echo "</td></tr>";
}
echo "</table>\n";
Html::ajaxFooter();
 /**
  * Print the Project task form
  *
  * @param $ID        integer  Id of the project task
  * @param $options   array    of possible options:
  *     - target form target
  *     - projects_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if ($ID > 0) {
         $this->check($ID, READ);
         $projects_id = $this->fields['projects_id'];
         $projecttasks_id = $this->fields['projecttasks_id'];
     } else {
         $projects_id = $options['projects_id'];
         $projecttasks_id = $options['projecttasks_id'];
         $this->check(-1, CREATE, $options);
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . _n('Project', 'Projects', Session::getPluralNumber()) . "</td>";
     echo "<td>";
     if ($this->isNewID($ID)) {
         echo "<input type='hidden' name='projects_id' value='{$projects_id}'>";
     }
     echo "<a href='project.form.php?id=" . $projects_id . "'>" . Dropdown::getDropdownName("glpi_projects", $projects_id) . "</a>";
     echo "</td>";
     echo "<td>" . __('As child of') . "</td>";
     echo "<td>";
     $this->dropdown(array('entity' => $this->fields['entities_id'], 'value' => $projecttasks_id, 'condition' => "`glpi_projecttasks`.`projects_id`='" . $this->fields['projects_id'] . "'", 'used' => array($this->fields['id'])));
     echo "</td></tr>";
     $showuserlink = 0;
     if (Session::haveRight('user', READ)) {
         $showuserlink = 1;
     }
     if ($ID) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Creation date') . "</td>";
         echo "<td>";
         echo sprintf(__('%1$s by %2$s'), Html::convDateTime($this->fields["date"]), getUserName($this->fields["users_id"], $showuserlink));
         echo "</td>";
         echo "<td>" . __('Last update') . "</td>";
         echo "<td>";
         echo Html::convDateTime($this->fields["date_mod"]);
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td colspan='3'>";
     Html::autocompletionTextField($this, "name", array('size' => 80));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('item', 'State') . "</td>";
     echo "<td>";
     ProjectState::dropdown(array('value' => $this->fields["projectstates_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ProjectTaskType::dropdown(array('value' => $this->fields["projecttasktypes_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Percent done') . "</td>";
     echo "<td>";
     Dropdown::showNumber("percent_done", array('value' => $this->fields['percent_done'], 'min' => 0, 'max' => 100, 'step' => 5, 'unit' => '%'));
     echo "</td>";
     echo "<td>";
     _e('Milestone');
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("is_milestone", $this->fields["is_milestone"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr><td colspan='4' class='subheader'>" . __('Planning') . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Planned start date') . "</td>";
     echo "<td>";
     Html::showDateTimeField("plan_start_date", array('value' => $this->fields['plan_start_date']));
     echo "</td>";
     echo "<td>" . __('Real start date') . "</td>";
     echo "<td>";
     Html::showDateTimeField("real_start_date", array('value' => $this->fields['real_start_date']));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Planned end date') . "</td>";
     echo "<td>";
     Html::showDateTimeField("plan_end_date", array('value' => $this->fields['plan_end_date']));
     echo "</td>";
     echo "<td>" . __('Real end date') . "</td>";
     echo "<td>";
     Html::showDateTimeField("real_end_date", array('value' => $this->fields['real_end_date']));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Planned duration') . "</td>";
     echo "<td>";
     Dropdown::showTimeStamp("planned_duration", array('min' => 0, 'max' => 100 * HOUR_TIMESTAMP, 'step' => HOUR_TIMESTAMP, 'value' => $this->fields["planned_duration"], 'addfirstminutes' => true, 'inhours' => true));
     echo "</td>";
     echo "<td>" . __('Effective duration') . "</td>";
     echo "<td>";
     Dropdown::showTimeStamp("effective_duration", array('min' => 0, 'max' => 100 * HOUR_TIMESTAMP, 'step' => HOUR_TIMESTAMP, 'value' => $this->fields["effective_duration"], 'addfirstminutes' => true, 'inhours' => true));
     if ($ID) {
         $ticket_duration = ProjectTask_Ticket::getTicketsTotalActionTime($this->getID());
         echo "<br>";
         printf(__('%1$s: %2$s'), __('Tickets duration'), Html::timestampToString($ticket_duration, false));
         echo '<br>';
         printf(__('%1$s: %2$s'), __('Total duration'), Html::timestampToString($ticket_duration + $this->fields["effective_duration"], false));
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Description') . "</td>";
     echo "<td colspan='3'>";
     echo "<textarea id='content' name='content' cols='90' rows='6'>" . $this->fields["content"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Comments') . "</td>";
     echo "<td colspan='3'>";
     echo "<textarea id='comment' name='comment' cols='90' rows='6'>" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
Exemple #20
0
 static function showListSimple()
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight(self::$rightname, self::RESERVEANITEM)) {
         return false;
     }
     $ri = new self();
     $ok = false;
     $showentity = Session::isMultiEntitiesMode();
     $values = array();
     if (isset($_SESSION['glpi_saved']['ReservationItem'])) {
         $_POST = $_SESSION['glpi_saved']['ReservationItem'];
     }
     if (isset($_POST['reserve'])) {
         echo "<div id='viewresasearch'  class='center'>";
         Toolbox::manageBeginAndEndPlanDates($_POST['reserve']);
         echo "<div id='nosearch' class='center firstbloc'>" . "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/reservationitem.php\">";
         echo __('See all reservable items') . "</a></div>\n";
     } else {
         echo "<div id='makesearch' class='center firstbloc'>" . "<a class='pointer' onClick=\"javascript:showHideDiv('viewresasearch','','','');" . "showHideDiv('makesearch','','','')\">";
         echo __('Find a free item in a specific period') . "</a></div>\n";
         echo "<div id='viewresasearch' style=\"display:none;\" class='center'>";
         $begin_time = time();
         $begin_time -= $begin_time % HOUR_TIMESTAMP;
         $_POST['reserve']["begin"] = date("Y-m-d H:i:s", $begin_time);
         $_POST['reserve']["end"] = date("Y-m-d H:i:s", $begin_time + HOUR_TIMESTAMP);
         $_POST['reservation_types'] = '';
     }
     echo "<form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
     echo "<th colspan='3'>" . __('Find a free item in a specific period') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     Html::showDateTimeField("reserve[begin]", array('value' => $_POST['reserve']["begin"], 'maybeempty' => false));
     echo "</td><td rowspan='3'>";
     echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
     $default_delay = floor((strtotime($_POST['reserve']["end"]) - strtotime($_POST['reserve']["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
     $rand = Dropdown::showTimeStamp("reserve[_duration]", array('min' => 0, 'max' => 48 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $params = array('duration' => '__VALUE__', 'end' => $_POST['reserve']["end"], 'name' => "reserve[end]");
     Ajax::updateItemOnSelectEvent("dropdown_reserve[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Item type') . "</td><td>";
     $sql = "SELECT DISTINCT(`itemtype`)\n              FROM `glpi_reservationitems`\n              WHERE `is_active` = 1" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']);
     $result = $DB->query($sql);
     while ($data = $DB->fetch_assoc($result)) {
         $values[$data['itemtype']] = $data['itemtype']::getTypeName();
     }
     $query = "SELECT `glpi_peripheraltypes`.`name`, `glpi_peripheraltypes`.`id`\n                FROM `glpi_peripheraltypes`\n                LEFT JOIN `glpi_peripherals`\n                  ON `glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`\n                LEFT JOIN `glpi_reservationitems`\n                  ON `glpi_reservationitems`.`items_id` = `glpi_peripherals`.`id`\n                WHERE `itemtype` = 'Peripheral'\n                      AND `is_active` = 1\n                      AND `peripheraltypes_id`" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']) . "\n                ORDER BY `glpi_peripheraltypes`.`name`";
     foreach ($DB->request($query) as $ptype) {
         $id = $ptype['id'];
         $values["Peripheral#{$id}"] = $ptype['name'];
     }
     Dropdown::showFromArray("reservation_types", $values, array('value' => $_POST['reservation_types'], 'display_emptychoice' => true));
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
     // GET method passed to form creation
     echo "<div id='nosearch' class='center'>";
     echo "<form name='form' method='GET' action='reservation.form.php'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n";
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $itemtable = getTableForItemType($itemtype);
         $otherserial = "'' AS otherserial";
         if ($item->isField('otherserial')) {
             $otherserial = "`{$itemtable}`.`otherserial`";
         }
         $begin = $_POST['reserve']["begin"];
         $end = $_POST['reserve']["end"];
         $left = "";
         $where = "";
         if (isset($_POST['submit']) && isset($begin) && isset($end)) {
             $left = "LEFT JOIN `glpi_reservations`\n                        ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n                            AND '" . $begin . "' < `glpi_reservations`.`end`\n                            AND '" . $end . "' > `glpi_reservations`.`begin`)";
             $where = " AND `glpi_reservations`.`id` IS NULL ";
         }
         if (isset($_POST["reservation_types"]) && !empty($_POST["reservation_types"])) {
             $tmp = explode('#', $_POST["reservation_types"]);
             $where .= " AND `glpi_reservationitems`.`itemtype` = '" . $tmp[0] . "'";
             if (isset($tmp[1]) && $tmp[0] == 'Peripheral' && $itemtype == 'Peripheral') {
                 $left .= " LEFT JOIN `glpi_peripheraltypes`\n                              ON (`glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`)";
                 $where .= " AND `{$itemtable}`.`peripheraltypes_id` = '" . $tmp[1] . "'";
             }
         }
         $query = "SELECT `glpi_reservationitems`.`id`,\n                          `glpi_reservationitems`.`comment`,\n                          `{$itemtable}`.`name` AS name,\n                          `{$itemtable}`.`entities_id` AS entities_id,\n                          {$otherserial},\n                          `glpi_locations`.`id` AS location,\n                          `glpi_reservationitems`.`items_id` AS items_id\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `{$itemtable}`\n                        ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n                            AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n                   {$left}\n                   LEFT JOIN `glpi_locations`\n                        ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n                   WHERE `glpi_reservationitems`.`is_active` = '1'\n                         AND `glpi_reservationitems`.`is_deleted` = '0'\n                         AND `{$itemtable}`.`is_deleted` = '0'\n                         {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n                   ORDER BY `{$itemtable}`.`entities_id`,\n                            `{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             while ($row = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>";
                 $typename = $item->getTypeName();
                 if ($itemtype == 'Peripheral') {
                     $item->getFromDB($row['items_id']);
                     if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
                         $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
                     }
                 }
                 echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>" . sprintf(__('%1$s - %2$s'), $typename, $row["name"]) . "</a></td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_locations", $row["location"]) . "</td>";
                 echo "<td>" . nl2br($row["comment"]) . "</td>";
                 if ($showentity) {
                     echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>";
                 }
                 echo "</tr>\n";
                 $ok = true;
             }
         }
     }
     if ($ok) {
         echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>";
         if (isset($_POST['reserve'])) {
             echo Html::hidden('begin', array('value' => $_POST['reserve']["begin"]));
             echo Html::hidden('end', array('value' => $_POST['reserve']["end"]));
         }
         echo "<input type='submit' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>\n";
     }
     echo "</table>\n";
     echo "<input type='hidden' name='id' value=''>";
     echo "</form>";
     // No CSRF token needed
     echo "</div>\n";
 }
            echo "&nbsp;<input type='submit' name='delete_checklist' class='submit' value='" . _sx('button', 'Post') . "'></td>";
            break;
        case "open_checklist":
            echo "<input type='hidden' name='checklist_type' value='" . $_POST['checklist_type'] . "'>";
            echo "<input type='hidden' name='plugin_resources_resources_id' value='" . $_POST['plugin_resources_resources_id'] . "'>";
            echo "&nbsp;<input type='submit' name='open_checklist' class='submit' value='" . _sx('button', 'Post') . "'></td>";
            break;
        case "close_checklist":
            echo "<input type='hidden' name='checklist_type' value='" . $_POST['checklist_type'] . "'>";
            echo "<input type='hidden' name='plugin_resources_resources_id' value='" . $_POST['plugin_resources_resources_id'] . "'>";
            echo "<input type='hidden' name='entities_id' value='" . $_POST['entities_id'] . "'>";
            echo "&nbsp;";
            _e('Templates');
            echo "&nbsp;";
            Dropdown::show('TicketTemplate', array('name' => 'tickettemplates_id', 'entities_id' => $_POST["entities_id"]));
            echo "&nbsp;";
            _e('Total duration');
            echo "&nbsp;";
            Dropdown::showTimeStamp('actiontime', array('addfirstminutes' => true));
            echo "&nbsp;<input type='submit' name='close_checklist' class='submit' value='" . _sx('button', 'Post') . "'></td>";
            break;
        case "add_task":
            echo "&nbsp;" . __('Assigned to') . "&nbsp;";
            User::dropdown(array('name' => "users_id", 'right' => 'interface'));
            echo "&nbsp;<input type='submit' name='add_task' class='submit' value='" . _sx('button', 'Post') . "'></td>";
            break;
        case "add_ticket":
            echo "&nbsp;<input type='submit' name='add_ticket' class='submit' value='" . _sx('button', 'Post') . "'></td>";
            break;
    }
}