diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 35705b661d9..5bfa27eadbc 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -428,10 +428,11 @@ class Conf $this->global->MAIN_MAIL_USE_MULTI_PART=1; // societe - if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard"; - if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum"; + if (empty($this->global->SOCIETE_CODECLIENT_ADDON)) $this->global->SOCIETE_CODECLIENT_ADDON="mod_codeclient_leopard"; + if (empty($this->global->SOCIETE_CODECOMPTA_ADDON)) $this->global->SOCIETE_CODECOMPTA_ADDON="mod_codecompta_panicum"; - if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint'; + if (empty($this->global->CHEQUERECEIPTS_ADDON)) $this->global->CHEQUERECEIPTS_ADDON='mod_chequereceipt_mint'; + if (empty($conf->global->TICKETSUP_ADDON)) $this->global->TICKETSUP_ADDON='mod_ticket_simple'; // Security if (empty($this->global->USER_PASSWORD_GENERATED)) $this->global->USER_PASSWORD_GENERATED='standard'; // Default password generator diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e06e071ee89..20c4b4f5a90 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1286,8 +1286,8 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Object db - * @param mixed $filterobj Object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource - * @param Contact $objcon Object contact + * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object + * @param Contact $objcon Filter on object contact to filter events on a contact * @param int $noprint Return string but does not output it * @param string $actioncode Filter on actioncode * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all). @@ -1295,11 +1295,10 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac * @param string $sortfield Sort field * @param string $sortorder Sort order * @return mixed Return html part or void if noprint is 1 - * TODO change function to be able to list event linked to an object. */ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep,a.id', $sortorder='DESC') { - global $user,$conf; + global $user, $conf; global $form; global $param; @@ -1317,14 +1316,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if (! empty($conf->agenda->enabled)) { // Recherche histo sur actioncomm - if (is_object($objcon) && $objcon->id) { - $sql = "SELECT DISTINCT a.id, a.label,"; - } - else - { - $sql = "SELECT a.id, a.label,"; - } - $sql.= " a.datep as dp,"; + if (is_object($objcon) && $objcon->id) { + $sql = "SELECT DISTINCT a.id, a.label,"; + } + else + { + $sql = "SELECT a.id, a.label,"; + } + $sql.= " a.datep as dp,"; $sql.= " a.datep2 as dp2,"; $sql.= " a.note, a.percent,"; $sql.= " a.fk_element, a.elementtype,"; @@ -1333,8 +1332,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $sql.= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; - elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", o.ref"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Facture') $sql.= ", o.ref"; + else $sql.= ", o.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; @@ -1353,6 +1352,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; elseif (is_object($filterobj) && get_class($filterobj) == 'Product') $sql.= ", ".MAIN_DB_PREFIX."product as o"; + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') $sql.= ", ".MAIN_DB_PREFIX."ticket as o"; $sql.= " WHERE a.entity IN (".getEntity('agenda').")"; if (is_object($filterobj) && in_array(get_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; @@ -1372,6 +1372,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; } + elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') + { + $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'"; + if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + } // Work with new table actioncomm_resources and multiple contact affectation. if (is_object($objcon) && $objcon->id) @@ -1403,8 +1408,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); - - //TODO Add limit for thirdparty in contexte very all result + + //TODO Add limit for thirdparty in contexte very all result $sql.= $db->order($sortfield, $sortorder); dol_syslog("company.lib::show_actions_done", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index e6ce5c1bddd..735050af437 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -103,7 +103,7 @@ function ticket_prepare_head($object) // History - $head[$h][0] = DOL_URL_ROOT.'/ticket/history.php?track_id=' . $object->track_id; + $head[$h][0] = DOL_URL_ROOT.'/ticket/agenda.php?track_id=' . $object->track_id; $head[$h][1] = $langs->trans('Events'); if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 09725355f43..e8ae0a8e6c6 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -799,7 +799,8 @@ class InterfaceActionsAuto extends DolibarrTriggers if ($object->sendtoid > 0) $contactforaction->fetch($object->sendtoid); } // Set societeforaction. - if ($object->socid > 0) $societeforaction->fetch($object->socid); + if ($object->socid > 0) $societeforaction->fetch($object->socid); + elseif ($object->fk_soc > 0) $societeforaction->fetch($object->fk_soc); $projectid = isset($object->fk_project)?$object->fk_project:0; if ($object->element == 'project') $projectid = $object->id; @@ -811,6 +812,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $elementid = $object->fk_adherent; $elementtype = 'member'; } + //var_dump($societeforaction);var_dump($contactforaction);exit; // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 143e30e8fb7..601e6c2aac3 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -105,6 +105,9 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_VALIDATE','Project validation','Executed when a project is validated','project',141); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_DELETE','Project deleted','Executed when a project is deleted','project',143); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CREATE','Ticket created','Executed when a ticket is created','ticket',161); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_MODIFY','Ticket modified','Executed when a ticket is modified','ticket',163); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',164); -- actions not enabled by default (no constant created for that) when we enable module agenda insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PRODUCT_MODIFY','Product or service modified','Executed when a product or sevice is modified','product',41); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',23); diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql new file mode 100644 index 00000000000..101bcb6f4f8 --- /dev/null +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -0,0 +1,38 @@ +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 9.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + + +-- Missing in 9.0 + + + +-- For 10.0 +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CREATE','Ticket created','Executed when a ticket is created','ticket',161); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_MODIFY','Ticket modified','Executed when a ticket is modified','ticket',163); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',164); diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index cd39a43abe8..95fadf00b68 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -92,6 +92,9 @@ EXPENSE_REPORT_REFUSEDInDolibarr=Expense report %s refused PROJECT_CREATEInDolibarr=Project %s created PROJECT_MODIFYInDolibarr=Project %s modified PROJECT_DELETEInDolibarr=Project %s deleted +TICKET_CREATEInDolibarr=Ticket %s created +TICKET_MODIFYInDolibarr=Ticket %s modified +TICKET_DELETEInDolibarr=Ticket %s deleted ##### End agenda events ##### AgendaModelModule=Document templates for event DateActionStart=Start date diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 75de962b7ce..f7140d2c6ee 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -276,6 +276,7 @@ TicketNotificationLogMessage=Log message TicketNotificationEmailBodyInfosTrackUrlinternal=View ticket into interface TicketNotificationNumberEmailSent=Notification email sent : %s +ActionsOnTicket=Events on ticket # # Boxes diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 1f9b35b8420..92c187ce438 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -18,8 +18,8 @@ /** * \file htdocs/projet/info.php - * \ingroup commande - * \brief Page with info on project + * \ingroup project + * \brief Page with events on project */ require '../main.inc.php'; @@ -34,7 +34,7 @@ $langs->load("projects"); $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); $socid = GETPOST('socid','int'); -$action = GETPOST('action','alpha'); +$action = GETPOST('action','aZ09'); $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield","alpha"); @@ -50,16 +50,15 @@ $pagenext = $page + 1; if (GETPOST('actioncode','array')) { - $actioncode=GETPOST('actioncode','array',3); - if (! count($actioncode)) $actioncode='0'; + $actioncode=GETPOST('actioncode','array',3); + if (! count($actioncode)) $actioncode='0'; } else { - $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } $search_agenda_label=GETPOST('search_agenda_label'); - // Security check $id = GETPOST("id",'int'); $socid=0; @@ -71,7 +70,7 @@ if (!$user->rights->projet->lire) accessforbidden(); /* - * Actions + * Actions */ $parameters=array('id'=>$socid); @@ -81,8 +80,8 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { - $actioncode=''; - $search_agenda_label=''; + $actioncode=''; + $search_agenda_label=''; } diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php new file mode 100644 index 00000000000..cddff9d2df6 --- /dev/null +++ b/htdocs/ticket/agenda.php @@ -0,0 +1,239 @@ + + * + * 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 3 of the License, or + * (at your option) any later version. + * + * This program 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 this program. If not, see . + */ + +/** + * \file htdocs/ticket/agenda.php + * \ingroup ticket + * \brief Page with events on ticket + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php'; +require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php'; +require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php"; +require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'other', 'ticket')); + +// Get parameters +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$track_id = GETPOST('track_id', 'alpha', 3); +$socid = GETPOST('socid', 'int'); +$action = GETPOST('action', 'aZ09'); + +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST("sortfield","alpha"); +$sortorder = GETPOST("sortorder"); +$page = GETPOST("page"); +$page = is_numeric($page) ? $page : 0; +$page = $page == -1 ? 0 : $page; +if (! $sortfield) $sortfield="a.datep,a.id"; +if (! $sortorder) $sortorder="DESC"; +$offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (GETPOST('actioncode','array')) +{ + $actioncode=GETPOST('actioncode','array',3); + if (! count($actioncode)) $actioncode='0'; +} +else +{ + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); +} +$search_agenda_label=GETPOST('search_agenda_label'); + +$object = new Ticket($db); +$object->fetch($id, $ref, $track_id); + +$extrafields = new ExtraFields($db); +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +if (!$action) { + $action = 'view'; +} + + +// Security check +$id = GETPOST("id",'int'); +$socid=0; +//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. +$result=restrictedArea($user,'ticket',$id,''); + +if (!$user->rights->ticket->read) { + accessforbidden(); +} +// restrict access for externals users +if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)) +{ + accessforbidden('', 0); +} +// or for unauthorized internals users +if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { + accessforbidden('', 0); +} + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +// Purge search criteria +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers +{ + $actioncode=''; + $search_agenda_label=''; +} + + + +/* + * View + */ + +$form = new Form($db); +$userstat = new User($db); +$formticket = new FormTicket($db); + +$title=$langs->trans("Ticket").' - '.$object->ref.' '.$object->name; +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info"); +$help_url = 'FR:DocumentationModuleTicket'; +llxHeader('', $title, $help_url); + + if ($socid > 0) { + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + + dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + + dol_fiche_end(); + } + + if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; + } elseif ($user->societe_id > 0) { + $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; + } + $head = ticket_prepare_head($object); + + dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); + + $morehtmlref ='
'; + $morehtmlref.= $object->subject; + // Author + if ($object->fk_user_create > 0) { + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; + + $langs->load("users"); + $fuser = new User($db); + $fuser->fetch($object->fk_user_create); + $morehtmlref .= $fuser->getNomUrl(0); + } + if (!empty($object->origin_email)) { + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; + $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; + } + + // Thirdparty + if (! empty($conf->societe->enabled)) + { + $morehtmlref.='
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + }*/ + $morehtmlref.=' : '; + if ($action == 'editcustomer') { + $morehtmlref.=$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref.=$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project'); + if ($user->rights->ticket->write) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(1); + } else { + $morehtmlref.=''; + } + } + } + + $morehtmlref.='
'; + + $linkback = '' . $langs->trans("BackToList") . ' '; + + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + + dol_fiche_end(); + + print '
'; + + +if (!empty($object->id)) +{ + print '
'; + $param='&id='.$object->id; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + + print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); + + // List of all actions + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index ab16161e844..a3d8b119d77 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -335,11 +335,12 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd if (! empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; + $morehtmlref.='
'.$langs->trans('Project'); if ($user->rights->ticket->write) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.='
'; diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index e836db4e1be..21c1087f276 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -146,13 +146,13 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $head = ticket_prepare_head($object); - dol_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticket'); + dol_fiche_head($head, 'contact', $langs->trans("Ticket"), 0, 'ticket'); $morehtmlref ='
'; $morehtmlref.= $object->subject; // Author if ($object->fk_user_create > 0) { - $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; $langs->load("users"); $fuser = new User($db); @@ -160,14 +160,62 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { $morehtmlref .= $fuser->getNomUrl(0); } if (!empty($object->origin_email)) { - $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; } + + // Thirdparty + if (! empty($conf->societe->enabled)) + { + $morehtmlref.='
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + }*/ + $morehtmlref.=' : '; + if ($action == 'editcustomer') { + $morehtmlref.=$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref.=$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(1); + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; $linkback = '' . $langs->trans("BackToList") . ' '; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); dol_fiche_end(); diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index 69b06e431bc..09edb6e85cb 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -119,7 +119,7 @@ if ($object->id) $morehtmlref.= $object->subject; // Author if ($object->fk_user_create > 0) { - $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; $langs->load("users"); $fuser = new User($db); @@ -127,14 +127,62 @@ if ($object->id) $morehtmlref .= $fuser->getNomUrl(0); } if (!empty($object->origin_email)) { - $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; } + + // Thirdparty + if (! empty($conf->societe->enabled)) + { + $morehtmlref.='
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticket->write) { + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + }*/ + $morehtmlref.=' : '; + if ($action == 'editcustomer') { + $morehtmlref.=$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref.=$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(1); + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.=''; $linkback = '' . $langs->trans("BackToList") . ' '; - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_fiche_end(); diff --git a/htdocs/ticket/history.php b/htdocs/ticket/history.php deleted file mode 100644 index 7efe7562a03..00000000000 --- a/htdocs/ticket/history.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program 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 this program. If not, see . - */ - -/** - * \file htdocs/ticket/history.php - * \ingroup ticket - * \brief History of ticket - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php'; -require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php"; -require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; - -if (!class_exists('Contact')) { - include DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; -} - -// Load translation files required by the page -$langs->loadLangs(array('companies', 'other', 'ticket')); - -// Get parameters -$id = GETPOST('id', 'int'); -$track_id = GETPOST('track_id', 'alpha', 3); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'aZ09'); - -// Security check -if (!$user->rights->ticket->read) { - accessforbidden(); -} - -$extrafields = new ExtraFields($db); -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - -if (!$action) { - $action = 'view'; -} - -$object = new Ticket($db); -$object->fetch($id, $ref, $track_id); - - -/* - * Actions - */ - -$actionobject = new ActionsTicket($db); - -$actionobject->doActions($action, $object); - - - -/* - * View - */ - -$help_url = 'FR:DocumentationModuleTicket'; -$page_title = $actionobject->getTitle($action); -llxHeader('', $page_title, $help_url); - -$userstat = new User($db); -$form = new Form($db); -$formticket = new FormTicket($db); - -if ($action == 'view') { - $res = $object->fetch($id, $ref, $track_id); - - if ($res > 0) { - // restrict access for externals users - if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id) - ) { - accessforbidden('', 0); - } - // or for unauthorized internals users - if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { - accessforbidden('', 0); - } - - if ($socid > 0) { - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); - dol_fiche_end(); - } - - if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { - $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; - } elseif ($user->societe_id > 0) { - $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; - } - $head = ticket_prepare_head($object); - - dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); - - $morehtmlref ='
'; - $morehtmlref.= $object->subject; - // Author - if ($object->fk_user_create > 0) { - $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; - - $langs->load("users"); - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $morehtmlref .= $fuser->getNomUrl(0); - } - if (!empty($object->origin_email)) { - $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; - $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; - } - $morehtmlref.='
'; - - $linkback = '' . $langs->trans("BackToList") . ' '; - - dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); - - dol_fiche_end(); - - print '
'; - // Logs list - print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticket'); - $actionobject->viewTimelineTicketLogs(true, $object); - print '
'; - print '
'; - } -} // End action view - -// End of page -llxFooter(''); -$db->close(); diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php index 086ea63bc0e..f89dd82cbca 100644 --- a/htdocs/ticket/index.php +++ b/htdocs/ticket/index.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/ticket/history.php + * \file htdocs/ticket/agenda.php * \ingroup ticket */