protected function saveModel($tasktemplate = false) { if (Input::get('id')) { $tasktemplate = TaskTemplate::find(Input::get('id')); } if (!$tasktemplate) { $tasktemplate = new TaskTemplate(); } $tasktemplate->title = Input::get('title'); $tasktemplate->description = Input::get('description'); $tasktemplate->group_id = Input::get('group_id'); $tasktemplate->deadline_days_gap = Input::get('deadline_days_gap'); $tasktemplate->save(); return $tasktemplate; }
public function addDefaultTasks($model) { // add to taskevents all the tasktemplates $default_tasks = TaskTemplate::all(); $event_date_col = $model->date()->first(); if (!$event_date_col) { return; } $event_date = $event_date_col->datetime_start->format('Y-m-d'); eerror_log("Le event date : " . $event_date); foreach ($default_tasks as $task_ndx => $task) { if ($task->deadline_days_gap > 0) { $task_deadline = date('Y-m-d', strtotime(-$task->deadline_days_gap . ' days', strtotime($event_date))); } else { $task_deadline = date('Y-m-d', strtotime($event_date)); } $new_task = new TaskEvent(); $new_task->title = $task->title; $new_task->description = $task->description; $new_task->due_date = $task_deadline; $new_task->status = 'incomplete'; $new_task->group_id = $task->group_id; $new_task->events_id = $model->id; $new_task->deadline_days_gap = $task->deadline_days_gap; $new_task->updated_by = Auth::user()->id; $new_task->owner_changed_at = date("Y-m-d H:i:s"); eerror_log('task due date ' . json_encode($new_task->due_date) . '\\n'); $new_task->save(); } }
public function getData() { $models = TaskTemplate::select($this->dataTableColumns); return Datatables::of($models)->addColumn('Group', function ($m) { $ret = TaskGroup::find($m->group_id)->name; Debugbar::info($ret); return $ret; })->removeColumn('group_id')->add_column('actions', '<a href="{{{ URL::to(\'/admin/tasktemplates/\' . $id . \'/edit\' ) }}}" class="iframe btn btn-xs btn-default cboxElement">{{{ Lang::get(\'button.edit\') }}}</a> <a href="{{{ URL::to(\'/admin/tasktemplates/\' . $id . \'/delete\' ) }}}" class="iframe btn btn-xs btn-danger cboxElement">{{{ Lang::get(\'button.delete\') }}}</a>')->make(); }
private function validateSaveTasktemplate4Common($request, array &$validateInfo) { /*{{{*/ if (false == TaskTemplate::scriptPathIsRight(trim($request->scriptpath))) { $validateInfo['error'][] = '路径输入不正确'; } if (trim($request->title) == '') { $validateInfo['error'][] = 'title不可为空'; } if (false == file_exists(trim($request->scriptpath))) { $validateInfo['warning'][] = '你输入的脚本路径在现有代码中不存在'; } if (trim($request->scriptauthoremail) == '') { $validateInfo['error'][] = '脚本作者email不能为空'; } else { if (false == XString::isEmail(trim($request->scriptauthoremail))) { $validateInfo['error'][] = '脚本作者email格式不正确'; } } if (trim($request->scriptauthorleaderemail) == '') { $validateInfo['error'][] = '团队Leader email不能为空'; } else { if (false == XString::isEmail(trim($request->scriptauthorleaderemail))) { $validateInfo['error'][] = '团队leader email格式不正确'; } } if (trim($request->scriptauthormobile) == '') { $validateInfo['error'][] = '作者电话不可为空'; } else { if (false == XString::isMobile($request->scriptauthormobile)) { $validateInfo['error'][] = '您输入的11位作者手机号码格式不正确'; } } if (trim($request->scriptauthorleadermobile) == '') { $validateInfo['error'][] = '团队leader电话不可为空'; } else { if (false == XString::isMobile($request->scriptauthorleadermobile)) { $validateInfo['error'][] = '您输入的11位团队leader手机号码格式不正确'; } } if (false == CronConfigMgr::cronConfigIsRight(CronConfigMgr::getCronConfigUseSSH())) { $validateInfo['error'][] = '机器上的cron配置格式有问题'; } }
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 */ $AJAX_INCLUDE = 1; include '../inc/includes.php'; header("Content-Type: application/json; charset=UTF-8"); Html::header_nocache(); Session::checkLoginUser(); $template = new TaskTemplate(); $template->getEmpty(); if (isset($_POST['tasktemplates_id']) && (int) $_POST['tasktemplates_id'] > 0) { $template->getFromDB($_POST['tasktemplates_id']); } $template->fields = array_map('html_entity_decode', $template->fields); echo json_encode($template->fields);
/** form for Task * * @param $ID Integer : Id of the task * @param $options array * - parent Object : the object **/ function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; $rand_template = mt_rand(); $rand_text = mt_rand(); $rand_type = mt_rand(); $rand_time = mt_rand(); if (isset($options['parent']) && !empty($options['parent'])) { $item = $options['parent']; } $fkfield = $item->getForeignKeyField(); if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[$fkfield] = $item->getField('id'); $this->check(-1, CREATE, $options); } $rand = mt_rand(); $this->showFormHeader($options); $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED); $rowspan = 5; if ($this->maybePrivate()) { $rowspan++; } if (isset($this->fields["state"])) { $rowspan++; } echo "<tr class='tab_bg_1'>"; echo "<td rowspan='{$rowspan}' style='width:100px'>" . __('Description') . "</td>"; echo "<td rowspan='{$rowspan}' style='width:50%' id='content{$rand_text}'>" . "<textarea name='content' style='width: 95%; height: 160px' id='task{$rand_text}'>" . $this->fields["content"] . "</textarea>"; echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });"); echo "</td>"; echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td style='width:100px'>" . _n('Task template', 'Task templates', 1) . "</td><td>"; TaskTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'on_change' => 'tasktemplate_update(this.value)')); echo "</td>"; echo "</tr>"; echo Html::scriptBlock(' function tasktemplate_update(value) { jQuery.ajax({ url: "' . $CFG_GLPI["root_doc"] . '/ajax/task.php", type: "POST", data: { tasktemplates_id: value } }).done(function(datas) { datas.taskcategories_id = isNaN(parseInt(datas.taskcategories_id)) ? 0 : parseInt(datas.taskcategories_id); datas.actiontime = isNaN(parseInt(datas.actiontime)) ? 0 : parseInt(datas.actiontime); $("#task' . $rand_text . '").html(datas.content); $("#dropdown_taskcategories_id' . $rand_type . '").select2("val", parseInt(datas.taskcategories_id)); $("#dropdown_actiontime' . $rand_time . '").select2("val", parseInt(datas.actiontime)); }); } '); if ($ID > 0) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Date') . "</td>"; echo "<td>"; Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false)); echo "</tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'> "; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Category') . "</td><td>"; TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'rand' => $rand_type, 'entity' => $item->fields["entities_id"], 'condition' => "`is_active` = '1'")); echo "</td></tr>\n"; if (isset($this->fields["state"])) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Status') . "</td><td>"; Planning::dropdownState("state", $this->fields["state"]); echo "</td></tr>\n"; } if ($this->maybePrivate()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Private') . "</td>"; echo "<td>"; Dropdown::showYesNo('is_private', $this->fields["is_private"]); echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Duration') . "</td><td>"; $toadd = array(); for ($i = 9; $i <= 100; $i++) { $toadd[] = $i * HOUR_TIMESTAMP; } Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'rand' => $rand_time, 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd)); echo "</td></tr>\n"; if ($ID <= 0) { Document_Item::showSimpleAddForItem($item); } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('By') . "</td>"; echo "<td colspan='2'>"; echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . " "; echo _n('User', 'Users', 1); $rand_user = mt_rand(); $params = array('name' => "users_id_tech", 'value' => $ID > -1 ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"], 'width' => ''); $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php"); User::dropdown($params); echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">"; echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n class='calendrier'>"; echo "</a>"; Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability'))); echo "<br />"; echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . " "; echo _n('Group', 'Groups', 1) . " "; $rand_group = mt_rand(); $params = array('name' => "groups_id_tech", 'value' => $ID > -1 ? $this->fields["groups_id_tech"] : Dropdown::EMPTY_VALUE, 'condition' => "is_task", 'rand' => $rand_group, 'entity' => $item->fields["entities_id"]); $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "group_available{$rand_group}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php"); Group::dropdown($params); echo "</td>\n"; echo "<td>"; if ($canplan) { echo __('Planning'); } if (!empty($this->fields["begin"])) { if (Session::haveRight('planning', Planning::READMY)) { echo "<script type='text/javascript' >\n"; echo "function showPlan" . $ID . $rand_text . "() {\n"; echo Html::jsHide("plan{$rand_text}"); $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'groups_id' => $this->fields["groups_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; echo "<div id='plan{$rand_text}' onClick='showPlan" . $ID . $rand_text . "()'>\n"; echo "<span class='showplan'>"; } if (isset($this->fields["state"])) { echo Planning::getState($this->fields["state"]) . "<br>"; } printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if (isset($this->fields["users_id_tech"]) && $this->fields["users_id_tech"] > 0) { echo "<br>" . getUserName($this->fields["users_id_tech"]); } if (isset($this->fields["groups_id_tech"]) && $this->fields["groups_id_tech"] > 0) { echo "<br>" . Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"]); } if (Session::haveRight('planning', Planning::READMY)) { echo "</span>"; echo "</div>\n"; echo "<div id='viewplan{$rand_text}'></div>\n"; } } else { if ($canplan) { echo "<script type='text/javascript' >\n"; echo "function showPlanUpdate{$rand_text}() {\n"; echo Html::jsHide("plan{$rand_text}"); $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'entity' => $item->fields['entities_id'], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'itemtype' => $this->getType(), 'items_id' => $this->getID()); Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "};"; echo "</script>"; if ($canplan) { echo "<div id='plan{$rand_text}' onClick='showPlanUpdate{$rand_text}()'>\n"; echo "<span class='vsubmit'>" . __('Plan this task') . "</span>"; echo "</div>\n"; echo "<div id='viewplan{$rand_text}'></div>\n"; } } else { _e('None'); } } echo "</td></tr>"; if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) { echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>"; PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID())); echo "</td><td colspan='2'></td></tr>"; } $this->showFormButtons($options); return true; }