From d4ae0395edbf7649f578fc5438189fc3b25ee497 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 18 Mar 2018 19:13:42 +0100 Subject: [PATCH] NEW Look and feel v8: Use a different picto for delete and unlink --- .../adherents/tpl/linkedobjectblock.tpl.php | 2 +- .../comm/propal/tpl/linkedobjectblock.tpl.php | 2 +- htdocs/commande/tpl/linkedobjectblock.tpl.php | 2 +- .../facture/tpl/linkedobjectblock.tpl.php | 2 +- .../tpl/linkedobjectblockForRec.tpl.php | 2 +- htdocs/contrat/tpl/linkedobjectblock.tpl.php | 6 +- .../core/class/html.formticketsup.class.php | 12 +- htdocs/core/lib/functions.lib.php | 3 +- .../expedition/tpl/linkedobjectblock.tpl.php | 2 +- .../tpl/linkedobjectblock.tpl.php | 2 +- .../fichinter/tpl/linkedobjectblock.tpl.php | 2 +- .../commande/tpl/linkedobjectblock.tpl.php | 2 +- .../facture/tpl/linkedobjectblock.tpl.php | 2 +- htdocs/langs/en_US/ticketsup.lang | 12 +- .../template/class/myobject.class.php | 2 +- .../tpl/linkedobjectblock.tpl.php | 2 +- htdocs/ticketsup/card.php | 259 ++++++------ .../class/actions_ticketsup.class.php | 381 +++++++++--------- htdocs/ticketsup/class/ticketsup.class.php | 23 +- htdocs/ticketsup/history.php | 60 +-- htdocs/ticketsup/index.php | 4 +- htdocs/ticketsup/new.php | 13 +- 22 files changed, 406 insertions(+), 391 deletions(-) diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 118f51a1a89..f89b8da20f6 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -53,7 +53,7 @@ foreach($linkedObjectBlock as $key => $objectlink) echo price($objectlink->amount); } ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) echo price($objectlink->total_ht); } ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) // For now, shipments must stay linked to order, so link is not deletable if($object->element != 'shipping') { ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index ca3ec7c89c0..d2dd999350d 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -67,7 +67,7 @@ foreach($linkedObjectBlock as $key => $objectlink) } } ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) print $objectlink->getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) date_contrat,'day'); ?> rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) + if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE)) { $totalcontrat = 0; foreach ($objectlink->lines as $linecontrat) { @@ -65,7 +65,7 @@ foreach($linkedObjectBlock as $key => $objectlink) echo price($totalcontrat); } ?> getLibStatut(7); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> diff --git a/htdocs/core/class/html.formticketsup.class.php b/htdocs/core/class/html.formticketsup.class.php index bbbed8c2bef..1570cb34883 100644 --- a/htdocs/core/class/html.formticketsup.class.php +++ b/htdocs/core/class/html.formticketsup.class.php @@ -173,12 +173,12 @@ class FormTicketsup print "\n"; } - // Customer + // Customer or supplier if ($this->withcompany) { // altairis: force company and contact id for external user if (empty($user->socid)) { // Company - print '' . $langs->trans("Customer") . ''; + print '' . $langs->trans("Thirdparty") . ''; $events = array(); $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events); @@ -242,7 +242,7 @@ class FormTicketsup // If no socid, set to first one (id=1) to avoid full contacts list $selectedCompany = $this->withfromsocid > 0 ? $this->withfromsocid : 1; $nbofcontacts = $form->select_contacts($selectedCompany, $this->withfromcontactid, 'contactid', 0, '', '', 0, 'minwidth200'); - $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external'); + $formcompany->selectTypeContact($ticketstatic, '', 'type', 'external', '', 0, 'maginleftonly'); print ''; } else { print ''; @@ -296,9 +296,9 @@ class FormTicketsup print $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2'); print ''; - // Not notify tiers at create - print ''; - print 'withnotnotifytiersatcreate?' checked="checked"':'').'>'; + // Notify thirdparty at creation + print ''; + print 'withnotnotifytiersatcreate?'':' checked="checked"').'>'; print ''; // TITLE diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 457f1ad1ed5..f4759240cd5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3063,7 +3063,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) - if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'resize', 'switch_off', 'switch_on', 'uparrow'))) + if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) { $fakey = $pictowithoutext; $facolor=''; $fasize=''; if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; } @@ -3074,6 +3074,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; } elseif ($pictowithoutext == 'resize') { $fakey = 'fa-crop'; $facolor='#444'; } elseif ($pictowithoutext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor='#555'; } + elseif ($pictowithoutext == 'unlink') { $fakey = 'fa-chain-broken'; $facolor='#555'; } else { $fakey = 'fa-'.$pictowithoutext; $facolor='#999'; } if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.=($morecss?' ':'').$reg[1]; } diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index 88811da2eab..e62356066e5 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -61,7 +61,7 @@ foreach($linkedObjectBlock as $key => $objectlink) // For now, shipments must stay linked to order, so link is not deletable if($object->element != 'commande') { ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> diff --git a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php index 95894a8987e..2d040834a12 100644 --- a/htdocs/expensereport/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expensereport/tpl/linkedobjectblock.tpl.php @@ -52,7 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink) echo price($objectlink->total_ht); } ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) datev,'day'); ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) echo price($objectlink->total_ht); } ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) } } ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'), 'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'), - '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'), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>0, 'help'=>'LinkToThirparty'), 'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index 8c49e42f557..ca604e61fcc 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -55,7 +55,7 @@ foreach($linkedObjectBlock as $key => $objectlink) echo price($objectlink->total_ht); } ?> getLibStatut(3); ?> - ">transnoentitiesnoconv("RemoveLink")); ?> + ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> projet->enabled)) { - include DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; + include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php'; } @@ -41,30 +41,23 @@ if (!empty($conf->contrat->enabled)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php'; } -if (!class_exists('Contact')) { - include DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; -} - // Load traductions files requiredby by page -$langs->load("companies"); -$langs->load("other"); -$langs->load("ticketsup"); +$langs->loadLangs(array("companies","other","ticketsup")); // Get parameters $id = GETPOST('id', 'int'); $track_id = GETPOST('track_id', 'alpha', 3); -$action = GETPOST('action', 'alpha', 3); $ref = GETPOST('ref', 'alpha'); $projectid = GETPOST('projectid', 'int'); +$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')); -$object = new ActionsTicketsup($db); -$object->doActions($action); - $extrafields = new ExtraFields($db); -$extralabels = $extrafields->fetch_name_optionals_label($object->dao->table_element); +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +$object = new Ticketsup($db); if (!$action) { $action = 'view'; @@ -75,14 +68,14 @@ if (GETPOST('modelselected')) { } // Store current page url -$url_page_current = dol_buildpath('/ticketsup/card.php', 1); +$url_page_current = DOL_URL_ROOT.'/ticketsup/card.php'; -if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { +if ($id || $track_id || $ref) { $res = $object->fetch($id, $track_id, $ref); } // Security check -$result = restrictedArea($user, 'ticketsup', $object->dao->id); +$result = restrictedArea($user, 'ticketsup', $object->id); @@ -90,6 +83,9 @@ $result = restrictedArea($user, 'ticketsup', $object->dao->id); * Actions */ +$actionobject = new ActionsTicketsup($db); +$actionobject->doActions($action, $object); + $permissiondellink = $user->rights->ticketsup->write; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -105,38 +101,38 @@ $form = new Form($db); $formticket = new FormTicketsup($db); if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') { - $res = $object->fetch($id, $track_id, $ref); if ($res > 0) { // or for unauthorized internals users - if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->dao->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) { + if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) { accessforbidden('', 0); } $help_url = 'FR:DocumentationModuleTicket'; - $page_title = $object->getTitle($action); + $page_title = $actionobject->getTitle($action); llxHeader('', $page_title, $help_url); // Confirmation close if ($action == 'close') { - print $form->formconfirm($url_page_current . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1); + print $form->formconfirm($url_page_current . "?track_id=" . $object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1); if ($ret == 'html') { print '
'; } } // Confirmation delete if ($action == 'delete') { - print $form->formconfirm($url_page_current . "?track_id=" . $track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1); + print $form->formconfirm($url_page_current . "?track_id=" . $object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1); } // Confirm reopen if ($action == 'reopen') { - print $form->formconfirm($url_page_current . '?track_id=' . $track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1); + print $form->formconfirm($url_page_current . '?track_id=' . $object->track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1); } // Confirmation status change if ($action == 'set_status') { $new_status = GETPOST('new_status'); - print $form->formconfirm($url_page_current . "?track_id=" . $track_id . "&new_status=" . GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->dao->statuts_short[$new_status])), "confirm_set_status", '', '', 1); + //var_dump($url_page_current . "?track_id=" . $object->track_id); + print $form->formconfirm($url_page_current . "?track_id=" . $object->track_id . "&new_status=" . GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->statuts_short[$new_status])), "confirm_set_status", '', '', 1); } // project info @@ -205,39 +201,39 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print "ErrorRecordNotFound"; } } elseif ($socid > 0) { - $object->dao->fetch_thirdparty(); - $head = societe_prepare_head($object->dao->thirdparty); + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); dol_fiche_head($head, 'ticketsup', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->dao->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); dol_fiche_end(); } if (!$user->societe_id && $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY) { - $object->dao->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; + $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'"; } elseif ($user->societe_id > 0) { - $object->dao->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; + $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; } - $head = ticketsup_prepare_head($object->dao); + $head = ticketsup_prepare_head($object); dol_fiche_head($head, 'tabTicketsup', $langs->trans("Ticket"), -1, 'ticketsup'); - $object->dao->label = $object->dao->ref; + $object->label = $object->ref; // Author - if ($object->dao->fk_user_create > 0) { - $object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' '; + if ($object->fk_user_create > 0) { + $object->label .= ' - ' . $langs->trans("CreatedBy") . ' '; $langs->load("users"); $fuser = new User($db); - $fuser->fetch($object->dao->fk_user_create); - $object->dao->label .= $fuser->getNomUrl(0); + $fuser->fetch($object->fk_user_create); + $object->label .= $fuser->getNomUrl(0); } - if (!empty($object->dao->origin_email)) { - $object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' '; - $object->dao->label .= $object->dao->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; + if (!empty($object->origin_email)) { + $object->label .= ' - ' . $langs->trans("CreatedBy") . ' '; + $object->label .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; } $linkback = '' . $langs->trans("BackToList") . ' '; - $object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); + $object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); print '
'; print '
'; @@ -245,12 +241,12 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti // Track ID print '' . $langs->trans("TicketTrackId") . ''; - if (!empty($object->dao->track_id)) { - if (empty($object->dao->ref)) { - $object->ref = $object->dao->id; + if (!empty($object->track_id)) { + if (empty($object->ref)) { + $object->ref = $object->id; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'track_id'); } else { - print $object->dao->track_id; + print $object->track_id; } } else { print $langs->trans('None'); @@ -259,51 +255,51 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti // Subject print ''; - print $form->editfieldkey("Subject", 'subject', $object->dao->subject, $object->dao, $user->rights->ticketsup->write && !$user->societe_id, 'string'); + print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticketsup->write && !$user->societe_id, 'string'); print ''; - print $form->editfieldval("Subject", 'subject', $object->dao->subject, $object->dao, $user->rights->ticketsup->write && !$user->societe_id, 'string'); + print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticketsup->write && !$user->societe_id, 'string'); print ''; // Creation date print '' . $langs->trans("DateCreation") . ''; - print dol_print_date($object->dao->datec, 'dayhour'); + print dol_print_date($object->datec, 'dayhour'); print ''; // Read date - if (!empty($object->dao->date_read)) { + if (!empty($object->date_read)) { print '' . $langs->trans("TicketReadOn") . ''; - print dol_print_date($object->dao->date_read, 'dayhour'); + print dol_print_date($object->date_read, 'dayhour'); print ''; print '' . $langs->trans("TicketTimeToRead") . ''; - print '' . convertSecondToTime($object->dao->date_read - $object->dao->datec) . ''; + print '' . convertSecondToTime($object->date_read - $object->datec) . ''; print ''; } // Close date - if (!empty($object->dao->date_close)) { + if (!empty($object->date_close)) { print '' . $langs->trans("TicketCloseOn") . ''; - print dol_print_date($object->dao->date_close, 'dayhour'); + print dol_print_date($object->date_close, 'dayhour'); print ''; } print ''; - // Customer + // Thirdparty print ''; print ''; - if ($action != 'editcustomer' && $object->dao->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) { - print ''; + if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) { + print ''; } print '
'; - print $langs->trans('Customer'); + print $langs->trans('ThirdParty'); print '' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '
'; print ''; if ($action == 'editcustomer') { - $form->form_thirdparty($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->fk_soc, 'editcustomer', ($object->dao->fk_soc ? 's.rowid <> ' . $object->dao->fk_soc : ''), 1); + $form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->fk_soc, 'editcustomer', ($object->fk_soc ? 's.rowid <> ' . $object->fk_soc : ''), 1); } else { - $form->form_thirdparty($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->fk_soc, 'none', 's.rowid <> ' . $object->dao->fk_soc, 1); + $form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->fk_soc, 'none', 's.rowid <> ' . $object->fk_soc, 1); } print ''; @@ -315,41 +311,41 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print $langs->trans('Project'); print ''; if ($action != 'classify' && $user->rights->ticketsup->write) { - print '' . img_edit($langs->trans('SetProject')) . ''; + print '' . img_edit($langs->trans('SetProject')) . ''; } print ''; print ''; if ($action == 'classify') { - $form->form_project($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->socid, $object->dao->fk_project, 'projectid'); + $form->form_project($url_page_current . '?track_id=' . $object->track_id, $object->socid, $object->fk_project, 'projectid'); } else { - $form->form_project($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->socid, $object->dao->fk_project, 'none'); + $form->form_project($url_page_current . '?track_id=' . $object->track_id, $object->socid, $object->fk_project, 'none'); } print ''; } // User assigned print '' . $langs->trans("UserAssignedTo") . ''; - if ($object->dao->fk_user_assign > 0) { - $userstat->fetch($object->dao->fk_user_assign); + if ($object->fk_user_assign > 0) { + $userstat->fetch($object->fk_user_assign); print $userstat->getNomUrl(1); } else { print $langs->trans('None'); } // Show user list to assignate one if status is "read" - if (GETPOST('set') == "assign_ticket" && $object->dao->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) { + if (GETPOST('set') == "assign_ticket" && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) { print '
'; print ''; print ''; - print ''; + print ''; print ' '; print $form->select_dolusers($user->id, 'fk_user_assign', 0); print ' '; print '
'; } - if ($object->dao->fk_statut < 8 && GETPOST('set') != "assign_ticket" && $user->rights->ticketsup->manage) { - print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; + if ($object->fk_statut < 8 && GETPOST('set') != "assign_ticket" && $user->rights->ticketsup->manage) { + print '' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . ''; } print ''; @@ -358,8 +354,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; - if ($action != 'progression' && $object->dao->fk_statut < 8 && !$user->societe_id) { - print ''; + if ($action != 'progression' && $object->fk_statut < 8 && !$user->societe_id) { + print ''; } print '
'; print $langs->trans('Progression') . ''; print '' . img_edit($langs->trans('Modify')) . '' . img_edit($langs->trans('Modify')) . '
'; print ''; @@ -368,21 +364,21 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; print ''; print ''; - print ''; + print ''; print ' '; print ''; } else { - print($object->dao->progress > 0 ? $object->dao->progress : '0') . '%'; + print($object->progress > 0 ? $object->progress : '0') . '%'; } print ''; print ''; // Timing (Duration sum of linked fichinter - $object->dao->fetchObjectLinked(); - $num = count($object->dao->linkedObjects); + $object->fetchObjectLinked(); + $num = count($object->linkedObjects); $timing = 0; if ($num) { - foreach ($object->dao->linkedObjects as $objecttype => $objects) { + foreach ($object->linkedObjects as $objecttype => $objects) { if ($objecttype = "fichinter") { foreach ($objects as $fichinter) { $timing += $fichinter->duration; @@ -404,28 +400,28 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print '
'; print ''; print ''; - print ''; + print ''; - print $object->dao->showOptionals($extrafields, 'edit'); + print $object->showOptionals($extrafields, 'edit'); print ''; print ' '; print ' '; print ''; print '
'; } else { - print $object->dao->showOptionals($extrafields); + print $object->showOptionals($extrafields); if ($user->rights->ticketsup->write) { print ''; - print '' . img_picto('', 'edit') . ' ' . $langs->trans('Edit') . ''; + print '' . img_picto('', 'edit') . ' ' . $langs->trans('Edit') . ''; print ''; } } } print ''; - // View Original message - $object->viewTicketOriginalMessage($user, $action); + // View Original message + $actionobject->viewTicketOriginalMessage($user, $action); // Fin colonne gauche et début colonne droite @@ -481,7 +477,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; print ' '; print ''; - print $formticket->{$property['list_function']}($object->dao->type_code, 'update_value', '', 0); + print $formticket->{$property['list_function']}($object->type_code, 'update_value', '', 0); print ''; print ' '; print ''; @@ -494,7 +490,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti } else { // Type print '' . $langs->trans("Type") . ''; - print $object->dao->type_label; + print $object->type_label; if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -503,7 +499,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti // Category print '' . $langs->trans("Category") . ''; - print $object->dao->category_label; + print $object->category_label; if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -512,7 +508,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti // Severity print '' . $langs->trans("TicketSeverity") . ''; - print $object->dao->severity_label; + print $object->severity_label; if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } @@ -522,14 +518,16 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; // End table actions // Display navbar with links to change ticket status - if (!$user->societe_id && $user->rights->ticketsup->write && $object->dao->fk_status < 8 && GETPOST('set') !== 'properties') { - $object->viewStatusActions(); + print ''; + if (!$user->societe_id && $user->rights->ticketsup->write && $object->fk_status < 8 && GETPOST('set') !== 'properties') { + $actionobject->viewStatusActions($object); } + print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png'); + print '
'; print '
'; - print '
'; print '
' . $langs->trans("Source") . '
@@ -545,7 +543,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti $contactstatic = new Contact($db); $userstatic = new User($db); foreach (array('internal', 'external') as $source) { - $tmpobject = $object->dao; + $tmpobject = $object; $tab = $tmpobject->listeContact(-1, $source); $num = count($tab); $i = 0; @@ -607,7 +605,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; + print '
'; // Contract if ($action == 'sel_contract') { @@ -644,8 +643,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti $form_contract = new FormContract($db); $form_contract->formSelectContract( - $url_page_current.'?track_id='.$object->dao->track_id, - $object->dao->fk_soc, + $url_page_current.'?track_id='.$object->track_id, + $object->fk_soc, GETPOST('contractid'), 'contractid' ); @@ -657,53 +656,47 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print dol_fiche_end(); + /* ActionBar */ print '
'; - // Show button to mark as read - if (($object->dao->fk_statut == '0' || empty($object->dao->date_read)) && !$user->societe_id) { - print '
'; - print '' . img_picto('', 'mark-read@ticketsup', 'height="12px"') . ' ' . $langs->trans('MarkAsRead') . ''; - print 'dao->fk_statut < 8 && $action != "add_message") { - print ''; + if ($object->fk_statut < 8 && $action != "add_message") { + print ''; } // Link to create an intervention // socid is needed otherwise fichinter ask it and forgot origin after form submit :\ - if (!$object->dao->fk_soc && $user->rights->ficheinter->creer) { + if (!$object->fk_soc && $user->rights->ficheinter->creer) { print ''; } - if ($object->dao->fk_soc > 0 && $object->dao->fk_statut < 8 && $user->rights->ficheinter->creer) { - print ''; + if ($object->fk_soc > 0 && $object->fk_statut < 8 && $user->rights->ficheinter->creer) { + print ''; } // Button to edit Properties - if ($object->dao->fk_statut < 5 && $user->rights->ticketsup->write) { - print ''; + if ($object->fk_statut < 5 && $user->rights->ticketsup->write) { + print ''; } // Button to link to a contract - if ($user->rights->ticketsup->write && $object->dao->fk_statut < 5 && $user->rights->contrat->creer) { - print ''; + if ($user->rights->ticketsup->write && $object->fk_statut < 5 && $user->rights->contrat->creer) { + print ''; } // Close ticket if statut is read - if ($object->dao->fk_statut > 0 && $object->dao->fk_statut < 8 && $user->rights->ticketsup->write) { - print ''; + if ($object->fk_statut > 0 && $object->fk_statut < 8 && $user->rights->ticketsup->write) { + print ''; } // Re-open ticket - if (!$user->socid && $object->dao->fk_statut == 8 && !$user->societe_id) { - print ''; + if (!$user->socid && $object->fk_statut == 8 && !$user->societe_id) { + print ''; } // Delete ticket if ($user->rights->ticketsup->delete && !$user->societe_id) { - print ''; + print ''; } print '
'; @@ -715,7 +708,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti // Message list print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticketsup'); $show_private_message = ($user->societe_id ? 0 : 1); - $object->viewTicketTimelineMessages($show_private_message); + $actionobject->viewTicketTimelineMessages($show_private_message, true, $object); print '
'; @@ -741,8 +734,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti $formticket = new FormTicketsup($db); $formticket->action = $action; - $formticket->track_id = $object->dao->track_id; - $formticket->id = $object->dao->id; + $formticket->track_id = $object->track_id; + $formticket->id = $object->id; $formticket->withfile = 2; $formticket->param = array('fk_user_create' => $user->id); @@ -751,32 +744,32 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti // Tableau des parametres complementaires du post $formticket->param['models']=$modelmail; $formticket->param['models_id']=GETPOST('modelmailselected', 'int'); - //$formticket->param['socid']=$object->dao->fk_soc; - $formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->dao->track_id; + //$formticket->param['socid']=$object->fk_soc; + $formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->track_id; $formticket->withsubstit = 1; - if ($object->dao->fk_soc > 0) { - $object->dao->fetch_thirdparty(); - $formticket->substit['__THIRDPARTY_NAME__'] = $object->dao->thirdparty->name; + if ($object->fk_soc > 0) { + $object->fetch_thirdparty(); + $formticket->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name; } $formticket->substit['__SIGNATURE__'] = $user->signature; - $formticket->substit['__TICKETSUP_TRACKID__'] = $object->dao->track_id; - $formticket->substit['__TICKETSUP_REF__'] = $object->dao->ref; - $formticket->substit['__TICKETSUP_SUBJECT__'] = $object->dao->subject; - $formticket->substit['__TICKETSUP_TYPE__'] = $object->dao->type_code; - $formticket->substit['__TICKETSUP_CATEGORY__'] = $object->dao->category_code; - $formticket->substit['__TICKETSUP_SEVERITY__'] = $object->dao->severity_code; - $formticket->substit['__TICKETSUP_MESSAGE__'] = $object->dao->message; - $formticket->substit['__TICKETSUP_PROGRESSION__'] = $object->dao->progress; - if ($object->dao->fk_user_assign > 0) { - $userstat->fetch($object->dao->fk_user_assign); + $formticket->substit['__TICKETSUP_TRACKID__'] = $object->track_id; + $formticket->substit['__TICKETSUP_REF__'] = $object->ref; + $formticket->substit['__TICKETSUP_SUBJECT__'] = $object->subject; + $formticket->substit['__TICKETSUP_TYPE__'] = $object->type_code; + $formticket->substit['__TICKETSUP_CATEGORY__'] = $object->category_code; + $formticket->substit['__TICKETSUP_SEVERITY__'] = $object->severity_code; + $formticket->substit['__TICKETSUP_MESSAGE__'] = $object->message; + $formticket->substit['__TICKETSUP_PROGRESSION__'] = $object->progress; + if ($object->fk_user_assign > 0) { + $userstat->fetch($object->fk_user_assign); $formticket->substit['__TICKETSUP_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); } - if ($object->dao->fk_user_create > 0) { - $userstat->fetch($object->dao->fk_user_create); + if ($object->fk_user_create > 0) { + $userstat->fetch($object->fk_user_create); $formticket->substit['__TICKETSUP_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname); } @@ -792,7 +785,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti * * Put here code to view linked object ****************************************************/ -$somethingshown = $form->showLinkedObjectBlock($object->dao); +$somethingshown = $form->showLinkedObjectBlock($object); // End of page llxFooter(''); diff --git a/htdocs/ticketsup/class/actions_ticketsup.class.php b/htdocs/ticketsup/class/actions_ticketsup.class.php index 317f3f187ff..1186b7fbd1e 100644 --- a/htdocs/ticketsup/class/actions_ticketsup.class.php +++ b/htdocs/ticketsup/class/actions_ticketsup.class.php @@ -79,21 +79,20 @@ class ActionsTicketsup * doActions * * @param string $action Action type + * @param Ticketsup $object Object Ticketsup * @return int 0 */ - public function doActions(&$action = '') + public function doActions(&$action = '', Ticketsup $object=null) { global $conf, $user, $langs, $mysoc; - $this->getInstanceDao(); - /* * Add file in email form */ if (GETPOST('addfile')) { // altairis : allow files from public interface if (GETPOST('track_id')) { - $res = $this->dao->fetch('', GETPOST('track_id','alpha')); + $res = $object->fetch('', GETPOST('track_id','alpha')); } ////if($res > 0) @@ -101,13 +100,13 @@ class ActionsTicketsup include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; // Set tmp directory TODO Use a dedicated directory for temp mails files - $vardir = $conf->ticketsup->dir_output . (!empty($this->dao->track_id) ? '/' . dol_sanitizeFileName($this->dao->track_id) : ''); + $vardir = $conf->ticketsup->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : ''); $upload_dir_tmp = $vardir . '/temp'; if (!dol_is_dir($upload_dir_tmp)) { dol_mkdir($upload_dir_tmp); } dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '-__file__'); - $action = !empty($this->dao->track_id) ? 'add_message' : 'create_ticket'; + $action = !empty($object->track_id) ? 'add_message' : 'create_ticket'; ////} } @@ -117,7 +116,7 @@ class ActionsTicketsup if (GETPOST('removedfile')) { // altairis : allow files from public interface if (GETPOST('track_id')) { - $res = $this->dao->fetch('', GETPOST('track_id')); + $res = $object->fetch('', GETPOST('track_id')); } ////if($res > 0) @@ -125,12 +124,12 @@ class ActionsTicketsup include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; // Set tmp directory - $vardir = $conf->ticketsup->dir_output . (!empty($this->dao->track_id) ? '/' . dol_sanitizeFileName($this->dao->track_id) : ''); + $vardir = $conf->ticketsup->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : ''); $upload_dir_tmp = $vardir . '/temp'; // TODO Delete only files that was uploaded from email form dol_remove_file_process($_POST['removedfile'], 0); - $action = !empty($this->dao->track_id) ? 'add_message' : 'create_ticket'; + $action = !empty($object->track_id) ? 'add_message' : 'create_ticket'; ////} } @@ -150,28 +149,28 @@ class ActionsTicketsup if (!$error) { $this->db->begin(); - $this->dao->track_id = generate_random_id(16); + $object->track_id = generate_random_id(16); - $this->dao->ref = GETPOST("ref", 'alpha'); - $this->dao->fk_soc = GETPOST("socid", 'int'); - $this->dao->subject = GETPOST("subject", 'alpha'); - $this->dao->message = GETPOST("message"); + $object->ref = GETPOST("ref", 'alpha'); + $object->fk_soc = GETPOST("socid", 'int'); + $object->subject = GETPOST("subject", 'alpha'); + $object->message = GETPOST("message"); - $this->dao->type_code = GETPOST("type_code", 'alpha'); - $this->dao->category_code = GETPOST("category_code", 'alpha'); - $this->dao->severity_code = GETPOST("severity_code", 'alpha'); + $object->type_code = GETPOST("type_code", 'alpha'); + $object->category_code = GETPOST("category_code", 'alpha'); + $object->severity_code = GETPOST("severity_code", 'alpha'); $notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha'); - $this->dao->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0; + $object->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0; $extrafields = new ExtraFields($this->db); - $extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $this->dao); + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - $id = $this->dao->create($user); + $id = $object->create($user); if ($id <= 0) { $error++; - $this->error = $this->dao->error; - $this->errors = $this->dao->errors; + $this->error = $object->error; + $this->errors = $object->errors; $action = 'create_ticket'; } @@ -186,31 +185,31 @@ class ActionsTicketsup $type_contact = GETPOST("type", 'alpha'); if ($contactid > 0 && $type_contact) { - $result = $this->dao->add_contact($contactid, GETPOST("type"), 'external'); + $result = $object->add_contact($contactid, GETPOST("type"), 'external'); } // altairis: link ticket to project if (GETPOST('projectid')) { - $this->dao->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid')); } // Auto assign user if ($conf->global->TICKETS_AUTO_ASSIGN_USER_CREATE) { - $result = $this->dao->assignUser($user, $user->id, 1); - $this->dao->add_contact($user->id, "SUPPORTTEC", 'internal'); + $result = $object->assignUser($user, $user->id, 1); + $object->add_contact($user->id, "SUPPORTTEC", 'internal'); } // Auto assign contrat $contractid = 0; if ($conf->global->TICKETS_AUTO_ASSIGN_CONTRACT_CREATE) { $contrat = new Contrat($this->db); - $contrat->socid = $this->dao->fk_soc; + $contrat->socid = $object->fk_soc; $list = $contrat->getListOfContracts(); if (is_array($list) && !empty($list)) { if (count($list) == 1) { $contractid = $list[0]->id; - $this->dao->setContract($contractid); + $object->setContract($contractid); } else { } } @@ -219,13 +218,13 @@ class ActionsTicketsup // Auto create fiche intervention if ($conf->global->TICKETS_AUTO_CREATE_FICHINTER_CREATE) { $fichinter = new Fichinter($this->db); - $fichinter->socid = $this->dao->fk_soc; + $fichinter->socid = $object->fk_soc; $fichinter->fk_project = GETPOST('projectid', 'int'); $fichinter->fk_contrat = $contractid; $fichinter->author = $user->id; $fichinter->modelpdf = 'soleil'; - $fichinter->origin = $this->dao->element; - $fichinter->origin_id = $this->dao->id; + $fichinter->origin = $object->element; + $fichinter->origin_id = $object->id; // Extrafields $extrafields = new ExtraFields($this->db); @@ -242,7 +241,7 @@ class ActionsTicketsup if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?track_id=' . $this->dao->track_id; + $url = 'card.php?track_id=' . $object->track_id; } header("Location: " . $url); @@ -259,7 +258,7 @@ class ActionsTicketsup if ($action == 'edit' && $user->rights->ticketsup->write) { $error = 0; - if ($this->dao->fetch(GETPOST('id')) < 0) { + if ($object->fetch(GETPOST('id')) < 0) { $error++; array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); $_GET["action"] = $_POST["action"] = ''; @@ -269,7 +268,7 @@ class ActionsTicketsup if (GETPOST('update') && GETPOST('id') && $user->rights->ticketsup->write) { $error = 0; - $ret = $this->dao->fetch(GETPOST('id')); + $ret = $object->fetch(GETPOST('id')); if ($ret < 0) { $error++; array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); @@ -287,15 +286,15 @@ class ActionsTicketsup if (!$error) { $this->db->begin(); - $this->dao->label = GETPOST("label"); - $this->dao->description = GETPOST("description"); + $object->label = GETPOST("label"); + $object->description = GETPOST("description"); //... - $ret = $this->dao->update(GETPOST('id'), $user); + $ret = $object->update(GETPOST('id'), $user); if ($ret <= 0) { $error++; - $this->errors = $this->dao->error; - $this->errors = $this->dao->errors; + $this->errors = $object->error; + $this->errors = $object->errors; $action = 'edit'; } @@ -308,29 +307,29 @@ class ActionsTicketsup } if ($action == "mark_ticket_read" && $user->rights->ticketsup->write) { - $this->dao->fetch('', GETPOST("track_id")); + $object->fetch('', GETPOST("track_id")); - if ($this->dao->markAsRead($user) > 0) { + if ($object->markAsRead($user) > 0) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogMesgReadBy', $user->getFullName($langs)); - $ret = $this->dao->createTicketLog($user, $log_action); + $ret = $object->createTicketLog($user, $log_action); if ($ret > 0) { setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); } else { setEventMessages($langs->trans('TicketMarkedAsReadButLogActionNotSaved'), null, 'errors'); } - header("Location: card.php?track_id=" . $this->dao->track_id . "&action=view"); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); exit; } else { - array_push($this->errors, $this->dao->error); + array_push($this->errors, $object->error); } $action = 'view'; } if ($action == "assign_user" && GETPOST('btn_assign_user') && $user->rights->ticketsup->write) { - $this->dao->fetch('', GETPOST("track_id")); + $object->fetch('', GETPOST("track_id")); - $useroriginassign = $this->dao->fk_user_assign; + $useroriginassign = $object->fk_user_assign; $usertoassign = GETPOST('fk_user_assign'); if (!$usertoassign) { $error++; @@ -339,38 +338,38 @@ class ActionsTicketsup } if (!$error) { - $ret = $this->dao->assignUser($user, $usertoassign); + $ret = $object->assignUser($user, $usertoassign); if ($ret) { // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { - $internal_contacts = $this->dao->listeContact(-1, 'internal'); + $internal_contacts = $object->listeContact(-1, 'internal'); foreach ($internal_contacts as $key => $contact) { if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) { } { //print "user à effacer : ".$useroriginassign; - $this->dao->delete_contact($contact['rowid']); + $object->delete_contact($contact['rowid']); } } } - $this->dao->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); + $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); } // Log action in ticket logs table - $this->dao->fetch_user($usertoassign); - $log_action = $langs->trans('TicketLogAssignedTo', $this->dao->user->getFullName($langs)); - $ret = $this->dao->createTicketLog($user, $log_action); + $object->fetch_user($usertoassign); + $log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs)); + $ret = $object->createTicketLog($user, $log_action); if ($ret > 0) { setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); } else { setEventMessages($langs->trans('TicketAssignedButLogActionNotSaved'), null, 'errors'); } - header("Location: card.php?track_id=" . $this->dao->track_id . "&action=view"); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); exit; } else { - array_push($this->errors, $this->dao->error); + array_push($this->errors, $object->error); } $action = 'view'; } @@ -381,18 +380,18 @@ class ActionsTicketsup $fieldtomodify = GETPOST('property') . '_code'; $fieldtomodify_label = GETPOST('property') . '_label'; - $oldvalue_code = $this->dao->$fieldtomodify; - $newvalue_code = $this->dao->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code'); + $oldvalue_code = $object->$fieldtomodify; + $newvalue_code = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code'); - $oldvalue_label = $this->dao->$fieldtomodify_label; - $newvalue_label = $this->dao->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label'); + $oldvalue_label = $object->$fieldtomodify_label; + $newvalue_label = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label'); - $this->dao->$fieldtomodify = $newvalue_code; + $object->$fieldtomodify = $newvalue_code; - $ret = $this->dao->update($user); + $ret = $object->update($user); if ($ret > 0) { $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); - $ret = $this->dao->createTicketLog($user, $log_action); + $ret = $object->createTicketLog($user, $log_action); if ($ret > 0) { setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); } @@ -406,13 +405,13 @@ class ActionsTicketsup if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $url = 'card.php?action=view&track_id=' . $object->track_id; } header("Location: " . $url); exit; } else { - setEventMessages($this->dao->error, null, 'errors'); + setEventMessages($object->error, null, 'errors'); $action = 'add_message'; } } @@ -423,10 +422,10 @@ class ActionsTicketsup if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticketsup->write) { $this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')); - if ($this->dao->close()) { + if ($object->close()) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs)); - $ret = $this->dao->createTicketLog($user, $log_action); + $ret = $object->createTicketLog($user, $log_action); if ($ret > 0) { setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
'); } else { @@ -442,10 +441,10 @@ class ActionsTicketsup if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') { $this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')); - if (($_SESSION['email_customer'] == $this->dao->origin_email || $_SESSION['email_customer'] == $this->dao->thirdparty->email) && $this->dao->close()) { + if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - $ret = $this->dao->createTicketLog($user, $log_action); + $ret = $object->createTicketLog($user, $log_action); if ($ret > 0) { setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); } else { @@ -461,7 +460,7 @@ class ActionsTicketsup if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticketsup->delete) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { - if ($this->dao->delete($user) > 0) { + if ($object->delete($user) > 0) { setEventMessages('
' . $langs->trans('TicketDeletedSuccess') . '
', null, 'mesgs'); Header("Location: index.php"); exit; @@ -476,7 +475,7 @@ class ActionsTicketsup // Set parent company if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { - $result = $this->dao->setCustomer(GETPOST('editcustomer', 'int')); + $result = $object->setCustomer(GETPOST('editcustomer', 'int')); $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); header("Location: " . $url); exit(); @@ -485,11 +484,11 @@ class ActionsTicketsup if ($action == 'set_progression' && $user->rights->ticketsup->write) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { - $result = $this->dao->setProgression(GETPOST('progress')); + $result = $object->setProgression(GETPOST('progress')); // Log action in ticket logs table $log_action = $langs->trans('TicketLogProgressSetTo', GETPOST('progress')); - $ret = $this->dao->createTicketLog($user, $log_action); - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $ret = $object->createTicketLog($user, $log_action); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); } @@ -498,19 +497,19 @@ class ActionsTicketsup if ($action == 'setsubject') { if ($this->fetch(GETPOST('id', 'int'))) { if ($action == 'setsubject') { - $this->dao->subject = trim(GETPOST('subject', 'alpha')); + $object->subject = trim(GETPOST('subject', 'alpha')); } - if ($action == 'setsubject' && empty($this->dao->subject)) { + if ($action == 'setsubject' && empty($object->subject)) { $mesg .= ($mesg ? '
' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); } if (!$mesg) { - if ($this->dao->update($user) >= 0) { - header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $this->dao->track_id); + if ($object->update($user) >= 0) { + header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); exit; } - $mesg = $this->dao->error; + $mesg = $object->error; } } } @@ -519,13 +518,13 @@ class ActionsTicketsup $res = $this->fetch('', GETPOST('track_id')); $extrafields = new ExtraFields($this->db); - $extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $this->dao); + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - $ret = $this->dao->update($user); + $ret = $object->update($user); if ($ret > 0) { setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); } @@ -535,13 +534,13 @@ class ActionsTicketsup elseif ($action == 'confirm_reopen' && $user->rights->ticketsup->manage && !GETPOST('cancel')) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { // prevent browser refresh from reopening ticket several times - if ($this->dao->fk_statut == 8) { - $res = $this->dao->setStatut(4); + if ($object->fk_statut == 8) { + $res = $object->setStatut(4); if ($res) { // Log action in ticket logs table $log_action = $langs->trans('TicketLogReopen'); - $ret = $this->dao->createTicketLog($user, $log_action); - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $ret = $object->createTicketLog($user, $log_action); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); } @@ -550,16 +549,16 @@ class ActionsTicketsup } // Categorisation dans projet elseif ($action == 'classin' && $user->rights->ticketsup->write) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { - $this->dao->setProject(GETPOST('projectid')); - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $object->setProject(GETPOST('projectid')); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); } } // Categorisation dans contrat elseif ($action == 'setcontract' && $user->rights->ticketsup->write) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { - $this->dao->setContract(GETPOST('contractid')); - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $object->setContract(GETPOST('contractid')); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); } @@ -567,19 +566,19 @@ class ActionsTicketsup // altairis: manage cancel button if (!GETPOST('cancel')) { $this->fetch('', GETPOST('track_id')); - $oldvalue_message = $this->dao->message; + $oldvalue_message = $object->message; $fieldtomodify = GETPOST('message_initial'); - $this->dao->message = $fieldtomodify; - $ret = $this->dao->update($user); + $object->message = $fieldtomodify; + $ret = $object->update($user); if ($ret > 0) { $log_action = $langs->trans('TicketInitialMessageModified') . " \n"; // include the Diff class dol_include_once('/ticketsup/class/utils_diff.class.php'); // output the result of comparing two files as plain text - $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($this->dao->message))); + $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); - $ret = $this->dao->createTicketLog($user, $log_action); + $ret = $object->createTicketLog($user, $log_action); if ($ret > 0) { setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs'); } @@ -591,13 +590,13 @@ class ActionsTicketsup elseif ($action == 'confirm_set_status' && $user->rights->ticketsup->write && !GETPOST('cancel')) { if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { $new_status = GETPOST('new_status', 'int'); - $old_status = $this->dao->fk_statut; - $res = $this->dao->setStatut($new_status); + $old_status = $object->fk_statut; + $res = $object->setStatut($new_status); if ($res) { // Log action in ticket logs table - $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($this->dao->statuts_short[$old_status]), $langs->transnoentities($this->dao->statuts_short[$new_status])); - $ret = $this->dao->createTicketLog($user, $log_action); - $url = 'card.php?action=view&track_id=' . $this->dao->track_id; + $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); + $ret = $object->createTicketLog($user, $log_action); + $url = 'card.php?action=view&track_id=' . $object->track_id; header("Location: " . $url); exit(); } @@ -624,9 +623,9 @@ class ActionsTicketsup $contactstatic = new Contact($this->db); $error = 0; - $ret = $this->dao->fetch('', GETPOST('track_id')); - $this->dao->socid = $this->dao->fk_soc; - $this->dao->fetch_thirdparty(); + $ret = $object->fetch('', GETPOST('track_id')); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); if ($ret < 0) { $error++; array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); @@ -640,15 +639,15 @@ class ActionsTicketsup } if (!$error) { - $this->dao->message = GETPOST("message"); - $this->dao->private = GETPOST("private_message"); + $object->message = GETPOST("message"); + $object->private = GETPOST("private_message"); $send_email = GETPOST('send_email', 'int'); - $id = $this->dao->createTicketMessage($user); + $id = $object->createTicketMessage($user); if ($id <= 0) { $error++; - $this->errors = $this->dao->error; - $this->errors = $this->dao->errors; + $this->errors = $object->error; + $this->errors = $object->errors; $action = 'add_message'; } @@ -660,14 +659,14 @@ class ActionsTicketsup */ if ($send_email > 0) { // Retrieve internal contact datas - $internal_contacts = $this->dao->getInfosTicketInternalContact(); + $internal_contacts = $object->getInfosTicketInternalContact(); $sendto = array(); if (is_array($internal_contacts) && count($internal_contacts) > 0) { // altairis: set default subject $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage'); + $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $this->dao->id); + $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id); $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE; $message = $langs->trans('TicketMessageMailIntroText'); @@ -677,9 +676,9 @@ class ActionsTicketsup // Coordonnées client $message .= "\n\n"; $message .= "==============================================\n"; - $message .= !empty($this->dao->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $this->dao->thirdparty->name : ''; - $message .= !empty($this->dao->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $this->dao->thirdparty->town : ''; - $message .= !empty($this->dao->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $this->dao->thirdparty->phone : ''; + $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $object->thirdparty->name : ''; + $message .= !empty($object->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $object->thirdparty->town : ''; + $message .= !empty($object->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; // Build array to display recipient list foreach ($internal_contacts as $key => $info_sendto) { @@ -698,10 +697,10 @@ class ActionsTicketsup } $message .= "\n"; // URL ticket - $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $this->dao->track_id; + $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id; // altairis: make html link on url - $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '' . $this->dao->track_id . '' . "\n"; + $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '' . $object->track_id . '' . "\n"; // Add global email address recipient // altairis: use new TICKETS_NOTIFICATION_EMAIL_TO configuration variable @@ -718,18 +717,18 @@ class ActionsTicketsup /* * Email for externals users if not private */ - if (empty($this->dao->private)) { + if (empty($object->private)) { // Retrieve email of all contacts (external) - $external_contacts = $this->dao->getInfosTicketExternalContact(); + $external_contacts = $object->getInfosTicketExternalContact(); // If no contact, get email from thirdparty if (is_array($external_contacts) && count($external_contacts) === 0) { - if (!empty($this->dao->fk_soc)) { - $this->dao->fetch_thirdparty($this->dao->fk_soc); - $array_company = array(array('firstname' => '', 'lastname' => $this->dao->thirdparty->name, 'email' => $this->dao->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->dao->thirdparty->id)); + if (!empty($object->fk_soc)) { + $object->fetch_thirdparty($object->fk_soc); + $array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id)); $external_contacts = array_merge($external_contacts, $array_company); - } elseif (empty($this->dao->fk_soc) && !empty($this->dao->origin_email)) { - $array_external = array(array('firstname' => '', 'lastname' => $this->dao->origin_email, 'email' => $this->dao->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->dao->thirdparty->id)); + } elseif (empty($object->fk_soc) && !empty($object->origin_email)) { + $array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id)); $external_contacts = array_merge($external_contacts, $array_external); } } @@ -738,7 +737,7 @@ class ActionsTicketsup if (is_array($external_contacts) && count($external_contacts) > 0) { // altairis: get default subject for email to external contacts $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage'); + $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); $message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKETS_MESSAGE_MAIL_INTRO; $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE; @@ -753,7 +752,7 @@ class ActionsTicketsup continue; } - if ($info_sendto['email'] != '' && $info_sendto['email'] != $this->dao->origin_email) { + if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { if(!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">"; $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')'; @@ -768,8 +767,8 @@ class ActionsTicketsup dol_buildpath('/ticketsup/public/view.php', 2) ) : dol_buildpath('/ticketsup/card.php', 2) - ) . '?track_id=' . $this->dao->track_id; - $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $this->dao->track_id . '' . "\n"; + ) . '?track_id=' . $object->track_id; + $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; // Build final message $message = $message_intro . $message; @@ -777,14 +776,14 @@ class ActionsTicketsup // Add signature $message .= '
' . $message_signature; - if (!empty($this->dao->origin_email)) { - $sendto[] = $this->dao->origin_email; + if (!empty($object->origin_email)) { + $sendto[] = $object->origin_email; } - if ($this->dao->fk_soc > 0 && ! in_array($this->dao->origin_email, $sendto)) { - $this->dao->socid = $this->dao->fk_soc; - $this->dao->fetch_thirdparty(); - if(!empty($this->dao->thirdparty->email)) $sendto[] = $this->dao->thirdparty->email; + if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); + if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; } // altairis: Add global email address reciepient @@ -803,13 +802,13 @@ class ActionsTicketsup $this->copyFilesForTicket(); // Set status to "answered" if not set yet, only for internal users - if ($this->dao->fk_statut < 3 && !$user->societe_id) { - $this->dao->setStatut(3); + if ($object->fk_statut < 3 && !$user->societe_id) { + $object->setStatut(3); } return 1; } else { - setEventMessages($this->dao->error, $this->dao->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); return -1; } } else { @@ -830,9 +829,9 @@ class ActionsTicketsup global $mysoc, $conf, $langs; $error = 0; - $ret = $this->dao->fetch('', GETPOST('track_id')); - $this->dao->socid = $this->dao->fk_soc; - $this->dao->fetch_thirdparty(); + $ret = $object->fetch('', GETPOST('track_id')); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); if ($ret < 0) { $error++; array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); @@ -846,12 +845,12 @@ class ActionsTicketsup } if (!$error) { - $this->dao->message = GETPOST("message"); - $id = $this->dao->createTicketMessage($user); + $object->message = GETPOST("message"); + $id = $object->createTicketMessage($user); if ($id <= 0) { $error++; - $this->errors = $this->dao->error; - $this->errors = $this->dao->errors; + $this->errors = $object->error; + $this->errors = $object->errors; $action = 'add_message'; } @@ -859,24 +858,24 @@ class ActionsTicketsup setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); // Retrieve internal contact datas - $internal_contacts = $this->dao->getInfosTicketInternalContact(); + $internal_contacts = $object->getInfosTicketInternalContact(); $sendto = array(); if (is_array($internal_contacts) && count($internal_contacts) > 0) { - $subject = '[' . $mysoc->name . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage'); + $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $this->dao->subject); + $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject); $message .= "\n"; $message .= GETPOST('message'); $message .= "\n"; // Coordonnées client - if ($this->dao->thirdparty->id > 0) { + if ($object->thirdparty->id > 0) { $message .= "\n\n"; $message .= "==============================================\n"; - $message .= $langs->trans('Thirparty') . " : " . $this->dao->thirdparty->name; - $message .= !empty($this->dao->thirdparty->town) ? $langs->trans('Town') . " : " . $this->dao->thirdparty->town : ''; + $message .= $langs->trans('Thirparty') . " : " . $object->thirdparty->name; + $message .= !empty($object->thirdparty->town) ? $langs->trans('Town') . " : " . $object->thirdparty->town : ''; $message .= "\n"; - $message .= !empty($this->dao->thirdparty->phone) ? $langs->trans('Phone') . " : " . $this->dao->thirdparty->phone : ''; + $message .= !empty($object->thirdparty->phone) ? $langs->trans('Phone') . " : " . $object->thirdparty->phone : ''; $message .= "\n"; } @@ -893,7 +892,7 @@ class ActionsTicketsup } // URL ticket - $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $this->dao->track_id; + $url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id; $message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $url_internal_ticket . "\n"; $message .= "\n\n"; @@ -913,12 +912,12 @@ class ActionsTicketsup */ // Retrieve email of all contacts external - $external_contacts = $this->dao->getInfosTicketExternalContact(); + $external_contacts = $object->getInfosTicketExternalContact(); $sendto = array(); if (is_array($external_contacts) && count($external_contacts) > 0) { - $subject = '[' . $mysoc->name . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage'); + $subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); - $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $this->dao->subject); + $message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject); $message .= "\n"; $message .= GETPOST('message'); @@ -934,28 +933,28 @@ class ActionsTicketsup $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : ''); } - $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $this->dao->track_id; + $url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $object->track_id; $message .= "\n\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . $url_public_ticket . "\n"; // Add signature $message .= '\n\n' . $message_signature; - if (!empty($this->dao->origin_email) && !in_array($this->dao->origin_email, $sendto)) { - $sendto[] = $this->dao->origin_email; + if (!empty($object->origin_email) && !in_array($object->origin_email, $sendto)) { + $sendto[] = $object->origin_email; } - if ($this->dao->fk_soc > 0 && !in_array($this->dao->origin_email, $sendto)) { - $sendto[] = $this->dao->thirdparty->email; + if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) { + $sendto[] = $object->thirdparty->email; } $this->sendTicketMessageByEmail($subject, $message, '', $sendto); } $this->copyFilesForTicket(); - $url = 'view.php?action=view_ticket&track_id=' . $this->dao->track_id; + $url = 'view.php?action=view_ticket&track_id=' . $object->track_id; header("Location: " . $url); exit; } else { - setEventMessages($this->dao->error, $this->dao->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { setEventMessages($this->error, $this->errors, 'errors'); @@ -1090,19 +1089,20 @@ class ActionsTicketsup /** * View list of logs with timeline view * - * @param boolean $show_user Show user who make action + * @param boolean $show_user Show user who make action + * @param Ticketsup $object Object */ - public function viewTimelineTicketLogs($show_user = true) + public function viewTimelineTicketLogs($show_user = true, $object = true) { global $conf, $langs, $bc; // Load logs in cache - $ret = $this->dao->loadCacheLogsTicket(); + $ret = $object->loadCacheLogsTicket(); - if (is_array($this->dao->cache_logs_ticket) && count($this->dao->cache_logs_ticket) > 0) { + if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { print '
'; - foreach ($this->dao->cache_logs_ticket as $id => $arraylogs) { + foreach ($object->cache_logs_ticket as $id => $arraylogs) { print '
'; print '
'; //print ''; @@ -1263,21 +1263,22 @@ class ActionsTicketsup /** * View list of message for ticket with timeline display * - * @param boolean $show_private Show private messages - * @param boolean $show_user Show user who make action + * @param boolean $show_private Show private messages + * @param boolean $show_user Show user who make action + * @param Ticketsup $object Object ticketsup */ - public function viewTicketTimelineMessages($show_private, $show_user = true) + public function viewTicketTimelineMessages($show_private, $show_user, Ticketsup $object) { global $conf, $langs, $user, $bc; // Load logs in cache - $ret = $this->dao->loadCacheMsgsTicket(); + $ret = $object->loadCacheMsgsTicket(); $action = GETPOST('action'); - if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) { + if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { print '
'; - foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) { + foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { if (!$arraymsgs['private'] || ($arraymsgs['private'] == "1" && $show_private) ) { @@ -1460,49 +1461,43 @@ class ActionsTicketsup /** * Print html navbar with link to set ticket status -<<<<<<< HEAD - * $selected : 0=>'NotRead', 1=>'Read', 3=>'Answered', 4=>'Assigned', 5 => 'InProgress', 6=> 'Waiting', 8=>'Closed', 9=>'Deleted' * + * @param Ticketsup $object Ticket sup * @return void -======= - * - * @global type $langs ->>>>>>> branch 'develop' of git@github.com:Dolibarr/dolibarr.git */ - public function viewStatusActions() + public function viewStatusActions(Ticketsup $object) { global $langs; + print '
'; print '
'; print '
'; print '
'; print '' . $langs->trans('TicketChangeStatus') . ''; print '
'; // Exclude status which requires specific method - $exclude_status = array(4, 9, 8); + $exclude_status = array(Ticketsup::STATUS_CLOSED, Ticketsup::STATUS_CANCELED); // Exclude actual status - $exclude_status = array_merge($exclude_status, array(intval($this->dao->fk_statut))); - - // If status is new, don't show link which allow mark ticket as read - // Specific method exists to mark a ticket as read - if ($this->dao->fk_statut == '0') { - $exclude_status = array_merge($exclude_status, array(1)); - } + $exclude_status = array_merge($exclude_status, array(intval($object->fk_statut))); // Sort results to be similar to status object list - sort($exclude_status); + //sort($exclude_status); //print '
'; - foreach ($this->dao->statuts_short as $status => $statut_label) { + foreach ($object->statuts_short as $status => $statut_label) { if (!in_array($status, $exclude_status)) { print ''; } } - print '

'; + print '

'; } diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index 3795978289e..7f011d7f459 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -191,9 +191,24 @@ class Ticketsup extends CommonObject 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) + 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) ); + /** + * Status + */ + const STATUS_NOT_READ = 0; + const STATUS_READ = 1; + const STATUS_ANSWERED = 3; + const STATUS_ASSIGNED = 4; + const STATUS_IN_PROGRESS = 5; + const STATUS_WAITING = 6; + const STATUS_CLOSED = 8; + const STATUS_CANCELED = 9; + + + + /** * Constructor * @@ -203,8 +218,8 @@ class Ticketsup extends CommonObject { $this->db = $db; - $this->statuts_short = array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'); - $this->statuts = array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'); + $this->statuts_short = array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'); + $this->statuts = array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'); } /** @@ -422,7 +437,7 @@ class Ticketsup extends CommonObject global $langs; // Check parameters - if (!$id && !$track_id && !$ref) { + if (! $id && ! $track_id && ! $ref) { $this->error = 'ErrorWrongParameters'; dol_print_error(get_class($this) . "::fetch " . $this->error); return -1; diff --git a/htdocs/ticketsup/history.php b/htdocs/ticketsup/history.php index b4e0e0e9249..6994cbeafc1 100644 --- a/htdocs/ticketsup/history.php +++ b/htdocs/ticketsup/history.php @@ -49,25 +49,33 @@ if (!$user->rights->ticketsup->read) { accessforbidden(); } -$object = new ActionsTicketsup($db); - -$object->doActions($action); - $extrafields = new ExtraFields($db); -$extralabels = $extrafields->fetch_name_optionals_label($object->dao->table_element); +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); if (!$action) { - $action = 'view'; + $action = 'view'; } -/*************************************************** - * PAGE - * - * Put here all code to build page - ****************************************************/ +$object = new Ticketsup($db); +$object->fetch($id, $track_id, $ref); + + +/* + * Actions + */ + +$actionobject = new ActionsTicketsup($db); + +$actionobject->doActions($action, $object); + + + +/* + * View + */ $help_url = 'FR:DocumentationModuleTicket'; -$page_title = $object->getTitle($action); +$page_title = $actionobject->getTitle($action); llxHeader('', $page_title, $help_url); $userstat = new User($db); @@ -79,20 +87,20 @@ if ($action == 'view') { if ($res > 0) { // restrict access for externals users - if ($user->societe_id > 0 && ($object->dao->fk_soc != $user->societe_id) + if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id) ) { accessforbidden('', 0); } // or for unauthorized internals users - if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->dao->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) { + if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) { accessforbidden('', 0); } if ($socid > 0) { - $object->dao->fetch_thirdparty(); - $head = societe_prepare_head($object->dao->thirdparty); + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); dol_fiche_head($head, 'ticketsup', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->dao->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom'); dol_fiche_end(); } @@ -101,26 +109,28 @@ if ($action == 'view') { } elseif ($user->societe_id > 0) { $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; } - $head = ticketsup_prepare_head($object->dao); + $head = ticketsup_prepare_head($object); dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticketsup'); - $object->dao->label = $object->dao->ref; + $object->label = $object->ref; // Author - if ($object->dao->fk_user_create > 0) { - $object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' '; + if ($object->fk_user_create > 0) { + $object->label .= ' - ' . $langs->trans("CreatedBy") . ' '; $langs->load("users"); $fuser = new User($db); - $fuser->fetch($object->dao->fk_user_create); - $object->dao->label .= $fuser->getNomUrl(0); + $fuser->fetch($object->fk_user_create); + $object->label .= $fuser->getNomUrl(0); } $linkback = '' . $langs->trans("BackToList") . ' '; - $object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); + + // TODO Merge this with dol_banner_tab + $object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); dol_fiche_end(); print '
'; // Logs list print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticketsup'); - $object->viewTimelineTicketLogs(); + $actionobject->viewTimelineTicketLogs(true, $object); print '
'; print '
'; } diff --git a/htdocs/ticketsup/index.php b/htdocs/ticketsup/index.php index 37cf7bf959c..2274ae0b889 100644 --- a/htdocs/ticketsup/index.php +++ b/htdocs/ticketsup/index.php @@ -53,7 +53,7 @@ $year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; $startyear = $year - 1; $endyear = $year; -$object = new ActionsTicketsup($db); +$object = new Ticketsup($db); /* @@ -180,7 +180,7 @@ if ($result) { if ((round($tick['unread']) ? 1 : 0) +(round($tick['read']) ? 1 : 0) +(round($tick['answered']) ? 1 : 0) +(round($tick['assigned']) ? 1 : 0) +(round($tick['inprogress']) ? 1 : 0) +(round($tick['waiting']) ? 1 : 0) +(round($tick['closed']) ? 1 : 0) +(round($tick['deleted']) ? 1 : 0) >= 2 ) { $dataseries = array(); - $dataseries[] = array('label' => $langs->trans("NotRead"), 'data' => round($tick['unread'])); + $dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread'])); $dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read'])); $dataseries[] = array('label' => $langs->trans("Answered"), 'data' => round($tick['answered'])); $dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned'])); diff --git a/htdocs/ticketsup/new.php b/htdocs/ticketsup/new.php index e08361e1e77..c784d5f04ac 100644 --- a/htdocs/ticketsup/new.php +++ b/htdocs/ticketsup/new.php @@ -39,7 +39,6 @@ $socid = GETPOST('socid', 'int'); $contactid = GETPOST('contactid', 'int'); $msg_id = GETPOST('msg_id', 'int'); $notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha'); -$notnotifytiersatcreate = !empty($notNotifyTiers); $action = GETPOST('action', 'alpha', 3); @@ -48,14 +47,15 @@ if (!$user->rights->ticketsup->read || !$user->rights->ticketsup->write) { accessforbidden(); } -$object = new ActionsTicketsup($db); +$object = new Ticketsup($db); +$actionobject = new ActionsTicketsup($db); /* * Actions */ -$object->doActions($action); +$actionobject->doActions($action, $object); @@ -63,11 +63,12 @@ $object->doActions($action); * View */ +$form = new Form($db); + $help_url = 'FR:DocumentationModuleTicket'; -$page_title = $object->getTitle($action); +$page_title = $actionobject->getTitle($action); llxHeader('', $page_title, $help_url); -$form = new Form($db); if ($action == 'create_ticket') { $formticket = new FormTicketsup($db); @@ -77,7 +78,7 @@ if ($action == 'create_ticket') { $formticket->withfromsocid = $socid ? $socid : $user->societe_id; $formticket->withfromcontactid = $contactid ? $contactid : ''; $formticket->withtitletopic = 1; - $formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate; + $formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate?1:0; $formticket->withusercreate = 1; $formticket->withref = 1; $formticket->fk_user_create = $user->id;