From 6d4b66a6188c7769e7c24d586fc3982a22c9a759 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jun 2011 08:19:09 +0000 Subject: [PATCH] New: unified action and event with trigger name --- htdocs/admin/agenda.php | 77 ++++++++++++++----- .../mysql/data/llx_c_action_trigger.sql | 20 ++++- .../install/mysql/migration/3.0.0-3.1.0.sql | 33 ++++++-- 3 files changed, 101 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index ce602ef6343..6978ed2aa72 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -37,8 +37,37 @@ $langs->load("agenda"); $action=$_POST["action"]; +// Load array of notifications type available +// TODO add function +$sql = "SELECT a.rowid, a.code, a.label, a.elementtype"; +$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; +$sql.= " WHERE a.entity = ".$conf->entity; +$sql.= " AND a.active = 1"; + +$resql=$db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $triggers[$i]['rowid'] = $obj->rowid; + $triggers[$i]['code'] = $obj->code; + $triggers[$i]['element'] = $obj->elementtype; + $triggers[$i]['label'] = ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label); + + $i++; + } + $db->free($resql); +} +else +{ + dol_print_error($db); +} // List of all events supported by triggers +/* $eventstolog=array( array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled), array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled), @@ -65,7 +94,7 @@ $eventstolog=array( array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled), array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled), ); - +*/ /* * Actions @@ -76,16 +105,16 @@ if ($_POST["action"] == "save" && empty($_POST["cancel"])) $db->begin(); - foreach ($eventstolog as $key => $arr) + foreach ($triggers as $trigger) { - $param='MAIN_AGENDA_ACTIONAUTO_'.$arr['id']; + $param='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; //print "param=".$param." - ".$_POST[$param]; if (! empty($_POST[$param])) dolibarr_set_const($db,$param,$_POST[$param],'chaine',0,'',$conf->entity); else dolibarr_del_const($db,$param,$conf->entity); } $db->commit(); - $mesg = "".$langs->trans("SetupSaved").""; + $mesg = ''.$langs->trans("SetupSaved").''; } @@ -113,26 +142,32 @@ print ''; print ''; $var=true; -print ""; -print ""; -print ""; +print '
".$langs->trans("ActionsEvents")."
'; +print ''; +print ''; print '\n"; -foreach ($eventstolog as $key => $arr) +print ''."\n"; +if (! empty($triggers)) { - if ($arr['id']) + foreach ($triggers as $trigger) { - $var=!$var; - print ''; - print ''; - print ''."\n"; + $module = $trigger['element']; + if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur'; + if ($module == 'shipping') $module = 'expedition_bon'; + if ($module == 'member') $module = 'adherent'; + //print 'module='.$module.'
'; + if ($conf->$module->enabled) + { + $var=!$var; + print ''; + print ''; + print ''; + print ''."\n"; + } } } print '
'.$langs->trans("ActionsEvents").''.$langs->trans("All").'/'.$langs->trans("None").''; -print "
'.$arr['id']; - if (! $arr['test']) print ' ('.$langs->trans("ModuleDisabledSoNoEvent").')'; - print ''; - $key='MAIN_AGENDA_ACTIONAUTO_'.$arr['id']; - $value=$conf->global->$key; - if ($arr['test']) print ''; - else print ''; - print '
'.$trigger['code'].''.$trigger['label'].''; + $key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; + $value=$conf->global->$key; + print ''; + print '
'; diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 2ca456cdf92..94b9c6c05ce 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -37,8 +37,26 @@ insert into llx_c_action_trigger (rowid,code,label,description,elementtype) valu insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (2,'BILL_VALIDATE','Validation facture client','Executed when a customer invoice is approved','facture'); insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (3,'ORDER_SUPPLIER_APPROVE','Approbation commande fournisseur','Executed when a supplier order is approved','order_supplier'); insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (4,'ORDER_SUPPLIER_REFUSE','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier'); -insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (5,'ORDER_VALIDATE','Validation commande client','Executed when a customer order is validated','order'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (5,'ORDER_VALIDATE','Validation commande client','Executed when a customer order is validated','commande'); insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (6,'PROPAL_VALIDATE','Validation proposition client','Executed when a commercial proposal is validated','propal'); insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (7,'WITHDRAW_TRANSMIT','Transmission prélèvement','Executed when a withdrawal is transmited','withdraw'); insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (8,'WITHDRAW_CREDIT','Créditer prélèvement','Executed when a withdrawal is credited','withdraw'); insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (9,'WITHDRAW_EMIT','Emission prélèvement','Executed when a withdrawal is emited','withdraw'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (13,'ORDER_SENTBYMAIL','Customer order sent by mail','Executed when a customer order is sent by mail ','commande'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (14,'BILL_PAYED','Customer invoice payed','Executed when a customer invoice is payed','facture'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (15,'BILL_CANCEL','Customer invoice canceled','Executed when a customer invoice is conceled','facture'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (16,'BILL_SENTBYMAIL','Customer invoice sent by mail','Executed when a customer invoice is sent by mail','facture'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (17,'ORDER_SUPPLIER_VALIDATE','Supplier order validated','Executed when a supplier order is validated','order_supplier'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (18,'ORDER_SUPPLIER_SENTBYMAIL','Supplier order sent by mail','Executed when a supplier order is sent by mail','order_supplier'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (19,'BILL_SUPPLIER_VALIDATE','Supplier invoice validated','Executed when a supplier invoice is validated','invoice_supplier'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (20,'BILL_SUPPLIER_PAYED','Supplier invoice payed','Executed when a supplier invoice is payed','invoice_supplier'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (21,'BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (22,'SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (23,'SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (24,'MEMBER_VALIDATE','Member validated','Executed when a member is validated','member'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (25,'MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (26,'MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member'); +insert into llx_c_action_trigger (rowid,code,label,description,elementtype) values (27,'MEMBER_DELETE','Member deleted','Executed when a member is deleted','member'); diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index a76f1e1dd67..e908deaad8e 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -140,6 +140,7 @@ ALTER TABLE llx_actioncomm ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id ALTER TABLE llx_actioncomm ADD COLUMN fk_element integer DEFAULT NULL AFTER note; ALTER TABLE llx_actioncomm ADD COLUMN elementtype varchar(16) DEFAULT NULL AFTER fk_element; +DROP table llx_c_action_trigger; create table llx_c_action_trigger ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -157,11 +158,29 @@ INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALU INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (2,'BILL_VALIDATE','Validation facture client','Executed when a customer invoice is approved','facture'); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (3,'ORDER_SUPPLIER_APPROVE','Approbation commande fournisseur','Executed when a supplier order is approved','order_supplier'); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (4,'ORDER_SUPPLIER_REFUSE','Refus commande fournisseur','Executed when a supplier order is refused','order_supplier'); -INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (5,'ORDER_VALIDATE','Validation commande client','Executed when a customer order is validated','order'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (5,'ORDER_VALIDATE','Validation commande client','Executed when a customer order is validated','commande'); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (6,'PROPAL_VALIDATE','Validation proposition client','Executed when a commercial proposal is validated','propal'); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (7,'WITHDRAW_TRANSMIT','Transmission prélèvement','Executed when a withdrawal is transmited','withdraw'); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (8,'WITHDRAW_CREDIT','Créditer prélèvement','Executed when a withdrawal is credited','withdraw'); INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (9,'WITHDRAW_EMIT','Emission prélèvement','Executed when a withdrawal is emited','withdraw'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (10,'COMPANY_CREATE','Third party created','Executed when a third party is created','societe'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (11,'CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (12,'PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (13,'ORDER_SENTBYMAIL','Customer order sent by mail','Executed when a customer order is sent by mail ','commande'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (14,'BILL_PAYED','Customer invoice payed','Executed when a customer invoice is payed','facture'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (15,'BILL_CANCEL','Customer invoice canceled','Executed when a customer invoice is conceled','facture'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (16,'BILL_SENTBYMAIL','Customer invoice sent by mail','Executed when a customer invoice is sent by mail','facture'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (17,'ORDER_SUPPLIER_VALIDATE','Supplier order validated','Executed when a supplier order is validated','order_supplier'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (18,'ORDER_SUPPLIER_SENTBYMAIL','Supplier order sent by mail','Executed when a supplier order is sent by mail','order_supplier'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (19,'BILL_SUPPLIER_VALIDATE','Supplier invoice validated','Executed when a supplier invoice is validated','invoice_supplier'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (20,'BILL_SUPPLIER_PAYED','Supplier invoice payed','Executed when a supplier invoice is payed','invoice_supplier'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (21,'BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (22,'SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (23,'SHIPPING_SENTBYMAIL','Shipping sent by mail','Executed when a shipping is sent by mail','shipping'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (24,'MEMBER_VALIDATE','Member validated','Executed when a member is validated','member'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (25,'MEMBER_SUBSCRIPTION','Member subscribed','Executed when a member is subscribed','member'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (26,'MEMBER_RESILIATE','Member resiliated','Executed when a member is resiliated','member'); +INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype) VALUES (27,'MEMBER_DELETE','Member deleted','Executed when a member is deleted','member'); DROP table llx_action_def; @@ -240,7 +259,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc --Add Mexique data (id pays=154) -- Regions Mexique -insert into llx_c_regions (rowid, fk_pays, code_region, cheflieu, tncc, nom, active) values (15401, 154, 15401, '', 0, 'Mexique', 1); +INSERT INTO llx_c_regions (rowid, fk_pays, code_region, cheflieu, tncc, nom, active) VALUES (15401, 154, 15401, '', 0, 'Mexique', 1); -- Provinces Mexique INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DIF', 15401, '', 0, 'DIF', 'Distrito Federal', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AGS', 15401, '', 0, 'AGS', 'Aguascalientes', 1); @@ -278,7 +297,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc --Add Colombie data (id pays=70) -- Regions Colombie -insert into llx_c_regions (rowid, fk_pays, code_region, cheflieu, tncc, nom, active) values (7001, 70, 7001, '', 0, 'Colombie', 1); +INSERT INTO llx_c_regions (rowid, fk_pays, code_region, cheflieu, tncc, nom, active) VALUES (7001, 70, 7001, '', 0, 'Colombie', 1); -- Provinces Colombie INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('ANT', 7001, '', 0, 'ANT', 'Antioquia', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('BOL', 7001, '', 0, 'BOL', 'Bolívar', 1); @@ -316,7 +335,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc --Add Honduras data (id pays=114) -- Regions Honduras -insert into llx_c_regions (rowid, fk_pays, code_region, cheflieu, tncc, nom, active) values (11401, 114, 11401, '', 0, 'Honduras', 1); +INSERT INTO llx_c_regions (rowid, fk_pays, code_region, cheflieu, tncc, nom, active) VALUES (11401, 114, 11401, '', 0, 'Honduras', 1); -- Provinces Honduras INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('AT', 11401, '', 0, 'AT', 'Atlántida', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('CH', 11401, '', 0, 'CH', 'Choluteca', 1); @@ -338,7 +357,7 @@ INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('YO', 11401, '', 0, 'YO', 'Yoro', 1); INSERT INTO llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) VALUES ('DC', 11401, '', 0, 'DC', 'Distrito Central', 1); -- Currency Honduras -insert into llx_c_currencies ( code, code_iso, active, label ) values ( 'LH', 'HNL', 1, 'Lempiras'); +INSERT INTO llx_c_currencies ( code, code_iso, active, label ) VALUES ( 'LH', 'HNL', 1, 'Lempiras'); -- ISV (VAT) Honduras -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1141,114, '0','0','No ISV',1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1142,114, '12','0','ISV 12%',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1141,114, '0','0','No ISV',1); +INSERT INTO llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) VALUES (1142,114, '12','0','ISV 12%',1);