From 8df834bd2a26f67d706fb16ecbadf2d6122d1ff5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Jul 2018 12:13:34 +0200 Subject: [PATCH] Debug module ticket --- htdocs/ticket/card.php | 2 +- htdocs/ticket/class/actions_ticket.class.php | 2 +- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/ticket/contact.php | 2 +- htdocs/ticket/history.php | 2 +- htdocs/ticket/index.php | 2 +- htdocs/ticket/list.php | 43 +++++++++++--------- htdocs/ticket/new.php | 2 +- htdocs/ticket/tpl/linkedobjectblock.tpl.php | 2 +- 9 files changed, 32 insertions(+), 27 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index cf49bda3562..b736b49646f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -5,7 +5,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 72e010eb1f4..6dc946ebad3 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -4,7 +4,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index de7f39049f8..3dc0ab39756 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -188,7 +188,7 @@ class Ticket extends CommonObject 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"), 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>60, 'notnull'=>-1,), - 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>1, 'enabled'=>1, 'position'=>41, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>1, 'enabled'=>1, 'position'=>41, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""), 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1), diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index e96fb015c04..22199bed745 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -5,7 +5,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/history.php b/htdocs/ticket/history.php index c982acf3a3a..c840f3aa1a8 100644 --- a/htdocs/ticket/history.php +++ b/htdocs/ticket/history.php @@ -3,7 +3,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index e87e0166bc0..9acfd66c3bb 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -3,7 +3,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index cc3291a5e00..c99ac7e7e3a 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -5,7 +5,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -20,6 +20,7 @@ /** * \file htdocs/ticket/list.php * \ingroup ticket + * \brief List page for tickets */ require '../main.inc.php'; @@ -90,7 +91,6 @@ foreach($object->fields as $key => $val) if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } - // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach($object->fields as $key => $val) @@ -106,7 +106,7 @@ foreach($object->fields as $key => $val) if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -177,16 +177,21 @@ if (empty($reshook)) * View */ -$help_url = 'FR:DocumentationModuleTicket'; -llxHeader('', $langs->trans('TicketList'), $help_url); - -$form = new Form($db); +$form=new Form($db); $formTicket = new FormTicket($db); +$now=dol_now(); + $user_assign = new User($db); $user_create = new User($db); $socstatic = new Societe($db); +$help_url = 'FR:DocumentationModuleTicket'; +$title = $langs->trans('TicketList'); + +llxHeader('', $title, $help_url); + + // Build and execute select // -------------------------------------------------------------------- @@ -204,8 +209,8 @@ $reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); $sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('ticket').")"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity($object->element).")"; else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { @@ -245,6 +250,7 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/','', $sql); */ $sql.=$db->order($sortfield,$sortorder); @@ -253,18 +259,17 @@ $sql.=$db->order($sortfield,$sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 { $page = 0; $offset = 0; } } -// if total resultset is smaller the limit, no need to do paging. +// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $resql = $result; $num = $nbtotalofrecords; } else @@ -434,7 +439,6 @@ if ($user->rights->ticket->delete) $arrayofmassactions['predelete']=$langs->tran if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - print '
'; if ($optioncss != '') print ''; print ''; @@ -456,7 +460,7 @@ if ($user->rights->ticket->write) $newcardbutton.= ''; } -print_barre_liste($langs->trans('TicketList'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_ticket', 0, $newcardbutton, '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_ticket', 0, $newcardbutton, '', $limit); if ($mode == 'my_assign') { print '
' . $langs->trans('TicketAssignedToMeInfos') . '

'; @@ -513,7 +517,6 @@ print ''; - foreach($object->fields as $key => $val) { $align=''; @@ -581,13 +584,15 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine=0; -if (! empty($extrafields->attributes[$object->table_element]['computed'])) { +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) +{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object } } + // Loop on record // -------------------------------------------------------------------- $i=0; @@ -696,7 +701,7 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $hidegeneratedfilelistifempty=1; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); $formfile = new FormFile($db); // Show list of available documents diff --git a/htdocs/ticket/new.php b/htdocs/ticket/new.php index c92a8538bdf..8f33d87c804 100644 --- a/htdocs/ticket/new.php +++ b/htdocs/ticket/new.php @@ -4,7 +4,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/htdocs/ticket/tpl/linkedobjectblock.tpl.php b/htdocs/ticket/tpl/linkedobjectblock.tpl.php index ec3703990bf..dd9f340429e 100644 --- a/htdocs/ticket/tpl/linkedobjectblock.tpl.php +++ b/htdocs/ticket/tpl/linkedobjectblock.tpl.php @@ -4,7 +4,7 @@ * * This program 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 + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful,