/** * A custom method within the Plugin to generate the content * * @return string : HTML form * @see class/ProjectTask.class.php */ function generateAddTaskBlock() { $output = ''; $do_add_project_task = new ProjectTask(); $do_add_project_task->sessionPersistent("do_add_project_task", "projects.php", OFUZ_TTL); $output .= $_SESSION['do_add_project_task']->getProjectTaskAddForm(); return $output; }
/** * @param string $json_column_array * @param string $json_argument_array * @param string $css_page_id * @param string $css_row_sort_id * @param string $entries_per_page * @param string $page * @param string $sortvalue * @param string $sortmethod * @return string * @throws ProjectIDMissingException */ public static function list_project_tasks($json_column_array, $json_argument_array, $css_page_id, $css_row_sort_id, $entries_per_page, $page, $sortvalue, $sortmethod) { $argument_array = json_decode($json_argument_array); $project_id = $argument_array[1]; if (is_numeric($project_id)) { $list_request = new ListRequest_IO(); $list_request->set_column_array($json_column_array); if (!is_numeric($entries_per_page) or $entries_per_page < 1) { $entries_per_page = 20; } $list_array = Project_Wrapper::list_project_tasks($project_id, $sortvalue, $sortmethod, $page * $entries_per_page - $entries_per_page, $page * $entries_per_page); if (is_array($list_array) and count($list_array) >= 1) { foreach ($list_array as $key => $value) { $start_date = new DatetimeHandler($list_array[$key]['start_date']); $end_date = new DatetimeHandler($list_array[$key]['end_date'] . " " . $list_array[$key]['end_time']); $list_array[$key]['start_date'] = $start_date->get_date(); $list_array[$key]['end_date'] = $end_date->get_date(); $list_array[$key]['end_time'] = $end_date->get_time(); if ($list_array[$key]['whole_day'] == "t") { $list_array[$key]['end_time'] = "whole day"; } if ($list_array[$key]['is_status_process'] or $list_array[$key]['is_process']) { $project_task = new ProjectTask($list_array[$key]['id']); } if ($list_array[$key]['is_status_process']) { $list_array[$key]['type'] = "Status Rel. Task"; $list_array[$key]['name'] = $project_task->get_name(); } if ($list_array[$key]['is_process']) { $list_array[$key]['type'] = "Task"; } if ($list_array[$key]['is_milestone']) { $list_array[$key]['type'] = "Milestone"; } else { $list_array[$key]['progress'] = "<img src='core/images/status_bar.php?length=100&height=15&linecolor=A0A0A0&color=" . $project_task->get_color() . "&value=" . $project_task->get_progress() . "' />"; } $paramquery = array(); $paramquery['session_id'] = $_GET['session_id']; $paramquery['username'] = $_GET['username']; $paramquery['nav'] = "project"; $paramquery['run'] = "task_detail"; $paramquery['id'] = $list_array[$key]['id']; $params = http_build_query($paramquery, '', '&'); $tmp_name = $list_array[$key]['name']; unset($list_array[$key]['name']); $list_array[$key]['name']['content'] = $tmp_name; $list_array[$key]['name']['link'] = $params; } } else { $list_request->empty_message("<span class='italic'>No Project tasks found!</span>"); } $list_request->set_array($list_array); return $list_request->get_page($page); } else { throw new ProjectIDMissingException(); } }
/** * A custom method within the Plugin to generate the content * * @return string : HTML * @see class/ProjectTask.class.php * @see class/OfuzHorizontalSlider.class.php */ function generateProgressBlock() { $output = ''; $output .= '<form method="get" action="' . $_SERVER['PHP_SELF'] . '">'; $do_project_task_progress = new ProjectTask(); $do_project_task_progress->getId($_SESSION['do_project_task']->idproject_task); $do_project_task_progress->sessionPersistent('do_project_task_progress', 'project.php', OFUZ_TTL); $_SESSION['do_project_task_progress']->setFields(new Fields()); $_SESSION['do_project_task_progress']->fields->addField(new OfuzHorizontalSlider("progress")); $_SESSION['do_project_task_progress']->setApplyRegistry(true, "Form"); $output .= $_SESSION['do_project_task_progress']->progress; $output .= '</form>'; return $output; }
public static function createProjectTask($projectTaskData) { try { $projectTask = new ProjectTask(); $projectTask->project_id = $projectTaskData['project_id']; $projectTask->parent_task_id = $projectTaskData['parent_task_id']; $projectTask->project_task_id = $projectTaskData['project_task_id']; $projectTask->percent_complete = $projectTaskData['percent_complete']; $projectTask->name = $projectTaskData['name']; $projectTask->save(); self::pushObject($projectTask); return $projectTask; } catch (Exception $ex) { die("Not all needed params were defined for new project task"); } }
function getZendBlockConent() { // echo $_GET['idprojecttask']; $do_project_task = new ProjectTask(); $idtask = $do_project_task->getTaskId($_GET['idprojecttask']); // echo $idtask; $data = $do_project_task->getProjectTaskDetailsByTaskId($idtask); //echo $data->getData('idproject'); $idproject = $data->getData('idproject'); //$idproject = $data['idproject']; //echo '-'.$idproject; $do_zend = new Zendesk(); if ($do_zend->zendeskProjectUserRelation($_SESSION['do_User']->iduser, $idproject)) { /*Ticket Block*/ $ticket = $do_zend->getZendTicketId($_SESSION['do_User']->iduser, $_GET['idprojecttask']); $ticket_id = $ticket['ticket']; if (!empty($ticket_id)) { $idzendesk_task_ticket_releation = $ticket['idzendesk_task_ticket_releation']; $output .= '<div style="position: relative;">'; $output .= '<b>Ticket ID: ' . $ticket_id . '</b>'; $e_remove_invitation = new Event("Zendesk->eventRemoveZendTicket"); $e_remove_invitation->addParam('idzendesk_task_ticket_releation', $idzendesk_task_ticket_releation); $e_remove_invitation->addParam("goto", "Task/" . $_SESSION['do_project_task']->idproject_task); $img_del = '<img src="/images/delete.gif" width="14px" height="14px" alt="" />'; $output .= '<div style="float:right;align:right;">' . $e_remove_invitation->getLink($img_del) . '</div>'; $output .= '</div><br /><br />'; } /* Ticket Block ends */ //$ticket_id = $do_zend->getZendTicketId($_SESSION['do_User']->iduser,$_GET['idprojecttask']); $output .= '<a href="#" onclick="showZBox();return false;">' . _('Add/Update Zendesk Ticket ID') . '</a>'; $output .= '<div id="task_zbox" style="display:none;">'; $e_zticket = new Event("Zendesk->eventAddZendTicket"); //$e_zticket->setLevel(160); $e_zticket->addParam("idproject", $idproject); $e_zticket->addParam("idproject_task", $_GET['idprojecttask']); $e_zticket->addParam("iduser", $_SESSION['do_User']->iduser); $e_zticket->addParam("goto", "Task/" . $_SESSION['do_project_task']->idproject_task); $output .= $e_zticket->getFormHeader(); $output .= $e_zticket->getFormEvent(); $output .= '<input type="text" name="z_ticket_id" id = "z_ticket_id" value= ' . $ticket_id . '>'; $output .= '<input value="' . _('Add Zend Ticket') . '" type="submit">'; $output .= $e_zticket->getFormFooter(); $output .= '<br /><br /><a href="#" onclick="hideZbox(); return false;">' . _('Hide') . '</a>'; $output .= '</div>'; } return $output; }
public function checkFileAccessSecurity($filename) { $return = false; /* Check if the request is from the Contact Portal and then do the operation */ if ($_SESSION['portal_idcontact'] != '') { $do_cnt_note = new ContactNotes(); if ($do_cnt_note->isDocumentForContact($_SESSION['portal_idcontact'], $filename)) { $return = true; } } elseif ($_SESSION['do_User']->iduser != '') { // We have userid set then the request is from a loggedin user $q_project_discuss = new sqlQuery($this->getDbCon()); $q_project_discuss->query("select idproject_task from project_discuss where document = '" . $filename . "'"); // Check if the file is in project_discuss if ($q_project_discuss->getNumRows()) { $q_project_discuss->fetch(); $do_proj_task = new ProjectTask(); if ($do_proj_task->isProjectTaskReletedToUser($q_project_discuss->getData("idproject_task"), $_SESSION['do_User']->iduser)) { $return = true; } } else { // Not in project Discuss then check in contact_note $q_cnt_note = new ContactNotes(); $q_cnt_note->query("select idcontact from contact_note where document = '" . $filename . "'"); if ($q_cnt_note->getNumRows()) { $q_cnt_note->fetch(); $do_cont = new Contact(); if ($do_cont->isContactRelatedToUser($q_cnt_note->getData("idcontact"))) { $return = true; } } } } return $return; }
<?php if (isset($milestone) && $milestone instanceof ProjectMilestone) { if (!$milestone->isTrashed()) { if (!$milestone->isCompleted() && $milestone->canEdit(logged_user())) { add_page_action(lang('complete milestone'), $milestone->getCompleteUrl(rawurlencode(get_url('milestone', 'view', array('id' => $milestone->getId())))), 'ico-complete', null, null, true); } // if if ($milestone->isCompleted() && $milestone->canEdit(logged_user())) { add_page_action(lang('open milestone'), $milestone->getOpenUrl(rawurlencode(get_url('milestone', 'view', array('id' => $milestone->getId())))), 'ico-reopen', null, null, true); } if (!$milestone->isCompleted()) { if (ProjectTask::canAdd(logged_user(), $milestone->getProject())) { add_page_action(lang('add task list'), $milestone->getAddTaskUrl(), 'ico-task'); } } // if if ($milestone->canEdit(logged_user())) { add_page_action(lang('edit'), $milestone->getEditUrl(), 'ico-edit', null, null, true); if (!$milestone->isArchived()) { add_page_action(lang('archive'), "javascript:if(confirm(lang('confirm archive object'))) og.openLink('" . $milestone->getArchiveUrl() . "');", 'ico-archive-obj'); } else { add_page_action(lang('unarchive'), "javascript:if(confirm(lang('confirm unarchive object'))) og.openLink('" . $milestone->getUnarchiveUrl() . "');", 'ico-unarchive-obj'); } } // if } if ($milestone->canDelete(logged_user())) { if ($milestone->isTemplate()) { add_page_action(lang('delete'), "javascript:if(confirm(lang('confirm delete milestone'))) og.openLink('" . $milestone->getDeletePermanentlyUrl() . "');", 'ico-delete', null, null, true); } else {
* 02110-1301 USA. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not * reasonably feasible for technical reasons, the Appropriate Legal Notices must * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". ********************************************************************************/ $sugarbean = new ProjectTask(); // perform the delete if given a record to delete if (empty($_REQUEST['record'])) { $GLOBALS['log']->info('delete called without a record id specified'); } else { $record = $_REQUEST['record']; $sugarbean->retrieve($record); if (!$sugarbean->ACLAccess('Delete')) { ACLController::displayNoAccess(true); sugar_cleanup(true); } $GLOBALS['log']->info("deleting record: {$record}"); $sugarbean->mark_deleted($record); } // handle the return location variables $return_module = empty($_REQUEST['return_module']) ? 'ProjectTask' : $_REQUEST['return_module'];
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'> </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 " <a class='vsubmit' href='" . $this->getLinkURL() . "&forcetab=TicketFollowup\$1&_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 " <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 " <a href='" . $this->getFormURL() . "?id=" . $ID . "&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 " "; 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') . "'> "; } } else { if (self::canUpdate()) { echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'> "; } } 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; }
function getAllProjectTasks() { $projectTasks = array(); $query = "SELECT * FROM project_task WHERE project_id = '" . $this->id . "' AND deleted = 0 ORDER BY project_task_id"; $result = $this->db->query($query, true, "Error retrieving project tasks"); $row = $this->db->fetchByAssoc($result); while ($row != null) { $projectTaskBean = new ProjectTask(); $projectTaskBean->id = $row['id']; $projectTaskBean->retrieve(); array_push($projectTasks, $projectTaskBean); $row = $this->db->fetchByAssoc($result); } return $projectTasks; }
$request = View::route($_GET); $pk = $request['pk']; $sql = array('id_project_task_items' => $pk, 'status' => '1'); $fields = array('id_project_task_items', 'id_project_task'); $model = new ProjectTaskItems(); $model->fields = $fields; $rs = $model->get($sql); $rsItem = $rs[0]; $sql = array('id_project_task_items' => $rsItem['id_project_task_items'], 'status' => '1'); $fields = array('id_member'); $model = new ProjectTaskItemsMemberSet(); $model->fields = $fields; $rsItemMembers = $model->get($sql); $sql = array('id_project_task' => $rsItem['id_project_task'], 'status' => '1'); $fields = array('id_project'); $model = new ProjectTask(); $model->fields = $fields; $rs = $model->get($sql); $rs = $rs[0]; $sql = array('id_project' => $rs['id_project'], 'status' => '2'); $fields = array('id_member'); $model = new ProjectMemberSet(); $model->fields = $fields; $rs = $model->get($sql); ?> <div class="modal-content"> <div class="modal-header"> <button class="close" onclick="boss.removeClass('modal_dialog', 'active')">x</button> <h3 class="modal-title font-open-sans">Adicionar membro a tarefa</h3> </div> <form action="/app/task/create_item_member/" method="post" target="iframesubmit">
/** * Create a new template * */ function new_template() { if (logged_user()->isGuest()) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $notAllowedMember = ''; if (!ProjectTask::canAdd(logged_user(), active_context(), $notAllowedMember)) { if (str_starts_with($notAllowedMember, '-- req dim --')) { flash_error(lang('must choose at least one member of', str_replace_first('-- req dim --', '', $notAllowedMember, $in))); } else { flash_error(lang('no context permissions to add', lang("tasks"), $notAllowedMember)); } ajx_current("empty"); return; } // if $id = get_id(); $task = ProjectTasks::findById($id); if (!$task instanceof ProjectTask) { $task_data = array('is_template' => true); } else { $task_data = array('milestone_id' => $task->getMilestoneId(), 'title' => $task->getObjectName(), 'assigned_to' => $task->getAssignedToContactId(), 'parent_id' => $task->getParentId(), 'priority' => $task->getPriority(), 'time_estimate' => $task->getTimeEstimate(), 'text' => $task->getText(), 'is_template' => true, 'copyId' => $task->getId()); // array if ($task->getStartDate() instanceof DateTimeValue) { $task_data['start_date'] = $task->getStartDate()->getTimestamp(); } if ($task->getDueDate() instanceof DateTimeValue) { $task_data['due_date'] = $task->getDueDate()->getTimestamp(); } } $task = new ProjectTask(); tpl_assign('task_data', $task_data); tpl_assign('task', $task); $this->setTemplate("add_task"); }
/** * Show team for a project task * * @param $task ProjectTask object * * @return boolean **/ function showTeam(ProjectTask $task) { global $DB, $CFG_GLPI; /// TODO : permit to simple add member of project team ? $ID = $task->fields['id']; $canedit = $task->canEdit($ID); $rand = mt_rand(); $nb = 0; $nb = $task->getTeamCount(); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='projecttaskteam_form{$rand}' id='projecttaskteam_form{$rand}' "; echo " method='post' action='" . Toolbox::getItemTypeFormURL('ProjectTaskTeam') . "'>"; echo "<input type='hidden' name='projecttasks_id' value='{$ID}'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . __('Add a team member') . "</tr>"; echo "<tr class='tab_bg_2'><td>"; $params = array('itemtypes' => ProjectTeam::$available_types, 'entity_restrict' => $task->fields['is_recursive'] ? getSonsOf('glpi_entities', $task->fields['entities_id']) : $task->fields['entities_id']); $addrand = Dropdown::showSelectItemFromItemtypes($params); echo "</td>"; echo "<td width='20%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $nb) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand); // 'specific_actions' // => array('delete' => _x('button', 'Delete permanently')) ); // // if ($this->fields['users_id'] != Session::getLoginUserID()) { // $massiveactionparams['confirm'] // = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.'); // } Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $nb) { $header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_top .= "</th>"; $header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= "</th>"; } $header_end .= "<th>" . __('Type') . "</th>"; $header_end .= "<th>" . _n('Member', 'Members', Session::getPluralNumber()) . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; foreach (ProjectTaskTeam::$available_types as $type) { if (isset($task->team[$type]) && count($task->team[$type])) { if ($item = getItemForItemtype($type)) { foreach ($task->team[$type] as $data) { $item->getFromDB($data['items_id']); echo "<tr class='tab_bg_2'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox('ProjectTaskTeam', $data["id"]); echo "</td>"; } echo "<td>" . $item->getTypeName(1) . "</td>"; echo "<td>" . $item->getLink() . "</td>"; echo "</tr>"; } } } } if ($nb) { echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; // Add items return true; }
/** * Copies subtasks from taskFrom to taskTo. * * @param ProjectTask $taskFrom * @param ProjectTask $taskTo */ function copySubTasks(ProjectTask $taskFrom, ProjectTask $taskTo, $as_template = false) { foreach ($taskFrom->getSubTasks() as $sub) { if ($sub->getId() == $taskTo->getId()) { continue; } $new = ProjectTasks::createTaskCopy($sub); $new->setIsTemplate($as_template); $new->setParentId($taskTo->getId()); $new->setMilestoneId($taskTo->getMilestoneId()); $new->setOrder(ProjectTasks::maxOrder($new->getParentId(), $new->getMilestoneId())); if ($sub->getIsTemplate()) { $new->setFromTemplateId($sub->getId()); } $new->save(); $object_controller = new ObjectController(); if (count($taskFrom->getMemberIds())) { $object_controller->add_to_members($new, $taskFrom->getMemberIds()); } $new->copyCustomPropertiesFrom($sub); $new->copyLinkedObjectsFrom($sub); ProjectTasks::copySubTasks($sub, $new, $as_template); } }
$sql = array('id_project_task_items_comments' => $pk, 'status' => 1); $model = new ProjectTaskItemsComments(); $model->fields = array('status' => 0); $update = $model->update($sql); if ($update) { $sql = array('id_project_task_items_comments' => $pk); $model->fields = array('id_project_task_items'); $rsComments = $model->get($sql); $rsComment = $rsComments[0]; $query = array("id_project_task_items" => $rsComment['id_project_task_items'], "status" => 1); $project = new ProjectTaskItems(); $project->fields = array('id_project_task_items', 'id_project_task'); $rsItem = $project->get($query); $rsItem = $rsItem[0]; $sql = array('id_project_task' => $rsItem['id_project_task'], 'status' => 1); $project = new ProjectTask(); $project->fields = array('id_project'); $rs = $project->get($sql); $rs = $rs[0]; ?> <script> var timePopup = setTimeout(function(){ window.parent.boss.removeClass('modal_dialog', 'active'); window.parent.boss.ajax.load('/app/task/view_task/?pk=<?php echo $rs["id_project"]; ?> ', '#app_pane_body'); }, 100); window.parent.$('#modal_window').empty(); window.parent.boss.ajax.load('/app/task/view_item/?pk=<?php echo $rsItem["id_project_task_items"];
static function getArrayInfo($raw_data, $full = false){ if(config_option("wysiwyg_tasks")){ if($raw_data['type_content'] == "text"){ $desc = nl2br(htmlspecialchars($raw_data['text'])); }else{ $desc = purify_html(nl2br($raw_data['text'])); } }else{ if($raw_data['type_content'] == "text"){ $desc = htmlspecialchars($raw_data['text']); }else{ $desc = html_to_text(html_entity_decode(nl2br($raw_data['text']), null, "UTF-8")); } } $member_ids = ObjectMembers::instance()->getCachedObjectMembers($raw_data['id']); $tmp_task = new ProjectTask(); $tmp_task->setObjectId($raw_data['id']); $tmp_task->setId($raw_data['id']); $tmp_task->setAssignedToContactId($raw_data['assigned_to_contact_id']); $result = array( 'id' => $raw_data['id'], 't' => $raw_data['name'], 'desc' => $desc, 'members' => $member_ids, 'c' => strtotime($raw_data['created_on']), 'cid' => (int)$raw_data['created_by_id'], 'otype' => $raw_data['object_subtype'], 'pc' => (int)$raw_data['percent_completed'], 'memPath' => str_replace('"',"'", str_replace("'", "\'", json_encode($tmp_task->getMembersToDisplayPath($member_ids)))) ); if ($full) { $result['description'] = $raw_data['text']; } $result['mas'] = (int)array_var($raw_data, 'multi_assignment'); if ($raw_data['completed_by_id'] > 0) { $result['s'] = 1; } if ($raw_data['parent_id'] > 0) { $result['pid'] = (int)$raw_data['parent_id']; } //if ($this->getPriority() != 200) $result['pr'] = (int)$raw_data['priority']; if ($raw_data['milestone_id'] > 0) { $result['mid'] = (int)$raw_data['milestone_id']; } if ($raw_data['assigned_to_contact_id'] > 0) { $result['atid'] = (int)$raw_data['assigned_to_contact_id']; } $result['atName'] = $tmp_task->getAssignedToName(); if ($raw_data['completed_by_id'] > 0) { $result['cbid'] = (int)$raw_data['completed_by_id']; $result['con'] = strtotime($raw_data['completed_on']);; } if ($raw_data['due_date'] != EMPTY_DATETIME) { $result['dd'] = strtotime($raw_data['due_date']) + logged_user()->getTimezone() * 3600; $result['udt'] = $raw_data['use_due_time'] ? 1 : 0; } if ($raw_data['start_date'] != EMPTY_DATETIME) { $result['sd'] = strtotime($raw_data['start_date']) + logged_user()->getTimezone() * 3600; $result['ust'] = $raw_data['use_start_time'] ? 1 : 0; } $time_estimate = $raw_data['time_estimate']; $result['te'] = $raw_data['time_estimate']; if ($time_estimate > 0) $result['et'] = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60) ; $result['tz'] = logged_user()->getTimezone() * 3600; $ot = $tmp_task->getOpenTimeslots(); if ($ot){ $users = array(); $time = array(); $paused = array(); foreach ($ot as $t){ if (!$t instanceof Timeslot) continue; $time[] = $t->getSeconds(); $users[] = $t->getContactId(); $paused[] = $t->isPaused()?1:0; if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) { $result['wpt'] = $t->getPausedOn()->getTimestamp(); } } $result['wt'] = $time; $result['wid'] = $users; $result['wp'] = $paused; } if ($raw_data['repeat_forever'] > 0 || $raw_data['repeat_num'] > 0 || $raw_data['repeat_end'] != EMPTY_DATETIME) { $result['rep'] = 1; } return $result; }
$project_task->assigned_user_id = 1; $project_task->name = 'Hold kick-off meeting with business units.'; $project_task->status = 'Not Started'; $project_task->date_start = create_date('2007', '11', '12'); //$project_task->time_start = create_time(8,0,0); $project_task->date_finish = create_date('2007', '11', '19'); //$project_task->time_finish = create_time(8,0,0); $project_task->project_id = $audit_plan_id; $project_task->project_task_id = '4'; $project_task->description = "Schedule the meeting with the head of business units to solicit help."; $project_task->duration = '6'; $project_task->duration_unit = 'Days'; $project_task->parent_task_id = '2'; $project_task->percent_complete = 0; $project_task->save(); $project_task = new ProjectTask(); $project_task->assigned_user_id = 1; $project_task->name = 'Gather data from meetings'; $project_task->date_start = create_date('2007', '11', '20'); //$project_task->time_start = create_time(8,0,0); $project_task->date_finish = create_date('2007', '11', '20'); //$project_task->time_finish = create_time(8,0,0); $project_task->project_id = $audit_plan_id; $project_task->project_task_id = '5'; $project_task->description = 'Need to organize the data and put it in the right spreadsheet.'; $project_task->duration = '1'; $project_task->duration_unit = 'Days'; $project_task->parent_task_id = '2'; $project_task->predecessor = '4'; $project_task->percent_complete = 0; $project_task->save();
public function testResourceName() { $processingTask = $this->projectTasks['taskFive']; $processingTask->percent_complete = '65'; $processingTask->save(); $taskOne = new ProjectTask(); $taskOne->retrieve($this->projectTasks['taskOne']->id); $this->assertEquals('22', $taskOne->percent_complete); $taskThree = new ProjectTask(); $taskThree->retrieve($this->projectTasks['taskThree']->id); $this->assertEquals('33', $taskThree->percent_complete); }
function action_create_project() { global $current_user, $db, $mod_strings; $project_name = $_POST['p_name']; $template_id = $_POST['template_id']; $project_start = $_POST['start_date']; $copy_all = isset($_POST['copy_all_tasks']) ? 1 : 0; $copy_tasks = isset($_POST['tasks']) ? $_POST['tasks'] : array(); //Get project start date if ($project_start != '') { $dateformat = $current_user->getPreference('datef'); $startdate = DateTime::createFromFormat($dateformat, $project_start); $start = $startdate->format('Y-m-d'); } $duration_unit = 'Days'; //Get the project template $template = new AM_ProjectTemplates(); $template->retrieve($template_id); //create project from template $project = new Project(); $project->name = $project_name; $project->estimated_start_date = $start; $project->status = $template->status; $project->priority = strtolower($template->priority); $project->description = $template->description; $project->assigned_user_id = $template->assigned_user_id; $project->save(); //copy all resources from template to project $template->load_relationship('am_projecttemplates_users_1'); $template_users = $template->get_linked_beans('am_projecttemplates_users_1', 'User'); $template->load_relationship('am_projecttemplates_contacts_1'); $template_contacts = $template->get_linked_beans('am_projecttemplates_contacts_1', 'Contact'); $project->load_relationship('project_users_1'); foreach ($template_users as $user) { $project->project_users_1->add($user->id); } $project->load_relationship('project_contacts_1'); foreach ($template_contacts as $contact) { $project->project_contacts_1->add($contact->id); } $template->load_relationship('am_projecttemplates_project_1'); $template->am_projecttemplates_project_1->add($project->id); //Get related project template tasks. Using sql query so that the results can be ordered. $get_tasks = "SELECT * FROM am_tasktemplates\n WHERE id\n IN (\n SELECT am_tasktemplates_am_projecttemplatesam_tasktemplates_idb\n FROM am_tasktemplates_am_projecttemplates_c\n WHERE am_tasktemplates_am_projecttemplatesam_projecttemplates_ida = '" . $template_id . "'\n AND deleted =0\n )\n AND deleted =0\n ORDER BY am_tasktemplates.order_number ASC"; $tasks = $db->query($get_tasks); //Create new project tasks from the template tasks $count = 1; while ($row = $db->fetchByAssoc($tasks)) { $project_task = new ProjectTask(); $project_task->name = $row['name']; $project_task->status = $row['status']; $project_task->priority = strtolower($row['priority']); $project_task->percent_complete = $row['percent_complete']; $project_task->predecessors = $row['predecessors']; $project_task->milestone_flag = $row['milestone_flag']; $project_task->relationship_type = $row['relationship_type']; $project_task->task_number = $row['task_number']; $project_task->order_number = $row['order_number']; $project_task->estimated_effort = $row['estimated_effort']; $project_task->utilization = $row['utilization']; if ($copy_all == 0 && !in_array($row['id'], $copy_tasks)) { $project_task->assigned_user_id = NULL; } else { $project_task->assigned_user_id = $row['assigned_user_id']; } $project_task->description = $row['description']; $project_task->duration = $row['duration']; $project_task->duration_unit = $duration_unit; $project_task->project_task_id = $count; //Flag to prevent after save logichook running when project_tasks are created (see custom/modules/ProjectTask/updateProject.php) $project_task->set_project_end_date = 0; if ($count == '1') { $project_task->date_start = $start; $enddate = $startdate->modify('+' . $row['duration'] . ' ' . $duration_unit); $end = $enddate->format('Y-m-d'); $project_task->date_finish = $end; $enddate_array[$count] = $end; $GLOBALS['log']->fatal("DATE:" . $end); } else { $start_date = $count - 1; $startdate = DateTime::createFromFormat('Y-m-d', $enddate_array[$start_date]); $GLOBALS['log']->fatal("DATE:" . $enddate_array[$start_date]); $start = $startdate->format('Y-m-d'); $project_task->date_start = $start; $enddate = $startdate->modify('+' . $row['duration'] . ' ' . $duration_unit); $end = $enddate->format('Y-m-d'); $project_task->date_finish = $end; $enddate = $end; $enddate_array[$count] = $end; } $project_task->save(); //link tasks to the newly created project $project_task->load_relationship('projects'); $project_task->projects->add($project->id); //Add assinged users from each task to the project resourses subpanel $project->load_relationship('project_users_1'); $project->project_users_1->add($row['assigned_user_id']); $count++; } //set project end date to the same as end date of the last task $GLOBALS['log']->fatal("project end -- DATE:" . $end); $project->estimated_end_date = $end; $project->save(); //redirct to new project SugarApplication::appendErrorMessage($mod_strings["LBL_NEW_PROJECT_CREATED"]); $params = array('module' => 'Project', 'action' => 'DetailView', 'record' => $project->id); SugarApplication::redirect('index.php?' . http_build_query($params)); }
$not_overdue_limit = 5; $overdue_limit = 20; $show_more = false; // Not due tasks $not_due_tasks = ProjectTasks::getUpcomingWithoutDate($not_overdue_limit + 1); if (count($not_due_tasks) > $not_overdue_limit) { $show_more = true; array_pop($not_due_tasks); } // Due Tasks $overdue_upcoming_objects = ProjectTasks::getOverdueAndUpcomingObjects($overdue_limit + 1); // FIXME: performance Killer if (count($overdue_upcoming_objects) > $overdue_limit) { $show_more = true; array_pop($overdue_upcoming_objects); } $overdue_upcoming_objects = array_merge($not_due_tasks, $overdue_upcoming_objects); $users = array(); // Render only when the context isnt 'all' and you have perms $render_add = active_context_members(false) && ProjectTask::canAdd(logged_user(), active_context()); if ($render_add) { $users[] = array(0, lang('dont assign')); foreach (allowed_users_to_assign() as $company) { foreach ($company['users'] as $user) { $name = logged_user()->getId() == $user['id'] ? lang('me') : $user['name']; $users[] = array($user['id'], $name); } } } include_once 'template.php';
require_once 'include/formbase.php'; global $current_user; $sugarbean = new Project(); $sugarbean = populateFromPost('', $sugarbean); $projectTasks = array(); if (isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] === "true") { $base_project_id = $_REQUEST['relate_id']; } else { $base_project_id = $sugarbean->id; } if (isset($_REQUEST['save_type']) || isset($_REQUEST['duplicateSave']) && $_REQUEST['duplicateSave'] === "true") { $query = "SELECT id FROM project_task WHERE project_id = '" . $base_project_id . "' AND deleted = 0"; $result = $sugarbean->db->query($query, true, "Error retrieving project tasks"); $row = $sugarbean->db->fetchByAssoc($result); while ($row != null) { $projectTaskBean = new ProjectTask(); $projectTaskBean->id = $row['id']; $projectTaskBean->retrieve(); $projectTaskBean->date_entered = ''; $projectTaskBean->date_modified = ''; array_push($projectTasks, $projectTaskBean); $row = $sugarbean->db->fetchByAssoc($result); } } if (isset($_REQUEST['save_type'])) { $sugarbean->id = ''; $sugarbean->assigned_user_id = $current_user->id; if ($_REQUEST['save_type'] == 'TemplateToProject') { $sugarbean->name = $_REQUEST['project_name']; $sugarbean->is_template = 0; } else {
http://indepnet.net/ http://glpi-project.org ------------------------------------------------------------------------- LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief * @since version 0.85 */ include '../inc/includes.php'; Session::haveRightsOr('project', array(Project::READALL, Project::READMY, ProjectTask::READMY)); Html::header(ProjectTask::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "tools", "project", 'task'); Search::show('ProjectTask'); Html::footer();
* 02110-1301 USA. * * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not * reasonably feasible for technical reasons, the Appropriate Legal Notices must * display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". ********************************************************************************/ $project = new ProjectTask(); if (!empty($_POST['record'])) { $project->retrieve($_POST['record']); } //// //// save the fields to the ProjectTask object //// if (isset($_REQUEST['email_id'])) { $project->email_id = $_REQUEST['email_id']; } require_once 'include/formbase.php'; $project = populateFromPost('', $project); if (!isset($_REQUEST['milestone_flag'])) { $project->milestone_flag = '0'; } $GLOBALS['check_notify'] = false;
* License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. */ require_once 'modules/ProjectTask/ProjectTask.php'; $project = new ProjectTask(); if (!empty($_POST['record'])) { $project->retrieve($_POST['record']); } //// //// save the fields to the ProjectTask object //// if (isset($_REQUEST['email_id'])) { $project->email_id = $_REQUEST['email_id']; } if ($_POST['order_number'] == '') { $_POST['order_number'] = '1'; } foreach ($project->column_fields as $field) { if (isset($_REQUEST[$field])) { $project->{$field} = $_REQUEST[$field];
/** * Generic Function to display Items * * @param $itemtype item type * @param $ID ID of the SEARCH_OPTION item * @param $data array containing data results * @param $num item num in the request * @param $meta is a meta item ? (default 0) * @param $addobjectparams array added parameters for union search * * @return string to print **/ static function giveItem($itemtype, $ID, array $data, $num, $meta = 0, array $addobjectparams = array()) { global $CFG_GLPI, $DB; $searchopt =& self::getOptions($itemtype); if (isset($CFG_GLPI["union_search_type"][$itemtype]) && $CFG_GLPI["union_search_type"][$itemtype] == $searchopt[$ID]["table"]) { if (isset($searchopt[$ID]['addobjectparams']) && $searchopt[$ID]['addobjectparams']) { return self::giveItem($data["TYPE"], $ID, $data, $num, $meta, $searchopt[$ID]['addobjectparams']); } return self::giveItem($data["TYPE"], $ID, $data, $num, $meta); } if (count($addobjectparams)) { $searchopt[$ID] = array_merge($searchopt[$ID], $addobjectparams); } // Plugin can override core definition for its type if ($plug = isPluginItemType($itemtype)) { $function = 'plugin_' . $plug['plugin'] . '_giveItem'; if (function_exists($function)) { $out = $function($itemtype, $ID, $data, $num); if (!empty($out)) { return $out; } } } $NAME = "ITEM_"; // if ($meta) { // $NAME = "META_"; // } if (isset($searchopt[$ID]["table"])) { $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; $linkfield = $searchopt[$ID]["linkfield"]; /// TODO try to clean all specific cases using SpecificToDisplay switch ($table . '.' . $field) { case "glpi_users.name": // USER search case if ($itemtype != 'User' && isset($searchopt[$ID]["forcegroupby"]) && $searchopt[$ID]["forcegroupby"]) { $out = ""; $count_display = 0; $added = array(); $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } for ($k = 0; $k < $data[$num]['count']; $k++) { if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0 || isset($data[$num][$k][2]) && $data[$num][$k][2] != '') { if ($count_display) { $out .= self::LBBR; } if ($itemtype == 'Ticket') { if (isset($data[$num][$k]['name']) && $data[$num][$k]['name'] > 0) { $userdata = getUserName($data[$num][$k]['name'], 2); $tooltip = ""; if (Session::haveRight('user', READ)) { $tooltip = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } $out .= sprintf(__('%1$s %2$s'), $userdata['name'], $tooltip); $count_display++; } } else { $out .= getUserName($data[$num][$k]['name'], $showuserlink); $count_display++; } // Manage alternative_email for tickets_users if ($itemtype == 'Ticket' && isset($data[$num][$k][2])) { $split = explode(self::LONGSEP, $data[$num][$k][2]); for ($l = 0; $l < count($split); $l++) { $split2 = explode(" ", $split[$l]); if (count($split2) == 2 && $split2[0] == 0 && !empty($split2[1])) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= "<a href='mailto:" . $split2[1] . "'>" . $split2[1] . "</a>"; } } } } } return $out; } if ($itemtype != 'User') { $toadd = ''; if ($itemtype == 'Ticket' && $data[$num][0]['id'] > 0) { $userdata = getUserName($data[$num][0]['id'], 2); $toadd = Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)); } $usernameformat = formatUserName($data[$num][0]['id'], $data[$num][0]['name'], $data[$num][0]['realname'], $data[$num][0]['firstname'], 1); return sprintf(__('%1$s %2$s'), $usernameformat, $toadd); } break; case "glpi_profiles.name": if ($itemtype == 'User' && $ID == 20) { $out = ""; $count_display = 0; $added = array(); for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_entities', $data[$num][$k]['entities_id'])); $comp = ''; if ($data[$num][$k]['is_recursive']) { $comp = __('R'); if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, ", "); } } if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, __('D')); } if (!empty($comp)) { $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")"); } if (!in_array($text, $added)) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= $text; $added[] = $text; } } } return $out; } break; case "glpi_entities.completename": if ($itemtype == 'User') { $out = ""; $added = array(); $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { $text = sprintf(__('%1$s - %2$s'), $data[$num][$k]['name'], Dropdown::getDropdownName('glpi_profiles', $data[$num][$k]['profiles_id'])); $comp = ''; if ($data[$num][$k]['is_recursive']) { $comp = __('R'); if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, ", "); } } if ($data[$num][$k]['is_dynamic']) { $comp = sprintf(__('%1$s%2$s'), $comp, __('D')); } if (!empty($comp)) { $text = sprintf(__('%1$s %2$s'), $text, "(" . $comp . ")"); } if (!in_array($text, $added)) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= $text; $added[] = $text; } } } return $out; } break; case "glpi_documenttypes.icon": if (!empty($data[$num][0]['name'])) { return "<img class='middle' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $data[$num][0]['name'] . "'>"; } return " "; case "glpi_documents.filename": $doc = new Document(); if ($doc->getFromDB($data['id'])) { return $doc->getDownloadLink(); } return NOT_AVAILABLE; case "glpi_tickets_tickets.tickets_id_1": $out = ""; $displayed = array(); for ($k = 0; $k < $data[$num]['count']; $k++) { $linkid = $data[$num][$k]['tickets_id_2'] == $data['id'] ? $data[$num][$k]['name'] : $data[$num][$k]['tickets_id_2']; if ($linkid > 0 && !isset($displayed[$linkid])) { $text = "<a "; $text .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id={$linkid}\">"; $text .= Dropdown::getDropdownName('glpi_tickets', $linkid) . "</a>"; if (count($displayed)) { $out .= self::LBBR; } $displayed[$linkid] = $linkid; $out .= $text; } } return $out; case "glpi_problems.id": if ($searchopt[$ID]["datatype"] == 'count') { if ($data[$num][0]['name'] > 0 && Session::haveRight("problem", Problem::READALL)) { if ($itemtype == 'ITILCategory') { $options['criteria'][0]['field'] = 7; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } else { $options['criteria'][0]['field'] = 12; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = 'all'; $options['criteria'][0]['link'] = 'AND'; $options['metacriteria'][0]['itemtype'] = $itemtype; $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name'); $options['metacriteria'][0]['searchtype'] = 'equals'; $options['metacriteria'][0]['value'] = $data['id']; $options['metacriteria'][0]['link'] = 'AND'; } $options['reset'] = 'reset'; $out = "<a id='problem{$itemtype}" . $data['id'] . "' "; $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.php?" . Toolbox::append_params($options, '&') . "\">"; $out .= $data[$num][0]['name'] . "</a>"; return $out; } } break; case "glpi_tickets.id": if ($searchopt[$ID]["datatype"] == 'count') { if ($data[$num][0]['name'] > 0 && Session::haveRight("ticket", Ticket::READALL)) { if ($itemtype == 'User') { // Requester if ($ID == 60) { $options['criteria'][0]['field'] = 4; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } // Writer if ($ID == 61) { $options['criteria'][0]['field'] = 22; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } // Assign if ($ID == 64) { $options['criteria'][0]['field'] = 5; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } } else { if ($itemtype == 'ITILCategory') { $options['criteria'][0]['field'] = 7; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = $data['id']; $options['criteria'][0]['link'] = 'AND'; } else { $options['criteria'][0]['field'] = 12; $options['criteria'][0]['searchtype'] = 'equals'; $options['criteria'][0]['value'] = 'all'; $options['criteria'][0]['link'] = 'AND'; $options['metacriteria'][0]['itemtype'] = $itemtype; $options['metacriteria'][0]['field'] = self::getOptionNumber($itemtype, 'name'); $options['metacriteria'][0]['searchtype'] = 'equals'; $options['metacriteria'][0]['value'] = $data['id']; $options['metacriteria'][0]['link'] = 'AND'; } } $options['reset'] = 'reset'; $out = "<a id='ticket{$itemtype}" . $data['id'] . "' "; $out .= "href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($options, '&') . "\">"; $out .= $data[$num][0]['name'] . "</a>"; return $out; } } break; case "glpi_tickets.due_date": case "glpi_problems.due_date": case "glpi_changes.due_date": // Due date + progress if ($ID == 151) { $out = Html::convDate($data[$num][0]['name']); // No due date in waiting status if ($data[$num][0]['status'] == CommonITILObject::WAITING) { return ''; } if (empty($data[$num][0]['name'])) { return ''; } if ($data[$num][0]['status'] == Ticket::SOLVED || $data[$num][0]['status'] == Ticket::CLOSED) { return $out; } $itemtype = getItemTypeForTable($table); $item = new $itemtype(); $item->getFromDB($data['id']); $percentage = 0; $totaltime = 0; $currenttime = 0; if ($item->isField('slas_id') && $item->fields['slas_id'] != 0) { // Have SLA $sla = new SLA(); $sla->getFromDB($item->fields['slas_id']); $currenttime = $sla->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s')); $totaltime = $sla->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']); } else { $calendars_id = Entity::getUsedConfig('calendars_id', $item->fields['entities_id']); if ($calendars_id != 0) { // Ticket entity have calendar $calendar = new Calendar(); $calendar->getFromDB($calendars_id); $currenttime = $calendar->getActiveTimeBetween($item->fields['date'], date('Y-m-d H:i:s')); $totaltime = $calendar->getActiveTimeBetween($item->fields['date'], $data[$num][0]['name']); } else { // No calendar $currenttime = strtotime(date('Y-m-d H:i:s')) - strtotime($item->fields['date']); $totaltime = strtotime($data[$num][0]['name']) - strtotime($item->fields['date']); } } if ($totaltime != 0) { $percentage = round(100 * $currenttime / $totaltime); } else { // Total time is null : no active time $percentage = 100; } if ($percentage > 100) { $percentage = 100; } $percentage_text = $percentage; if ($_SESSION['glpiduedatewarning_unit'] == '%') { $less_warn_limit = $_SESSION['glpiduedatewarning_less']; $less_warn = 100 - $percentage; } else { if ($_SESSION['glpiduedatewarning_unit'] == 'hour') { $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * HOUR_TIMESTAMP; $less_warn = $totaltime - $currenttime; } else { if ($_SESSION['glpiduedatewarning_unit'] == 'day') { $less_warn_limit = $_SESSION['glpiduedatewarning_less'] * DAY_TIMESTAMP; $less_warn = $totaltime - $currenttime; } } } if ($_SESSION['glpiduedatecritical_unit'] == '%') { $less_crit_limit = $_SESSION['glpiduedatecritical_less']; $less_crit = 100 - $percentage; } else { if ($_SESSION['glpiduedatecritical_unit'] == 'hour') { $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * HOUR_TIMESTAMP; $less_crit = $totaltime - $currenttime; } else { if ($_SESSION['glpiduedatecritical_unit'] == 'day') { $less_crit_limit = $_SESSION['glpiduedatecritical_less'] * DAY_TIMESTAMP; $less_crit = $totaltime - $currenttime; } } } $color = $_SESSION['glpiduedateok_color']; if ($less_crit < $less_crit_limit) { $color = $_SESSION['glpiduedatecritical_color']; } else { if ($less_warn < $less_warn_limit) { $color = $_SESSION['glpiduedatewarning_color']; } } //Calculate bar progress $out .= "<div class='center' style='background-color: #ffffff; width: 100%;\n border: 1px solid #9BA563; position: relative;' >"; $out .= "<div style='position:absolute;'> " . $percentage_text . "%</div>"; $out .= "<div class='center' style='background-color: " . $color . ";\n width: " . $percentage . "%; height: 12px' ></div>"; $out .= "</div>"; return $out; } break; case "glpi_softwarelicenses.number": if ($data[$num][0]['min'] == -1) { return __('Unlimited'); } if (empty($data[$num][0]['name'])) { return 0; } return $data[$num][0]['name']; case "glpi_auth_tables.name": return Auth::getMethodName($data[$num][0]['name'], $data[$num][0]['auths_id'], 1, $data[$num][0]['ldapname'] . $data[$num][0]['mailname']); case "glpi_reservationitems.comment": if (empty($data[$num][0]['name'])) { return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data["refID"] . "' >" . __('None') . "</a>"; } return "<a title=\"" . __s('Modify the comment') . "\"\n href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.form.php?id=" . $data['refID'] . "' >" . Html::resume_text($data[$num][0]['name']) . "</a>"; case 'glpi_crontasks.description': $tmp = new CronTask(); return $tmp->getDescription($data[$num][0]['name']); case 'glpi_changes.status': $status = Change::getStatus($data[$num][0]['name']); return "<img src=\"" . Change::getStatusIconURL($data[$num][0]['name']) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_problems.status': $status = Problem::getStatus($data[$num][0]['name']); return "<img src=\"" . Problem::getStatusIconURL($data[$num][0]['name']) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_tickets.status': $status = Ticket::getStatus($data[$num][0]['name']); return "<img src=\"" . Ticket::getStatusIconURL($data[$num][0]['name']) . "\"\n alt=\"{$status}\" title=\"{$status}\"> {$status}"; case 'glpi_projectstates.name': $out = ''; $query = "SELECT `color`\n FROM `glpi_projectstates`\n WHERE `name` = '" . $data[$num][0]['name'] . "'"; foreach ($DB->request($query) as $color) { $color = $color['color']; $out = "<div style=\"background-color:" . $color . ";\">"; $name = $data[$num][0]['name']; if (isset($data[$num][0]['trans'])) { $name = $data[$num][0]['trans']; } if ($itemtype == 'ProjectState') { $out .= "<a href='" . $CFG_GLPI["root_doc"] . "/front/projectstate.form.php?id=" . $data[$num][0]["id"] . "'>" . $name . "</a></div>"; } else { $out .= $name . "</div>"; } } return $out; case 'glpi_items_tickets.items_id': case 'glpi_items_problems.items_id': if (!empty($data[$num])) { $items = array(); foreach ($data[$num] as $key => $val) { if (is_numeric($key)) { if (!empty($val['itemtype']) && ($item = getItemForItemtype($val['itemtype']))) { if ($item->getFromDB($val['name'])) { $items[] = $item->getLink(array('comments' => true)); } } } } if (!empty($items)) { return implode("<br>", $items); } } return ' '; case 'glpi_items_tickets.itemtype': case 'glpi_items_problems.itemtype': if (!empty($data[$num])) { $itemtypes = array(); foreach ($data[$num] as $key => $val) { if (is_numeric($key)) { if (!empty($val['name'])) { if (substr($val['name'], 0, 6) == 'Plugin') { $plug = new $val['name'](); $name = $plug->getTypeName(); $itemtypes[] = __($name); } else { $itemtypes[] = __($val['name']); } } } } if (!empty($itemtypes)) { return implode("<br>", $itemtypes); } } return ' '; case 'glpi_tickets.name': case 'glpi_problems.name': case 'glpi_changes.name': if (isset($data[$num][0]['content']) && isset($data[$num][0]['id']) && isset($data[$num][0]['status'])) { $link = Toolbox::getItemTypeFormURL($itemtype); $out = "<a id='{$itemtype}" . $data[$num][0]['id'] . "' href=\"" . $link; $out .= strstr($link, '?') ? '&' : '?'; $out .= 'id=' . $data[$num][0]['id']; // Force solution tab if solved if ($item = getItemForItemtype($itemtype)) { if (in_array($data[$num][0]['status'], $item->getSolvedStatusArray())) { $out .= "&forcetab={$itemtype}\$2"; } } $out .= "\">"; $name = $data[$num][0]['name']; if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][0]['id']); } $out .= $name . "</a>"; $hdecode = Html::entity_decode_deep($data[$num][0]['content']); $content = Toolbox::unclean_cross_side_scripting_deep($hdecode); $out = sprintf(__('%1$s %2$s'), $out, Html::showToolTip(nl2br(Html::Clean($content)), array('applyto' => $itemtype . $data[$num][0]['id'], 'display' => false))); return $out; } case 'glpi_ticketvalidations.status': $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { if ($data[$num][$k]['name']) { $status = TicketValidation::getStatus($data[$num][$k]['name']); $bgcolor = TicketValidation::getStatusColor($data[$num][$k]['name']); $out .= (empty($out) ? '' : self::LBBR) . "<div style=\"background-color:" . $bgcolor . ";\">" . $status . '</div>'; } } return $out; case 'glpi_ticketsatisfactions.satisfaction': if (self::$output_type == self::HTML_OUTPUT) { return TicketSatisfaction::displaySatisfaction($data[$num][0]['name']); } break; case 'glpi_projects._virtual_planned_duration': return Html::timestampToString(ProjectTask::getTotalPlannedDurationForProject($data["id"]), false); case 'glpi_projects._virtual_effective_duration': return Html::timestampToString(ProjectTask::getTotalEffectiveDurationForProject($data["id"]), false); case 'glpi_cartridgeitems._virtual': return Cartridge::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT); case 'glpi_printers._virtual': return Cartridge::getCountForPrinter($data["id"], self::$output_type != self::HTML_OUTPUT); case 'glpi_consumableitems._virtual': return Consumable::getCount($data["id"], $data[$num][0]['alarm_threshold'], self::$output_type != self::HTML_OUTPUT); case 'glpi_links._virtual': $out = ''; $link = new Link(); if (($item = getItemForItemtype($itemtype)) && $item->getFromDB($data['id']) && $link->getfromDB($data[$num][0]['id']) && $item->fields['entities_id'] == $link->fields['entities_id']) { if (count($data[$num])) { $count_display = 0; foreach ($data[$num] as $val) { if (is_array($val)) { $links = Link::getAllLinksFor($item, $val); foreach ($links as $link) { if ($count_display) { $out .= self::LBBR; } $out .= $link; $count_display++; } } } } } return $out; case 'glpi_reservationitems._virtual': if ($data[$num][0]['is_active']) { return "<a href='reservation.php?reservationitems_id=" . $data["refID"] . "' title=\"" . __s('See planning') . "\">" . "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''></a>"; } else { return " "; } } } //// Default case // Link with plugin tables : need to know left join structure if (isset($table)) { if (preg_match("/^glpi_plugin_([a-z0-9]+)/", $table . '.' . $field, $matches)) { if (count($matches) == 2) { $plug = $matches[1]; $function = 'plugin_' . $plug . '_giveItem'; if (function_exists($function)) { $out = $function($itemtype, $ID, $data, $num); if (!empty($out)) { return $out; } } } } } $unit = ''; if (isset($searchopt[$ID]['unit'])) { $unit = $searchopt[$ID]['unit']; } // Preformat items if (isset($searchopt[$ID]["datatype"])) { switch ($searchopt[$ID]["datatype"]) { case "itemlink": $linkitemtype = getItemTypeForTable($searchopt[$ID]["table"]); $out = ""; $count_display = 0; $separate = self::LBBR; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = self::LBHR; } for ($k = 0; $k < $data[$num]['count']; $k++) { if (isset($data[$num][$k]['id'])) { if ($count_display) { $out .= $separate; } $count_display++; $page = $linkitemtype::getFormUrl(); $page .= strpos($page, '?') ? '&id' : '?id'; $name = Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit); if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][$k]['name'])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data[$num][$k]['id']); } $out .= "<a id='" . $linkitemtype . "_" . $data['id'] . "_" . $data[$num][$k]['id'] . "' href='{$page}=" . $data[$num][$k]['id'] . "'>" . $name . "</a>"; } } return $out; case "text": $separate = self::LBBR; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = self::LBHR; } $out = ''; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= $separate; } $count_display++; $text = ""; if (isset($searchopt[$ID]['htmltext']) && $searchopt[$ID]['htmltext']) { $text = Html::clean(Toolbox::unclean_cross_side_scripting_deep(nl2br($data[$num][$k]['name']))); } else { $text = nl2br($data[$num][$k]['name']); } if (self::$output_type == self::HTML_OUTPUT && Toolbox::strlen($text) > $CFG_GLPI['cut']) { $rand = mt_rand(); $out .= sprintf(__('%1$s %2$s'), "<span id='text{$rand}'>" . Html::resume_text($text, $CFG_GLPI['cut']) . '</span>', Html::showToolTip($text, array('applyto' => "text{$rand}", 'display' => false))); } else { $out .= $text; } } } return $out; case "date": case "date_delay": $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) { $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel']; } else { $out .= (empty($out) ? '' : self::LBBR) . Html::convDate($data[$num][$k]['name']); } } return $out; case "datetime": $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { if (is_null($data[$num][$k]['name']) && isset($searchopt[$ID]['emptylabel']) && $searchopt[$ID]['emptylabel']) { $out .= (empty($out) ? '' : self::LBBR) . $searchopt[$ID]['emptylabel']; } else { $out .= (empty($out) ? '' : self::LBBR) . Html::convDateTime($data[$num][$k]['name']); } } return $out; case "timestamp": $withseconds = false; if (isset($searchopt[$ID]['withseconds'])) { $withseconds = $searchopt[$ID]['withseconds']; } $withdays = true; if (isset($searchopt[$ID]['withdays'])) { $withdays = $searchopt[$ID]['withdays']; } $out = ''; for ($k = 0; $k < $data[$num]['count']; $k++) { $out .= (empty($out) ? '' : '<br>') . Html::timestampToString($data[$num][$k]['name'], $withseconds, $withdays); } return $out; case "email": $out = ''; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if ($count_display) { $out .= self::LBBR; } $count_display++; if (!empty($data[$num][$k]['name'])) { $out .= empty($out) ? '' : self::LBBR; $out .= "<a href='mailto:" . $data[$num][$k]['name'] . "'>" . $data[$num][$k]['name']; $out .= "</a>"; } } return empty($out) ? " " : $out; case "weblink": $orig_link = trim($data[$num][0]['name']); if (!empty($orig_link)) { // strip begin of link $link = preg_replace('/https?:\\/\\/(www[^\\.]*\\.)?/', '', $orig_link); $link = preg_replace('/\\/$/', '', $link); if (Toolbox::strlen($link) > $CFG_GLPI["url_maxlength"]) { $link = Toolbox::substr($link, 0, $CFG_GLPI["url_maxlength"]) . "..."; } return "<a href=\"" . formatOutputWebLink($orig_link) . "\" target='_blank'>{$link}</a>"; } return " "; case "count": case "number": $out = ""; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= self::LBBR; } $count_display++; if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) { $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']]; } else { $number = str_replace(' ', ' ', Html::formatNumber($data[$num][$k]['name'], false, 0)); $out .= Dropdown::getValueWithUnit($number, $unit); } } } return $out; case "decimal": $out = ""; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= self::LBBR; } $count_display++; if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) { $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']]; } else { $number = str_replace(' ', ' ', Html::formatNumber($data[$num][$k]['name'])); $out .= Dropdown::getValueWithUnit($number, $unit); } } } return $out; case "bool": $out = ""; $count_display = 0; for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= self::LBBR; } $count_display++; $out .= Dropdown::getValueWithUnit(Dropdown::getYesNo($data[$num][$k]['name']), $unit); } } return $out; case "itemtypename": if ($obj = getItemForItemtype($data[$num][0]['name'])) { return $obj->getTypeName(); } return ""; case "language": if (isset($CFG_GLPI['languages'][$data[$num][0]['name']])) { return $CFG_GLPI['languages'][$data[$num][0]['name']][0]; } return __('Default value'); } } // Manage items with need group by / group_concat $out = ""; $count_display = 0; $separate = self::LBBR; if (isset($searchopt[$ID]['splititems']) && $searchopt[$ID]['splititems']) { $separate = self::LBHR; } for ($k = 0; $k < $data[$num]['count']; $k++) { if (strlen(trim($data[$num][$k]['name'])) > 0) { if ($count_display) { $out .= $separate; } $count_display++; // Get specific display if available $itemtype = getItemTypeForTable($table); if ($item = getItemForItemtype($itemtype)) { $tmpdata = $data[$num][$k]; // Copy name to real field $tmpdata[$field] = $data[$num][$k]['name']; $specific = $item->getSpecificValueToDisplay($field, $tmpdata, array('html' => true, 'searchopt' => $searchopt[$ID])); } if (!empty($specific)) { $out .= $specific; } else { if (isset($searchopt[$ID]['toadd']) && isset($searchopt[$ID]['toadd'][$data[$num][$k]['name']])) { $out .= $searchopt[$ID]['toadd'][$data[$num][$k]['name']]; } else { // Empty is 0 or empty if (empty($split[0]) && isset($searchopt[$ID]['emptylabel'])) { $out .= $searchopt[$ID]['emptylabel']; } else { // Trans field exists if (isset($data[$num][$k]['trans']) && !empty($data[$num][$k]['trans'])) { $out .= Dropdown::getValueWithUnit($data[$num][$k]['trans'], $unit); } else { $out .= Dropdown::getValueWithUnit($data[$num][$k]['name'], $unit); } } } } } } return $out; // Trans in group concat if (count($split) == 3 && !empty($split[1])) { return Dropdown::getValueWithUnit($split[1], $unit); } return Dropdown::getValueWithUnit($split[0], $unit); }
/** * Task has been assigned to the user * * @param ProjectTask $task * @return boolean * @throws NotifierConnectionError */ function taskAssigned(ProjectTask $task) { if ($task->isCompleted()) { return true; // task has been already completed... } if (!$task->getAssignedTo() instanceof Contact) { return true; // not assigned to user } if (!is_valid_email($task->getAssignedTo()->getEmailAddress())) { return true; } tpl_assign('task_assigned', $task); $locale = $task->getAssignedTo()->getLocale(); Localization::instance()->loadSettings($locale, ROOT . '/language'); tpl_assign('title', $task->getObjectName()); tpl_assign('by', $task->getAssignedBy()->getObjectName()); tpl_assign('asigned', $task->getAssignedTo()->getObjectName()); $text = ""; if (config_option("wysiwyg_tasks")) { $text = purify_html(nl2br($task->getDescription())); } else { $text = escape_html_whitespace($task->getDescription()); } tpl_assign('description', $text); //descripction tpl_assign('description_title', lang("new task assigned to you desc", $task->getObjectName(), $task->getAssignedBy()->getObjectName())); //description_title //priority if ($task->getPriority()) { if ($task->getPriority() >= ProjectTasks::PRIORITY_URGENT) { $priorityColor = "#FF0000"; $priority = lang('urgent priority'); } else { if ($task->getPriority() >= ProjectTasks::PRIORITY_HIGH) { $priorityColor = "#FF9088"; $priority = lang('high priority'); } else { if ($task->getPriority() <= ProjectTasks::PRIORITY_LOW) { $priorityColor = "white"; $priority = lang('low priority'); } else { $priorityColor = "#DAE3F0"; $priority = lang('normal priority'); } } } tpl_assign('priority', array($priority, $priorityColor)); } //ALL SUBSCRIBERS if ($task->getSubscribers()) { $subscribers = $task->getSubscribers(); $string_subscriber = ''; $total_s = count($subscribers); $c = 0; foreach ($subscribers as $subscriber) { $c++; if ($c == $total_s && $total_s > 1) { $string_subscriber .= lang('and'); } else { if ($c > 1) { $string_subscriber .= ", "; } } $string_subscriber .= $subscriber->getFirstName(); if ($subscriber->getSurname() != "") { $string_subscriber .= " " . $subscriber->getSurname(); } } tpl_assign('subscribers', $string_subscriber); // subscribers } //context $contexts = array(); $members = $task->getMembers(); if (count($members) > 0) { foreach ($members as $member) { $dim = $member->getDimension(); if ($dim->getIsManageable()) { if ($dim->getCode() == "customer_project" || $dim->getCode() == "customers") { $obj_type = ObjectTypes::findById($member->getObjectTypeId()); if ($obj_type instanceof ObjectType) { $contexts[$dim->getCode()][$obj_type->getName()][] = '<span style="' . get_workspace_css_properties($member->getMemberColor()) . '">' . $member->getName() . '</span>'; } } else { $contexts[$dim->getCode()][] = '<span style="' . get_workspace_css_properties($member->getMemberColor()) . '">' . $member->getName() . '</span>'; } } } } tpl_assign('contexts', $contexts); //workspaces //start date, due date or start if ($task->getStartDate() instanceof DateTimeValue) { $date = Localization::instance()->formatDescriptiveDate($task->getStartDate(), $task->getAssignedTo()->getTimezone()); $time = Localization::instance()->formatTime($task->getStartDate(), $task->getAssignedTo()->getTimezone()); if ($time > 0) { $date .= " " . $time; } tpl_assign('start_date', $date); //start_date } if ($task->getDueDate() instanceof DateTimeValue) { $date = Localization::instance()->formatDescriptiveDate($task->getDueDate(), $task->getAssignedTo()->getTimezone()); $time = Localization::instance()->formatTime($task->getDueDate(), $task->getAssignedTo()->getTimezone()); if ($time > 0) { $date .= " " . $time; } tpl_assign('due_date', $date); //due_date } $attachments = array(); try { $content = FileRepository::getBackend()->getFileContent(owner_company()->getPictureFile()); if ($content) { $file_path = ROOT . "/tmp/logo_empresa.png"; $handle = fopen($file_path, 'wb'); if ($handle) { fwrite($handle, $content); fclose($handle); $attachments['logo'] = array('cid' => gen_id() . substr($task->getAssignedTo()->getEmailAddress(), strpos($task->getAssignedTo()->getEmailAddress(), '@')), 'path' => $file_path, 'type' => 'image/png', 'disposition' => 'inline', 'name' => 'logo_empresa.png'); tpl_assign('attachments', $attachments); // attachments } } } catch (FileNotInRepositoryError $e) { unset($attachments['logo']); } tpl_assign('attachments', $attachments); // attachments self::queueEmail(array(self::prepareEmailAddress($task->getAssignedTo()->getEmailAddress(), $task->getAssignedTo()->getObjectName())), null, null, self::prepareEmailAddress($task->getUpdatedBy()->getEmailAddress(), $task->getUpdatedByDisplayName()), lang('new task assigned to you', $task->getObjectName()), tpl_fetch(get_template_path('task_assigned', 'notifier')), 'text/html', '8bit', $attachments); // send $locale = logged_user() instanceof Contact ? logged_user()->getLocale() : DEFAULT_LOCALIZATION; Localization::instance()->loadSettings($locale, ROOT . '/language'); }
/** * Creates the string for the user's events and todos between the given start * and end times * * @param UserBean $user_bean the current UserBean * @param DateTime $start_date_time the start date to search from * @param DateTime $end_date_time the end date to search to * @param string $dtstamp the current timestamp * @return string the entries for events and todos */ protected function createSugarIcal(&$user_bean, &$start_date_time, &$end_date_time, $dtstamp) { $ical_array = array(); global $DO_USER_TIME_OFFSET, $sugar_config, $current_user, $timedate; $hide_calls = false; if (!empty($_REQUEST['hide_calls']) && $_REQUEST['hide_calls'] == "true") { $hide_calls = true; } $taskAsVTODO = true; if (!empty($_REQUEST['show_tasks_as_events']) && ($_REQUEST['show_tasks_as_events'] == "1" || $_REQUEST['show_tasks_as_events'] == "true")) { $taskAsVTODO = false; } $acts_arr = CalendarActivity::get_activities($user_bean->id, !$taskAsVTODO, $start_date_time, $end_date_time, 'month', !$hide_calls); // loop thru each activity, get start/end time in UTC, and return iCal strings foreach ($acts_arr as $act) { $event = $act->sugar_bean; if (!$hide_calls || $hide_calls && $event->object_name != "Call") { $ical_array[] = array("BEGIN", "VEVENT"); $ical_array[] = array("SUMMARY", $event->name); $ical_array[] = array("DTSTART;TZID=" . $user_bean->getPreference('timezone'), str_replace("Z", "", $timedate->tzUser($act->start_time, $current_user)->format(self::UTC_FORMAT))); $ical_array[] = array("DTEND;TZID=" . $user_bean->getPreference('timezone'), str_replace("Z", "", $timedate->tzUser($act->end_time, $current_user)->format(self::UTC_FORMAT))); $ical_array[] = array("DTSTAMP", $dtstamp); $ical_array[] = array("DESCRIPTION", $event->description); $ical_array[] = array("URL;VALUE=URI", $sugar_config['site_url'] . "/index.php?module=" . $event->module_dir . "&action=DetailView&record=" . $event->id); $ical_array[] = array("UID", $event->id); if ($event->object_name == "Meeting") { $ical_array[] = array("LOCATION", $event->location); $eventUsers = $event->get_meeting_users(); $query = "SELECT contact_id as id from meetings_contacts where meeting_id='{$event->id}' AND deleted=0"; $eventContacts = $event->build_related_list($query, new Contact()); $eventAttendees = array_merge($eventUsers, $eventContacts); if (is_array($eventAttendees)) { foreach ($eventAttendees as $attendee) { if ($attendee->id != $user_bean->id) { // Define the participant status $participant_status = ''; if (!empty($attendee->accept_status)) { switch ($attendee->accept_status) { case 'accept': $participant_status = ';PARTSTAT=ACCEPTED'; break; case 'decline': $participant_status = ';PARTSTAT=DECLINED'; break; case 'tentative': $participant_status = ';PARTSTAT=TENTATIVE'; break; } } $ical_array[] = array('ATTENDEE' . $participant_status . ';CN="' . $attendee->get_summary_text() . '"', 'mailto:' . (!empty($attendee->email1) ? $attendee->email1 : '*****@*****.**')); } } } } if ($event->object_name == "Call") { $eventUsers = $event->get_call_users(); $eventContacts = $event->get_contacts(); $eventAttendees = array_merge($eventUsers, $eventContacts); if (is_array($eventAttendees)) { foreach ($eventAttendees as $attendee) { if ($attendee->id != $user_bean->id) { // Define the participant status $participant_status = ''; if (!empty($attendee->accept_status)) { switch ($attendee->accept_status) { case 'accept': $participant_status = ';PARTSTAT=ACCEPTED'; break; case 'decline': $participant_status = ';PARTSTAT=DECLINED'; break; case 'tentative': $participant_status = ';PARTSTAT=TENTATIVE'; break; } } $ical_array[] = array('ATTENDEE' . $participant_status . ';CN="' . $attendee->get_summary_text() . '"', 'mailto:' . (!empty($attendee->email1) ? $attendee->email1 : '*****@*****.**')); } } } } if (isset($event->reminder_time) && $event->reminder_time > 0 && $event->status != "Held") { $ical_array[] = array("BEGIN", "VALARM"); $ical_array[] = array("TRIGGER", "-PT"); $ical_array[] = array("ACTION", "DISPLAY"); $ical_array[] = array("DESCRIPTION", $event->name); $ical_array[] = array("END", "VALARM"); } $ical_array[] = array("END", "VEVENT"); } } $str = vCal::create_ical_string_from_array($ical_array, true); require_once 'include/TimeDate.php'; $timedate = new TimeDate(); $today = gmdate("Y-m-d"); $today = $timedate->handle_offset($today, $timedate->dbDayFormat, false); require_once 'modules/ProjectTask/ProjectTask.php'; $where = "project_task.assigned_user_id='{$user_bean->id}' " . "AND (project_task.status IS NULL OR (project_task.status!='Deferred')) " . "AND (project_task.date_start IS NULL OR " . CalendarActivity::get_occurs_within_where_clause('project_task', '', $start_date_time, $end_date_time, 'date_start', 'month') . ")"; $seedProjectTask = new ProjectTask(); $projectTaskList = $seedProjectTask->get_full_list("", $where); if (is_array($projectTaskList)) { foreach ($projectTaskList as $projectTask) { $str .= $this->createSugarIcalTodo($user_bean, $projectTask, "ProjectTask", $dtstamp); } } if ($taskAsVTODO) { require_once 'modules/Tasks/Task.php'; $where = "tasks.assigned_user_id='{$user_bean->id}' " . "AND (tasks.status IS NULL OR (tasks.status!='Deferred')) " . "AND (tasks.date_start IS NULL OR " . CalendarActivity::get_occurs_within_where_clause('tasks', '', $start_date_time, $end_date_time, 'date_start', 'month') . ")"; $seedTask = new Task(); $taskList = $seedTask->get_full_list("", $where); if (is_array($taskList)) { foreach ($taskList as $task) { $str .= $this->createSugarIcalTodo($user_bean, $task, "Tasks", $dtstamp); } } } return $str; }
/** * @see ProjectInterface::set_next_status() * @return bool * @throws ProjectSetNextStatusException */ public function set_next_status() { global $transaction; if ($this->project_id) { if ($this->is_current_status_fulfilled()) { $transaction_id = $transaction->begin(); $current_status_id = $this->get_current_status_id(); $next_status_id = $this->get_next_status_id(); $project_has_project_status = new ProjectHasProjectStatus_Access(null); if ($project_has_project_status->create($this->project_id, $next_status_id) != null) { if (ProjectTask::check_over_time_tasks($this->project_id) == false) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectSetNextStatusException(); } $project_log = new ProjectLog(null); if ($project_log->create($this->project_id, null) != null) { if ($project_log->link_status($next_status_id) == true) { if ($transaction_id != null) { $transaction->commit($transaction_id); } return true; } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectSetNextStatusException(); } } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectSetNextStatusException(); } } else { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw new ProjectSetNextStatusException(); } } else { throw new ProjectSetNextStatusException(); } } else { throw new ProjectSetNextStatusException(); } }
/** * Show projecttasks for a ticket * * @param $ticket Ticket object **/ static function showForTicket(Ticket $ticket) { global $DB, $CFG_GLPI; $ID = $ticket->getField('id'); if (!$ticket->can($ID, READ)) { return false; } $canedit = $ticket->canEdit($ID); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_projecttasks_tickets`.`id` AS linkID,\n `glpi_projecttasks`.*\n FROM `glpi_projecttasks`\n LEFT JOIN `glpi_projecttasks_tickets`\n ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_projecttasks`.`name`"; $result = $DB->query($query); $pjtasks = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $pjtasks[$data['id']] = $data; $used[$data['id']] = $data['id']; } } // if ($canedit) { // echo "<div class='firstbloc'>"; // echo "<form name='projecttaskticket_form$rand' id='projecttaskticket_form$rand' // method='post' action='".Toolbox::getItemTypeFormURL(__CLASS__)."'>"; // // echo "<table class='tab_cadre_fixe'>"; // echo "<tr class='tab_bg_2'><th colspan='3'>".__('Add a project task')."</th></tr>"; // // echo "<tr class='tab_bg_2'><td class='right'>"; // echo "<input type='hidden' name='tickets_id' value='$ID'>"; // $condition = "`glpi_projecttasks`.`projectstates_id` <> 3"; // ProjectTask::dropdown(array('used' => $used, // 'entity' => $ticket->getEntityID(), // 'entity_sons' => $ticket->isRecursive(), // 'condition' => $condition, // 'displaywith' => array('id'))); // echo "</td><td width='20%'>"; // // echo "<a href='".Toolbox::getItemTypeFormURL('ProjectTask')."?tickets_id=$ID'>"; // // _e('Create a project task from this ticket'); // // echo "</a>"; // echo "</td><td class='center'>"; // echo "<input type='submit' name='add' value=\""._sx('button', 'Add')."\" class='submit'>"; // echo "</td></tr>"; // // echo "</table>"; // Html::closeForm(); // echo "</div>"; // } echo "<div class='spaced'>"; if ($numrows) { $columns = array('projectname' => Project::getTypeName(Session::getPluralNumber()), 'name' => ProjectTask::getTypeName(Session::getPluralNumber()), 'tname' => __('Type'), 'sname' => __('Status'), 'percent_done' => __('Percent done'), 'plan_start_date' => __('Planned start date'), 'plan_end_date' => __('Planned end date'), 'planned_duration' => __('Planned duration'), '_effect_duration' => __('Effective duration'), 'fname' => __('Father')); if (isset($_GET["order"]) && $_GET["order"] == "DESC") { $order = "DESC"; } else { $order = "ASC"; } if (!isset($_GET["sort"]) || empty($_GET["sort"])) { $_GET["sort"] = "plan_start_date"; } if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) { $sort = "`" . $_GET["sort"] . "`"; } else { $sort = "`plan_start_date` {$order}, `name`"; } $query = "SELECT `glpi_projecttasks`.*,\n `glpi_projecttasktypes`.`name` AS tname,\n `glpi_projectstates`.`name` AS sname,\n `glpi_projectstates`.`color`,\n `father`.`name` AS fname,\n `father`.`id` AS fID,\n `glpi_projects`.`name` AS projectname,\n `glpi_projects`.`content` AS projectcontent\n FROM `glpi_projecttasks`\n LEFT JOIN `glpi_projecttasktypes`\n ON (`glpi_projecttasktypes`.`id` = `glpi_projecttasks`.`projecttasktypes_id`)\n LEFT JOIN `glpi_projectstates`\n ON (`glpi_projectstates`.`id` = `glpi_projecttasks`.`projectstates_id`)\n LEFT JOIN `glpi_projecttasks` as father\n ON (`father`.`id` = `glpi_projecttasks`.`projecttasks_id`)\n LEFT JOIN `glpi_projecttasks_tickets`\n ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n LEFT JOIN `glpi_projects`\n ON (`glpi_projecttasks`.`projects_id` = `glpi_projects`.`id`)\n WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n ORDER BY {$sort} {$order}"; Session::initNavigateListItems('ProjectTask', sprintf(__('%1$s = %2$s'), $ticket::getTypeName(1), $ticket->getName())); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='10'>" . ProjectTask::getTypeName($numrows) . "</th>"; echo "</tr>"; $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>"; $header = '<tr>'; foreach ($columns as $key => $val) { // Non order column if ($key[0] == '_') { $header .= "<th>{$val}</th>"; } else { $header .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>"; } } $header .= "</tr>\n"; echo $header; while ($data = $DB->fetch_assoc($result)) { Session::addToNavigateListItems('ProjectTask', $data['id']); $rand = mt_rand(); echo "<tr class='tab_bg_2'>"; echo "<td>"; $link = "<a id='Project" . $data["projects_id"] . $rand . "' href='project.form.php?id=" . $data['projects_id'] . "'>" . $data['projectname'] . (empty($data['projectname']) ? "(" . $data['projects_id'] . ")" : "") . "</a>"; echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['projectcontent'], array('display' => false, 'applyto' => "Project" . $data["projects_id"] . $rand))); echo "</td>"; echo "<td>"; $link = "<a id='ProjectTask" . $data["id"] . $rand . "' href='projecttask.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a>"; echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['content'], array('display' => false, 'applyto' => "ProjectTask" . $data["id"] . $rand))); echo "</td>"; echo "<td>" . $data['tname'] . "</td>"; echo "<td"; echo " style=\"background-color:" . $data['color'] . "\""; echo ">" . $data['sname'] . "</td>"; echo "<td>"; echo Dropdown::getValueWithUnit($data["percent_done"], "%"); echo "</td>"; echo "<td>" . Html::convDateTime($data['plan_start_date']) . "</td>"; echo "<td>" . Html::convDateTime($data['plan_end_date']) . "</td>"; echo "<td>" . Html::timestampToString($data['planned_duration'], false) . "</td>"; echo "<td>" . Html::timestampToString(ProjectTask::getTotalEffectiveDuration($data['id']), false) . "</td>"; echo "<td>"; if ($data['projecttasks_id'] > 0) { $father = Dropdown::getDropdownName('glpi_projecttasks', $data['projecttasks_id']); echo "<a id='ProjectTask" . $data["projecttasks_id"] . $rand . "' href='projecttask.form.php?id=" . $data['projecttasks_id'] . "'>" . $father . (empty($father) ? "(" . $data['projecttasks_id'] . ")" : "") . "</a>"; } echo "</td></tr>"; } echo $header; echo "</table>\n"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table>\n"; } } echo "</div>"; } }
/** @file * @brief * @since version 0.85 */ include '../inc/includes.php'; Session::checkCentralAccess(); if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["projects_id"])) { $_GET["projects_id"] = ""; } if (!isset($_GET["projecttasks_id"])) { $_GET["projecttasks_id"] = ""; } $task = new ProjectTask(); if (isset($_POST["add"])) { $task->check(-1, CREATE, $_POST); $newID = $task->add($_POST); Event::log($task->fields['projects_id'], 'project', 4, "maintain", sprintf(__('%s adds a task'), $_SESSION["glpiname"])); if ($_SESSION['glpibackcreated']) { Html::redirect($task->getFormURL() . "?id=" . $newID); } else { Html::redirect(Project::getFormURL() . "?projects_id=" . $task->fields['projects_id']); } } else { if (isset($_POST["purge"])) { $task->check($_POST['id'], PURGE); $task->delete($_POST, 1); Event::log($task->fields['projects_id'], 'project', 4, "maintain", sprintf(__('%s purges a task'), $_SESSION["glpiname"])); Html::redirect(Project::getFormURL() . "?id=" . $task->fields['projects_id']);