diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index eeca990ef28..8ebb9f43b1e 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -142,6 +142,11 @@ if ($id > 0 && $removeelem > 0) { $tmpobject = new User($db); $result = $tmpobject->fetch($removeelem); $elementtype = 'user'; + } elseif ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) { + require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; + $tmpobject = new Ticket($db); + $result = $tmpobject->fetch($removeelem); + $elementtype = 'ticket'; } $result = $object->del_type($tmpobject, $elementtype); @@ -167,7 +172,8 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi if ($elemid && $action == 'addintocategory' && (($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) || ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) || - ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) + ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) || + ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) )) { if ($type == Categorie::TYPE_PRODUCT) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -181,6 +187,10 @@ if ($elemid && $action == 'addintocategory' && require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $newobject = new Societe($db); $elementtype = 'supplier'; + } elseif ($type == Categorie::TYPE_TICKET) { + require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; + $newobject = new Ticket($db); + $elementtype = 'ticket'; } $result = $newobject->fetch($elemid); @@ -1024,6 +1034,78 @@ if ($type == Categorie::TYPE_WAREHOUSE) { } } +if ($type == Categorie::TYPE_TICKET) { + $permission = ($user->rights->categorie->creer || $user->rights->categorie->creer); + + $tickets = $object->getObjectsInCateg($type, 0, $limit, $offset); + if ($tickets < 0) { + dol_print_error($db, $object->error, $object->errors); + } else { + // Form to add record into a category + $showclassifyform = 1; + if ($showclassifyform) { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("AddTicketIntoCategory").'  '; + $form->selectTickets('', 'elemid'); + print '
'; + print '
'; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + $param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($tickets); $nbtotalofrecords = ''; $newcardbutton = ''; + print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit); + + + print ''."\n"; + print ''."\n"; + + if (count($tickets) > 0) { + $i = 0; + foreach ($tickets as $ticket) { + $i++; + if ($i > $limit) break; + + print "\t".''."\n"; + print '\n"; + print '\n"; + // Link to delete from category + print ''; + print "\n"; + } + } else { + print ''; + } + print "
'.$langs->trans("Ref").'
'; + print $ticket->getNomUrl(1); + print "'.$ticket->label."'; + if ($permission) { + print ""; + print $langs->trans("DeleteFromCat"); + print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft'); + print ""; + } + print '
'.$langs->trans("ThisCategoryHasNoItems").'
\n"; + + print '
'."\n"; + } +} // End of page llxFooter(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b3ae722a5d3..ceac7015065 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6521,11 +6521,11 @@ abstract class CommonObject } elseif (in_array($type, array('int', 'integer'))) { $tmp = explode(',', $size); $newsize = $tmp[0]; - $out = ''; + $out = ' 0 ? ' maxlength="'.$newsize.'"' : '').' value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>'; } elseif (in_array($type, array('real'))) { $out = ''; } elseif (preg_match('/varchar/', $type)) { - $out = ''; + $out = ' 0 ? ' maxlength="'.$size.'"' : '').' value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>'; } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; } elseif (preg_match('/^text/', $type)) { @@ -7492,7 +7492,7 @@ abstract class CommonObject if ($display_type == 'card') { $out .= ''; - if ( ! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER) && $action == 'view') { $out .= ''; } $out .= 'ref; $object->title = $langs->trans("CopyOf")." ".$object->title; + if (empty($object->host)) { + $object->host = 'imap.example.com'; + } // ... // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { @@ -849,11 +852,11 @@ class EmailCollector extends CommonObject $regexstring = ''; //$transformationstring=''; $regforregex = array(); - if (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*):([^:])$/', $valueforproperty, $regforregex)) { + if (preg_match('/^EXTRACT:([a-zA-Z0-9_]+):(.*):([^:])$/', $valueforproperty, $regforregex)) { $sourcefield = $regforregex[1]; $regexstring = $regforregex[2]; //$transofrmationstring=$regforregex[3]; - } elseif (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { + } elseif (preg_match('/^EXTRACT:([a-zA-Z0-9_]+):(.*)$/', $valueforproperty, $regforregex)) { $sourcefield = $regforregex[1]; $regexstring = $regforregex[2]; } @@ -1199,15 +1202,20 @@ class EmailCollector extends CommonObject $iforemailloop = 0; foreach ($arrayofemail as $imapemail) { if ($nbemailprocessed > 1000) { - break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect + break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect) } $iforemailloop++; + // GET header and overview datas + $header = imap_fetchheader($connection, $imapemail, 0); + $overview = imap_fetch_overview($connection, $imapemail, 0); + + /* print $header; var_dump($overview); */ + + // Process $header of email $header = preg_replace('/\r\n\s+/m', ' ', $header); // When a header line is on several lines, merge lines - /*print $header; - print $header;*/ $matches = array(); preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $header, $matches); @@ -1297,9 +1305,6 @@ class EmailCollector extends CommonObject $this->db->begin(); - // GET Email meta datas - $overview = imap_fetch_overview($connection, $imapemail, 0); - dol_syslog("msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." from=".$overview[0]->from." to=".$overview[0]->to." subject=".$overview[0]->subject); $overview[0]->subject = $this->decodeSMTPSubject($overview[0]->subject); @@ -1309,10 +1314,14 @@ class EmailCollector extends CommonObject // Removed emojis $overview[0]->subject = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $overview[0]->subject); - // Parse IMAP email structure + // GET IMAP email structure/content + global $htmlmsg, $plainmsg, $charset, $attachments; + $this->getmsg($connection, $imapemail); + //print $plainmsg; var_dump($plainmsg); exit; + //$htmlmsg,$plainmsg,$charset,$attachments $messagetext = $plainmsg ? $plainmsg : dol_string_nohtmltag($htmlmsg, 0); // Removed emojis @@ -1640,13 +1649,15 @@ class EmailCollector extends CommonObject if ($operation['type'] == 'loadthirdparty' || $operation['type'] == 'loadandcreatethirdparty') { if (empty($operation['actionparam'])) { $errorforactions++; - $this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be a rule like 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to set or extract data"; + $this->error = "Action loadthirdparty or loadandcreatethirdparty has empty parameter. Must be a rule like 'name=HEADER:^From:(.*);' or 'name=SET:xxx' or 'name=EXTRACT:(body|subject):regex where 'name' can be replaced with 'id' or 'email' to define how to set or extract data. More properties can also be set, for example client=SET:2;"; $this->errors[] = $this->error; } else { $actionparam = $operation['actionparam']; + $idtouseforthirdparty = ''; $nametouseforthirdparty = ''; + $emailtouseforthirdparty = ''; - // $this->actionparam = 'SET:aaa' or 'EXTRACT:BODY:....' + // $actionparam = 'param=SET:aaa' or 'param=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { $sourcestring = ''; @@ -1654,7 +1665,7 @@ class EmailCollector extends CommonObject $regexstring = ''; $regforregex = array(); - if (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { + if (preg_match('/^EXTRACT:([a-zA-Z0-9_]+):(.*)$/', $valueforproperty, $regforregex)) { $sourcefield = $regforregex[1]; $regexstring = $regforregex[2]; } @@ -1674,10 +1685,18 @@ class EmailCollector extends CommonObject if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) { //var_dump($regforval[count($regforval)-1]);exit; // Overwrite param $tmpproperty - $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + if ($propertytooverwrite == 'id') { + $idtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + } elseif ($propertytooverwrite == 'email') { + $emailtouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + } else { + $nametouseforthirdparty = isset($regforval[count($regforval) - 1]) ? trim($regforval[count($regforval) - 1]) : null; + } } else { // Regex not found + $idtouseforthirdparty = null; $nametouseforthirdparty = null; + $emailtouseforthirdparty = null; } //var_dump($object->$tmpproperty);exit; } else { @@ -1689,7 +1708,13 @@ class EmailCollector extends CommonObject } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $reg)) { //if (preg_match('/^options_/', $tmpproperty)) $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $reg[1]; //else $object->$tmpproperty = $reg[1]; - $nametouseforthirdparty = $reg[2]; + if ($propertytooverwrite == 'id') { + $idtouseforthirdparty = $reg[2]; + } elseif ($propertytooverwrite == 'email') { + $emailtouseforthirdparty = $reg[2]; + } else { + $nametouseforthirdparty = $reg[2]; + } } else { $errorforactions++; $this->error = 'Bad syntax for description of action parameters: '.$actionparam; @@ -1698,8 +1723,8 @@ class EmailCollector extends CommonObject } } - if (!$errorforactions && $nametouseforthirdparty) { - $result = $thirdpartystatic->fetch(0, $nametouseforthirdparty); + if (!$errorforactions && ($idtouseforthirdparty || $emailtouseforthirdparty || $nametouseforthirdparty)) { + $result = $thirdpartystatic->fetch($idtouseforthirdparty, $nametouseforthirdparty, '', '', '', '', '', '', '', '', $emailtouseforthirdparty); if ($result < 0) { $errorforactions++; $this->error = 'Error when getting thirdparty with name '.$nametouseforthirdparty.' (may be 2 record exists with same name ?)'; @@ -1707,20 +1732,20 @@ class EmailCollector extends CommonObject break; } elseif ($result == 0) { if ($operation['type'] == 'loadthirdparty') { - dol_syslog("Third party with name ".$nametouseforthirdparty." was not found"); + dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found"); $errorforactions++; $this->error = 'ErrorFailedToLoadThirdParty'; $this->errors[] = 'ErrorFailedToLoadThirdParty'; } elseif ($operation['type'] == 'loadandcreatethirdparty') { - dol_syslog("Third party with name ".$nametouseforthirdparty." was not found. We try to create it."); + dol_syslog("Third party with id=".$idtouseforthirdparty." email=".$emailtouseforthirdparty." name=".$nametouseforthirdparty." was not found. We try to create it."); // Create thirdparty $thirdpartystatic->name = $nametouseforthirdparty; if ($fromtext != $nametouseforthirdparty) { $thirdpartystatic->name_alias = $fromtext; } - $thirdpartystatic->email = $from; + $thirdpartystatic->email = ($emailtouseforthirdparty ? $emailtouseforthirdparty : $from); // Overwrite values with values extracted from source email $errorforthisaction = $this->overwritePropertiesOfObject($thirdpartystatic, $operation['actionparam'], $messagetext, $subject, $header); diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 5457a9ee376..cd1ff267fb7 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -220,13 +220,12 @@ class CommandeFournisseurDispatch extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); if (!$notrigger) { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. - - //// Call triggers - //$result=$this->call_trigger('MYOBJECT_CREATE',$user); - //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} - //// End call triggers + // Call triggers + $result=$this->call_trigger('LINERECEPTION_CREATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers } } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 82229198185..527c0353486 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -227,7 +227,7 @@ class Holiday extends CommonObject if ($result >= 0) { $this->db->commit(); - return 1; + return 0; // for cronjob use (0 is OK, any other value is an error code) } else { $this->db->rollback(); return -1; diff --git a/htdocs/install/mysql/tables/llx_object_lang.sql b/htdocs/install/mysql/tables/llx_object_lang.sql index cc4352f3acc..01b70b208ff 100644 --- a/htdocs/install/mysql/tables/llx_object_lang.sql +++ b/htdocs/install/mysql/tables/llx_object_lang.sql @@ -25,7 +25,7 @@ create table llx_object_lang fk_object integer DEFAULT 0 NOT NULL, type_object varchar(32) NOT NULL, -- value found into $object->element: 'thirdparty', 'contact', '...' property varchar(32) NOT NULL, -- name of property - lang varchar(5) DEFAULT 0 NOT NULL, + lang varchar(5) DEFAULT '' NOT NULL, value text, import_key varchar(14) DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3f8077ba9f3..4ec6a69b053 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2092,7 +2092,7 @@ LargerThan=Larger than IfTrackingIDFoundEventWillBeLinked=Note that If a tracking ID of an object is found into email, or if the email is an answer of an email aready collected and linked to an object, the created event will be automatically linked to the known related object. WithGMailYouCanCreateADedicatedPassword=With a GMail account, if you enabled the 2 steps validation, it is recommanded to create a dedicated second password for the application instead of using your own account passsword from https://myaccount.google.com/. EmailCollectorTargetDir=It may be a desired behaviour to move the email into another tag/directory when it was processed successfully. Just set name of directory here to use this feature (Do NOT use special characters in name). Note that you must also use a read/write login account. -EmailCollectorLoadThirdPartyHelp=You can use this action to use the email content to find and load an existing thirdparty in your database. The found (or created) thirdparty will be used for following actions that need it. In the parameter field you can use for example 'EXTRACT:BODY:Name:\s([^\s]*)' if you want to extract the name of the thirdparty from a string 'Name: name to find' found into the body. +EmailCollectorLoadThirdPartyHelp=You can use this action to use the email content to find and load an existing thirdparty in your database. The found (or created) thirdparty will be used for following actions that need it.
For example, if you want to create a thirdparty with a name extracted a string 'Name: name to find' found into the body, use sender email as email, you can set the parameter field like this:
'email=HEADER:^From:(.*);name=EXTRACT:BODY:Name:\s([^\s]*);client=SET:2;'
EndPointFor=End point for %s : %s DeleteEmailCollector=Delete email collector ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector? diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 2393a02ee50..0e6b1d69b36 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF WatermarkOnDraftHolidayCards=Watermarks on draft leave requests HolidaysToApprove=Holidays to approve NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays +HolidayBalanceMonthlyUpdate=Monthly update of holiday balance diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang index 4b806e1edbd..20bfb122c75 100644 --- a/htdocs/langs/fr_FR/categories.lang +++ b/htdocs/langs/fr_FR/categories.lang @@ -17,6 +17,7 @@ ContactsCategoriesArea=Espace tags/catégories de contacts AccountsCategoriesArea=Espace des tags/categories de comptes bancaires ProjectsCategoriesArea=Espace des tags/catégories des projets UsersCategoriesArea=Espace des tags/catégories des utilisateurs +TicketsCategoriesArea=Espace tags/catégories des tickets SubCats=Sous-catégories CatList=Liste des tags/catégories CatListAll=Liste de toutes les catégories (de tous types) @@ -90,6 +91,7 @@ CategorieRecursivHelp=Si l'option est activé, quand un produit est ajouté dans AddProductServiceIntoCategory=Ajouter le produit/service suivant AddCustomerIntoCategory=Assigner cette catégorie au client AddSupplierIntoCategory=Assigner cette catégorie au fournisseur +AddTicketIntoCategory=Assigner cette catégorie au ticket ShowCategory=Afficher tag/catégorie ByDefaultInList=Par défaut dans la liste ChooseCategory=Choisissez une catégorie diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index eff2ba39c21..dc074c817f8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2004-2021 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani @@ -1280,7 +1280,8 @@ class Societe extends CommonObject $this->get_codefournisseur($this, 1); } - $this->code_compta = trim($this->code_compta); + $this->code_compta_client = trim(empty($this->code_compta) ? $this->code_compta_client : $this->code_compta); + $this->code_compta = $this->code_compta_client; // for backward compatbility $this->code_compta_fournisseur = trim($this->code_compta_fournisseur); // Check parameters. More tests are done later in the ->verify() @@ -1292,8 +1293,8 @@ class Societe extends CommonObject $customer = false; if (!empty($allowmodcodeclient) && !empty($this->client)) { - // Attention get_codecompta peut modifier le code suivant le module utilise - if (empty($this->code_compta)) { + // If $allowmodcodeclient is set and value is not set, we generate it + if (empty($this->code_compta_client)) { $ret = $this->get_codecompta('customer'); if ($ret < 0) { return -1; @@ -1305,8 +1306,8 @@ class Societe extends CommonObject $supplier = false; if (!empty($allowmodcodefournisseur) && !empty($this->fournisseur)) { - // Attention get_codecompta peut modifier le code suivant le module utilise - if ($this->code_compta_fournisseur == "") { + // If $allowmodcodefournisseur is set and value is not set, we generate it + if (empty($this->code_compta_fournisseur)) { $ret = $this->get_codecompta('supplier'); if ($ret < 0) { return -1; @@ -1460,7 +1461,7 @@ class Societe extends CommonObject if ($customer) { $sql .= ", code_client = ".(!empty($this->code_client) ? "'".$this->db->escape($this->code_client)."'" : "null"); - $sql .= ", code_compta = ".(!empty($this->code_compta) ? "'".$this->db->escape($this->code_compta)."'" : "null"); + $sql .= ", code_compta = ".(!empty($this->code_compta_client) ? "'".$this->db->escape($this->code_compta_client)."'" : "null"); } if ($supplier) { @@ -3311,7 +3312,8 @@ class Societe extends CommonObject $result = $mod->get_code($this->db, $this, $type); if ($type == 'customer') { - $this->code_compta = $mod->code; + $this->code_compta_client = $mod->code; + $this->code_compta = $this->code_compta_client; // For backward compatibility } elseif ($type == 'supplier') { $this->code_compta_fournisseur = $mod->code; } @@ -3323,6 +3325,7 @@ class Societe extends CommonObject } } else { if ($type == 'customer') { + $this->code_compta_client = ''; $this->code_compta = ''; } elseif ($type == 'supplier') { $this->code_compta_fournisseur = ''; @@ -4262,21 +4265,6 @@ class Societe extends CommonObject return $lib; } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set prospect level - * - * @param User $user User who sets the discount - * @return int <0 if KO, >0 if OK - * @deprecated Use update function instead - */ - public function set_prospect_level(User $user) - { - // phpcs:enable - return $this->update($this->id, $user); - } - /** * Return status of prospect * @@ -4356,20 +4344,6 @@ class Societe extends CommonObject return "Error, mode/status not found"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set outstanding value - * - * @param User $user User making change - * @return int <0 if KO, >0 if OK - * @deprecated Use update function instead - */ - public function set_OutstandingBill(User $user) - { - // phpcs:enable - return $this->update($this->id, $user); - } - /** * Return amount of order not paid and total * diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 038ed7350d5..c6256324257 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -136,7 +136,7 @@ if ($socid) { $params = ''; $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id; - $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopage='.urlencode($backtopage), '', 1, $params); + $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params); print '
'; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 5faa7b201b7..be53c46b051 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -31,6 +31,7 @@ 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'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; if (!empty($conf->projet->enabled)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -202,6 +203,10 @@ if (empty($reshook)) { $contactid = GETPOST('contactid', 'int'); $type_contact = GETPOST("type", 'alpha'); + // Category association + $categories = GETPOST('categories', 'array'); + $object->setCategories($categories); + if ($contactid > 0 && $type_contact) { $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $object->add_contact($contactid, $typeid, 'external'); @@ -312,7 +317,11 @@ if (empty($reshook)) { $object->severity_code = GETPOST('severity_code', 'alpha'); $ret = $object->update($user); - if ($ret <= 0) { + if ($ret > 0) { + // Category association + $categories = GETPOST('categories', 'array'); + $object->setCategories($categories); + } else { $error++; } @@ -1054,6 +1063,13 @@ if ($action == 'create' || $action == 'presend') { print ''; } + // Categories + if ($conf->categorie->enabled) { + print ''.$langs->trans("Categories").''; + print $form->showCategories($object->id, Categorie::TYPE_TICKET, 1); + print ""; + } + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index 418b81f8b41..4fbd57c212b 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -366,6 +366,6 @@ class HolidayTest extends PHPUnit\Framework\TestCase $localobjecta->updateConfCP('lastUpdate', '20100101120000'); $result = $localobjecta->updateBalance(); - $this->assertEquals($result, 1); + $this->assertEquals($result, 0); } }