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'); ?> load("banks"); $langs->load("categories"); +$langs->load("bills"); +$langs->load("withdrawals"); // Security check if ($user->societe_id > 0) accessforbidden(); -$langs->load("bills"); -$langs->load("withdrawals"); - // Get supervariables $action = GETPOST('action','alpha'); $id = GETPOST('id','int'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index de69513e62a..fe0cbb9e27b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1640,13 +1640,14 @@ else print ''; if ($user->rights->contrat->creer && count($arrayothercontracts) && ($object->statut >= 0)) { - print ''; + print ''; + print ''; print img_picto($langs->trans("MoveToAnotherContract"),'uparrow'); print ''; } if ($user->rights->contrat->creer && ($object->statut >= 0)) { - print ''; + print ''; print img_edit(); print ''; } diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index a44f20679b8..ae4a56ef4a9 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -52,10 +52,10 @@ foreach($linkedObjectBlock as $key => $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/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index a67d2c3ac02..936d269f82a 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Frederic France + * Copyright (C) 2018 Josep Lluís Amador * * 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 @@ -20,7 +21,7 @@ /** * \file htdocs/core/boxes/box_contacts.php - * \ingroup societes + * \ingroup contacts * \brief Module to show box of contacts */ @@ -57,7 +58,7 @@ class box_contacts extends ModeleBoxes $this->db=$db; - $this->hidden=! ($user->rights->societe->lire); + $this->hidden=! ($user->rights->societe->lire && $user->rights->societe->contact->lire); } /** @@ -75,12 +76,12 @@ class box_contacts extends ModeleBoxes $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedContacts",$max)); - if ($user->rights->societe->lire) + if ($user->rights->societe->lire && $user->rights->societe->contact->lire) { $sql = "SELECT sp.rowid as id, sp.lastname, sp.firstname, sp.civility as civility_id, sp.datec, sp.tms, sp.fk_soc, sp.statut as status"; $sql.= ", sp.address, sp.zip, sp.town, sp.phone, sp.phone_perso, sp.phone_mobile"; $sql.= ", s.nom as socname, s.name_alias"; - $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; + $sql.= ", s.client, s.fournisseur, s.code_client, s.code_fournisseur"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -91,98 +92,97 @@ class box_contacts extends ModeleBoxes $sql.= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { + if ($result) { $num = $db->num_rows($result); $contactstatic=new Contact($db); $societestatic=new Societe($db); $line = 0; - while ($line < $num) - { + while ($line < $num) + { $objp = $db->fetch_object($result); $datec=$db->jdate($objp->datec); $datem=$db->jdate($objp->tms); - $contactstatic->id=$objp->id; + $contactstatic->id=$objp->id; $contactstatic->lastname=$objp->lastname; - $contactstatic->firstname=$objp->firstname; - $contactstatic->civility_id=$objp->civility_id; + $contactstatic->firstname=$objp->firstname; + $contactstatic->civility_id=$objp->civility_id; $contactstatic->statut=$objp->status; - $contactstatic->phone_pro = $objp->phone; - $contactstatic->phone_perso = $objp->phone_perso; - $contactstatic->phone_mobile = $objp->phone_mobile; - $contactstatic->address = $objp->address; - $contactstatic->zip = $objp->zip; - $contactstatic->town = $objp->town; + $contactstatic->phone_pro = $objp->phone; + $contactstatic->phone_perso = $objp->phone_perso; + $contactstatic->phone_mobile = $objp->phone_mobile; + $contactstatic->address = $objp->address; + $contactstatic->zip = $objp->zip; + $contactstatic->town = $objp->town; $societestatic->id = $objp->fk_soc; - $societestatic->name = $objp->socname; - $societestatic->name_alias = $objp->name_alias; - $societestatic->code_client = $objp->code_client; - $societestatic->code_fournisseur = $objp->code_fournisseur; - $societestatic->client = $objp->client; - $societestatic->fournisseur = $objp->fournisseur; + $societestatic->name = $objp->socname; + $societestatic->name_alias = $objp->name_alias; + $societestatic->code_client = $objp->code_client; + $societestatic->code_fournisseur = $objp->code_fournisseur; + $societestatic->client = $objp->client; + $societestatic->fournisseur = $objp->fournisseur; - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => $contactstatic->getNomUrl(1), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $contactstatic->getNomUrl(1), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => '', - 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), - 'asis' => 1, - ); + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => ($objp->fk_soc > 0 ? $societestatic->getNomUrl(1) : ''), + 'asis' => 1, + ); - $this->info_box_contents[$line][] = array( - 'td' => 'class="right"', - 'text' => dol_print_date($datem, "day"), - ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); - $this->info_box_contents[$line][] = array( - 'td' => 'align="right" class="nowrap" width="18"', - 'text' => $contactstatic->getLibStatut(3), - 'asis'=>1, - ); + $this->info_box_contents[$line][] = array( + 'td' => 'align="right" class="nowrap" width="18"', + 'text' => $contactstatic->getLibStatut(3), + 'asis'=>1, + ); - $line++; - } + $line++; + } - if ($num==0) - $this->info_box_contents[$line][0] = array( - 'td' => 'align="center"', - 'text'=>$langs->trans("NoRecordedContacts"), - ); + if ($num==0) + $this->info_box_contents[$line][0] = array( + 'td' => 'align="center"', + 'text'=>$langs->trans("NoRecordedContacts"), + ); - $db->free($result); - } else { - $this->info_box_contents[0][0] = array( - 'td' => '', - 'maxlength'=>500, - 'text' => ($db->error().' sql='.$sql), - ); - } - } else { - $this->info_box_contents[0][0] = array( - 'td' => 'align="left" class="nohover opacitymedium"', - 'text' => $langs->trans("ReadPermissionNotAllowed") - ); - } - - } + $db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'align="left" class="nohover opacitymedium"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } /** * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput=0) - { + function showBox($head = null, $contents = null, $nooutput=0) + { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 861848e6924..2d5ba165365 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -134,7 +134,7 @@ class ExtraFields * * @param string $attrname Code of attribute * @param string $label label of attribute - * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...) + * @param int $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...) * @param int $pos Position of attribute * @param string $size Size/length of attribute * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 55345d68cc7..5ff93994e73 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -996,7 +996,7 @@ class FormMail extends Form * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position + * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position or -2 for exact match with label (no aswer if not found) * @param int $active 1=Only active template, 0=Only disabled, -1=All * @param string $label Label of template * @return ModelMail @@ -1005,14 +1005,20 @@ class FormMail extends Form { $ret = new ModelMail(); + if ($id == -2 && empty($label)) + { + $this->error = 'LabelIsMandatoryWhenIdIs-2'; + return -1; + } + $sql = "SELECT label, topic, joinfiles, content, content_lines, lang"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; $sql.= " AND entity IN (".getEntity('c_email_templates').")"; $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; - if ($label) $sql.=" AND label ='".$this->db->escape($label)."'"; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; + if ($label) $sql.=" AND label ='".$db->escape($label)."'"; + if (is_object($outputlangs)) $sql.= " AND (lang = '".$db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' @@ -1034,8 +1040,11 @@ class FormMail extends Form $ret->content_lines = $obj->content_lines; $ret->joinfiles = $obj->joinfiles; } - else // If there is no template at all - { + elseif($id == -2) { + // Not found with the provided label + return -1; + } + else { // If there is no template at all $defaultmessage=''; if ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } diff --git a/htdocs/core/class/html.formticketsup.class.php b/htdocs/core/class/html.formticketsup.class.php index bbbed8c2bef..3310b83eb09 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 'withnotifytiersatcreate?' checked="checked"':'').'>'; print ''; // TITLE diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b5794758d23..2177559c0ab 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1340,6 +1340,25 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r //} } } + elseif ($object->element == 'ticketsup') + { + $width=80; $cssclass='photoref'; + $showimage=$object->is_photo_available($conf->ticketsup->dir_output.'/'.$object->track_id); + $maxvisiblephotos=(isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO)?$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO:2); + if ($conf->browser->phone) $maxvisiblephotos=1; + if ($showimage) $morehtmlleft.='
'.$object->show_photos($conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'
'; + else + { + if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) { + $nophoto=''; + $morehtmlleft.='
'; + } + //elseif ($conf->browser->layout != 'phone') { // Show no photo link + $nophoto='/public/theme/common/nophoto.png'; + $morehtmlleft.='
No photo
'; + //} + } + } else { if ($showimage) @@ -3063,7 +3082,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'))) + if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow'))) { $fakey = $pictowithoutext; $facolor=''; $fasize=''; if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; } @@ -3072,7 +3091,10 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ elseif ($pictowithoutext == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; } elseif ($pictowithoutext == 'delete') { $fakey = 'fa-trash'; $facolor='#444'; } elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; } + elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize='1.2em'; $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/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index e44ab8cafd8..2061b03d2ae 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -46,11 +46,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc function __construct($db) { global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("bank"); - $langs->load("withdrawals"); - $langs->load("companies"); + + // Translations + $langs->loadLangs(array("main", "bank", "withdrawals", "companies")); $this->db = $db; $this->name = "sepamandate"; @@ -104,13 +102,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - - $outputlangs->load("main"); - $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("projects"); - $outputlangs->load("withdrawals"); - $outputlangs->load("bills"); + + // Translations + $outputlangs->loadLangs(array("main", "dict", "withdrawals", "companies", "projects", "bills")); if (! empty($conf->bank->dir_output)) { diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b2a0a6faf4f..f90323cda0e 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -320,7 +320,7 @@ class modProduct extends DolibarrModules 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0' ); - $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef'); + $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); } if (! empty($conf->global->PRODUIT_MULTIPRICES)) diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 9fb5eb27a64..e08983f9e10 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -131,8 +131,8 @@ $langs->load("modulebuilder"); }); - -
?attrname=" method="post"> + +?attrname=" id="formeditextrafield" method="post"> diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 23e5aff0cae..ecdda360309 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2018 Laurent Destailleur * Copyright (C) 2012-2017 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -91,7 +91,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel if (! empty($conf->multicompany->enabled)) { print ''.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).''; } - print ''.img_edit().''; + print ''.img_edit().''; print "  ".img_delete()."\n"; print ""; } diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index 13c5b7ece00..b6428c51b28 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -172,39 +172,56 @@ class InterfaceStripe if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - $thirdparty=new Societe($this->db); - $thirdparty->fetch($object->fk_soc); + if ($stripecu) { + // Get customer (required to get a card) + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $customer = \Stripe\Customer::retrieve($stripecu); + } else { + $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); + } - if ($object->client != 0) { - $card = $stripe->cardStripe($thirdparty, $object, $stripeacc, $servicestatus); - if (card) { - /*if (! empty($object->email)) - { - $customer->email = $object->email; + if ($customer) + { + $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); + if ($card) { + $card->metadata=array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR'])); + try { + $card->save($dataforcard); + } + catch(Exception $e) + { + $this->error = $e->getMessages(); + } } - $customer->description = $object->name; - // TODO More data - //$customer->vat = $object->tva_intra - - card->save(); - */ } } } if ($action == 'COMPANYPAYMENTMODE_DELETE' && $object->type == 'card') { dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id); - $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripeacc = $stripe->getStripeAccount($service); // No need of network access for this + $stripecu = $stripe->getStripeCustomerAccount($object->fk_soc); // No need of network access for this - $thirdparty=new Societe($this->db); - $thirdparty->fetch($object->fk_soc); + if ($stripecu) + { + // Get customer (required to get a card) + if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage + $customer = \Stripe\Customer::retrieve($stripecu); + } else { + $customer = \Stripe\Customer::retrieve($stripecu, array("stripe_account" => $stripeacc)); + } - $card = $stripe->cardStripe($thirdparty, $object, $stripeacc, $servicestatus); - if ($card) { - if (method_exists($card, 'detach')) $card->detach(); - else $card->delete(); + if ($customer) + { + $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); + if ($card) { + if (method_exists($card, 'detach')) $card->detach(); + else $card->delete(); + } + } } } 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'); ?> datestart = $datestart; $object->dateend = $dateend; $object->capital = $capital; - $object->nbterm = GETPOST("nbterm"); - $object->rate = GETPOST("rate"); + $object->nbterm = GETPOST("nbterm",'int'); + $object->rate = price2num(GETPOST("rate",'alpha')); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index 19e8f5f84bf..1de0e908c97 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -292,11 +292,18 @@ class Loan extends CommonObject { $this->db->begin(); + if (! is_numeric($this->nbterm)) + { + $this->error='BadValueForParameterForNbTerm'; + return -1; + } + $sql = "UPDATE ".MAIN_DB_PREFIX."loan"; $sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " capital='".price2num($this->db->escape($this->capital))."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',"; + $sql.= " nbterm=".$this->nbterm.","; $sql.= " accountancy_account_capital = '".$this->db->escape($this->account_capital)."',"; $sql.= " accountancy_account_insurance = '".$this->db->escape($this->account_insurance)."',"; $sql.= " accountancy_account_interest = '".$this->db->escape($this->account_interest)."',"; @@ -431,12 +438,12 @@ class Loan extends CommonObject $linkstart = ''; $linkend = ''; - + $result .= $linkstart; if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); if ($withpicto != 2) $result.= ($maxlen?dol_trunc($this->ref,$maxlen):$this->ref); $result .= $linkend; - + return $result; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index c9c6c2d4cde..115155e629a 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -502,7 +502,7 @@ if (! defined('NOLOGIN')) $allowedmethodtopostusername = 2; if (defined('MAIN_AUTHENTICATION_POST_METHOD')) $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); $usertotest = (! empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username","alpha",$allowedmethodtopostusername)); - $passwordtotest = GETPOST('password','none',2); + $passwordtotest = GETPOST('password','none',$allowedmethodtopostusername); $entitytotest = (GETPOST('entity','int') ? GETPOST('entity','int') : (!empty($conf->entity) ? $conf->entity : 1)); // Define if we received data to test the login. diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 267a869fb46..5024ec48d5d 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -81,7 +81,7 @@ class MyObject extends CommonObject 'entity' =>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), @@ -461,10 +461,11 @@ class MyObject extends CommonObject /** * Action executed by scheduler - * CAN BE A CRON TASK + * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters' * * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ + //public function doScheduledJob($param1, $param2, ...) public function doScheduledJob() { global $conf, $langs; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 6eebc4d85e2..fd29143613a 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -272,7 +272,7 @@ print '
'; * Last modified products */ $max=15; -$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.fk_price_expression,"; +$sql = "SELECT p.rowid, p.label, p.price, p.ref, p.fk_product_type, p.tosell, p.tobuy, p.tobatch, p.fk_price_expression,"; $sql.= " p.entity,"; $sql.= " p.tms as datem"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; @@ -336,7 +336,8 @@ if ($result) $product_static->ref=$objp->ref; $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; - $product_static->entity = $objp->entity; + $product_static->entity = $objp->entity; + $product_static->status_batch = $objp->tobatch; print $product_static->getNomUrl(1,'',16); print "\n"; print ''.dol_trunc($objp->label,32).''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 662c15507f0..e31a88e6f5c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -698,6 +698,7 @@ else $product_static->type = $obj->fk_product_type; $product_static->status_buy = $obj->tobuy; $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; $product_static->entity = $obj->entity; $product_static->pmp = $obj->pmp; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index f732c44fc31..1566e5d36c0 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -446,7 +446,7 @@ else $totalunit=0; $totalvalue=$totalvaluesell=0; - $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; $sql.= " ps.reel as value"; $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_product = p.rowid"; @@ -487,10 +487,11 @@ else print ''; print ""; $productstatic->id=$objp->rowid; - $productstatic->ref = $objp->ref; - $productstatic->label = $objp->produit; + $productstatic->ref = $objp->ref; + $productstatic->label = $objp->produit; $productstatic->type=$objp->type; $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; print $productstatic->getNomUrl(1,'stock',16); print ''; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index b41a990fbc1..41c8f9ae1f0 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -415,7 +415,7 @@ $formother=new FormOther($db); $formproduct=new FormProduct($db); if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); -$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,"; +$sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; @@ -891,6 +891,7 @@ if ($resql) $productstatic->label=$objp->produit; $productstatic->type=$objp->type; $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; $productlot->id = $objp->lotid; $productlot->batch= $objp->batch; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index e148caeb328..90f0fc56755 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -195,6 +195,52 @@ if (empty($reshook)) $permtodelete = $user->rights->projet->supprimer; $uploaddir = $conf->projet->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + // Close records + if (! $error && $massaction == 'close' && $user->rights->projet->creer) + { + $db->begin(); + + $objecttmp=new $objectclass($db); + $nbok = 0; + foreach($toselect as $toselectid) + { + $result=$objecttmp->fetch($toselectid); + if ($result > 0) + { + $userWrite = $object->restrictedProjectArea($user,'write'); + if ($userWrite > 0 && $objecttmp->statut == 1) { + $result = $objecttmp->setClose($user); + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } elseif($userWrite <= 0) { + setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings'); + } else { + setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings'); + } + } + else + { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } + } + + if (! $error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); + } + } } @@ -390,7 +436,9 @@ $arrayofmassactions = array( ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + $massactionbutton=$form->selectMassAction('', $arrayofmassactions); print ''; diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 7f373c8de4e..a63d55c5e8f 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -39,7 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; -$langs->loadLangs(array("companies","commercial","banks","bills")); +$langs->loadLangs(array("companies","commercial","banks","bills",'paypal','stripe')); // Security check @@ -210,7 +210,7 @@ if (empty($reshook)) $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); $companypaymentmode->cvn = GETPOST('cvn','alpha'); - $companypaymentmode->country_code = $mysoc->country_code; + $companypaymentmode->country_code = $object->country_code; $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 329f26ca40e..e093e93521a 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -223,15 +223,17 @@ class Stripe extends CommonObject { try { if (empty($key)) { // If the Stripe connect account not set, we use common API usage - $card = \Stripe\Card::retrieve("$cardref"); + $card = $cu->sources->retrieve($cardref); } else { - $card = \Stripe\Card::retrieve("$cardref", array("stripe_account" => $key)); + $card = $cu->sources->retrieve($cardref, array("stripe_account" => $key)); } } catch(Exception $e) { $this->error = $e->getMessage(); + dol_syslog($this->error, LOG_WARNING); } + } elseif ($createifnotlinkedtostripe) { @@ -277,6 +279,7 @@ class Stripe extends CommonObject catch(Exception $e) { $this->error = $e->getMessage(); + dol_syslog($this->error, LOG_WARNING); } } } 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'); ?> form>div.div-table-responsive { div.fiche>div.tabBar>form>div.div-table-responsive { min-height: 392px; } +div.fiche { + text-align: justify; +} .flexcontainer { browser->name, array('chrome','firefox'))) echo 'display: inline-flex;'."\n"; ?> @@ -1331,7 +1334,8 @@ div.nopadding { .pictowarning { vertical-align: text-bottom; } -.fiche img.pictoedit, .fiche span.pictoedit { +.fiche .arearef img.pictoedit, .fiche .arearef span.pictoedit, +.fiche .fichecenter img.pictoedit, .fiche .fichecenter span.pictoedit { opacity: 0.4; } .colorthumb { @@ -3116,8 +3120,8 @@ ul.noborder li:nth-child(even):not(.liste_titre) { { .boxstats, .boxstats130 { margin: 3px; - border: 1px solid #ccc; - box-shadow: none; + /*border: 1px solid #ccc; + box-shadow: none; */ } .boxstats130 { text-align: diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c088e0d4acd..5b8d82aaa53 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1339,7 +1339,8 @@ table.noborder tr.liste_titre td { .pictowarning { vertical-align: text-bottom; } -.fiche img.pictoedit, .fiche span.pictoedit { +.fiche .arearef img.pictoedit, .fiche .arearef span.pictoedit, +.fiche .fichecenter img.pictoedit, .fiche .fichecenter span.pictoedit { opacity: 0.9; } img.hideonsmartphone.pictoactionview { diff --git a/htdocs/ticketsup/card.php b/htdocs/ticketsup/card.php index dfc0704e824..55ebed62c7d 100644 --- a/htdocs/ticketsup/card.php +++ b/htdocs/ticketsup/card.php @@ -23,15 +23,15 @@ */ require '../main.inc.php'; - -require_once 'class/actions_ticketsup.class.php'; +require_once DOL_DOCUMENT_ROOT . '/ticketsup/class/actions_ticketsup.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticketsup.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/ticketsup.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; +require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; if (!empty($conf->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,44 @@ 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; + $morehtmlref ='
'; + $morehtmlref.= $object->subject; // Author - if ($object->dao->fk_user_create > 0) { - $object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' '; + if ($object->fk_user_create > 0) { + $morehtmlref .= '
' . $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); + $morehtmlref .= $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)) { + $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' '; + $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; } + $morehtmlref.='
'; + $linkback = '' . $langs->trans("BackToList") . ' '; - $object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); + + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); print '
'; print '
'; @@ -245,12 +246,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 +260,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 +316,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 +359,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 +369,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 +405,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 +482,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 +495,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 +504,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 +513,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 +523,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 +548,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 +610,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; + print '
'; // Contract if ($action == 'sel_contract') { @@ -644,8 +648,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 +661,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 +713,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 +739,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 +749,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 +790,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..08c28ad3085 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,32 +149,33 @@ 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') > 0 ? GETPOST("socid", 'int') : 0; + $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'); - $notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha'); - $this->dao->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0; + $object->type_code = GETPOST("type_code", 'alpha'); + $object->category_code = GETPOST("category_code", 'alpha'); + $object->severity_code = GETPOST("severity_code", 'alpha'); + $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); + $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; $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'; } - if (!$error && $id > 0) { + if (!$error && $id > 0) + { $this->db->commit(); // File transfer @@ -186,46 +186,47 @@ 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')); + if (GETPOST('projectid') > 0) { + $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 { } } } // Auto create fiche intervention - if ($conf->global->TICKETS_AUTO_CREATE_FICHINTER_CREATE) { + 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 +243,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 +260,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 +270,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 +288,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 +309,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 +340,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 +382,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 +407,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 +424,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 +443,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,9 +462,9 @@ 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"); + Header("Location: ".DOL_URL_ROOT."/ticketsup/list.php"); exit; } else { $langs->load("errors"); @@ -476,7 +477,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 +486,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 +499,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 +520,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 +536,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 +551,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 +568,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 +592,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 +625,11 @@ 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(); + + $object = new Ticketsup($this->db); + $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 +643,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 +663,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 +680,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 +701,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 +721,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 +741,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 +756,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 +771,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 +780,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 +806,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 +833,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 +849,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 +862,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 +896,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 +916,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 +937,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 +1093,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 +1267,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 +1465,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..584f9508f6d 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'); } /** @@ -337,8 +352,8 @@ class Ticketsup extends CommonObject $sql .= ") VALUES ("; $sql .= " " . (!isset($this->ref) ? '' : "'" . $this->db->escape($this->ref) . "'") . ","; $sql .= " " . (!isset($this->track_id) ? 'NULL' : "'" . $this->db->escape($this->track_id) . "'") . ","; - $sql .= " " . (!isset($this->fk_soc) ? '0' : "'" . $this->db->escape($this->fk_soc) . "'") . ","; - $sql .= " " . (!isset($this->fk_project) ? '0' : "'" . $this->db->escape($this->fk_project) . "'") . ","; + $sql .= " " . ($this->fk_soc > 0 ? $this->db->escape($this->fk_soc) : "null") . ","; + $sql .= " " . ($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "null") . ","; $sql .= " " . (!isset($this->origin_email) ? 'NULL' : "'" . $this->db->escape($this->origin_email) . "'") . ","; $sql .= " " . ($this->fk_user_create > 0 ? $this->fk_user_create : ($user->id > 0 ? $user->id : 'NULL')) . ","; $sql .= " " . ($this->fk_user_assign > 0 ? $this->fk_user_assign : 'NULL') . ","; @@ -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; @@ -2397,78 +2412,6 @@ class Ticketsup extends CommonObject return $defaultref; } - /** - * Show tab footer of a card - * - * @param string $paramid Name of parameter to use to name the id into the URL next/previous link - * @param string $morehtml More html content to output just before the nav bar - * @param int $shownav Show Condition (navigation is shown if value is 1) - * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) - * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous - * @param string $morehtmlref More html to show after ref - * @param string $moreparam More param to add in nav link url. - * @param int $nodbprefix Do not include DB prefix to forge table name - * @param string $morehtmlleft More html code to show before ref - * @param string $morehtmlright More html code to show before navigation arrows - * @param string $onlybanner 1 - * @return void - */ - public function ticketsupBannerTab($paramid, $morehtml = '', $shownav = 1, $fieldid = 'id', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlright = '', $onlybanner=0) - { - global $conf, $form, $user, $langs; - - $maxvisiblephotos = 1; - $showimage = 1; - $showbarcode = empty($conf->barcode->enabled) ? 0 : ($this->barcode ? 1 : 0); - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { - $showbarcode = 0; - } - - $modulepart = 'ticketsup'; - print '
'; - - $width = 80; - $height = 70; - $cssclass = 'photoref'; - //$showimage=$this->is_photo_available($conf->ticketsup->multidir_output[$this->entity]); - $showimage = $this->is_photo_available($conf->ticketsup->dir_output . '/' . $this->track_id); - $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : $maxvisiblephotos); - if ($conf->browser->phone) { - $maxvisiblephotos = 1; - } - - if ($showimage) { - $morehtmlleft .= '
' - . $this->show_photos($conf->ticketsup->dir_output, 'small', $maxvisiblephotos, 0, 0, 0, $height, $width, 0) - . '
'; - } else { - $nophoto = '/public/theme/common/nophoto.png'; - $morehtmlleft .= '
No photo
'; - } - $morehtmlright .= $this->getLibStatut(2); - - if (!empty($this->name_alias)) { - $morehtmlref .= '
' . $this->name_alias . '
'; - } - // For thirdparty - if (!empty($this->label)) { - $morehtmlref .= '
' . $this->label . '
'; - } - // For product - if ($this->element != 'product') { - $morehtmlref .= '
'; - $morehtmlref .= $this->getBannerAddress('refaddress', $this); - $morehtmlref .= '
'; - } - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { - $morehtmlref .= '
'; - $morehtmlref .= $langs->trans("TechnicalID") . ': ' . $this->id; - $morehtmlref .= '
'; - } - print $form->showrefnav($this, 'ref', $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlright); - print '
'; - print '
'; - } /** * Return if at least one photo is available diff --git a/htdocs/ticketsup/contact.php b/htdocs/ticketsup/contact.php index 356aa47ffd5..5dceabe9476 100644 --- a/htdocs/ticketsup/contact.php +++ b/htdocs/ticketsup/contact.php @@ -149,17 +149,26 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { dol_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticketsup'); - $object->label = $object->ref; + $morehtmlref ='
'; + $morehtmlref.= $object->subject; // Author if ($object->fk_user_create > 0) { - $object->label .= ' - ' . $langs->trans("CreatedBy") . ' '; - $langs->load("users"); - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $object->label .= $fuser->getNomUrl(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") . ' '; - $object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback, 1); + + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); dol_fiche_end(); diff --git a/htdocs/ticketsup/document.php b/htdocs/ticketsup/document.php index 0f528ee17bb..a19a972c143 100644 --- a/htdocs/ticketsup/document.php +++ b/htdocs/ticketsup/document.php @@ -123,18 +123,29 @@ if ($object->id) { $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'"; } $head = ticketsup_prepare_head($object); + dol_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticketsup'); - $object->label = $object->ref; + + $morehtmlref ='
'; + $morehtmlref.= $object->subject; // Author if ($object->fk_user_create > 0) { - $object->label .= ' - ' . $langs->trans("CreatedBy") . ' '; - $langs->load("users"); - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $object->label .= $fuser->getNomUrl(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") . ' '; - $object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); + + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref); dol_fiche_end(); diff --git a/htdocs/ticketsup/history.php b/htdocs/ticketsup/history.php index b4e0e0e9249..56f8e95fe0b 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,37 @@ 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; + + $morehtmlref ='
'; + $morehtmlref.= $object->subject; // Author - if ($object->dao->fk_user_create > 0) { - $object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' '; - $langs->load("users"); - $fuser = new User($db); - $fuser->fetch($object->dao->fk_user_create); - $object->dao->label .= $fuser->getNomUrl(0); + 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") . ' '; - $object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback); + + 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@ticketsup'); - $object->viewTimelineTicketLogs(); + $actionobject->viewTimelineTicketLogs(true, $object); print '
'; print '
'; } diff --git a/htdocs/ticketsup/index.php b/htdocs/ticketsup/index.php index 37cf7bf959c..cef4faa80ba 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'])); @@ -300,6 +300,8 @@ if ($result) { $i = 0; $transRecordedType = $langs->trans("LatestNewTickets", $max); + + print '
'; print ''; print ''; print ''; @@ -355,6 +357,7 @@ if ($result) { } print "
' . $transRecordedType . '' . $langs->trans('Ref') . '
"; + print '
'; } else { dol_print_error($db); } diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index a54394522f8..934a528763e 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -17,7 +17,7 @@ */ /** - * Tickets List + * Tickets List * * @package ticketsup */ diff --git a/htdocs/ticketsup/new.php b/htdocs/ticketsup/new.php index e08361e1e77..605db702c4a 100644 --- a/htdocs/ticketsup/new.php +++ b/htdocs/ticketsup/new.php @@ -38,8 +38,7 @@ $id = GETPOST('id', 'int'); $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); +$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); $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->withnotifytiersatcreate = ($notifyTiers?1:0); $formticket->withusercreate = 1; $formticket->withref = 1; $formticket->fk_user_create = $user->id;