* Copyright 2010 (c) Fusionforge Team
* Copyright 2011, Franck Villaume - Capgemini
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2014,2016, Franck Villaume - TrivialDev
- * Copyright 2016, Stéphane-Eymeric Bredthauer - TrivialDev
+ * Copyright 2014,2016-2017,2021, Franck Villaume - TrivialDev
+ * Copyright 2016-2017, Stéphane-Eymeric Bredthauer - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
require_once $gfcommon.'tracker/ArtifactExtraFieldElement.class.php';
require_once $gfcommon.'tracker/ArtifactWorkflow.class.php';
+require_once $gfcommon.'tracker/EffortUnitFactory.class.php';
require_once $gfcommon.'include/utils_crossref.php';
-require_once $gfcommon.'include/UserManager.class.php';
+require_once $gfcommon.'widget/WidgetLayoutManager.class.php';
class ArtifactTypeHtml extends ArtifactType {
if (!forge_get_config('use_tracker')) {
exit_disabled();
}
- $group_id= $this->Group->getID();
+ global $group_id;
+ $group_id = $this->Group->getID();
//required by new site_project_header
- $params['group']=$group_id;
- $params['toptab']='tracker';
- $params['tabtext']=$this->getName();
+ $params['group'] = $group_id;
+ $params['toptab'] = 'tracker';
+ $params['tabtext'] = $this->getName();
$labels = array();
$links = array();
$labels[] = _('Export CSV');
$links[] = '/tracker/?func=csv&group_id='.$group_id.'&atid='. $this->getID();
$attr[] = array('title' => _('Download data from this tracker as csv file.'));
- if (forge_check_perm ('tracker',$this->getID(),'submit')) {
+ if (forge_check_perm('tracker', $this->getID(),'submit')) {
$labels[] = _('Submit New');
$links[] = '/tracker/?func=add&group_id='.$group_id.'&atid='. $this->getID();
$attr[] = array('title' => _('Add a new issue.'));
$labels[] = _('Administration');
$links[] = '/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID();
$attr[] = array('title' => _('Global administration for trackers. Create, clone, workflow, fields ...'));
+
+ if (forge_get_config('use_tracker_widget_display')) {
+ $sql = "SELECT l.* FROM layouts AS l INNER JOIN owner_layouts AS o ON(l.id = o.layout_id)
+ WHERE o.owner_type = $1
+ AND o.owner_id = $2
+ AND o.is_default = 1";
+ $res = db_query_params($sql,array('t', $this->getID()));
+ if($res && db_numrows($res) < 1) {
+ $lm = new WidgetLayoutManager();
+ $lm->createDefaultLayoutForTracker($this->getID());
+ $res = db_query_params($sql,array('t', $this->getID()));
+ }
+ $id = db_result($res, 0 , 'id');
+ $url = '/widgets/widgets.php?owner=t'.$this->getID().'&layout_id='.$id;
+ $labels[] = _('Add widgets');
+ $labels[] = _('Customize Layout');
+ $attr[] = array('title' => _('Customfields must be linked to a widget to be displayed. Use “Add widgets” to create new widget to link and organize your customfields.'));
+ $attr[] = array('title' => _('General layout to display “Submit New” form or detailed view of an existing artifact can be customize. Use “Customize Layout” to that purpose.'));
+ $links[] = $url;
+ $links[] = $url.'&update=layout';
+ }
}
}
$params['submenu'] = $HTML->subMenu($labels, $links, $attr);
site_project_header($params);
- if ($this)
- plugin_hook("blocks", "tracker_".$this->getName());
-
+ if ($this) {
+ plugin_hook('blocks', 'tracker_'.$this->getName());
+ }
}
function footer($params = array()) {
global $HTML;
$this->header($params);
$group_id= $this->Group->getID();
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id;
- $title_arr[]=_('New Tracker');
- $attr_arr[] = array('title'=>_('Create a new tracker.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&update_type=1';
- $title_arr[]=_('Update Settings');
- $attr_arr[] = array('title'=>_('Set up preferences like expiration times, email addresses.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_extrafield=1';
- $title_arr[]=_('Manage Custom Fields');
- $attr_arr[] = array('title'=>_('Add new boxes like Phases, Quality Metrics, Components, etc. Once added they can be used with other selection boxes (for example, Categories or Groups) to describe and browse bugs or other artifact types.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&workflow=1';
- $title_arr[]=_('Manage Workflow');
- $attr_arr[] = array('title'=>_('Edit tracker workflow.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&customize_list=1';
- $title_arr[]=_('Customize List');
- $attr_arr[] = array('title'=>_('Customize display for the tracker.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_canned=1';
- $title_arr[]=_('Manage Canned Responses');
- $attr_arr[] = array('title'=>_('Create/change generic response messages for the tracker.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&clone_tracker=1';
- $title_arr[]=_('Apply Template Tracker');
- $attr_arr[] = array('title'=>_('Duplicate parameters and fields from a template trackers in this one.'));
-
- $links_arr[]='/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&delete=1';
- $title_arr[]=_('Delete');
- $attr_arr[] = array('title'=>_('Permanently delete this tracker.'));
-
- echo $HTML->printSubMenu($title_arr, $links_arr, $attr_arr);
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id, _('New Tracker'), array('title'=>_('Create a new tracker.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&update_type=1', _('Update Settings'), array('title'=>_('Set up preferences like expiration times, email addresses.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&effort_units=1', _('Manage Effort Units'), array('title'=>_('Manage Effort Units for Effort custom extra field.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_extrafield=1', _('Manage Custom Fields'), array('title'=>_('Add new boxes like Phases, Quality Metrics, Components, etc. Once added they can be used with other selection boxes (for example, Categories or Groups) to describe and browse bugs or other artifact types.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&workflow=1', _('Manage Workflow'), array('title'=>_('Edit tracker workflow.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&customize_list=1', _('Customize List'), array('title'=>_('Customize display for the tracker.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&add_canned=1', _('Manage Canned Responses'), array('title'=>_('Create/change generic response messages for the tracker.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&clone_tracker=1', _('Apply Template Tracker'), array('title'=>_('Duplicate parameters and fields from a template trackers in this one.'))));
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID().'&delete=1', _('Delete'), array('title'=>_('Permanently delete this tracker.'))));
+ $hook_params = array('group_id' => $group_id, 'atid' => $this->getID());
+ plugin_hook_by_reference("admin_tracker_add_actions", $hook_params);
+ if (isset($hook_params['result'])) {
+ foreach($hook_params['result'] as $action => $values) {
+ $elementLi[] = array('content' => util_make_link('/tracker/admin/?group_id='.$group_id.'&atid='.$this->getID()."&$action=1", $values['text'], array('title'=>$values['description'])));
+ }
+ }
+ echo $HTML->html_list($elementLi);
}
function adminFooter($params) {
$types = array(),
$status_show_100 = false,
$mode = '') {
+ global $HTML;
+ global $ah;
+
if ($mode == 'NEW') {
$efarr = $this->getExtraFields($types, false, false);
} else {
} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_DATETIME ||
$type == ARTIFACT_EXTRAFIELDTYPE_DATE) {
$efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_DATERANGE;
+ } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
+ $efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_EFFORTRANGE;
} else {
$efarr[$i]['field_type'] = ARTIFACT_EXTRAFIELDTYPE_TEXT;
}
$post_name = '';
$i=$keys[$k];
- if (!isset($selected[$efarr[$i]['extra_field_id']]))
+ if (!isset($selected[$efarr[$i]['extra_field_id']])) {
$selected[$efarr[$i]['extra_field_id']] = '';
-
+ }
$value = $selected[$efarr[$i]['extra_field_id']];
$type = $efarr[$i]['field_type'];
// Convert the values (ids) to names in the ids order.
$new = array();
for ($j=0; $j<count($arr); $j++) {
- if (is_array($value) && in_array($arr[$j]['element_id'],$value)) {
+ if (is_array($value) && in_array($arr[$j]['element_id'], $value)) {
$new[]= $arr[$j]['element_name'];
} elseif ($arr[$j]['element_id'] === $value) {
$new[] = $arr[$j]['element_name'];
$type == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
$value = preg_replace('/((http|https|ftp):\/\/\S+)/',
"<a href=\"\\1\" target=\"_blank\">\\1</a>", $value);
- } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
+ } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_RELATION || $type == ARTIFACT_EXTRAFIELDTYPE_PARENT) {
// Convert artifact id to links.
- $value = preg_replace_callback('/\b(\d+)\b/', create_function('$matches', 'return _artifactid2url($matches[1], \'title\');'), $value);
+ $callback = function ($matches) { return _artifactid2url($matches, 'title'); };
+ $value = preg_replace_callback('/\b(\d+)\b/', $callback, $value);
} elseif ($type == ARTIFACT_EXTRAFIELDTYPE_DATETIME && $value!='') {
$value = date('Y-m-d H:i', $value);
+ } elseif ($type == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
+ if (!isset($effortUnitSet)) {
+ $effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
+ $effortUnitFactory = New EffortUnitFactory($effortUnitSet);
+ }
+ $value = $effortUnitFactory->encodedToString($value);
}
$template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}', $post_name, $template);
$template = str_replace('{$'.$efarr[$i]['field_name'].'}', $value, $template);
}
if ($mode == 'UPDATE' || $mode == 'NEW') {
- if (in_array($efarr[$i]['extra_field_id'],$efInFormula)) {
+ if (in_array($efarr[$i]['extra_field_id'], $efInFormula)) {
$attrs['class'] = (empty($attrs['class']) ? '':$attrs['class'].' ').'in-formula';
}
- if (in_array($efarr[$i]['extra_field_id'],$efWithFormula)) {
+ if (in_array($efarr[$i]['extra_field_id'], $efWithFormula)) {
$attrs['class'] = (empty($attrs['class']) ? '':$attrs['class'].' ').'with-formula readonly';
$attrs['readonly'] = 'readonly';
}
}
- if (!isset($selected[$efarr[$i]['extra_field_id']]))
+ if (!isset($selected[$efarr[$i]['extra_field_id']])) {
$selected[$efarr[$i]['extra_field_id']] = '';
-
+ }
if ($status_show_100) {
$efarr[$i]['show100'] = $status_show_100;
}
+ $allowed = false;
+
if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
- $allowed=false;
if (!is_null($efarr[$i]['parent']) && !empty($efarr[$i]['parent']) && $efarr[$i]['parent']!='100') {
$aefParentId = $efarr[$i]['parent'];
$selectedElmnts = (isset($selected[$aefParentId]) ? $selected[$aefParentId] : '');
- $aef = new ArtifactExtraField($this,$efarr[$i]['extra_field_id']);
+ $aef = new ArtifactExtraField($this, $efarr[$i]['extra_field_id']);
$allowed = $aef->getAllowedValues($selectedElmnts);
}
}
if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SELECT) {
-
- $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,$allowed, $attrs);
+ $str = $this->renderSelect($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $show_any, $text_any, $allowed, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_CHECKBOX) {
- $str = $this->renderCheckbox($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'], $allowed, $attrs);
+ $str = $this->renderCheckbox($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $allowed, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RADIO) {
- $str = $this->renderRadio($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any, $text_any, $allowed, $attrs);
+ $str = $this->renderRadio($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $show_any, $text_any, $allowed, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_INTEGER) {
$attrs['pattern'] = $efarr[$i]['pattern'];
}
if ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT) {
- $str = $this->renderTextField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
+ $str = $this->renderTextField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
} else {
- $str = $this->renderIntegerField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
+ $str = $this->renderIntegerField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
}
if ($mode == 'QUERY') {
- $post_name = ' <i>'._('(%% for wildcards)').'</i> ';
+ $post_name = ' '.html_e('em', array(), _('(%% for wildcards)')).' ';
}
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXTAREA) {
- $str = $this->renderTextArea($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
+ $str = $this->renderTextArea($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
if ($mode == 'QUERY') {
- $post_name = ' <i>'._('(%% for wildcards)').'</i>';
+ $post_name = ' '.html_e('em', array(), _('(%% for wildcards)'));
}
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTISELECT) {
- $str = $this->renderMultiSelectBox($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'], $allowed, $attrs);
+ $str = $this->renderMultiSelectBox($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $allowed, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_STATUS) {
+ // parent artifact can't be close if a child is still open
+ if ($mode == 'UPDATE' &&
+ $efarr[$i]['aggregation_rule'] == ARTIFACT_EXTRAFIELD_AGGREGATION_RULE_STATUS_CLOSE_RESTRICTED &&
+ $ah->hasChildren()) {
+ $children = $ah->getChildren();
+ $childOpen = false;
+ foreach ($children as $child) {
+ if ($child['status_id'] == 1) {
+ $childOpen = true;
+ break;
+ }
+ }
+ if ($childOpen) {
+ $aef = new ArtifactExtraField($this, $efarr[$i]['extra_field_id']);
+ $statusArr = $aef->getAvailableValues();
+ $openStatus = array();
+ foreach ($statusArr as $status) {
+ if ($status['status_id']==1) {
+ $openStatus[] = $status['element_id'];
+ }
+ }
+ if ($allowed) {
+ $allowed = array_intersect($allowed, $openStatus);
+ } else {
+ $allowed = $openStatus;
+ }
+ }
+ }
// Get the allowed values from the workflow.
$atw = new ArtifactWorkflow($this, $efarr[$i]['extra_field_id']);
$selected_node = $selected[$efarr[$i]['extra_field_id']];
} else {
$selected_node = 100;
+
}
- $allowed = $atw->getNextNodes($selected_node);
+ $allowedWF = $atw->getNextNodes($selected_node);
+ if ($allowed) {
+ $allowed = array_intersect($allowed, $allowedWF);
+ } else {
+ $allowed = $allowedWF;
+ }
$allowed[] = $selected_node;
- $str = $this->renderSelect($efarr[$i]['extra_field_id'],$selected_node,$status_show_100,$text_100,$show_any,$text_any, $allowed, $attrs);
+ $str = $this->renderSelect($efarr[$i]['extra_field_id'], $selected_node, $status_show_100, $text_100, $show_any, $text_any, $allowed, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION) {
-
- $str = $this->renderRelationField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['attribute1'],$efarr[$i]['attribute2'], $attrs);
+ $str = $this->renderRelationField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
+ if ($mode == 'UPDATE' || $mode == 'NEW') {
+ $post_name = $HTML->getEditFieldPic(_('Click to edit'), _('Click to edit'), array('onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
+ }
+ } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_PARENT) {
+ $str = $this->renderParentField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
if ($mode == 'UPDATE' || $mode == 'NEW') {
- $post_name = html_image('ic/forum_edit.gif', 37, 15 ,array('title'=>"Click to edit", 'alt'=>"Click to edit", 'onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
+ $post_name = $HTML->getEditFieldPic(_('Click to edit'), _('Click to edit'), array('onclick'=>"switch2edit(this, 'show$i', 'edit$i')"));
}
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_DATETIME) {
- $str = $this->renderDatetime($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']], $attrs);
+ $str = $this->renderDatetime($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_USER) {
- $str = $this->renderUserField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false, $attrs);
+ $str = $this->renderUserField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $show_any, $text_any,false, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTIUSER) {
- $str = $this->renderMultiUserField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false, $attrs);
+ $str = $this->renderMultiUserField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $show_any, $text_any,false, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELEASE) {
- $str = $this->renderReleaseField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false, $attrs);
+ $str = $this->renderReleaseField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $show_any, $text_any,false, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_MULTIRELEASE) {
- $str = $this->renderMultiReleaseField($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']],$efarr[$i]['show100'],$efarr[$i]['show100label'],$show_any,$text_any,false, $attrs);
+ $str = $this->renderMultiReleaseField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['show100'], $efarr[$i]['show100label'], $show_any, $text_any,false, $attrs);
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_DATERANGE) {
if ($mode == 'QUERY') {
- $post_name = ' <i>'._('(YYYY-MM-DD YYYY-MM-DD Format)').'</i>';
+ $post_name = ' '.html_e('em', array(), _('(YYYY-MM-DD YYYY-MM-DD Format)'));
}
- $str = $this->renderDateRange($efarr[$i]['extra_field_id'],$selected[$efarr[$i]['extra_field_id']], $attrs);
+ $str = $this->renderDateRange($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $attrs);
+ } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
+ $str = $this->renderEffort($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
+ } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_EFFORTRANGE) {
+ $str = $this->renderEffortRange($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $efarr[$i]['attribute1'], $efarr[$i]['attribute2'], $attrs);
+ } elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_SLA) {
+ $str = $this->renderSLAField($efarr[$i]['extra_field_id'], $selected[$efarr[$i]['extra_field_id']], $attrs);
}
- $template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}',$post_name,$template);
- $template = str_replace('{$'.$efarr[$i]['field_name'].'}',$str,$template);
+ $template = str_replace('{$PostName:'.$efarr[$i]['field_name'].'}', $post_name, $template);
+ $template = str_replace('{$'.$efarr[$i]['field_name'].'}', $str, $template);
}
if($template != NULL){
- if ($mode == 'UPDATE' || $mode == 'NEW') {
+ if ($mode == 'UPDATE' || $mode == 'NEW' || $mode == 'QUERY') {
echo $this->javascript();
}
echo $template;
}
}
- function renderRelatedTasks($group, $ah) {
+ function renderRelatedTasks($group, $ah, $formid = null) {
global $HTML;
if (!$group->usesPM()) {
return;
$return = '';
- $taskcount = db_numrows($ah->getRelatedTasks());
- db_result_reset($ah->getRelatedTasks());
+ $tasks = $ah->getRelatedTasks();
+ $taskcount = db_numrows($tasks);
if (forge_check_perm('tracker_admin', $ah->ArtifactType->Group->getID())) {
$is_admin=true;
} else {
$is_admin=false;
}
-
$totalPercentage = 0;
if ($taskcount > 0) {
$title_arr = array();
(($is_admin) ? $title_arr[]=_('Remove Relation') : '');
$return .= $HTML->listTableTop($title_arr);
- for ($i = 0; $i < $taskcount; $i++) {
- $taskinfo = db_fetch_array($ah->relatedtasks, $i);
+ while ($taskinfo = db_fetch_array($tasks)) {
$totalPercentage += $taskinfo['percent_complete'];
$taskid = $taskinfo['project_task_id'];
$projectid = $taskinfo['group_project_id'];
- $groupid = $taskinfo['group_id'];
if (forge_check_perm('pm', $projectid, 'read')) {
$summary = util_unconvert_htmlspecialchars($taskinfo['summary']);
$startdate = date(_('Y-m-d H:i'), $taskinfo['start_date']);
$enddate = date(_('Y-m-d H:i'), $taskinfo['end_date']);
- $status = $taskinfo['status_name'];
- $return .= '<tr>
- <td>'.util_make_link('/pm/task.php?func=detailtask&project_task_id='.$taskid.'&group_id='.$groupid.'&group_project_id='.$projectid, '[T'.$taskid.'] '.$summary).'</td>
+ $status = $taskinfo['status_name'];
+ $return .= '<tr>
+ <td>'.util_make_link('/pm/t_follow.php/'.$taskid, '[T'.$taskid.'] '.$summary).'</td>
<td><div class="percentbar" style="width: 100px;">
<div style="width:'.round($taskinfo['percent_complete']).'px;"></div></div></td>
<td>'.$startdate.'</td>
<td>'.$enddate.'</td>
<td>'.$status.' ('.$taskinfo['percent_complete'].'%)</td>'.
- (($is_admin) ? '<td><input type="checkbox" name="remlink[]" value="'.$taskid.'" /></td>' : '').
+ (($is_admin) ? '<td><input type="checkbox" '.(($formid) ? 'form="'.$formid.'"' : '').' name="remlink[]" value="'.$taskid.'" /></td>' : '').
'</tr>';
}
}
return $return;
}
- function renderFiles($group_id, $ah) {
+ function renderFiles($group_id, $ah, $formid = null) {
global $HTML;
$file_list =& $ah->getFiles();
$count=count($file_list);
$title_arr[] = _('Date');
$title_arr[] = _('By');
$title_arr[] = _('Download');
+ if (forge_check_perm('tracker', $this->getID(), 'tech')) {
+ $title_arr[] = '';
+ }
$return .= $HTML->listTableTop($title_arr);
foreach ($file_list as $file) {
$return .= '<td>'.human_readable_bytes($file->getSize()).'</td>';
$return .= '<td>'.htmlspecialchars($file->getName()).'</td>';
$return .= '<td>'.date(_('Y-m-d H:i'), $file->getDate()).'</td>';
- $return .= '<td>'.$file->getSubmittedUnixName().'</td>';
+ $return .= '<td>'.util_display_user($file->getSubmittedUnixName(), $file->getSubmittedBy(), $file->getSubmittedRealName()).'</td>';
$return .= '<td>'.util_make_link('/tracker/download.php/'.$group_id.'/'. $this->getID().'/'. $ah->getID() .'/'.$file->getID().'/'.$file->getName(), htmlspecialchars($file->getName())).'</td>';
- if (forge_check_perm ('tracker', $this->getID(), 'tech')) {
- $return .= '<td><input type="checkbox" name="delete_file[]" value="'. $file->getID() .'">'._('Delete').'</td>';
+ if (forge_check_perm('tracker', $this->getID(), 'tech')) {
+ $return .= '<td><input type="checkbox" name="delete_file[]" '.(($formid) ? 'form="'.$formid.'"' : '').' value="'. $file->getID() .'">'._('Delete').'</td>';
}
$return .= '</tr>';
}
// Use template only for the browse (not for query or mass update)
if (($mode === 'DISPLAY' || $mode === 'DETAIL' || $mode === 'UPDATE' || $mode == 'NEW')
&& $this->data_array['custom_renderer']) {
- return preg_replace('/<!--(\S+.*?)-->/','{$\\1}',$this->data_array['custom_renderer']);
+ return preg_replace('/<!--(\S+.*?)-->/','{$\\1}', $this->data_array['custom_renderer']);
} else {
return $this->generateRenderHTML($types, $mode);
}
* @param string $mode Display mode (QUERY OR DISPLAY OR NEW)
* @return string HTML template.
*/
- function generateRenderHTML($types=array(), $mode) {
+ function generateRenderHTML($types, $mode) {
if ($mode == 'NEW') {
$efarr = $this->getExtraFields($types, false, false);
} else {
$keys=array_keys($efarr);
$count=count($keys);
- if ($count == 0) return '';
-
+ if ($count == 0) {
+ return '';
+ }
for ($k=0; $k<$count; $k++) {
$i=$keys[$k];
} elseif ($efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_TEXT ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_INTEGER ||
$efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_RELATION ||
- $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_DATETIME) {
+ $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_PARENT ||
+ $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_DATETIME ||
+ $efarr[$i]['field_type'] == ARTIFACT_EXTRAFIELDTYPE_EFFORT) {
//text fields might be really wide, so need a row to themselves.
if (($col_count == 1) && ($efarr[$i]['attribute1'] > 30)) {
* @param array $attrs
* @return string HTML code for the box and choices
*/
- function renderSelect ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false, $attrs = array ()) {
+ function renderSelect($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed=false, $attrs = array()) {
if ($text_100 == 'none'){
$text_100=_('None');
}
$dependency .= (empty($dependency) ? '':', ').'{"field":'.$key.', "elmnt": ['.implode(', ', $cElmnt).']}';
}
$dependency = '['.$dependency.']';
- $opt_attrs[$i]= array( 'data-dependency'=>$dependency);
+ $opt_attrs[$i]= array('data-dependency'=>$dependency);
}
}
if ($aef->isAutoAssign()) {
- $autoAssignTo = UserManager::instance()->getUserById($aefe->getAutoAssignto());
- $opt_attrs[$i]=array_merge(isset($opt_attrs[$i]) ? $opt_attrs[$i] : array(), array( 'data-autoassignto'=>'{"id":'.$aefe->getAutoAssignto().', "name":"'.$autoAssignTo->getRealName().' ('.$autoAssignTo->getUnixName().')"}'));
+ $autoAssignTo = user_get_object($aefe->getAutoAssignto());
+ $opt_attrs[$i]=array_merge(isset($opt_attrs[$i]) ? $opt_attrs[$i] : array(), array('data-autoassignto'=>'{"id":'.$aefe->getAutoAssignto().', "name":"'.$autoAssignTo->getRealName().' ('.$autoAssignTo->getUnixName().')"}'));
}
}
if ($show_100 && !empty($aefChildren)) {
- $attrs_100 = array( 'data-dependency'=>'{"fields": ['.implode(', ',$aefChildren).']}');
+ $attrs_100 = array('data-dependency'=>'{"fields": ['.implode(', ', $aefChildren).']}');
}
- return html_build_select_box_from_arrays ($vals,$texts,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed, $attrs, $opt_attrs, $attrs_100);
+ return html_build_select_box_from_arrays($vals, $texts,'extra_fields['.$extra_field_id.']', $checked, $show_100, $text_100, $show_any, $text_any, $allowed, $attrs, $opt_attrs, $attrs_100);
}
/**
* @param array $attrs
* @return string HTML code for the box and choices
*/
- function renderUserField ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false, $attrs = array ()) {
+ function renderUserField($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed=false, $attrs = array()) {
if ($text_100 == 'none' || $text_100 == 'nobody'){
$text_100=_('Nobody');
}
asort($userArray,SORT_FLAG_CASE | SORT_STRING);
$keys = array_keys($userArray);
$vals = array_values($userArray);
- return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed, $attrs);
+ return html_build_select_box_from_arrays($keys, $vals,'extra_fields['.$extra_field_id.']', $checked, $show_100, $text_100, $show_any, $text_any, $allowed, $attrs);
}
/**
* @param array $attrs
* @return string HTML code for the box and choices
*/
- function renderMultiUserField ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false, $attrs = array ()) {
+ function renderMultiUserField($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed=false, $attrs = array()) {
if ($text_100 == 'none' || $text_100 == 'nobody'){
$text_100=_('Nobody');
}
$checked=array();
}
if (!is_array($checked)) {
- $checked = explode(',',$checked);
+ $checked = explode(',', $checked);
}
$arr = $this->getExtraFieldElements($extra_field_id);
$userArray[$checkedUser->getID()] = $checkedUser->getRealName().' '._('[DELETED]');
}
asort($userArray,SORT_FLAG_CASE | SORT_STRING);
- $size = min( count($userArray)+1, 15);
+ $size = min(count($userArray)+1, 15);
$keys = array_keys($userArray);
$vals = array_values($userArray);
- return html_build_multiple_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.'][]',$checked,$size, $show_100,$text_100,$allowed, $attrs);
+ return html_build_multiple_select_box_from_arrays($keys, $vals,'extra_fields['.$extra_field_id.'][]', $checked, $size, $show_100, $text_100, $allowed, $attrs);
}
/**
* @param array $attrs
* @return string HTML code for the box and choices
*/
- function renderReleaseField ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false, $attrs = array ()) {
+ function renderReleaseField($extra_field_id, $checked = 'xzxz', $show_100 = false, $text_100 = 'none', $show_any = false, $text_any = 'Any', $allowed = false, $attrs = array()) {
if ($text_100 == 'none'){
$text_100=_('None');
}
$selectedPackagesId[$i]=$arr[$i]['element_name'];
}
- $packages = get_frs_packages($this->getGroup());
- uasort($packages, 'compareObjectName');
- foreach ($packages as $package) {
- if (in_array($package->getID(), $selectedPackagesId)) {
- $releases = $package->getReleases();
+ $fpFactory = new FRSPackageFactory($this->getGroup());
+ if ($fpFactory && is_object($fpFactory) && !$fpFactory->isError()) {
+ $packages = $fpFactory->getFRSs(true);
+ uasort($packages, 'compareObjectName');
+ foreach ($packages as $package) {
+ $releases = $package->getReleases(false);
uasort($releases, 'compareObjectName');
foreach ($releases as $release) {
$optGroup[] = $package->getName();
$releasesArray[$release->getID()] = $release->getName();
}
}
- }
- $keys = array_keys($releasesArray);
- $vals = array_values($releasesArray);
- return html_build_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any, $allowed, $attrs, $releasesAttrs, array(), $optGroup);
+ $keys = array_keys($releasesArray);
+ $vals = array_values($releasesArray);
+ return html_build_select_box_from_arrays($keys, $vals, 'extra_fields['.$extra_field_id.']', $checked, $show_100, $text_100, $show_any, $text_any, $allowed, $attrs, $releasesAttrs, array(), $optGroup);
+ } else {
+ global $HTML;
+ return $HTML->error_msg(_('Unable to get FRS Package Factory'));
+ }
}
/**
* @param array $attrs
* @return string HTML code for the box and choices
*/
- function renderMultiReleaseField ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed=false, $attrs = array ()) {
+ function renderMultiReleaseField($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed=false, $attrs=array()) {
if ($text_100 == 'none'){
$text_100=_('None');
}
$checked=array();
}
if (!is_array($checked)) {
- $checked = explode(',',$checked);
+ $checked = explode(',', $checked);
}
$releasesArray = array();
}
}
}
- $size = min( count($releasesArray) + count($optGroup) + 1, 15);
+ $size = min(count($releasesArray) + count($optGroup) + 1, 15);
$keys = array_keys($releasesArray);
$vals = array_values($releasesArray);
- return html_build_multiple_select_box_from_arrays ($keys,$vals,'extra_fields['.$extra_field_id.'][]',$checked,$size, $show_100,$text_100,$allowed, $attrs, $releasesAttrs, array(), $optGroup);
+ return html_build_multiple_select_box_from_arrays($keys, $vals,'extra_fields['.$extra_field_id.'][]', $checked, $size, $show_100, $text_100, $allowed, $attrs, $releasesAttrs, array(), $optGroup);
}
/**
* @param string $text_100 What $string to call the '100 row'
* @param bool $show_any
* @param string $text_any
+ * @param bool $allowed
* @param array $attrs Array of other attributes
* @return string HTML code using radio buttons
*/
- function renderRadio ($extra_field_id,$checked='xzxz',$show_100=false,$text_100='none',$show_any=false,$text_any='Any', $allowed = false, $attrs = array()) {
+ function renderRadio($extra_field_id, $checked='xzxz', $show_100=false, $text_100='none', $show_any=false, $text_any='Any', $allowed = false, $attrs = array()) {
$arr = $this->getExtraFieldElements($extra_field_id);
$aef = new ArtifactExtraField($this, $extra_field_id);
$dependency = '';
if (!empty($aefChildren)) {
$cElmntArr = $aefe->getChildrenElements();
- if (!empty($cElmntArr))
- {
+ if (!empty($cElmntArr)) {
foreach ($cElmntArr as $key=>$cElmnt) {
$childField = new ArtifactExtraField($this, $key);
$dependency .= (empty($dependency) ? '':', ').'{"field":'.$key.', "elmnt": ['.implode(', ', $cElmnt).']}';
}
}
if ($aef->isAutoAssign()) {
- $autoAssignTo = UserManager::instance()->getUserById($aefe->getAutoAssignto());
- $radios_attrs[$i]=array_merge(isset($radios_attrs[$i]) ? $radios_attrs[$i] : array(), array( 'data-autoassignto'=>'{"id":'.$aefe->getAutoAssignto().', "name":"'.$autoAssignTo->getRealName().' ('.$autoAssignTo->getUnixName().')"}'));
+ $autoAssignTo = user_get_object($aefe->getAutoAssignto());
+ $radios_attrs[$i]=array_merge(isset($radios_attrs[$i]) ? $radios_attrs[$i] : array(), array('data-autoassignto'=>'{"id":'.$aefe->getAutoAssignto().', "name":"'.$autoAssignTo->getRealName().' ('.$autoAssignTo->getUnixName().')"}'));
}
}
if ($show_100 && !empty($aefChildren)) {
- $attrs_100 = array( 'data-dependency'=>'{"fields": ['.implode(', ',$aefChildren).']}');
+ $attrs_100 = array('data-dependency'=>'{"fields": ['.implode(', ', $aefChildren).']}');
}
- return html_build_radio_buttons_from_arrays ($vals,$texts,'extra_fields['.$extra_field_id.']',$checked,$show_100,$text_100,$show_any,$text_any,$allowed,$attrs,$radios_attrs,$attrs_100);
+ return html_build_radio_buttons_from_arrays($vals, $texts,'extra_fields['.$extra_field_id.']', $checked, $show_100, $text_100, $show_any, $text_any, $allowed, $attrs, $radios_attrs, $attrs_100);
}
/**
* @param array $checked The items that should be checked
* @param bool|string $show_100 Whether to show the '100 row'
* @param string $text_100 What to call the '100 row'
+ * @param bool $allowed
* @param array $attrs Array of other attributes
* @return string radio buttons
*/
- function renderCheckbox ($extra_field_id,$checked=array(),$show_100=false,$text_100='none', $allowed=false, $attrs = array()) {
+ function renderCheckbox($extra_field_id, $checked=array(), $show_100=false, $text_100='none', $allowed=false, $attrs = array()) {
if ($text_100 == 'none'){
$text_100=_('None');
}
}
}
if ($show_100 && !empty($aefChildren)) {
- $attrs_100['data-dependency'] ='{"fields": ['.implode(', ',$aefChildren).']}';
+ $attrs_100['data-dependency'] ='{"fields": ['.implode(', ', $aefChildren).']}';
}
- return html_build_checkboxes_from_arrays($vals,$texts,'extra_fields['.$extra_field_id.']',$checked,false,$show_100,$text_100,$allowed,$attrs,$chk_attrs,$attrs_100);
+ return html_build_checkboxes_from_arrays($vals, $texts,'extra_fields['.$extra_field_id.']', $checked,false, $show_100, $text_100, $allowed, $attrs, $chk_attrs, $attrs_100);
}
/**
* @param array $checked The items that should be checked
* @param bool|string $show_100 Whether to show the '100 row'
* @param string $text_100 What to call the '100 row'
+ * @param bool $allowed
* @param array $attrs Array of other attributes
* @return string radio multiselectbox
*/
- function renderMultiSelectBox($extra_field_id,$checked=array(),$show_100=false,$text_100='none', $allowed=false, $attrs=array()) {
+ function renderMultiSelectBox($extra_field_id, $checked=array(), $show_100=false, $text_100='none', $allowed=false, $attrs=array()) {
if (!$checked) {
$checked=array();
}
if (!is_array($checked)) {
- $checked = explode(',',$checked);
+ $checked = explode(',', $checked);
}
$arr = $this->getExtraFieldElements($extra_field_id);
$aef = new ArtifactExtraField($this, $extra_field_id);
$dependency .= (empty($dependency) ? '':', ').'{"field":'.$key.', "elmnt": ['.implode(', ', $cElmnt).']}';
}
$dependency = '['.$dependency.']';
- $opt_attrs[$i]= array( 'data-dependency'=>$dependency);
+ $opt_attrs[$i]= array('data-dependency'=>$dependency);
}
}
}
- $size = min( count($arr)+1, 15);
+ $size = min(count($arr)+1, 15);
if ($show_100 && !empty($aefChildren)) {
- $attrs_100 = array( 'data-dependency'=>'{"fields": ['.implode(', ',$aefChildren).']}');
+ $attrs_100 = array('data-dependency'=>'{"fields": ['.implode(', ', $aefChildren).']}');
}
- return html_build_multiple_select_box_from_arrays($vals,$texts,"extra_fields[$extra_field_id][]",$checked,$size,$show_100,$text_100, $allowed, $attrs, $opt_attrs, $attrs_100);
+ return html_build_multiple_select_box_from_arrays($vals, $texts,"extra_fields[$extra_field_id][]", $checked, $size, $show_100, $text_100, $allowed, $attrs, $opt_attrs, $attrs_100);
}
/**
* @param array $attrs Array of other attributes
* @return string HTML code of corresponding input tag.
*/
- function renderTextField ($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+ function renderTextField($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
return html_e('input', array_merge(array('type'=>'text', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$contents, 'size'=>$size, 'maxlength'=>$maxlength), $attrs));
}
* @param array $attrs Array of other attributes
* @return string HTML code of corresponding input tag.
*/
- function renderIntegerField ($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+ function renderIntegerField($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
$intAttrs = array('type'=>'number', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$contents, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0);
$newattrs = array_merge($intAttrs, $attrs);
- return html_e('input',$newattrs);
+ return html_e('input', $newattrs);
}
/**
* @param array $attrs Array of other attributes
* @return string text area and data.
*/
- function renderRelationField ($extra_field_id,$contents,$size,$maxlength, $attrs = array()) {
+ function renderRelationField($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
$arr = $this->getExtraFieldElements($extra_field_id);
for ($i=0; $i<count($arr); $i++) {
$keys[$i]=$arr[$i]['element_id'];
$vals[$i]=$arr[$i]['element_name'];
}
// Convert artifact id to links.
- $html_contents = preg_replace_callback('/\b(\d+)\b/', create_function('$matches', 'return _artifactid2url($matches[1], \'title\');'), $contents);
- $edit_contents = $this->renderTextField ($extra_field_id,$contents,$size,$maxlength);
- return html_e('div',array_merge(array( 'id'=>'edit'.$extra_field_id, 'style'=>'display: none', 'title'=>_('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)')), $attrs), $edit_contents)
- .html_e('div',array_merge(array( 'id'=>'show'.$extra_field_id, 'style'=>'display: block'), $attrs), $html_contents);
+ $attrsTxt = array();
+ if (isset($attrs['form'])) {
+ $attrsTxt['form'] = $attrs['form'];
+ }
+ $callback = function ($matches) { return _artifactid2url($matches, 'title'); };
+ $html_contents = preg_replace_callback('/\b(\d+)\b/', $callback, $contents);
+ $edit_contents = $this->renderTextField ($extra_field_id, $contents, $size, $maxlength, $attrsTxt);
+ return html_e('div',array_merge(array('id'=>'edit'.$extra_field_id, 'style'=>'display: none', 'title'=>_('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)')), $attrs), $edit_contents)
+ .html_e('div',array_merge(array('id'=>'show'.$extra_field_id, 'style'=>'display: block'), $attrs), $html_contents);
+ }
+
+ /**
+ * renderParentField - this function builds a parent field.
+ *
+ * @param int $extra_field_id The ID of this field.
+ * @param string $contents The data for this field.
+ * @param string $size
+ * @param string $maxlength
+ * @param array $attrs Array of other attributes
+ * @return string text area and data.
+ */
+ function renderParentField($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+ global $ah;
+ $arr = $this->getExtraFieldElements($extra_field_id);
+ for ($i=0; $i<count($arr); $i++) {
+ $keys[$i]=$arr[$i]['element_id'];
+ $vals[$i]=$arr[$i]['element_name'];
+ }
+ $attrsTxt = array();
+ if (isset($attrs['form'])) {
+ $attrsTxt['form'] = $attrs['form'];
+ }
+ if (is_object($ah)) {
+ $attrsTxt['pattern']='^(?!'.$ah->getID().'$)\d*$';
+ } else {
+ $attrsTxt['pattern']='^\d*$';
+ }
+ // Convert artifact id to links.
+ $callback = function ($matches) { return _artifactid2url($matches, 'title'); };
+ $html_contents = preg_replace_callback('/\b(\d+)\b/', $callback, $contents);
+ $edit_contents = $this->renderTextField ($extra_field_id, $contents, $size, $maxlength, $attrsTxt);
+ return html_e('div',array_merge(array('id'=>'edit'.$extra_field_id, 'style'=>'display: none', 'title'=>_('Tip: Enter a space-separated list of artifact ids ([#NNN] also accepted)')), $attrs), $edit_contents)
+ .html_e('div',array_merge(array('id'=>'show'.$extra_field_id, 'style'=>'display: block'), $attrs), $html_contents);
}
/**
* @param array $attrs Array of other attributes
* @return string text area and data.
*/
- function renderTextArea ($extra_field_id,$contents,$rows,$cols, $attrs = array()) {
+ function renderTextArea($extra_field_id, $contents, $rows, $cols, $attrs = array()) {
return html_e('textarea', array_merge(array('name'=>'extra_fields['.$extra_field_id.']', 'rows'=>$rows, 'cols'=>$cols), $attrs), $contents, false);
}
-
/**
* renderDatetime - this function builds a Datetime field.
*
function renderDatetime($extra_field_id, $datetime, $attrs = array()) {
if (!$datetime=='') {
$datetime_format = _('Y-m-d H:i');
- $datetime = date($datetime_format,$datetime);
+ $datetime = date($datetime_format, $datetime);
+ }
+ if (isset($attrs['class'])) {
+ $attrs['class'] = $attrs['class'] . ' datetimepicker';
+ } else {
+ $attrs['class'] = 'datetimepicker';
}
- return html_e('input', array_merge(array('type'=>'text', 'name'=>'extra_fields['.$extra_field_id.']', 'class'=>'datetimepicker', 'value'=>$datetime),$attrs));
+ return html_e('input', array_merge(array('type'=>'text', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$datetime), $attrs));
}
function renderDateRange($extra_field_id, $dateRange, $attrs = array()) {
// http://html5pattern.com/Dates
// Date with leapyear-check
$datepattern = '(?:19|20)(?:(?:[13579][26]|[02468][048])-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))|(?:[0-9]{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:29|30))|(?:(?:0[13578]|1[02])-31)))';
- return html_e('input', array_merge(array('type'=>'text', 'name'=>'extra_fields['.$extra_field_id.']', 'pattern'=>$datepattern.' '.$datepattern, 'maxlength'=>21, 'size'=>21, 'value'=>$dateRange),$attrs));
+ return html_e('input', array_merge(array('type'=>'text', 'name'=>'extra_fields['.$extra_field_id.']', 'pattern'=>$datepattern.' '.$datepattern, 'maxlength'=>21, 'size'=>21, 'value'=>$dateRange), $attrs));
}
- function technicianBox($name = 'assigned_to[]', $checked = 'xzxz', $show_100 = true, $text_100 = 'none', $extra_id = '-1', $extra_name = '', $multiple = false) {
+ /**
+ * renderEffort - this function builds a Effort extra field.
+ *
+ * @param int $extra_field_id The ID of this field.
+ * @param string $contents The data for this field.
+ * @param string $size
+ * @param string $maxlength
+ * @param array $attrs Array of other attributes
+ * @return string text area and data.
+ */
+ function renderEffort($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+ $effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
+ $effortUnitFactory = New EffortUnitFactory($effortUnitSet);
+ $units = $effortUnitFactory->getUnits();
+ $vals = array();
+ $texts = array();
+ $factors = array();
+ foreach ($units as $unit) {
+ $vals [] = $unit->getID();
+ $texts [] = $unit->getName();
+ $opts_attrs []['data-factor'] = $unit->getConversionFactorForBaseUnit();
+ }
+ $valueInUnitBase = $effortUnitFactory->encodedToValueInBaseUnit($contents);
+ $value = $effortUnitFactory->encodedToValue($contents);
+ $unitId = $effortUnitFactory->encodedToUnitId($contents);
+ if (isset($attrs['class'])) {
+ $attrs['class'] .= ' effort';
+ } else {
+ $attrs['class'] = 'effort';
+ }
+ $attrs['data-effortid'] = $extra_field_id;
+ $hiddenAttrs = array();
+ if (isset($attrs['form'])) {
+ $hiddenAttrs['form'] = $attrs['form'];
+ }
+ $return = html_e('input', array_merge(array('type'=>'hidden', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$valueInUnitBase.'U'.$unitId), $hiddenAttrs));
+ $return .= html_e('input', array_merge(array('type'=>'number', 'name'=>'value['.$extra_field_id.']', 'value'=>$value, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0), $attrs));
+ $return .= html_build_select_box_from_arrays($vals, $texts, 'unit['.$extra_field_id.']', $unitId, false, '', false, '', false, $attrs, $opts_attrs);
+ return $return;
+ }
+
+ function renderEffortRange($extra_field_id, $contents, $size, $maxlength, $attrs = array()) {
+ $effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
+ $effortUnitFactory = New EffortUnitFactory($effortUnitSet);
+ $units = $effortUnitFactory->getUnits();
+ $vals = array();
+ $texts = array();
+ $opts_attrs = array();
+ foreach ($units as $unit) {
+ $vals [] = $unit->getID();
+ $texts [] = $unit->getName();
+ $opts_attrs []['data-factor'] = $unit->getConversionFactorForBaseUnit();
+ }
+ $contentsFrom = '0U'.$vals[0];
+ $contentsTo = '0U'.$vals[0];
+ if (preg_match('/^(\d+U\d+) ?(\d+U\d+)?$/', $contents, $matches)) {
+ $contentsFrom = $matches[1];
+ $contentsTo = $matches[2];
+ }
+ $valueInUnitBaseFrom = $effortUnitFactory->encodedToValueInBaseUnit($contentsFrom);
+ $valueInUnitBaseTo = $effortUnitFactory->encodedToValueInBaseUnit($contentsTo);
+ $valueFrom = $effortUnitFactory->encodedToValue($contentsFrom);
+ $valueTo = $effortUnitFactory->encodedToValue($contentsTo);
+ $unitIdFrom = $effortUnitFactory->encodedToUnitId($contentsFrom);
+ $unitIdTo = $effortUnitFactory->encodedToUnitId($contentsTo);
+ $attrs['data-effortid'] = $extra_field_id;
+ if (isset($attrs['class'])) {
+ $attrs['class'] .= ' effort-range';
+ } else {
+ $attrs['class'] = 'effort-range';
+ }
+ $attrsFrom = $attrs;
+ $attrsTo = $attrs;
+ $hiddenAttrs = array();
+ if (isset($attrs['form'])) {
+ $hiddenAttrs['form'] = $attrs['form'];
+ }
+ $return = html_e('input', array_merge(array('type'=>'hidden', 'name'=>'extra_fields['.$extra_field_id.']', 'value'=>$valueInUnitBaseFrom.'U'.$unitIdFrom.' '.$valueInUnitBaseTo.'U'.$unitIdTo), $hiddenAttrs));
+ $return .= _('Between')._(':').html_e('br');
+ $return .= html_e('input', array_merge(array('type'=>'number', 'name'=>'value_from['.$extra_field_id.']', 'value'=>$valueFrom, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0), $attrsFrom));
+ $return .= html_build_select_box_from_arrays($vals, $texts, 'unit_from['.$extra_field_id.']', $unitIdFrom, false, '', false, '', false, $attrsFrom, $opts_attrs);
+ $return .= html_e('br');
+ $return .= _('and')._(':').html_e('br');
+ $return .= html_e('input', array_merge(array('type'=>'number', 'name'=>'value_to['.$extra_field_id.']', 'value'=>$valueTo, 'size'=>$size, 'maxlength'=>$maxlength, 'min'=>0), $attrsTo));
+ $return .= html_build_select_box_from_arrays($vals, $texts, 'unit_to['.$extra_field_id.']', $unitIdTo, false, '', false, '', false, $attrsTo, $opts_attrs);
+ return $return;
+ }
+
+ /**
+ * renderFormulaField - this function builds a formula field (RO).
+ *
+ * @param string $contents The data for this field.
+ * @return string
+ */
+ function renderFormulaField($contents) {
+ return $contents;
+ }
+
+ /**
+ * renderSLAField - this function builds a formula field (RO).
+ *
+ * @param int $extra_field_id The ID of this field.
+ * @param string $contents The data for this field.
+ * @param $ef
+ * @return string
+ */
+ function renderSLAField($extra_field_id, $contents, $ef) {
+ global $aid;
+
+ if (!isset($aid) ||!$aid) {
+ return '';
+ }
+
+ $config = parse_ini_string($ef["attributes"]);
+ $field_name = $config['field'];
+ $rule = explode(':', $config['values']);
+
+ if (!isset($config['start_id']) || $aid >= $config['start_id']) {
+ // Get Max value from
+ // @todo use global variable $aid !!!
+ $artifact = artifact_get_object($aid);
+ $value = $artifact->getFieldDataByKey('alias', $field_name);
+ $field = $artifact->getFieldTypeByKey('alias', $field_name);
+ $elements = $artifact->ArtifactType->getExtraFieldElements($field['extra_field_id']);
+ for ($i = 0; $i < count($elements); $i++) {
+ if ($elements[$i]['element_name'] == $value) {
+ $max = 60 * $rule[$i];
+ continue;
+ }
+ }
+
+ if (!isset($max)) {
+ $value = '<span class="label label-warning">Not Set</span>';
+ } elseif ($ef['alias'] == 'response_time') {
+ // Implement Response SLA: Time from create to first comment.
+ $messages = $artifact->getMessageObjects();
+ if (!empty($messages)) {
+ $message = $messages[count($messages) - 1];
+ $current_time = $message->getAddDate();
+ $timer_is_running = false;
+ } elseif ($artifact->getStatusID() == 2) {
+ $current_time = $artifact->getCloseDate();
+ $timer_is_running = false;
+ } else {
+ $current_time = time();
+ $timer_is_running = true;
+ }
+ $time = $current_time - $artifact->getOpenDate();
+ $percent = round(100 * $time / $max);
+ $remaining = $max - $time;
+ if ($remaining >= 0) {
+ $value = gmdate("G\h i", $remaining);
+ } else {
+ $value = html_e('strong', array(), '-' . gmdate("G\h i", -$remaining));
+ }
+
+ if (!$timer_is_running) {
+ if ($remaining >= 0) {
+ $value = '<span class="label label-success">' . _('OK') . '</span>';
+ } else {
+ $value = '<span class="label label-danger">' . _('Missed') . '</span>';
+ }
+ } else {
+ if ($percent > 90) {
+ $value = '<span class="sla-alert">' . $value . '</span>';
+ } elseif ($percent > 80) {
+ $value = '<span class="sla-warning">' . $value . '</span>';
+ } else {
+ $value = '<span class="sla-normal">' . $value . '</span>';
+ }
+ }
+ } elseif ($ef['alias'] == 'resolution_time') {
+ // Implement Resolution SLA: Time from create to closed state.
+ list($last_status_change, $timer, $timer_is_running) = json_decode($contents);
+
+ $time = $timer;
+ if ($timer_is_running) {
+ $time += time() - $last_status_change;
+ }
+
+ $percent = round(100 * $time / $max);
+ $remaining = $max - $time;
+ if ($remaining >= 0) {
+ $value = gmdate("G\h i", $remaining);
+ } else {
+ $value = html_e('strong', array(), '-' . gmdate("G\h i", -$remaining));
+ }
+ if ($artifact->getStatusID() == 2) {
+ if ($remaining >= 0) {
+ $value = '<span class="label label-success">' . _('OK') . '</span>';
+ } else {
+ $value = '<span class="label label-danger">' . _('Missed') . '</span>';
+ }
+ } else {
+ if (!$timer_is_running) {
+ $value = ' <span class="label label-info">' . _('Suspended') . '</span>';
+ } elseif ($percent > 90) {
+ $value = '<span class="sla-alert">' . $value . '</span>';
+ } elseif ($percent > 80) {
+ $value = '<span class="sla-warning">' . $value . '</span>';
+ } else {
+ $value = '<span class="sla-normal">' . $value . '</span>';
+ }
+ }
+ }
+ } else {
+ $value = '<span class="label label-default">' . _('Not Available') . '</span>';
+ }
+ return $value;
+ }
+
+ function technicianBox($name = 'assigned_to[]', $checked = 'xzxz', $show_100 = true, $text_100 = 'none', $extra_id = '-1', $extra_name = '', $multiple = false, $attrs = array()) {
if ($text_100=='none'){
$text_100=_('Nobody');
}
-
$engine = RBACEngine::getInstance();
$techs = $engine->getUsersByAllowedAction('tracker', $this->getID(), 'tech') ;
if ($multiple) {
if (!is_array($checked)) {
- $checked = explode(',',$checked);
+ $checked = explode(',', $checked);
}
$size = min(count($ids)+1, 15);
- return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100);
+ return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100, false, $attrs);
} else {
- return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100);
+ return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100, false, false, false, $attrs);
}
}
- function submitterBox ($name='submitted_by[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
+ function submitterBox($name = 'submitted_by[]', $checked = 'xzxz', $show_100 = true, $text_100 = 'none', $extra_id = '-1', $extra_name = '', $multiple = false, $attrs = array()) {
if ($text_100=='none'){
$text_100=_('Nobody');
}
if ($multiple) {
if (!is_array($checked)) {
- $checked = explode(',',$checked);
+ $checked = explode(',', $checked);
}
- $size = min( count($ids)+1, 15);
- return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,$size,$show_100,$text_100);
+ $size = min(count($ids)+1, 15);
+ return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100, false, $attrs);
} else {
- return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
+ return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100, false, $attrs);
}
}
- function lastModifierBox ($name='last_modified_by[]',$checked='xzxz',$show_100=true,$text_100='none',$extra_id='-1',$extra_name='',$multiple=false) {
+ function lastModifierBox($name = 'last_modified_by[]', $checked = 'xzxz', $show_100 = true, $text_100 = 'none', $extra_id = '-1', $extra_name = '', $multiple = false) {
if ($text_100=='none'){
$text_100=_('Nobody');
}
$result = $this->getLastModifiers();
- $ids =& util_result_column_to_array($result,0);
- $names =& util_result_column_to_array($result,1);
+ $ids =& util_result_column_to_array($result, 0);
+ $names =& util_result_column_to_array($result, 1);
if ($extra_id != '-1') {
- $ids[]=$extra_id;
- $names[]=$extra_name;
+ $ids[] = $extra_id;
+ $names[] = $extra_name;
}
if ($multiple) {
if (!is_array($checked)) {
- $checked = explode(',',$checked);
+ $checked = explode(',', $checked);
}
- $size = min( count($ids)+1, 15);
- return html_build_multiple_select_box_from_arrays ($ids,$names,$name,$checked,$size,$show_100,$text_100);
+ $size = min(count($ids)+1, 15);
+ return html_build_multiple_select_box_from_arrays($ids, $names, $name, $checked, $size, $show_100, $text_100);
} else {
- return html_build_select_box_from_arrays ($ids,$names,$name,$checked,$show_100,$text_100);
+ return html_build_select_box_from_arrays($ids, $names, $name, $checked, $show_100, $text_100);
}
}
- function cannedResponseBox ($name='canned_response',$checked='xzxz') {
- return html_build_select_box ($this->getCannedResponses(),$name,$checked);
+ function cannedResponseBox($name = 'canned_response', $checked = 'xzxz', $attrs = array()) {
+ if (!isset($attrs['id'])) {
+ $attrs['id'] = $name;
+ }
+ return html_build_select_box($this->getCannedResponses(), $name, $checked, true, 'none', false, '', false, $attrs);
}
/**
* statusBox - show the statuses - automatically shows the "custom statuses" if they exist
*
- *
+ * @param string $name
+ * @param string $checked
+ * @param bool $show_100
+ * @param string $text_100
+ * @param array $attrs
+ * @return string HTML code
*/
- function statusBox ($name='status_id',$checked='xzxz',$show_100=false,$text_100='none') {
+ function statusBox($name = 'status_id', $checked = 'xzxz', $show_100 = false, $text_100 = 'none', $attrs = array()) {
if ($text_100=='none'){
$text_100=_('None');
}
- return html_build_select_box($this->getStatuses(),$name,$checked,$show_100,$text_100);
+ return html_build_select_box($this->getStatuses(), $name, $checked, $show_100, $text_100, false, '', false, $attrs);
+ }
+
+ /**
+ * priorityBox - show the priorities
+ *
+ * @param string $name
+ * @param string $checked_val
+ * @param bool $nochange
+ * @param array $attrs
+ * @param bool $show_any
+ * @return string HTML code
+ */
+ function priorityBox($name = 'priority', $checked_val = '3', $nochange = false, $attrs = array(), $show_any = false){
+ return html_build_priority_select_box($name, $checked_val, $nochange, $attrs, $show_any);
}
function javascript() {
var invalidInputMsg = '". _("This choice is not allowed")."';
var groupId =".$this->Group->getID().";
var atId = ".$this->getID().";";
+ $effortUnitSet = New EffortUnitSet($this, $this->getEffortUnitSet());
+ if ($effortUnitSet->isAutoconvert()) {
+ $jseffort = <<<'EOS'
+ $("select.effort").change(function(){
+ var effortid = $(this).data("effortid");
+ var value = parseInt(parseInt($("input[name='extra_fields["+effortid+"]']").val())/$("select[name='unit["+effortid+"]'] option:selected").data('factor'));
+ $("input[name='value["+effortid+"]']").val(value);
+ $("input[name='extra_fields["+effortid+"]']").val(value*$("select[name='unit["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
+ });
+ $("input.effort").change(function(){
+ var effortid = $(this).data("effortid");
+ var value = $("input[name='value["+effortid+"]']").val();
+ $("input[name='extra_fields["+effortid+"]']").val(value*$("select[name='unit["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
+ });
+ $(".effort-range").change(function(){
+ var effortid = $(this).data("effortid");
+ $("input[name='extra_fields["+effortid+"]']").val($("input[name='value_from["+effortid+"]']").val()*$("select[name='unit_from["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit_from["+effortid+"]']").val()+' '+$("input[name='value_to["+effortid+"]']").val()*$("select[name='unit_to["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit_to["+effortid+"]']").val());
+ });
+EOS;
+ } else {
+ $jseffort = <<<'EOS'
+ $(".effort").change(function(){
+ var effortid = $(this).data("effortid");
+ $("input[name='extra_fields["+effortid+"]']").val($("input[name='value["+effortid+"]']").val()*$("select[name='unit["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit["+effortid+"]']").val());
+ });
+ $(".effort-range").change(function(){
+ var effortid = $(this).data("effortid");
+ $("input[name='extra_fields["+effortid+"]']").val($("input[name='value_from["+effortid+"]']").val()*$("select[name='unit_from["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit_from["+effortid+"]']").val()+' '+$("input[name='value_to["+effortid+"]']").val()*$("select[name='unit_to["+effortid+"]'] option:selected").data('factor')+'U'+$("select[name='unit_to["+effortid+"]']").val());
+ });
+EOS;
+ }
$javascript = <<<'EOS'
+ function showMessage( msg_text, msg_class) {
+ $("#maindiv h1").append($("<p>", { "class": msg_class }).html( msg_text )).show();
+ };
$.expr[':'].invalid = function(elem, index, match) {
- for (let invalid of document.querySelectorAll(':invalid') ) {
- if (elem === invalid) { return true; }
+ var invalids = document.querySelectorAll(':invalid'), result = false, len = invalids.length;
+ if (len) {
+ for (var i=0; i<len; i++) {
+ if (elem === invalids[i]) {
+ result = true;
+ break;
+ }
}
- return false;
+ }
+ return result;
};
+
$("input[type='radio'].readonly, input[type='checkbox'].readonly").on('click', function(){
return false;
}).on('keydown', function(event){
if(event.keyCode !== 9) return false;
});
- $(".in-formula[name^='extra_fields']").on('change', function(){
+ $(".in-formula").change(function(){
$.ajax({
type: 'POST',
url: 'index.php',
- data: 'rtype=ajax&function=get_formulas_results&group_id='+groupId+'&atid='+atId+'&'+$("[name^='extra_fields']" ).serialize(),
+ data: 'rtype=ajax&function=get_formulas_results&group_id='+groupId+'&atid='+atId+'&status='+$("select[name='status_id'] option:selected").text()+'&assigned_to='+$("select[name='assigned_to'] option:selected").text()+'&'+$("[name^='extra_fields'], #tracker-summary, #tracker-description, [name='priority']").serialize(),
async: false,
dataType: 'json',
success: function(answer){
}
fields = answer['fields'];
$.each(fields, function (index, field) {
+ if (field.error!=null){
+ showMessage(field.error, 'error');
+ }
fieldObj = $("[name^='extra_fields["+field.id+"]']");
- console.log(fieldObj);
- console.log(fieldObj.is("input[type='radio']"));
if (fieldObj.is("input[type='checkbox']")){
- console.log("checkbox");
fieldObj.each(function() {
var in_array = -1;
for (var key in field.value) {
}
});
} else if (fieldObj.is("input[type='radio']")){
- console.log("radio");
fieldObj.each(function() {
- console.log($(this));
var in_array = -1;
for (var key in field.value) {
if (field.value[key] == $(this).val()) {
break;
}
}
- console.log(in_array);
if (in_array > -1) {
$(this).prop("checked",true);
} else {
}
});
});
- $(".autoassign[name^='extra_fields']").on('change', function(){
+
+ $("img.addparent").click(function(){
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: 'rtype=ajax&function=add_parent&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&parent_id='+$("input#parent_id").val(),
+ async: false,
+ dataType: 'json',
+ success: function(answer){
+ if(answer['message']) {
+ showMessage(answer['message'], 'error');
+ } else {
+ $("table.parent").replaceWith(answer['parent']);
+ $("input[name='extra_fields["+answer['parent_efid']+"]']").val(answer['parent_id']);
+ $("div#show"+answer['parent_efid']).html(answer['parent_link']);
+ $("input#parent_id").val('');
+ $("div.addparent").addClass('hide');
+ $("img.removeparent").click(function(){
+ removeParent($(this).data("id"));
+ });
+ }
+ return true;
+ }
+ });
+ });
+
+ $("img.addchild").click(function(){
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: 'rtype=ajax&function=add_child&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&child_id='+$("input#child_id").val(),
+ async: false,
+ dataType: 'json',
+ success: function(answer){
+ if(answer['message']) {
+ showMessage(answer['message'], 'error');
+ } else {
+ $("table.children").replaceWith(answer['children']);
+ $("input#child_id").val('');
+ $("img.removechild").click(function(){
+ removeChild($(this).data("id"));
+ });
+ }
+ return true;
+ }
+ });
+ });
+
+
+ $("img.removeparent").click(function(){
+ removeParent($(this).data("id"));
+ });
+
+ function removeParent(id) {
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: 'rtype=ajax&function=remove_parent&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&parent_id='+id,
+ async: false,
+ dataType: 'json',
+ success: function(answer){
+ if(answer['message']) {
+ showMessage(answer['message'], 'error');
+ } else {
+ $("table#parent"+id).remove();
+ $("div.addparent").removeClass('hide');
+ }
+ return true;
+ }
+ });
+ };
+
+ $("img.removechild").click(function(){
+ removeChild($(this).data("id"));
+ });
+
+ function removeChild(id) {
+ $.ajax({
+ type: 'POST',
+ url: 'index.php',
+ data: 'rtype=ajax&function=remove_child&group_id='+groupId+'&atid='+atId+'&aid='+$("input#aid").val()+'&child_id='+id,
+ async: false,
+ dataType: 'json',
+ success: function(answer){
+ if(answer['message']) {
+ showMessage(answer['message'], 'error');
+ } else {
+ $("span#child"+id).remove();
+ }
+ return true;
+ }
+ });
+ };
+ $(".autoassign[name^='extra_fields']").change(function(){
if ($(this).prop('tagName') == 'SELECT') {
var elmnts = $(this).children('option:selected');
} else {
$("span#tracker-assigned_to").text(aat.name);
});
});
- $(".with-depcy[name^='extra_fields']").on('change', function(){
+ $(".with-depcy[name^='extra_fields']").change(function(){
if ($(this).prop('tagName') == 'SELECT') {
var elmnts = $(this).children('option:selected');
} else {
});
});
EOS;
- return html_e('script', array( 'type'=>'text/javascript'), '//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$javascript.'});'."\n".'//]]>');
+ return html_e('script', array('type'=>'text/javascript'), '//<![CDATA['."\n".'$(function(){'.$jsvariable."\n".$jseffort."\n".$javascript.'});'."\n".'//]]>');
}
}