Merge pull request #724 from KreizIT/develop

Add trigger BILL_UNVALIDATE when invoice is unvalidate
This commit is contained in:
Laurent Destailleur 2013-03-09 09:55:29 -08:00
commit e03487f865
9 changed files with 477 additions and 427 deletions

View File

@ -10,6 +10,7 @@
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -1828,10 +1829,29 @@ class Facture extends CommonInvoice
} }
} }
if ($error == 0) if ($error == 0)
{ {
$old_statut=$this->statut;
$this->brouillon = 1; $this->brouillon = 1;
$this->statut = 0; $this->statut = 0;
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_UNVALIDATE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++;
$this->errors=$interface->errors;
$this->statut=$old_statut;
$this->brouillon=0;
}
// Fin appel triggers
} else {
$this->db->rollback();
return -1;
}
if ($error == 0)
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }

View File

@ -5,6 +5,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -85,6 +86,7 @@ class modAgenda extends DolibarrModules
$this->const[11] = array("MAIN_AGENDA_ACTIONAUTO_BILL_SUPPLIER_VALIDATE","chaine","1"); $this->const[11] = array("MAIN_AGENDA_ACTIONAUTO_BILL_SUPPLIER_VALIDATE","chaine","1");
$this->const[12] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_VALIDATE","chaine","1"); $this->const[12] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_VALIDATE","chaine","1");
$this->const[13] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_SENTBYMAIL","chaine","1"); $this->const[13] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_SENTBYMAIL","chaine","1");
$this->const[14] = array("MAIN_AGENDA_ACTIONAUTO_BILL_UNVALIDATE","chaine","1");
// New pages on tabs // New pages on tabs
// ----------------- // -----------------

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -256,6 +257,21 @@ class InterfaceActionsAuto
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref); $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0;
$ok=1;
}
elseif ($action == 'BILL_UNVALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other");
$langs->load("bills");
$langs->load("agenda");
$object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
$object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
$object->sendtoid=0; $object->sendtoid=0;

View File

@ -25,7 +25,6 @@
* ou: interface_99_all_Mytrigger.class.php * ou: interface_99_all_Mytrigger.class.php
* - Le fichier doit rester stocke dans core/triggers * - Le fichier doit rester stocke dans core/triggers
* - Le nom de la classe doit etre InterfaceMytrigger * - Le nom de la classe doit etre InterfaceMytrigger
* - Le nom de la methode constructeur doit etre InterfaceMytrigger
* - Le nom de la propriete name doit etre Mytrigger * - Le nom de la propriete name doit etre Mytrigger
*/ */
@ -353,6 +352,10 @@ class InterfaceDemo
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }
elseif ($action == 'BILL_VALIDATE') elseif ($action == 'BILL_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
}
elseif ($action == 'BILL_UNVALIDATE')
{ {
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }

View File

@ -6,6 +6,7 @@
-- Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com> -- Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
-- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> -- Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
-- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es> -- Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
-- Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
-- --
-- This program is free software; you can redistribute it and/or modify -- 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 -- it under the terms of the GNU General Public License as published by
@ -30,27 +31,28 @@
-- List of all managed triggered events (used for trigger agenda and for notification) -- List of all managed triggered events (used for trigger agenda and for notification)
-- --
delete from llx_c_action_trigger; 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',18); 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 (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',11); 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',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 (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 (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 (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 (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',17); 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 (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 (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 (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 (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 (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',10); 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',13); 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',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',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',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',19); 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',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',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',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',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',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);

View File

@ -123,3 +123,7 @@ ALTER TABLE llx_facturedet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEF
ALTER TABLE llx_propaldet MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0'; ALTER TABLE llx_propaldet MODIFY COLUMN localtax1_type varchar(10) NOT NULL DEFAULT '0';
ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0'; ALTER TABLE llx_propaldet MODIFY COLUMN localtax2_type varchar(10) NOT NULL DEFAULT '0';
--Add new trigger on Invoice BILL_UNVALIDATE + Index
UPDATE `llx_c_action_trigger` SET rang=rang+1 WHERE rang>=10;
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);
ALTER TABLE llx_c_action_trigger ADD INDEX action_trigger_rang (rang)

View File

@ -18,3 +18,4 @@
ALTER TABLE llx_c_action_trigger ADD UNIQUE INDEX uk_action_trigger_code (code); ALTER TABLE llx_c_action_trigger ADD UNIQUE INDEX uk_action_trigger_code (code);
ALTER TABLE llx_c_action_trigger ADD INDEX action_trigger_rang (rang);

View File

@ -12,6 +12,7 @@ BirthdayAlertOn= birthday alert active
BirthdayAlertOff= birthday alert inactive BirthdayAlertOff= birthday alert inactive
Notify_FICHINTER_VALIDATE=Intervention validated Notify_FICHINTER_VALIDATE=Intervention validated
Notify_BILL_VALIDATE=Customer invoice validated Notify_BILL_VALIDATE=Customer invoice validated
Notify_BILL_UNVALIDATE=Customer invoice unvalidated
Notify_ORDER_SUPPLIER_APPROVE=Supplier order approved Notify_ORDER_SUPPLIER_APPROVE=Supplier order approved
Notify_ORDER_SUPPLIER_REFUSE=Supplier order refused Notify_ORDER_SUPPLIER_REFUSE=Supplier order refused
Notify_ORDER_VALIDATE=Customer order validated Notify_ORDER_VALIDATE=Customer order validated

View File

@ -12,6 +12,7 @@ BirthdayAlertOn= alerte anniversaire active
BirthdayAlertOff= alerte anniversaire inactive BirthdayAlertOff= alerte anniversaire inactive
Notify_FICHINTER_VALIDATE=Validation fiche intervention Notify_FICHINTER_VALIDATE=Validation fiche intervention
Notify_BILL_VALIDATE=Validation facture client Notify_BILL_VALIDATE=Validation facture client
Notify_BILL_UNVALIDATE=Dévalidation facture client
Notify_ORDER_SUPPLIER_APPROVE=Approbation commande fournisseur Notify_ORDER_SUPPLIER_APPROVE=Approbation commande fournisseur
Notify_ORDER_SUPPLIER_REFUSE=Refus commande fournisseur Notify_ORDER_SUPPLIER_REFUSE=Refus commande fournisseur
Notify_ORDER_VALIDATE=Validation commande client Notify_ORDER_VALIDATE=Validation commande client