From 4c12369a261e4e078237b56536aa87f7d1913dca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 10:33:36 +0200 Subject: [PATCH] Debug module ticket --- .../core/class/html.formticketsup.class.php | 6 +- htdocs/core/js/lib_foot.js.php | 7 +- htdocs/langs/en_US/ticketsup.lang | 1 - htdocs/ticketsup/card.php | 140 +++++++++--------- .../class/actions_ticketsup.class.php | 37 +---- htdocs/ticketsup/class/ticketsup.class.php | 4 +- 6 files changed, 87 insertions(+), 108 deletions(-) diff --git a/htdocs/core/class/html.formticketsup.class.php b/htdocs/core/class/html.formticketsup.class.php index b076a0923eb..82ce12b8a03 100644 --- a/htdocs/core/class/html.formticketsup.class.php +++ b/htdocs/core/class/html.formticketsup.class.php @@ -443,7 +443,7 @@ class FormTicketsup $ticketstat->loadCacheTypesTickets(); - print ''; if ($empty) { print ''; } @@ -543,7 +543,7 @@ class FormTicketsup $ticketstat->loadCacheCategoriesTickets(); - print ''; if ($empty) { print ''; } @@ -612,7 +612,7 @@ class FormTicketsup print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ajax_combobox('select'.$htmlname,'',0,0,'off'); + print ajax_combobox('select'.$htmlname); } /** diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index f93fa57923f..cc08af7431f 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -135,8 +135,11 @@ print ' /* If page_y set, we set scollbar with it */ page_y=getParameterByName(\'page_y\', 0); /* search in GET parameter */ if (page_y == 0) page_y = jQuery("#page_y").text(); /* search in POST parameter that is filed at bottom of page */ - console.log("page_y found is "+page_y); - if (page_y > 0) $(\'html, body\').scrollTop(page_y); + if (page_y > 0) + { + console.log("page_y found is "+page_y); + $(\'html, body\').scrollTop(page_y); + } /* Set handler to add page_y param on output (click on href links or submit button) */ jQuery(".reposition").click(function() { diff --git a/htdocs/langs/en_US/ticketsup.lang b/htdocs/langs/en_US/ticketsup.lang index d81cd799203..84cc786ef6d 100644 --- a/htdocs/langs/en_US/ticketsup.lang +++ b/htdocs/langs/en_US/ticketsup.lang @@ -171,7 +171,6 @@ TicketChangeType=Change type TicketChangeCategory=Change category TicketChangeSeverity=Change severity TicketAddMessage=Add a message -TicketEditProperties=Edit properties AddMessage=Add a message MessageSuccessfullyAdded=Ticket added TicketMessageSuccessfullyAdded=Message successfully added diff --git a/htdocs/ticketsup/card.php b/htdocs/ticketsup/card.php index b85d53763bf..4b186867302 100644 --- a/htdocs/ticketsup/card.php +++ b/htdocs/ticketsup/card.php @@ -45,11 +45,11 @@ if (!empty($conf->contrat->enabled)) { $langs->loadLangs(array("companies","other","ticketsup")); // Get parameters -$id = GETPOST('id', 'int'); -$track_id = GETPOST('track_id', 'alpha', 3); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$track_id = GETPOST('track_id', 'alpha', 3); +$ref = GETPOST('ref', 'alpha'); $projectid = GETPOST('projectid', 'int'); -$action = GETPOST('action', 'alpha', 3); +$action = GETPOST('action', 'alpha', 3); // Initialize technical object to manage hooks of ticketsup. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ticketsupcard','globalcard')); @@ -63,7 +63,7 @@ if (!$action) { $action = 'view'; } //Select mail models is same action as add_message -if (GETPOST('modelselected')) { +if (GETPOST('modelselected','alpha')) { $action = 'add_message'; } @@ -121,6 +121,25 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) } } +if ($action == "change_property" && GETPOST('btn_update_ticket_prop','alpha') && $user->rights->ticketsup->write) +{ + $object->fetch(GETPOST('id','int'), '', GETPOST('track_id','alpha')); + + $object->type_code = GETPOST('update_value_type','az09'); + $object->category_code = GETPOST('update_value_category','az09'); + $object->severity_code = GETPOST('update_value_severity','az09'); + + $ret = $object->update($user); + if ($ret > 0) { + $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); + $ret = $object->createTicketLog($user, $log_action); + if ($ret > 0) { + setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); + } + } + $action = 'view'; +} + $permissiondellink = $user->rights->ticketsup->write; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -471,92 +490,82 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti * Classification and actions on ticket * ***************************************************/ - /* - * Ticket properties - */ + + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; print ''; - print ''; + print ''; print ''; - if (GETPOST('set') == 'properties' && $user->rights->ticketsup->write) { - /* - * Form to change ticket properties - */ - $j = 0; - $ticketprop[$j] = array( - 'dict' => 'type', - 'list_function' => 'selectTypesTickets', - 'label' => 'TicketChangeType', - ); - $j++; - $ticketprop[$j] = array( - 'dict' => 'category', - 'list_function' => 'selectCategoriesTickets', - 'label' => 'TicketChangeCategory', - ); - $j++; - $ticketprop[$j] = array( - 'dict' => 'severity', - 'list_function' => 'selectSeveritiesTickets', - 'label' => 'TicketChangeSeverity', - ); - foreach ($ticketprop as $property) { - print ''; - print ''; - print ''; - } + if (GETPOST('set','alpha') == 'properties' && $user->rights->ticketsup->write) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } else { // Type - print ''; // Category print ''; // Severity print ''; } print '
'; + print ''; print $langs->trans('Properties'); print ''; + if (GETPOST('set','alpha') == 'properties' && $user->rights->ticketsup->write) { + print ''; + } + else { + // Button to edit Properties + if ($object->fk_statut < 5 && $user->rights->ticketsup->write) { + print '' . img_edit($langs->trans('Modify')) . ''; + } + } + print '
'; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print ' '; - print ''; - print $formticket->{$property['list_function']}($object->type_code, 'update_value', '', 0); - print ''; - print ' '; - print '
'; - print ''; - - print '
'; + print $langs->trans('TicketChangeType'); + print ''; + print $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2); + print '
'; + print $langs->trans('TicketChangeCategory'); + print ''; + print $formticket->selectCategoriesTickets($object->category_code, 'update_value_category', '', 2); + print '
'; + print $langs->trans('TicketChangeSeverity'); + print ''; + print $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); + print '
' . $langs->trans("Type") . ''; - print $object->type_label; + print '
' . $langs->trans("Type") . ''; + print $langs->getLabelFromKey($db, $object->type_code, 'c_ticketsup_type', 'code', 'label'); /*if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ - print '
' . $langs->trans("Category") . ''; - print $object->category_label; + print $langs->getLabelFromKey($db, $object->category_code, 'c_ticketsup_category', 'code', 'label'); /*if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ - print '
' . $langs->trans("TicketSeverity") . ''; - print $object->severity_label; + print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticketsup_severity', 'code', 'label'); /*if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ - print '
'; // End table actions - print '
'; + + print ''; + print ''; // Display navbar with links to change ticket status print ''; @@ -718,11 +727,6 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; } - // Button to edit Properties - if ($object->fk_statut < 5 && $user->rights->ticketsup->write) { - print ''; - } - // Button to link to a contract if ($user->rights->ticketsup->write && $object->fk_statut < 5 && $user->rights->contrat->creer) { print ''; diff --git a/htdocs/ticketsup/class/actions_ticketsup.class.php b/htdocs/ticketsup/class/actions_ticketsup.class.php index f53426c6a13..a3fda3ac543 100644 --- a/htdocs/ticketsup/class/actions_ticketsup.class.php +++ b/htdocs/ticketsup/class/actions_ticketsup.class.php @@ -383,31 +383,6 @@ class ActionsTicketsup $action = 'view'; } - if ($action == "change_property" && GETPOST('btn_update_ticket_prop') && $user->rights->ticketsup->write) { - $this->fetch('', '', GETPOST('track_id','alpha')); - - $fieldtomodify = GETPOST('property') . '_code'; - $fieldtomodify_label = GETPOST('property') . '_label'; - - $oldvalue_code = $object->$fieldtomodify; - $newvalue_code = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code'); - - $oldvalue_label = $object->$fieldtomodify_label; - $newvalue_label = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label'); - - $object->$fieldtomodify = $newvalue_code; - - $ret = $object->update($user); - if ($ret > 0) { - $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); - } - } - $action = 'view'; - } - if ($action == "new_message" && GETPOST('btn_add_message') && $user->rights->ticketsup->read) { $ret = $this->newMessage($user, $action); if ($ret) { @@ -1152,16 +1127,16 @@ class ActionsTicketsup print '
'; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; - print ''; print ''; - - print '
'; - print '' . $langs->trans("InitialMessage") . ' '; + print '
'; + print $langs->trans("InitialMessage"); + print ''; if ($user->rights->ticketsup->manage) { - print '' . img_edit($langs->trans('Modify')) . ' ' . $langs->trans('Modify') . ''; + print '' . img_edit($langs->trans('Modify')) . ''; } print '
'; + print ''; if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') { // MESSAGE $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; @@ -1470,7 +1445,7 @@ class ActionsTicketsup global $langs; print '
'; - print '
'; + print '
'; print '
'; print '
'; print '' . $langs->trans('TicketChangeStatus') . ''; diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index b416819b4b6..61e5f5dd04a 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -181,7 +181,7 @@ class Ticketsup extends CommonObject 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>1, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-2, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), @@ -815,12 +815,10 @@ class Ticketsup extends CommonObject $sql .= " datec=" . (dol_strlen($this->datec) != 0 ? "'" . $this->db->idate($this->datec) . "'" : 'null') . ","; $sql .= " date_read=" . (dol_strlen($this->date_read) != 0 ? "'" . $this->db->idate($this->date_read) . "'" : 'null') . ","; $sql .= " date_close=" . (dol_strlen($this->date_close) != 0 ? "'" . $this->db->idate($this->date_close) . "'" : 'null') . ""; - $sql .= " WHERE rowid=" . $this->id; $this->db->begin(); - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++;