From 5f6ac1374c4732be031770c132463aeba5874de5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 4 Jun 2011 13:12:44 +0000 Subject: [PATCH] New: best method for linked object with actioncomm New: add action "shipping send by mail" --- htdocs/admin/agenda.php | 47 +++++------ htdocs/comm/action/class/actioncomm.class.php | 59 +++++++------- htdocs/comm/action/fiche.php | 10 +-- htdocs/comm/propal.php | 11 +-- htdocs/commande/fiche.php | 11 +-- htdocs/compta/facture.php | 11 +-- htdocs/core/class/commonobject.class.php | 45 ++++++++++- htdocs/core/class/html.formactions.class.php | 13 +-- htdocs/expedition/fiche.php | 15 ++-- htdocs/fichinter/fiche.php | 11 +-- htdocs/fourn/commande/fiche.php | 11 +-- htdocs/fourn/facture/fiche.php | 11 +-- htdocs/includes/modules/modAgenda.class.php | 2 + .../interface_modAgenda_ActionsAuto.class.php | 79 ++++++++----------- htdocs/install/etape5.php | 14 ++-- .../install/mysql/migration/3.0.0-3.1.0.sql | 9 ++- .../mysql/tables/llx_actioncomm.key.sql | 6 +- .../install/mysql/tables/llx_actioncomm.sql | 63 +++++++-------- htdocs/install/upgrade2.php | 63 ++++++++++++++- htdocs/langs/en_US/agenda.lang | 1 + htdocs/langs/en_US/commercial.lang | 1 + htdocs/langs/en_US/sendings.lang | 2 + htdocs/langs/fr_FR/agenda.lang | 1 + htdocs/langs/fr_FR/commercial.lang | 1 + htdocs/langs/fr_FR/sendings.lang | 2 + htdocs/lib/company.lib.php | 26 +++--- 26 files changed, 313 insertions(+), 212 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 26b72245514..ce602ef6343 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2008-2010 Laurent Destailleur + * Copyright (C) 2011 Regis Houssin * * 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 @@ -39,28 +40,30 @@ $action=$_POST["action"]; // 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), - array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled), - array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled), - array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled), - array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled), - array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled), - array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled), - array('id'=>'FICHEINTER_VALIDATE', 'test'=>$conf->ficheinter->enabled), - array('id'=>'ORDER_SUPPLIER_VALIDATE','test'=>$conf->fournisseur->enabled), + array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled), + array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled), + array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled), + array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled), + array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled), + array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled), + array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled), + array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled), + array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled), + array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled), + array('id'=>'FICHEINTER_VALIDATE', 'test'=>$conf->ficheinter->enabled), + array('id'=>'ORDER_SUPPLIER_VALIDATE', 'test'=>$conf->fournisseur->enabled), array('id'=>'ORDER_SUPPLIER_SENTBYMAIL','test'=>$conf->fournisseur->enabled), - array('id'=>'BILL_SUPPLIER_VALIDATE', 'test'=>$conf->fournisseur->enabled), - array('id'=>'BILL_SUPPLIER_PAYED', 'test'=>$conf->fournisseur->enabled), - array('id'=>'BILL_SUPPLIER_SENTBYMAIL', 'test'=>$conf->fournisseur->enabled), -// array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled), -// array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled), - array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled), - array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled), + array('id'=>'BILL_SUPPLIER_VALIDATE', 'test'=>$conf->fournisseur->enabled), + array('id'=>'BILL_SUPPLIER_PAYED', 'test'=>$conf->fournisseur->enabled), + array('id'=>'BILL_SUPPLIER_SENTBYMAIL', 'test'=>$conf->fournisseur->enabled), + array('id'=>'SHIPPING_VALIDATE', 'test'=>$conf->expedition_bon->enabled), + array('id'=>'SHIPPING_SENTBYMAIL', 'test'=>$conf->expedition_bon->enabled), +// array('id'=>'PAYMENT_CUSTOMER_CREATE', 'test'=>$conf->facture->enabled), +// array('id'=>'PAYMENT_SUPPLIER_CREATE', 'test'=>$conf->fournisseur->enabled), + array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled), + array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled), + array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled), + array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled), ); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c28260945f7..4c8cd75d1a6 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -75,11 +75,8 @@ class ActionComm extends CommonObject var $percentage; // Properties for links to other tables - var $orderrowid; - var $propalrowid; - var $facid; - var $supplierorderrowid; - var $supplierinvoicerowid; + var $fk_element; + var $elementtype; // Ical var $icalname; @@ -177,11 +174,8 @@ class ActionComm extends CommonObject $sql.= "fk_user_action,"; $sql.= "fk_user_done,"; $sql.= "label,percent,priority,fulldayevent,location,punctual,"; - $sql.= "fk_facture,"; - $sql.= "propalrowid,"; - $sql.= "fk_commande,"; - $sql.= "fk_supplier_invoice,"; - $sql.= "fk_supplier_order,"; + $sql.= "fk_element,"; + $sql.= "elementtype,"; $sql.= "entity"; $sql.= ") VALUES ("; $sql.= "'".$this->db->idate($now)."',"; @@ -200,11 +194,8 @@ class ActionComm extends CommonObject $sql.= ($this->usertodo->id > 0?"'".$this->usertodo->id."'":"null").","; $sql.= ($this->userdone->id > 0?"'".$this->userdone->id."'":"null").","; $sql.= "'".$this->db->escape($this->label)."','".$this->percentage."','".$this->priority."','".$this->fulldayevent."','".$this->db->escape($this->location)."','".$this->punctual."',"; - $sql.= ($this->facid?$this->facid:"null").","; - $sql.= ($this->propalrowid?$this->propalrowid:"null").","; - $sql.= ($this->orderrowid?$this->orderrowid:"null").","; - $sql.= ($this->supplierinvoicerowid?$this->supplierinvoicerowid:"null").","; - $sql.= ($this->supplierorderrowid?$this->supplierorderrowid:"null").","; + $sql.= ($this->fk_element?$this->fk_element:"null").","; + $sql.= ($this->elementtype?"'".$this->elementtype."'":"null").","; $sql.= $conf->entity; $sql.= ")"; @@ -255,7 +246,8 @@ class ActionComm extends CommonObject $sql.= " a.fk_project,"; $sql.= " a.fk_user_author, a.fk_user_mod,"; $sql.= " a.fk_user_action, a.fk_user_done,"; - $sql.= " a.fk_contact, a.percent as percentage, a.fk_facture, a.fk_commande, a.propalrowid,"; + $sql.= " a.fk_contact, a.percent as percentage,"; + $sql.= " a.fk_element, a.elementtype,"; $sql.= " a.priority, a.fulldayevent, a.location,"; $sql.= " c.id as type_id, c.code as type_code, c.libelle,"; $sql.= " s.nom as socname,"; @@ -289,23 +281,27 @@ class ActionComm extends CommonObject $this->datec = $this->db->jdate($obj->datec); $this->datem = $this->db->jdate($obj->datem); - $this->note =$obj->note; - $this->percentage =$obj->percentage; + $this->note = $obj->note; + $this->percentage = $obj->percentage; - $this->author->id = $obj->fk_user_author; - $this->usermod->id = $obj->fk_user_mod; + $this->author->id = $obj->fk_user_author; + $this->usermod->id = $obj->fk_user_mod; - $this->usertodo->id = $obj->fk_user_action; - $this->userdone->id = $obj->fk_user_done; - $this->priority = $obj->priority; - $this->fulldayevent = $obj->fulldayevent; - $this->location = $obj->location; + $this->usertodo->id = $obj->fk_user_action; + $this->userdone->id = $obj->fk_user_done; + $this->priority = $obj->priority; + $this->fulldayevent = $obj->fulldayevent; + $this->location = $obj->location; - $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working - $this->societe->id = $obj->fk_soc; - $this->contact->id = $obj->fk_contact; - $this->fk_project = $obj->fk_project; + $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->societe->id = $obj->fk_soc; + $this->contact->id = $obj->fk_contact; + $this->fk_project = $obj->fk_project; + + $this->fk_element = $obj->fk_element; + $this->elementtype = $obj->elementtype; + /* $this->fk_facture = $obj->fk_facture; if ($this->fk_facture) { @@ -326,7 +322,7 @@ class ActionComm extends CommonObject $this->objet_url = img_object($langs->trans("ShowOrder"),'order').' '.''.$langs->trans("Order").''; $this->objet_url_type = 'order'; } - + */ } $this->db->free($resql); return 1; @@ -694,7 +690,8 @@ class ActionComm extends CommonObject $sql.= " a.fk_soc,"; $sql.= " a.fk_user_author, a.fk_user_mod,"; $sql.= " a.fk_user_action, a.fk_user_done,"; - $sql.= " a.fk_contact, a.fk_facture, a.percent as percentage, a.fk_commande,"; + $sql.= " a.fk_contact, a.percent as percentage,"; + $sql.= " a.fk_element, a.elementtype,"; $sql.= " a.priority, a.fulldayevent, a.location,"; $sql.= " u.firstname, u.name,"; $sql.= " s.nom as socname,"; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index b8b1c11c685..5aaffb705bd 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -809,10 +809,10 @@ if ($id) print ''; // Object linked - if ($act->objet_url) + if (! empty($act->fk_element) && ! empty($act->elementtype)) { print ''.$langs->trans("LinkedObject").''; - print ''.$act->objet_url.''; + print ''.$act->getElementUrl($act->fk_element,$act->elementtype,1).''; } // Description @@ -970,11 +970,11 @@ if ($id) print $act->priority; print ''; - // Linked object - if ($act->objet_url) + // Object linked + if (! empty($act->fk_element) && ! empty($act->elementtype)) { print ''.$langs->trans("LinkedObject").''; - print ''.$act->objet_url.''; + print ''.$act->getElementUrl($act->fk_element,$act->elementtype,1).''; } // Description diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 206d325be13..24cbf40325b 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -527,11 +527,12 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] $error=0; // Initialisation donnees - $object->sendtoid=$sendtoid; - $object->actiontypecode=$actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2= $actionmsg2; - $object->propalrowid=$object->id; + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index de8b31f900c..34793ac3164 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1036,11 +1036,12 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P $error=0; // Initialisation donnees - $object->sendtoid=$sendtoid; - $object->actiontypecode=$actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2= $actionmsg2; - $object->orderrowid=$object->id; + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 64ba7847a7b..011dd922b2d 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1277,11 +1277,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $error=0; // Initialisation donnees - $object->sendtoid=$sendtoid; - $object->actiontypecode=$actiontypecode; - $object->actionmsg = $actionmsg; // Long text - $object->actionmsg2= $actionmsg2; // Short text - $object->facid=$object->id; + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; // Long text + $object->actionmsg2 = $actionmsg2; // Short text + $object->fk_element = $object->id; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6643f6e674a..c022daa6438 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1464,7 +1464,50 @@ class CommonObject // TODO: All functions here must be redesigned and moved as they are not business functions but output functions - + /** + * + * Enter description here ... + * @param unknown_type $objectid + * @param unknown_type $objecttype + * @param unknown_type $withpicto + * @param unknown_type $option + */ + function getElementUrl($objectid,$objecttype,$withpicto=0,$option='') + { + global $conf; + + // Parse element/subelement (ex: project_task) + $module = $element = $subelement = $objecttype; + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) + { + $module = $element = $regs[1]; + $subelement = $regs[2]; + } + + $classpath = $element.'/class'; + + // To work with non standard path + if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } + if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } + if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; } + if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; } + if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; } + if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; } + + $classfile = strtolower($subelement); $classname = ucfirst($subelement); + if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; } + if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; } + + if ($conf->$module->enabled) + { + dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + + $object = new $classname($this->db); + $ret=$object->fetch($objectid); + if ($ret > 0) return $object->getNomUrl($withpicto,$option); + } + } + /* This is to show linked object block */ /** diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 3fade13857f..158cea4fe09 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -109,17 +109,8 @@ class FormActions $sql.= ' FROM '.MAIN_DB_PREFIX.'actioncomm as a, '.MAIN_DB_PREFIX.'user as u'; $sql.= ' WHERE a.fk_user_author = u.rowid'; if ($socid) $sql .= ' AND a.fk_soc = '.$socid; - if ($typeelement == 'invoice') $sql.= ' AND a.fk_facture = '.$object->id; - elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $sql.= ' AND a.fk_supplier_invoice = '.$object->id; - elseif ($typeelement == 'propal') $sql.= ' AND a.propalrowid = '.$object->id; - elseif ($typeelement == 'order') $sql.= ' AND a.fk_commande = '.$object->id; - elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $sql.= ' AND a.fk_supplier_order = '.$object->id; - elseif ($typeelement == 'project') $sql.= ' AND a.fk_project = '.$object->id; - else - { - dol_print_error('','Bad value for parameter typeelement'); - return -1; - } + if ($typeelement == 'project') $sql.= ' AND a.fk_project = '.$object->id; + else $sql.= ' AND a.fk_element = '.$object->id.' AND a.elementtype = "'.$typeelement.'"'; dol_syslog("FormActions::showactions sql=".$sql); $resql = $this->db->query($sql); diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index a4d2ce767e3..332477d818c 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -404,11 +404,12 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P $error=0; // Initialisation donnees - $object->sendtoid=$sendtoid; - $object->actiontypecode=$actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2= $actionmsg2; - $object->shippingrowid=$object->id; + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); @@ -1296,11 +1297,9 @@ else print ''; // List of actions on element - /* include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); $formactions=new FormActions($db); $somethingshown=$formactions->showactions($object,'shipping',$socid); - */ print ''; } @@ -1315,7 +1314,7 @@ else $file = $conf->expedition->dir_output . '/sending/' . $ref . '/' . $ref . '.pdf'; print '
'; - print_titre($langs->trans('SendShippingByMail')); + print_titre($langs->trans('SendShippingByEMail')); // Cree l'objet formulaire mail include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index fd862164514..4f97a98a626 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -513,11 +513,12 @@ if ($_POST['action'] == 'send' && ! $_POST['cancel'] && (empty($conf->global->MA $error=0; // Initialisation donnees - $fichinter->sendtoid=$sendtoid; - $fichinter->actiontypecode=$actiontypecode; - $fichinter->actionmsg = $actionmsg; - $fichinter->actionmsg2= $actionmsg2; - $fichinter->rowid=$fichinter->id; + $fichinter->sendtoid = $sendtoid; + $fichinter->actiontypecode = $actiontypecode; + $fichinter->actionmsg = $actionmsg; + $fichinter->actionmsg2 = $actionmsg2; + $fichinter->fk_element = $fichinter->id; + $fichinter->elementtype = $fichinter->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 86968d47044..8fc6001ac68 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -690,11 +690,12 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P $error=0; // Initialisation donnees - $object->sendtoid=$sendtoid; - $object->actiontypecode=$actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2= $actionmsg2; - $object->supplierorderrowid=$object->id; + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index f638c9190c9..43470eda132 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -743,11 +743,12 @@ if ($_POST['action'] == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] $error=0; // Initialisation donnees - $facturefourn->sendtoid=$sendtoid; - $facturefourn->actiontypecode=$actiontypecode; - $facturefourn->actionmsg = $actionmsg; - $facturefourn->actionmsg2= $actionmsg2; - $facturefourn->supplierorderrowid=$facturefourn->id; + $facturefourn->sendtoid = $sendtoid; + $facturefourn->actiontypecode = $actiontypecode; + $facturefourn->actionmsg = $actionmsg; + $facturefourn->actionmsg2 = $actionmsg2; + $facturefourn->fk_element = $facturefourn->id; + $facturefourn->elementtype = $facturefourn->element; // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); diff --git a/htdocs/includes/modules/modAgenda.class.php b/htdocs/includes/modules/modAgenda.class.php index e4c9422e1e5..3a01b9f50da 100644 --- a/htdocs/includes/modules/modAgenda.class.php +++ b/htdocs/includes/modules/modAgenda.class.php @@ -88,6 +88,8 @@ class modAgenda extends DolibarrModules $this->const[9] = array("MAIN_AGENDA_ACTIONAUTO_BILL_SENTBYMAIL","chaine","1"); $this->const[10] = array("MAIN_AGENDA_ACTIONAUTO_ORDER_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[13] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_SENTBYMAIL","chaine","1"); // New pages on tabs // ----------------- diff --git a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php index 1089a7cd20d..dec23a7426d 100644 --- a/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php +++ b/htdocs/includes/triggers/interface_modAgenda_ActionsAuto.class.php @@ -96,9 +96,8 @@ class InterfaceActionsAuto * $object->sendtoid (id of contact) * $object->socid * Optionnal: - * $object->facid - * $object->propalrowid - * $object->orderrowid + * $object->fk_element + * $object->elementtype * * @param action Event code (COMPANY_CREATE, PROPAL_VALIDATE, ...) * @param object Object action is done on @@ -132,7 +131,8 @@ class InterfaceActionsAuto $object->sendtoid=0; $object->socid=$object->id; - $object->facid=$object->orderrowid=$object->propalrowid=0; + $object->fk_element=0; + $object->elementtype=''; $ok=1; } elseif ($action == 'CONTRACT_VALIDATE') @@ -148,7 +148,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'PROPAL_VALIDATE') @@ -163,8 +162,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->propalrowid=$object->id; - $object->facid=$object->orderrowid=0; $ok=1; } elseif ($action == 'PROPAL_SENTBYMAIL') @@ -182,8 +179,6 @@ class InterfaceActionsAuto } $object->sendtoid=0; - $object->propalrowid=$object->id; - $object->orderrowid=$object->facid=0; $ok=1; } elseif ($action == 'PROPAL_CLOSE_SIGNED') @@ -198,8 +193,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->propalrowid=$object->id; - $object->facid=$object->orderrowid=0; $ok=1; } elseif ($action == 'PROPAL_CLOSE_REFUSED') @@ -214,8 +207,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->propalrowid=$object->id; - $object->facid=$object->orderrowid=0; $ok=1; } elseif ($action == 'ORDER_VALIDATE') @@ -230,8 +221,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->orderrowid=$object->id; - $object->propalrowid=$object->facid=0; $ok=1; } elseif ($action == 'ORDER_SENTBYMAIL') @@ -249,8 +238,6 @@ class InterfaceActionsAuto } $object->sendtoid=0; - $object->facid=$object->id; - $object->orderrowid=$object->propalrowid=0; $ok=1; // Parameters $object->xxx defined by caller @@ -268,8 +255,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->id; - $object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'BILL_SENTBYMAIL') @@ -287,8 +272,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; } - $object->facid=$object->id; - $object->orderrowid=$object->propalrowid=0; $ok=1; // Parameters $object->xxx defined by caller @@ -306,8 +289,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->id; - $object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'BILL_CANCEL') @@ -323,8 +304,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->id; - $object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'FICHEINTER_VALIDATE') @@ -342,6 +321,25 @@ class InterfaceActionsAuto $object->sendtoid=0; $ok=1; } + elseif ($action == 'SHIPPING_SENTBYMAIL') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + $langs->load("other"); + $langs->load("sendings"); + $langs->load("agenda"); + + $object->actiontypecode='AC_SHIP'; + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingSentByEMail",$object->ref); + if (empty($object->actionmsg)) + { + $object->actionmsg=$langs->transnoentities("ShippingSentByEMail",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + } + + $ok=1; + + // Parameters $object->xxx defined by caller + } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); @@ -354,8 +352,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->supplierorderrowid=$object->id; - $object->supplierinvoicerowid=$object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') @@ -375,8 +371,6 @@ class InterfaceActionsAuto } $object->sendtoid=0; - $object->supplierorderrowid=$object->id; - $object->supplierinvoicerowid=$object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'BILL_SUPPLIER_VALIDATE') @@ -392,8 +386,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->supplierinvoicerowid=$object->id; - $object->supplierorderrowid=$object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') @@ -413,8 +405,6 @@ class InterfaceActionsAuto } $object->sendtoid=0; - $object->supplierorderrowid=$object->id; - $object->supplierinvoicerowid=$object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'BILL_SUPPLIER_PAYED') @@ -430,8 +420,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->supplierinvoicerowid=$object->id; - $object->supplierorderrowid=$object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } elseif ($action == 'BILL_SUPPLIER_CANCELED') @@ -447,8 +435,6 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->supplierinvoicerowid=$object->id; - $object->facid=$object->orderrowid=$object->propalrowid=0; $ok=1; } @@ -468,7 +454,8 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->orderrowid=$object->propalrowid=0; + $object->fk_element=0; + $object->elementtype=''; $ok=1; } elseif ($action == 'MEMBER_SUBSCRIPTION') @@ -488,7 +475,8 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->orderrowid=$object->propalrowid=0; + $object->fk_element=0; + $object->elementtype=''; $ok=1; } elseif ($action == 'MEMBER_MODIFY') @@ -510,7 +498,8 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->orderrowid=$object->propalrowid=0; + $object->fk_element=0; + $object->elementtype=''; $ok=1; } elseif ($action == 'MEMBER_DELETE') @@ -528,7 +517,8 @@ class InterfaceActionsAuto $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->sendtoid=0; - $object->facid=$object->orderrowid=$object->propalrowid=0; + $object->fk_element=0; + $object->elementtype=''; $ok=1; } @@ -564,11 +554,8 @@ class InterfaceActionsAuto //$actioncomm->usertodo = $user; // User affected to action $actioncomm->userdone = $user; // User doing action - $actioncomm->facid = $object->facid; - $actioncomm->orderrowid = $object->orderrowid; - $actioncomm->propalrowid = $object->propalrowid; - $actioncomm->supplierinvoicerowid = $object->supplierinvoicerowid; - $actioncomm->supplierorderrowid = $object->supplierorderrowid; + $actioncomm->fk_element = $object->fk_element; + $actioncomm->elementtype = $object->elementtype; $ret=$actioncomm->add($user); // User qui saisit l'action if ($ret > 0) diff --git a/htdocs/install/etape5.php b/htdocs/install/etape5.php index 3496469c15b..d7c794268d7 100644 --- a/htdocs/install/etape5.php +++ b/htdocs/install/etape5.php @@ -47,6 +47,8 @@ if (isset($_POST["action"]) && preg_match('/upgrade/i',$_POST["action"])) // If $langs->load("admin"); $langs->load("install"); +$action=GETPOST('action'); + $success=0; // Init "forced values" to nothing. "forced values" are used after an doliwamp install wizard. @@ -74,7 +76,7 @@ dolibarr_install_syslog("etape5: Entering etape5.php page", LOG_INFO); */ // If install, check pass and pass_verif used to create admin account -if (isset($_POST['action']) && $_POST["action"] == "set") +if ($action == "set") { if ($_POST["pass"] <> $_POST["pass_verif"]) { @@ -110,7 +112,7 @@ if (! GETPOST("versionfrom") && ! GETPOST("versionto") && ! is_writable($conffil exit; } -if ($_POST["action"] == "set" || preg_match('/upgrade/i',$_POST["action"])) +if ($action == "set" || preg_match('/upgrade/i',$action)) { print ''; $error=0; @@ -142,7 +144,7 @@ if ($_POST["action"] == "set" || preg_match('/upgrade/i',$_POST["action"])) $ok = 0; // If first install - if ($_POST["action"] == "set") + if ($action == "set") { // Active module user $modName='modUser'; @@ -226,7 +228,7 @@ if ($_POST["action"] == "set" || preg_match('/upgrade/i',$_POST["action"])) } } // If upgrade - elseif (preg_match('/upgrade/i',$_POST["action"])) + elseif (preg_match('/upgrade/i',$action)) { if ($db->connected == 1) { @@ -281,7 +283,7 @@ print "
"; // Create lock file // If first install -if (GETPOST("action") == "set") +if ($action == "set") { if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { @@ -331,7 +333,7 @@ if (GETPOST("action") == "set") } } // If upgrade -elseif (preg_match('/upgrade/i',GETPOST("action"))) +elseif (preg_match('/upgrade/i',$action)) { if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE) || ($conf->global->MAIN_VERSION_LAST_UPGRADE == DOL_VERSION)) { 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 d7f7b95a71e..b426f291ed3 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 @@ -109,8 +109,6 @@ INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (2, 'AV_1W', '1 INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (3, 'AV_2W', '2 weeks', 1); INSERT INTO llx_c_availability (rowid,code,label,active) VALUES (4, 'AV_3W', '3 weeks', 1); -ALTER TABLE llx_actioncomm ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id; - ALTER TABLE llx_propaldet ADD INDEX idx_propaldet_fk_product (fk_product); ALTER TABLE llx_commandedet ADD INDEX idx_commandedet_fk_product (fk_product); ALTER TABLE llx_facturedet ADD INDEX idx_facturedet_fk_product (fk_product); @@ -135,6 +133,13 @@ ALTER TABLE llx_livraison ADD COLUMN ref_int varchar(30) AFTER ref_ext; INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max',0); INSERT INTO llx_c_actioncomm (id, code, type, libelle, module, position) VALUES ( 10, 'AC_SHIP', 'system', 'Send shipping by email' ,'shipping', 11); +ALTER TABLE llx_actioncomm DROP INDEX idx_actioncomm_fk_facture; +ALTER TABLE llx_actioncomm DROP INDEX idx_actioncomm_fk_supplier_order; +ALTER TABLE llx_actioncomm DROP INDEX idx_actioncomm_fk_supplier_invoice; +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; + --Add Chile data (id pays=67) -- Regions Chile INSERT INTO llx_c_regions (rowid, code_region, fk_pays, cheflieu, tncc, nom, active) VALUES (6701, 6701, 67, NULL, NULL, 'Tarapacá', 1); diff --git a/htdocs/install/mysql/tables/llx_actioncomm.key.sql b/htdocs/install/mysql/tables/llx_actioncomm.key.sql index 6f728d01077..031bfb614e1 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.key.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.key.sql @@ -1,5 +1,6 @@ -- ============================================================================ --- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2005-2011 Laurent Destailleur +-- Copyright (C) 2011 Regis Houssin -- -- 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 @@ -22,6 +23,3 @@ ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_datea (datea); ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_soc (fk_soc); ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_contact (fk_contact); -ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_facture (fk_facture); -ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_supplier_order (fk_supplier_order); -ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_fk_supplier_invoice (fk_supplier_invoice); diff --git a/htdocs/install/mysql/tables/llx_actioncomm.sql b/htdocs/install/mysql/tables/llx_actioncomm.sql index bb307db0636..3aa9555979e 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.sql @@ -24,44 +24,39 @@ create table llx_actioncomm ( - id integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, -- multi company id - datep datetime, -- date debut planifiee - datep2 datetime, -- deprecated - datea datetime, -- date debut realisation - datea2 datetime, -- deprecated + id integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + datep datetime, -- date debut planifiee + datep2 datetime, -- deprecated + datea datetime, -- date debut realisation + datea2 datetime, -- deprecated - fk_action integer, -- type de l'action - label varchar(128) NOT NULL, -- libelle de l'action + fk_action integer, -- type de l'action + label varchar(128) NOT NULL, -- libelle de l'action - datec datetime, -- date creation - tms timestamp, -- date modif - fk_user_author integer, -- id user qui a cree l'action - fk_user_mod integer, -- id dernier user qui a modifier l'action + datec datetime, -- date creation + tms timestamp, -- date modif + fk_user_author integer, -- id user qui a cree l'action + fk_user_mod integer, -- id dernier user qui a modifier l'action - fk_project integer, - fk_soc integer, - fk_contact integer, - fk_parent integer NOT NULL default 0, + fk_project integer, + fk_soc integer, + fk_contact integer, + fk_parent integer NOT NULL default 0, - fk_user_action integer, -- id de la personne qui doit effectuer l'action - fk_user_done integer, -- id de la personne qui a effectue l'action - priority smallint, - fulldayevent smallint NOT NULL default 0, - punctual smallint NOT NULL default 1, - percent smallint NOT NULL default 0, - location varchar(128), - durationp real, -- duree planifiee - durationa real, -- deprecated - note text, - - propalrowid integer, - fk_commande integer, - fk_facture integer, - fk_contract integer, - - fk_supplier_order integer, - fk_supplier_invoice integer + fk_user_action integer, -- id de la personne qui doit effectuer l'action + fk_user_done integer, -- id de la personne qui a effectue l'action + priority smallint, + fulldayevent smallint NOT NULL default 0, + punctual smallint NOT NULL default 1, + percent smallint NOT NULL default 0, + location varchar(128), + durationp real, -- duree planifiee + durationa real, -- deprecated + note text, + + fk_element integer DEFAULT NULL, + elementtype varchar(16) DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index a7c58167955..a3763d60a99 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2010 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2010 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -315,6 +315,8 @@ if (! GETPOST("action") || preg_match('/upgrade/i',GETPOST('action'))) if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { migrate_directories($db,$langs,$conf,'/rss','/externalrss'); + + migrate_actioncomm_element($db,$langs,$conf); // Reload modules migrate_reload_modules($db,$langs,$conf); @@ -3079,6 +3081,65 @@ function migrate_shipping_delivery2($db,$langs,$conf) print ''; } +/* + * Migrate link stored into fk_xxxx into fk_element and elementtype + */ +function migrate_actioncomm_element($db,$langs,$conf) +{ + print ''; +} + /** * Migration directory diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index a58fbed4b50..a149b9b78a7 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -43,6 +43,7 @@ OrderSentByEMail=Customer order %s sent by EMail InvoiceSentByEMail=Customer invoice %s sent by EMail SupplierOrderSentByEMail=Supplier order %s sent by EMail SupplierInvoiceSentByEMail=Supplier invoice %s sent by EMail +ShippingSentByEMail=Shipping %s sent by EMail NewCompanyToDolibarr= Third party created DateActionPlannedStart= Planned start date DateActionPlannedEnd= Planned end date diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index 77e43725df6..7e12b70a16d 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -76,6 +76,7 @@ ActionAC_REL=Send customer invoice by mail (reminder) ActionAC_CLO=Close ActionAC_EMAILING=Send mass email ActionAC_COM=Send customer order by mail +ActionAC_SHIP=Send shipping by mail ActionAC_SUP_ORD=Send supplier order by mail ActionAC_SUP_INV=Send supplier invoice by mail ActionAC_OTH=Other diff --git a/htdocs/langs/en_US/sendings.lang b/htdocs/langs/en_US/sendings.lang index 6d580df49c9..b5747aba519 100644 --- a/htdocs/langs/en_US/sendings.lang +++ b/htdocs/langs/en_US/sendings.lang @@ -50,6 +50,8 @@ WarningNoQtyLeftToSend=Warning, no products waiting to be shipped. StatsOnShipmentsOnlyValidated=Statistics conducted on shipments only validated DateDeliveryPlanned=Planed date of delivery DateReceived=Date delivery received +SendShippingByEMail=Send shipping by EMail +SendShippingRef=Send shipping %s # Sending methods SendingMethodCATCH=Catch by customer diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index 8b54ce9fe62..ced9a840d93 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -43,6 +43,7 @@ OrderSentByEMail=Commande client %s envoyée par EMail InvoiceSentByEMail=Facture client %s envoyée par EMail SupplierOrderSentByEMail=Commande fournisseur %s envoyée par EMail SupplierInvoiceSentByEMail=Facture fournisseur %s envoyée par EMail +ShippingSentByEMail=Bon d'expédition %s envoyé par EMail NewCompanyToDolibarr=Tiers créé DateActionPlannedStart=Date début réalisation prévue DateActionPlannedEnd=Date fin réalisation prévue diff --git a/htdocs/langs/fr_FR/commercial.lang b/htdocs/langs/fr_FR/commercial.lang index 8f17cdc48f3..3ff85718105 100644 --- a/htdocs/langs/fr_FR/commercial.lang +++ b/htdocs/langs/fr_FR/commercial.lang @@ -76,6 +76,7 @@ ActionAC_REL=Relance facture client par mail ActionAC_CLO=Clôture ActionAC_EMAILING=Envoi mailing masse ActionAC_COM=Envoi commande client par mail +ActionAC_SHIP=Envoi bon d'expédition par mail ActionAC_SUP_ORD=Envoi commande fournisseur par mail ActionAC_SUP_INV=Envoi facture fournisseur par mail ActionAC_OTH=Autre diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang index 9a58f12a9ff..34d00985fa4 100644 --- a/htdocs/langs/fr_FR/sendings.lang +++ b/htdocs/langs/fr_FR/sendings.lang @@ -50,6 +50,8 @@ WarningNoQtyLeftToSend=Alerte, aucun produit en attente de livraison. StatsOnShipmentsOnlyValidated=Statistiques effectuées sur les expéditions validées uniquement DateDeliveryPlanned=Date livraison prévue DateReceived=Date réception réelle +SendShippingByEMail=Envoi bon d'expédition par EMail +SendShippingRef=Envoi bon d'expédition %s # Sending methods SendingMethodCATCH=Enlèvement par le client diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index a432b7a1144..8a3f557a260 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -559,7 +559,8 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) $sql.= " a.datep as dp,"; $sql.= " a.datea as da,"; $sql.= " a.percent,"; - $sql.= " a.propalrowid, a.fk_user_author, a.fk_contact,"; + $sql.= " a.fk_user_author, a.fk_contact,"; + $sql.= " a.fk_element, a.elementtype,"; $sql.= " c.code as acode, c.libelle,"; $sql.= " u.login, u.rowid,"; $sql.= " sp.name, sp.firstname"; @@ -600,9 +601,9 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) else $out.=' '; $out.=''; - if ($obj->propalrowid) + if ($obj->fk_element && $obj->elementtype == "propal") { - $out.=''; // Objet lie + // TODO uniformize $out.='
'; + + print '
'; + print ''.$langs->trans('MigrationActioncommElement')."
\n"; + + $elements = array( 'propal' => 'propalrowid', + 'commande' => 'fk_commande', + 'facture' => 'fk_facture', + 'contrat' => 'fk_contract', + 'order_supplier' => 'fk_supplier_order', + 'invoice_supplier' => 'fk_supplier_invoice' + ); + + foreach($elements as $type => $field) + { + $result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm",$field); + $obj = $db->fetch_object($result); + if ($obj) + { + dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field); + + $db->begin(); + + $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET "; + $sql.= "fk_element = ".$field.", elementtype = '".$type."'"; + $sql.= " WHERE ".$field." IS NOT NULL"; + $sql.= " AND fk_element IS NULL"; + $sql.= " AND elementtype IS NULL"; + + $resql = $db->query($sql); + if ($resql) + { + $db->commit(); + + // DDL commands must not be inside a transaction + $sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field; + $db->query($sqlDrop); + print ". "; + } + else + { + dol_print_error($db); + $db->rollback(); + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + } + + print '
'.img_object($langs->trans("ShowAction"),"task"); + $out.=''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); $out.=$libelle; @@ -689,7 +690,7 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $sql.= " a.datep as dp,"; $sql.= " a.datep2 as dp2,"; $sql.= " a.note, a.percent,"; - $sql.= " a.propalrowid as pid, a.fk_commande as oid, a.fk_facture as fid,"; + $sql.= " a.fk_element, a.elementtype,"; $sql.= " a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle,"; $sql.= " u.login, u.rowid as user_id,"; @@ -717,7 +718,7 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) 'acode'=>$obj->acode,'libelle'=>$obj->libelle, 'userid'=>$obj->user_id,'login'=>$obj->login, 'contact_id'=>$obj->fk_contact,'name'=>$obj->name,'firstname'=>$obj->firstname, - 'pid'=>$obj->pid,'oid'=>$obj->oid,'fid'=>$obj->fid); + 'fk_element'=>$obj->fk_element,'elementtype'=>$obj->elementtype); $numaction++; $i++; } @@ -777,6 +778,8 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $actionstatic=new ActionComm($db); $userstatic=new User($db); $contactstatic = new Contact($db); + + // TODO uniformize $propalstatic=new Propal($db); $orderstatic=new Commande($db); $facturestatic=new Facture($db); @@ -820,23 +823,24 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) $out.=''.dol_trunc($histo[$key]['note'], 30).''; - if ($histo[$key]['pid'] && $conf->propal->enabled) + if ($histo[$key]['elementtype'] == 'propal' && $conf->propal->enabled) { $propalstatic->ref=$langs->trans("ProposalShort"); - $propalstatic->id=$histo[$key]['pid']; + $propalstatic->id=$histo[$key]['fk_element']; $out.=$propalstatic->getNomUrl(1); } - elseif ($histo[$key]['oid'] && $conf->commande->enabled) + elseif ($histo[$key]['elementtype'] == 'commande' && $conf->commande->enabled) { $orderstatic->ref=$langs->trans("Order"); - $orderstatic->id=$histo[$key]['oid']; + $orderstatic->id=$histo[$key]['fk_element']; $out.=$orderstatic->getNomUrl(1); } - elseif ($histo[$key]['fid'] && $conf->facture->enabled) + elseif ($histo[$key]['elementtype'] == 'facture' && $conf->facture->enabled) { $facturestatic->ref=$langs->trans("Invoice"); - $facturestatic->id=$histo[$key]['fid']; + $facturestatic->id=$histo[$key]['fk_element']; $facturestatic->type=$histo[$key]['ftype']; $out.=$facturestatic->getNomUrl(1,'compta'); }