diff --git a/ChangeLog b/ChangeLog index 30b640ac130..864fb7fba21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,9 @@ For users: - New: Form to add a photo is immediatly available on photo page if permissions are ok (save one click per photo to add). - New: Add option PRODUCT_MAX_VISIBLE_PHOTO to limit number of photos - shown on main product card. + shown on main product card. +- New: Add event FICHINTER_CLASSIFY_BILLED into list of possible events to + create an automatic event into agenda. - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem @@ -29,6 +31,7 @@ For translators: For developers: - New: Add hook "searchAgendaFrom". - New: Add trigger DON_UPDATE, DON_DELETE +- Qual: Removed hard coded rowid into data init of table llx_c_action_trigger. WARNING: Following change may create regression for some external modules, but was necessary to make Dolibarr better: diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index f3fb1d9b6c9..c7cb4258935 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2014 Laurent Destailleur * Copyright (C) 2011 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent * @@ -36,11 +36,11 @@ $langs->load("other"); $action = GETPOST('action','alpha'); $cancel = GETPOST('cancel','alpha'); + // Get list of triggers available $sql = "SELECT a.rowid, a.code, a.label, a.elementtype"; $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql.= " ORDER BY a.rang ASC"; - $resql=$db->query($sql); if ($resql) { @@ -67,6 +67,7 @@ else /* * Actions */ + if ($action == "save" && empty($cancel)) { $i=0; @@ -153,6 +154,7 @@ print ''; print ''.$langs->trans("ActionsEvents").''; print ''.$langs->trans("All").'/'.$langs->trans("None").''; print ''."\n"; +// Show each trigger if (! empty($triggers)) { foreach ($triggers as $trigger) @@ -165,6 +167,9 @@ if (! empty($triggers)) //print 'module='.$module.'
'; if (! empty($conf->$module->enabled)) { + // Discard special case. + if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; + $var=!$var; print ''; print ''.$trigger['code'].''; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 19facf72876..79193b07084 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -116,8 +116,8 @@ class InterfaceActionsAuto $key='MAIN_AGENDA_ACTIONAUTO_'.$action; //dol_syslog("xxxxxxxxxxx".$key); - if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing - if (empty($conf->global->$key)) return 0; // Log events not enabled for this action + if (empty($conf->agenda->enabled)) return 0; // Module not active, we do nothing + if (empty($conf->global->$key)) return 0; // Do not log events not enabled for this action $ok=0; @@ -370,11 +370,26 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("InterventionSentByEMail",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; - // Parameters $object->sendotid defined by caller + // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok=1; } - elseif ($action == 'SHIPPING_VALIDATE') + elseif ($action == 'FICHINTER_CLASSIFY_BILLED') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("other"); + $langs->load("interventions"); + $langs->load("agenda"); + + $object->actiontypecode='AC_OTH_AUTO'; + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InterventionClassifiedBilled",$object->ref); + $object->actionmsg=$langs->transnoentities("InterventionClassifiedBilled",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + + $object->sendtoid=0; + $ok=1; + } + elseif ($action == 'SHIPPING_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $langs->load("other"); @@ -470,7 +485,7 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - // Parameters $object->sendotid defined by caller + // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; $ok=1; } @@ -629,6 +644,7 @@ class InterfaceActionsAuto $object->actionmsg=$langs->transnoentities("ProjectCreatedInDolibarr",$object->ref); $object->actionmsg.="\n".$langs->transnoentities("Project").': '.$object->ref; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + $object->sendtoid=0; $ok=1; } @@ -647,6 +663,7 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + $object->sendtoid=0; $ok=1; } @@ -662,6 +679,7 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + $object->sendtoid=0; $ok=1; } @@ -677,6 +695,7 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Task").': '.$object->ref; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + $object->sendtoid=0; $ok=1; } @@ -723,8 +742,8 @@ class InterfaceActionsAuto $actioncomm->contact = $contactforaction; $actioncomm->societe = $societeforaction; $actioncomm->author = $user; // User saving action - //$actioncomm->usertodo = $user; // User affected to action - $actioncomm->userdone = $user; // User doing action + $actioncomm->usertodo = $user; // User owner of action + //$actioncomm->userdone = $user; // User doing action $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 971d2d7514a..6eddd5883c8 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -32,38 +32,39 @@ -- List of all managed triggered events (used for trigger agenda and for notification) -- delete from llx_c_action_trigger; -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (1,'FICHINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',19); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (2,'BILL_VALIDATE','Customer invoice validated','Executed when a customer invoice is approved','facture',6); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (3,'ORDER_SUPPLIER_APPROVE','Supplier order request approved','Executed when a supplier order is approved','order_supplier',12); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (5,'ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (6,'PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (13,'ORDER_SENTBYMAIL','Customer order sent by mail','Executed when a customer order is sent by mail ','commande',5); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (14,'BILL_PAYED','Customer invoice payed','Executed when a customer invoice is payed','facture',7); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (15,'BILL_CANCEL','Customer invoice canceled','Executed when a customer invoice is conceled','facture',8); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (16,'BILL_SENTBYMAIL','Customer invoice sent by mail','Executed when a customer invoice is sent by mail','facture',9); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (17,'ORDER_SUPPLIER_VALIDATE','Supplier order validated','Executed when a supplier order is validated','order_supplier',11); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (18,'ORDER_SUPPLIER_SENTBYMAIL','Supplier order sent by mail','Executed when a supplier order is sent by mail','order_supplier',14); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (19,'BILL_SUPPLIER_VALIDATE','Supplier invoice validated','Executed when a supplier invoice is validated','invoice_supplier',15); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (20,'BILL_SUPPLIER_PAYED','Supplier invoice payed','Executed when a supplier invoice is payed','invoice_supplier',16); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (21,'BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier',17); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (22,'SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (23,'SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (24,'MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (25,'MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member',23); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (26,'MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',24); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (27,'MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',25); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (28,'BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',10); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (29,'FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',29); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (30,'PROJECT_CREATE','Project creation','Executed when a project is created','project',30); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (31,'PROPAL_CLOSE_SIGNED','Customer proposal closed signed','Executed when a customer proposal is closed signed','propal',31); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (32,'PROPAL_CLOSE_REFUSED','Customer proposal closed refused','Executed when a customer proposal is closed refused','propal',32); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (33,'BILL_SUPPLIER_CANCELED','Supplier invoice cancelled','Executed when a supplier invoice is cancelled','invoice_supplier',33); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (34,'MEMBER_MODIFY','Member modified','Executed when a member is modified','member',34); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (35,'TASK_CREATE','Task created','Executed when a project task is created','project',35); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (36,'TASK_MODIFY','Task modified','Executed when a project task is modified','project',36); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (37,'TASK_DELETE','Task deleted','Executed when a project task is deleted','project',37); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',19); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_VALIDATE','Customer invoice validated','Executed when a customer invoice is approved','facture',6); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_APPROVE','Supplier order request approved','Executed when a supplier order is approved','order_supplier',12); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',13); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_VALIDATE','Customer order validate','Executed when a customer order is validated','commande',4); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_VALIDATE','Customer proposal validated','Executed when a commercial proposal is validated','propal',2); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('COMPANY_CREATE','Third party created','Executed when a third party is created','societe',1); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SENTBYMAIL','Customer order sent by mail','Executed when a customer order is sent by mail ','commande',5); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_PAYED','Customer invoice payed','Executed when a customer invoice is payed','facture',7); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_CANCEL','Customer invoice canceled','Executed when a customer invoice is conceled','facture',8); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SENTBYMAIL','Customer invoice sent by mail','Executed when a customer invoice is sent by mail','facture',9); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_VALIDATE','Supplier order validated','Executed when a supplier order is validated','order_supplier',11); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_SENTBYMAIL','Supplier order sent by mail','Executed when a supplier order is sent by mail','order_supplier',14); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_VALIDATE','Supplier invoice validated','Executed when a supplier invoice is validated','invoice_supplier',15); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_PAYED','Supplier invoice payed','Executed when a supplier invoice is payed','invoice_supplier',16); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier',17); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping',21); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_VALIDATE','Member validated','Executed when a member is validated','member',22); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member',23); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_DELETE','Member deleted','Executed when a member is deleted','member',25); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',10); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_SENTBYMAIL','Intervention sent by mail','Executed when a intervention is sent by mail','ficheinter',19); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',30); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_CLOSE_SIGNED','Customer proposal closed signed','Executed when a customer proposal is closed signed','propal',2); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_CLOSE_REFUSED','Customer proposal closed refused','Executed when a customer proposal is closed refused','propal',2); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_CANCELED','Supplier invoice cancelled','Executed when a supplier invoice is cancelled','invoice_supplier',17); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MEMBER_MODIFY','Member modified','Executed when a member is modified','member',24); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',35); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',36); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',37); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('FICHINTER_CLASSIFY_BILLED','Classify intervention as billed','Executed when a intervention is classified as billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19); diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index 707772e8981..86e290552c9 100644 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -20,6 +20,7 @@ ALTER TABLE llx_c_paiement ADD COLUMN accountancy_code varchar(32) DEFAULT NULL AFTER active; +insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (29,'FICHINTER_CLASSIFY_BILLED','Classify intervention as billed','Executed when a intervention is classified as billed (when option FICHINTER_DISABLE_DETAILS is set)','ficheinter',19); ALTER TABLE llx_accountingaccount add column entity integer DEFAULT 1 NOT NULL AFTER rowid; ALTER TABLE llx_accountingaccount add column datec datetime NOT NULL AFTER entity; diff --git a/htdocs/install/mysql/tables/llx_c_action_trigger.sql b/htdocs/install/mysql/tables/llx_c_action_trigger.sql index 26f46c6ff8f..fa8052d77f9 100644 --- a/htdocs/install/mysql/tables/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/tables/llx_c_action_trigger.sql @@ -14,6 +14,9 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- +-- This table is a list of all available possible automatic actions +-- It is read only by admin page to select action code and save them +-- into llx_const with name MAIN_AGENDA_ACTIONAUTO_XXX_YYY. -- =================================================================== create table llx_c_action_trigger @@ -24,5 +27,4 @@ create table llx_c_action_trigger description varchar(255), elementtype varchar(16) NOT NULL, rang integer DEFAULT 0 - )ENGINE=innodb; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index fcee3d669cf..347e2b5fb59 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -58,6 +58,7 @@ SupplierInvoiceSentByEMail=Supplier invoice %s sent by EMail ShippingSentByEMail=Shipping %s sent by EMail ShippingValidated= Shipping %s validated InterventionSentByEMail=Intervention %s sent by EMail +InterventionClassifiedBilled=Intervention %s classified as Billed NewCompanyToDolibarr= Third party created DateActionPlannedStart= Planned start date DateActionPlannedEnd= Planned end date