From 86ffc321955b0b7622c5f93fb39d341cf264ae08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Dec 2010 13:16:02 +0000 Subject: [PATCH] Qual: Uniformize a lot of code (supplier_invoice => invoice_supplier, same for order) New: Add link between supplier invoices and supplier orders. --- dev/skeletons/modMyModule.class.php | 4 +- htdocs/admin/fournisseur.php | 8 +-- htdocs/compta/bank/treso.php | 4 +- htdocs/compta/facture.php | 11 ++-- htdocs/compta/facture/class/facture.class.php | 13 ++-- htdocs/core/class/commonobject.class.php | 48 ++++++++------- htdocs/core/class/html.formactions.class.php | 21 ++++--- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/class/html.formother.class.php | 3 +- htdocs/ecm/index.php | 4 +- htdocs/ecm/search.php | 4 +- .../fourn/class/fournisseur.facture.class.php | 26 +++++--- htdocs/fourn/commande/fiche.php | 29 +++++++-- .../commande/tpl/linkedobjectblock.tpl.php | 61 +++++++++++++++++++ htdocs/fourn/facture/contact.php | 2 +- htdocs/fourn/facture/fiche.php | 29 +++++++-- .../facture/tpl/linkedobjectblock.tpl.php | 61 +++++++++++++++++++ htdocs/includes/modules/modGravatar.class.php | 11 ---- .../modules/rapport/pdf_paiement.class.php | 3 +- .../modules_facturefournisseur.php | 2 +- .../modules_commandefournisseur.php | 2 +- .../install/mysql/data/llx_c_actioncomm.sql | 4 +- .../install/mysql/data/llx_c_type_contact.sql | 8 +-- .../install/mysql/migration/2.9.0-3.0.0.sql | 11 +++- .../install/mysql/tables/llx_extra_fields.sql | 2 +- htdocs/lib/fourn.lib.php | 8 +-- htdocs/lib/project.lib.php | 9 ++- 27 files changed, 289 insertions(+), 101 deletions(-) create mode 100755 htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php create mode 100755 htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 403f656f914..1f040cf6c07 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -103,8 +103,8 @@ class modMyModule extends DolibarrModules // where entity can be // 'thirdparty' to add a tab in third party view // 'intervention' to add a tab in intervention view - // 'supplier_order' to add a tab in supplier order view - // 'supplier_invoice' to add a tab in supplier invoice view + // 'order_supplier' to add a tab in supplier order view + // 'invoice_supplier' to add a tab in supplier invoice view // 'invoice' to add a tab in customer invoice view // 'order' to add a tab in customer order view // 'product' to add a tab in product view diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 733e5af3a07..4c732e567c6 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -154,12 +154,12 @@ if ($_GET["action"] == 'setdoc') { $db->begin(); - if ($_GET["type"] == 'supplier_order' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if ($_GET["type"] == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) { $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $_GET["value"]; } - if ($_GET["type"] == 'supplier_invoice' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if ($_GET["type"] == 'invoice_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) { $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $_GET["value"]; } @@ -317,7 +317,7 @@ $dir = DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/pdf/'; print_titre($langs->trans("OrdersModelModule")); // Defini tableau def de modele -$type='supplier_order'; +$type='order_supplier'; $def = array(); $sql = "SELECT nom"; @@ -438,7 +438,7 @@ $dir = DOL_DOCUMENT_ROOT.'/includes/modules/supplier_invoice/pdf/'; print_titre($langs->trans("BillsPDFModules")); // Defini tableau def de modele -$type='supplier_invoice'; +$type='invoice_supplier'; $def = array(); $sql = "SELECT nom"; diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index 9907414aad7..ef08c96bfe3 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -161,7 +161,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) $sql.= " ORDER BY dlr ASC"; // Supplier invoices - $sql2= " SELECT 'supplier_invoice' as family, ff.rowid as objid, ff.facnumber as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; + $sql2= " SELECT 'invoice_supplier' as family, ff.rowid as objid, ff.facnumber as ref, (-1*ff.total_ttc) as total_ttc, ff.type, ff.date_lim_reglement as dlr,"; $sql2.= " s.rowid as socid, s.nom, s.fournisseur"; $sql2.= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql2.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON ff.fk_soc = s.rowid"; @@ -255,7 +255,7 @@ if ($_REQUEST["account"] || $_REQUEST["ref"]) //$obj = $db->fetch_object($result); $obj = array_shift($tab_sqlobj); - if ($obj->family == 'supplier_invoice') + if ($obj->family == 'invoice_supplier') { // TODO This code is to avoid to count suppliers credit note (ff.type = 2) // Ajouter gestion des avoirs fournisseurs, champ diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b4c41864262..e39fea44603 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -664,7 +664,7 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - // If creation from another object of another module + // If creation from another object of another module (Example: origin=propal, originid=1) if ($_POST['origin'] && $_POST['originid']) { // Parse element/subelement (ex: project_task) @@ -691,12 +691,13 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) $classname = ucfirst($subelement); $srcobject = new $classname($db); - $result=$srcobject->fetch($_POST['originid']); + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); + $result=$srcobject->fetch($object->origin_id); if ($result > 0) { // TODO mutualiser $lines = $srcobject->lignes; - if (sizeof($lines)) $lines = $srcobject->lines; + if (sizeof($srcobject->lines)) $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject,'fetch_lignes')) $lines = $srcobject->fetch_lignes(); if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); @@ -743,11 +744,13 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) } else { + $mesg=$srcobject->error; $error++; } } else { + $mesg=$object->error; $error++; } } @@ -2924,8 +2927,6 @@ else $genallowed=$user->rights->facture->creer; $delallowed=$user->rights->facture->supprimer; - $var=true; - print '
'; $somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3bcb7794e68..bfcc3bb8f18 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -233,10 +233,10 @@ class Facture extends CommonObject $sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL'); $sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL'); $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ",".($this->note?"'".addslashes($this->note)."'":"null"); - $sql.= ",".($this->note_public?"'".addslashes($this->note_public)."'":"null"); - $sql.= ",".($this->ref_client?"'".addslashes($this->ref_client)."'":"null"); - $sql.= ",".($this->fk_facture_source?"'".addslashes($this->fk_facture_source)."'":"null"); + $sql.= ",".($this->note?"'".$this->db->escape($this->note)."'":"null"); + $sql.= ",".($this->note_public?"'".$this->db->escape($this->note_public)."'":"null"); + $sql.= ",".($this->ref_client?"'".$this->db->escape($this->ref_client)."'":"null"); + $sql.= ",".($this->fk_facture_source?"'".$this->db->escape($this->fk_facture_source)."'":"null"); $sql.= ",".($user->id > 0 ? "'".$user->id."'":"null"); $sql.= ",".($this->fk_project?$this->fk_project:"null"); $sql.= ','.$this->cond_reglement_id; @@ -249,6 +249,7 @@ class Facture extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture'); + // Update ref with new one $this->ref='(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->ref."' WHERE rowid=".$this->id; @@ -615,7 +616,7 @@ class Facture extends CommonObject global $conf; if (empty($rowid) && empty($ref) && empty($ref_ext)) return -1; - + $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.type,f.fk_soc,f.amount,f.tva, f.localtax1, f.localtax2, f.total,f.total_ttc,f.remise_percent,f.remise_absolue,f.remise'; $sql.= ', f.datef as df'; $sql.= ', f.date_lim_reglement as dlr'; @@ -636,7 +637,7 @@ class Facture extends CommonObject if ($rowid) $sql.= " AND f.rowid=".$rowid; if ($ref) $sql.= " AND f.facnumber='".$this->db->escape($ref)."'"; if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - + dol_syslog("Facture::Fetch sql=".$sql, LOG_DEBUG); $result = $this->db->query($sql); if ($result) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index df72fda6422..2e6e8e21b5b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -344,23 +344,23 @@ class CommonObject } /** - * \brief La liste des valeurs possibles de type de contacts - * \param source internal, external or all if not defined - * \param order Sort order by : code or rowid - * \return array La liste des natures + * Return array with list of possible values for type of contacts + * @param source internal, external or all if not defined + * @param order Sort order by : code or rowid + * @return array List of type of contacts */ function liste_type_contact($source='internal', $order='code') { global $langs; $tab = array(); - $sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc"; $sql.= " WHERE tc.element='".$this->element."'"; if (! empty($source)) $sql.= " AND tc.source='".$source."'"; $sql.= " ORDER by tc.".$order; + //print "sql=".$sql; $resql=$this->db->query($sql); if ($resql) { @@ -379,8 +379,8 @@ class CommonObject } else { - $this->error=$this->db->error(); - // dol_print_error($this->db); + $this->error=$this->db->lasterror(); + //dol_print_error($this->db); return null; } } @@ -398,7 +398,7 @@ class CommonObject function getIdContact($source,$code,$status=0) { global $conf; - + $result=array(); $i=0; @@ -987,7 +987,7 @@ class CommonObject $fieldlocaltax1='total_localtax1'; $fieldlocaltax2='total_localtax2'; - if ($this->element == 'facture_fourn') + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { $fieldtva='tva'; } @@ -1038,7 +1038,7 @@ class CommonObject $fieldht='total'; } - if ($this->element == 'facture_fourn') + if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { $fieldtva='total_tva'; } @@ -1079,7 +1079,8 @@ class CommonObject } /** - * Add objects linked in llx_element_element. + * Add objects linked in llx_element_element. + * @return int <=0 if KO, >0 if OK */ function add_object_linked() { @@ -1097,6 +1098,7 @@ class CommonObject $sql.= ", '".$this->element."'"; $sql.= ")"; + dol_syslog("CommonObject::add_object_linked sql=".$sql); if ($this->db->query($sql)) { $this->db->commit(); @@ -1104,7 +1106,7 @@ class CommonObject } else { - $this->error=$this->db->lasterror()." - sql=$sql"; + $this->error=$this->db->lasterror(); $this->db->rollback(); return 0; } @@ -1345,25 +1347,29 @@ class CommonObject * Show linked object block * TODO This must be moved into a html.class file instead of a business class. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. - * @param $object + * @param $objecttype Type of object (invoice, propal, order, invoice_supplier, order_supplier, ...) * @param $objectid * @param $somethingshown */ - function showLinkedObjectBlock($object,$objectid,$somethingshown=0) + function showLinkedObjectBlock($objecttype,$objectid,$somethingshown=0) { global $langs,$bc; $num = sizeof($objectid); if ($num) { - $classpath = $object.'/class'; - $tplpath = $object; - if ($object == 'facture') $tplpath = 'compta/'.$object; $classpath = $tplpath.'/class'; // To work with non standard path - if ($object == 'propal') $tplpath = 'comm/'.$object; $classpath = $tplpath.'/class'; // To work with non standard path + $classpath = $objecttype.'/class'; + $tplpath = $objecttype; + if ($objecttype == 'facture') $tplpath = 'compta/'.$objecttype; $classpath = $tplpath.'/class'; // To work with non standard path + if ($objecttype == 'propal') $tplpath = 'comm/'.$objecttype; $classpath = $tplpath.'/class'; // To work with non standard path + if ($objecttype == 'invoice_supplier') $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; // To work with non standard path + if ($objecttype == 'order_supplier') $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; // To work with non standard path - //print $classpath." - ".$tplpath; - $classname = ucfirst($object); - if(!class_exists($classname)) require(DOL_DOCUMENT_ROOT."/".$classpath."/".$object.".class.php"); + $classfile = strtolower($objecttype); $classname = ucfirst($objecttype); + if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; } + if ($objecttype == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; } + //print $classfile." - ".$classpath." - ".$tplpath; + if(!class_exists($classname)) require(DOL_DOCUMENT_ROOT."/".$classpath."/".$classfile.".class.php"); $linkedObjectBlock = new $classname($this->db); include(DOL_DOCUMENT_ROOT.'/'.$tplpath.'/tpl/linkedobjectblock.tpl.php'); return $num; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 5ea7d56dde6..c9f3e717f45 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -90,7 +90,7 @@ class FormActions /** * Show list of actions for element * @param object Object - * @param typeelement 'invoice','propal','order' + * @param typeelement 'invoice','propal','order','invoice_supplier','order_supplier' * @param socid socid of user * @return int <0 if KO, >=0 if OK */ @@ -105,11 +105,16 @@ class FormActions $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; - if ($typeelement == 'supplier_invoice') $sql.= ' AND a.fk_supplier_invoice = '.$object->id; - if ($typeelement == 'propal') $sql.= ' AND a.propalrowid = '.$object->id; - if ($typeelement == 'order') $sql.= ' AND a.fk_commande = '.$object->id; - if ($typeelement == 'supplier_order') $sql.= ' AND a.fk_supplier_order = '.$object->id; - if ($typeelement == 'project') $sql.= ' AND a.fk_project = '.$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; + } dol_syslog("FormActions::showactions sql=".$sql); $resql = $this->db->query($sql); @@ -119,10 +124,10 @@ class FormActions if ($num) { if ($typeelement == 'invoice') $title=$langs->trans('ActionsOnBill'); - if ($typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnSupplierBill'); + if ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title=$langs->trans('ActionsOnBill'); if ($typeelement == 'propal') $title=$langs->trans('ActionsOnPropal'); if ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); - if ($typeelement == 'supplier_order') $title=$langs->trans('ActionsOnSupplierOrder'); + if ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); if ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); print_titre($title); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 50b43db9ac3..23572468b79 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -126,7 +126,7 @@ class FormFile /** * Show the box with list of available documents for object - * @param modulepart propal=propal, facture=facture, ... + * @param modulepart propal, facture, facture_fourn, ... * @param filename Sub dir to scan (Example: '9/9', 'FA9999'). Use '' if filedir already complete) * @param filedir Dir to scan * @param urlsource Url of origin page (for return) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 155c6557c08..12ed562a12e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -489,7 +489,8 @@ function PLineSelect(&$inc, $parent, $lines, $level=0, $selectedtask=0, $selecte $lastprojectid=0; - for ($i = 0 ; $i < sizeof($lines) ; $i++) + $numlines=sizeof($lines); + for ($i = 0 ; $i < $numlines ; $i++) { if ($lines[$i]->fk_parent == $parent) { diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 2e72d372a4d..8aa7608e4f5 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -362,9 +362,9 @@ if ($conf->societe->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, if ($conf->propal->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); } if ($conf->contrat->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } if ($conf->commande->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } -if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_order', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } if ($conf->facture->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } -if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_invoice', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } //*********************** diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 989a17a3e46..acfcef0777f 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -110,9 +110,9 @@ if ($conf->societe->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, if ($conf->propal->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Prop"), 'desc'=>$langs->trans("ECMDocsByProposals")); } if ($conf->contrat->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); } if ($conf->commande->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } -if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_order', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); } if ($conf->facture->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); } -if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'supplier_invoice', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } +if ($conf->fournisseur->enabled) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); } //*********************** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 1e6e6dca001..4c8cc8ee4d7 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -41,7 +41,7 @@ class FactureFournisseur extends Facture var $db; var $error; - var $element='facture_fourn'; + var $element='invoice_supplier'; var $table_element='facture_fourn'; var $table_element_line='facture_fourn_det'; var $fk_element='fk_facture_fourn'; @@ -77,6 +77,7 @@ class FactureFournisseur extends Facture var $lines; var $fournisseur; + /** * \brief Constructeur de la classe * \param DB Database access handler @@ -86,8 +87,6 @@ class FactureFournisseur extends Facture function FactureFournisseur($DB, $socid='', $facid='') { $this->db = $DB ; - $this->table = 'facture_fourn'; - $this->tabledetail = 'facture_fourn_det'; $this->id = $facid; $this->socid = $socid; @@ -139,14 +138,14 @@ class FactureFournisseur extends Facture $sql.= ", date_lim_reglement"; $sql.= ")"; $sql.= " VALUES ("; - $sql.= "'".addslashes($number)."'"; + $sql.= "'".$this->db->escape($number)."'"; $sql.= ", ".$conf->entity; - $sql.= ", '".addslashes($this->libelle)."'"; + $sql.= ", '".$this->db->escape($this->libelle)."'"; $sql.= ", ".$this->socid; $sql.= ", ".$this->db->idate(gmmktime()); $sql.= ", '".$this->db->idate($this->date)."'"; - $sql.= ", '".addslashes($this->note)."'"; - $sql.= ", '".addslashes($this->note_public)."'"; + $sql.= ", '".$this->db->escape($this->note)."'"; + $sql.= ", '".$this->db->escape($this->note_public)."'"; $sql.= ", ".$user->id.","; $sql.= $this->date_echeance!=''?"'".$this->db->idate($this->date_echeance)."'":"null"; $sql.= ")"; @@ -156,6 +155,19 @@ class FactureFournisseur extends Facture if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn'); + + + // Add object linked + if (! $error && $this->id && $this->origin && $this->origin_id) + { + $ret = $this->add_object_linked(); + if (! $ret) + { + dol_print_error($this->db); + $error++; + } + } + foreach ($this->lines as $i => $val) { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)'; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 836d24e8e20..d564ba28c36 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1339,6 +1339,25 @@ if ($id > 0 || ! empty($ref)) $somethingshown=$formfile->show_documents('commande_fournisseur',$comfournref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); + $object=$commande; + + /* + * Linked object block + */ + $object->load_object_linked($object->id,$object->element); + + foreach($object->linked_object as $linked_object => $linked_objectid) + { + $tmpmodule=$linked_object; + if ($linked_object == 'invoice_supplier') $tmpmodule='fournisseur'; + if ($linked_object == 'order_supplier') $tmpmodule='fournisseur'; + if($conf->$tmpmodule->enabled && $linked_object != $object->element) + { + $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); + } + } + + print ''; if ( $user->rights->fournisseur->commande->commander && $commande->statut == 2) @@ -1400,10 +1419,12 @@ if ($id > 0 || ! empty($ref)) } // List of actions on element - // include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); - // $formactions=new FormActions($db); - // $somethingshown=$formactions->showactions($commande,'supplier_order',$socid); - + /* Hidden because" available into "Log" tab + print '
'; + include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($commande,'order_supplier',$socid); + */ print ''; } diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php new file mode 100755 index 00000000000..3c4c97d1597 --- /dev/null +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -0,0 +1,61 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + +load("orders"); +if ($somethingshown) { echo '
'; } +print_titre($langs->trans('RelatedOrders')); +?> + + + + + + + +fetch($objectid[$i]); + $var=!$var; +?> + > + + + + +total_ht; +} + +?> + + + + + +
trans("Ref"); ?>trans("Date"); ?>trans("AmountHTShort"); ?>trans("Status"); ?>
+ trans("ShowOrder"),"order").' '.$linkedObjectBlock->ref; ?>date,'day'); ?>total_ht); ?>getLibStatut(3); ?>
trans('TotalHT'); ?> 
+ + \ No newline at end of file diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index a8a75d07afb..1994d2b1265 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -202,7 +202,7 @@ if ($id > 0) /* * Ajouter une ligne de contact - * Non affich� en mode modification de ligne + * Non affiche en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->facture->creer) { diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index eda13c50ca1..a5276b93edb 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -238,7 +238,7 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) if ($element == 'contract') { $element = $subelement = 'contrat'; } if ($element == 'order_supplier') { $element = 'fourn'; $subelement = 'fournisseur.commande'; } - $facfou->origin = $_POST['origin']; + $facfou->origin = $_POST['origin']; $facfou->origin_id = $_POST['originid']; $facid = $facfou->create($user); @@ -256,7 +256,7 @@ if ($_POST['action'] == 'add' && $user->rights->fournisseur->facture->creer) { // TODO mutualiser $lines = $srcobject->lignes; - if (sizeof($lines)) $lines = $srcobject->lines; + if (sizeof($srcobject->lines)) $lines = $srcobject->lines; if (empty($lines) && method_exists($srcobject,'fetch_lignes')) $lines = $srcobject->fetch_lignes(); if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); @@ -1796,17 +1796,34 @@ else $genallowed=$user->rights->fournisseur->facture->creer; $delallowed=$user->rights->fournisseur->facture->supprimer; - $somethingshown=$formfile->show_documents('facture_fournisseur',$facfournref,$filedir,$urlsource,$genallowed,$delallowed,$facture->modelpdf); + print '
'; + $somethingshown=$formfile->show_documents('facture_fournisseur',$facfournref,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf); + + $object=$fac; + + /* + * Linked object block + */ + $object->load_object_linked($object->id,$object->element); + + foreach($object->linked_object as $linked_object => $linked_objectid) + { + $tmpmodule=$linked_object; + if ($linked_object == 'invoice_supplier') $tmpmodule='fournisseur'; + if ($linked_object == 'order_supplier') $tmpmodule='fournisseur'; + if($conf->$tmpmodule->enabled && $linked_object != $object->element) + { + $somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); + } + } print ''; print '
'; // List of actions on element - /* include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($fac,'invoice_supplier',$socid); - */ + $somethingshown=$formactions->showactions($object,'invoice_supplier',$socid); print ''; } diff --git a/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php new file mode 100755 index 00000000000..b2b01865454 --- /dev/null +++ b/htdocs/fourn/facture/tpl/linkedobjectblock.tpl.php @@ -0,0 +1,61 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ +?> + + + +load("bills"); +if ($somethingshown) { echo '
'; } +if ($num > 1) print_titre($langs->trans("RelatedBills")); +else print_titre($langs->trans("RelatedBill")); +?> + + + + + + + +fetch($objectid[$i]); + $var=!$var; +?> + > + + + + +total_ht; +} +?> + + + + + +
trans("Ref"); ?>trans("Date"); ?>trans("AmountHTShort"); ?>trans("Status"); ?>
+ trans("ShowBill"),"bill").' '.$linkedObjectBlock->ref; ?>date,'day'); ?>total_ht); ?>getLibStatut(3); ?>
trans("TotalHT"); ?> 
+ + \ No newline at end of file diff --git a/htdocs/includes/modules/modGravatar.class.php b/htdocs/includes/modules/modGravatar.class.php index a2235a1dfba..256bd67dc2f 100644 --- a/htdocs/includes/modules/modGravatar.class.php +++ b/htdocs/includes/modules/modGravatar.class.php @@ -92,17 +92,6 @@ class modGravatar extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); - // where entity can be - // 'thirdparty' to add a tab in third party view - // 'intervention' to add a tab in intervention view - // 'supplier_order' to add a tab in supplier order view - // 'supplier_invoice' to add a tab in supplier invoice view - // 'invoice' to add a tab in customer invoice view - // 'order' to add a tab in customer order view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'member' to add a tab in fundation member view - // Boxes $this->boxes = array(); // List of boxes diff --git a/htdocs/includes/modules/rapport/pdf_paiement.class.php b/htdocs/includes/modules/rapport/pdf_paiement.class.php index 861a2e4e6d6..1b3e1da2f49 100644 --- a/htdocs/includes/modules/rapport/pdf_paiement.class.php +++ b/htdocs/includes/modules/rapport/pdf_paiement.class.php @@ -273,7 +273,8 @@ class pdf_paiement $oldprowid = 0; $pdf->SetFillColor(220,220,220); $yp = 0; - for ($j = 0 ; $j < sizeof($lines) ; $j++) + $numlines=sizeof($lines); + for ($j = 0 ; $j < $numlines ; $j++) { $i = $j; if ($oldprowid <> $lines[$j][7]) diff --git a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php index 8f5ecca3acd..bbdc416c782 100755 --- a/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/includes/modules/supplier_invoice/modules_facturefournisseur.php @@ -44,7 +44,7 @@ class ModelePDFSuppliersInvoices { global $conf; - $type='supplier_invoice'; + $type='invoice_supplier'; $liste=array(); include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php'); diff --git a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php index 562a4aa3727..771f5ebbbaf 100644 --- a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php @@ -49,7 +49,7 @@ class ModelePDFSuppliersOrders { global $conf; - $type='supplier_order'; + $type='order_supplier'; $liste=array(); include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php'); diff --git a/htdocs/install/mysql/data/llx_c_actioncomm.sql b/htdocs/install/mysql/data/llx_c_actioncomm.sql index b50dfa813a2..f3321925056 100644 --- a/htdocs/install/mysql/data/llx_c_actioncomm.sql +++ b/htdocs/install/mysql/data/llx_c_actioncomm.sql @@ -40,6 +40,6 @@ insert into llx_c_actioncomm (id, code, type, libelle, module) values ( 4, 'AC_E insert into llx_c_actioncomm (id, code, type, libelle, module) values ( 5, 'AC_RDV', 'system', 'Rendez-vous' ,NULL); insert into llx_c_actioncomm (id, code, type, libelle, module) values ( 8, 'AC_COM', 'system', 'Send customer order by email' ,'order'); insert into llx_c_actioncomm (id, code, type, libelle, module) values ( 9, 'AC_FAC', 'system', 'Send customer invoice by email' ,'invoice'); -insert into llx_c_actioncomm (id, code, type, libelle, module) values (30, 'AC_SUP_ORD', 'system', 'Send supplier invoice by email' ,'supplier_order'); -insert into llx_c_actioncomm (id, code, type, libelle, module) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'supplier_invoice'); +insert into llx_c_actioncomm (id, code, type, libelle, module) values (30, 'AC_SUP_ORD', 'system', 'Send supplier invoice by email' ,'order_supplier'); +insert into llx_c_actioncomm (id, code, type, libelle, module) values (31, 'AC_SUP_INV', 'system', 'Send supplier invoice by email' ,'invoice_supplier'); insert into llx_c_actioncomm (id, code, type, libelle, module) values (50, 'AC_OTH', 'system', 'Other' ,NULL); diff --git a/htdocs/install/mysql/data/llx_c_type_contact.sql b/htdocs/install/mysql/data/llx_c_type_contact.sql index 3eac9e208c4..4238000eb14 100644 --- a/htdocs/install/mysql/data/llx_c_type_contact.sql +++ b/htdocs/install/mysql/data/llx_c_type_contact.sql @@ -46,10 +46,10 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (61, 'facture', 'external', 'SHIPPING', 'Contact client livraison', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (62, 'facture', 'external', 'SERVICE', 'Contact client prestation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'facture_fourn', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'facture_fourn', 'external', 'BILLING', 'Contact fournisseur facturation', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (72, 'facture_fourn', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); -insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (73, 'facture_fourn', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (70, 'invoice_supplier', 'internal', 'SALESREPFOLL', 'Responsable suivi du paiement', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (71, 'invoice_supplier', 'external', 'BILLING', 'Contact fournisseur facturation', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (72, 'invoice_supplier', 'external', 'SHIPPING', 'Contact fournisseur livraison', 1); +insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (73, 'invoice_supplier', 'external', 'SERVICE', 'Contact fournisseur prestation', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (91, 'commande','internal', 'SALESREPFOLL', 'Responsable suivi de la commande', 1); insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (100,'commande','external', 'BILLING', 'Contact client facturation commande', 1); diff --git a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql index a0ca8ea2746..b57c68b3692 100644 --- a/htdocs/install/mysql/migration/2.9.0-3.0.0.sql +++ b/htdocs/install/mysql/migration/2.9.0-3.0.0.sql @@ -148,4 +148,13 @@ INSERT INTO llx_action_def (code,titre,description,objet_type) values ('NOTIFY_E ALTER TABLE llx_prelevement_notifications MODIFY action varchar(32); -ALTER TABLE llx_c_tva ADD COLUMN accountancy_code varchar(15) DEFAULT NULL; \ No newline at end of file +ALTER TABLE llx_c_tva ADD COLUMN accountancy_code varchar(15) DEFAULT NULL; + + +UPDATE llx_c_actioncomm set module='invoice_supplier' WHERE module='supplier_invoice'; +UPDATE llx_c_actioncomm set module='order_supplier' WHERE module='supplier_order'; +UPDATE llx_documentmodel set type='invoice_supplier' WHERE type='supplier_invoice'; +UPDATE llx_documentmodel set type='order_supplier' WHERE type='supplier_order'; +UPDATE llx_c_type_contact set element='invoice_supplier' WHERE element='facture_fourn'; +UPDATE llx_c_type_contact set module='invoice_supplier' WHERE module='supplier_invoice'; +UPDATE llx_c_type_contact set module='order_supplier' WHERE module='supplier_order'; diff --git a/htdocs/install/mysql/tables/llx_extra_fields.sql b/htdocs/install/mysql/tables/llx_extra_fields.sql index 0c1b24de982..79e1d50aaa3 100644 --- a/htdocs/install/mysql/tables/llx_extra_fields.sql +++ b/htdocs/install/mysql/tables/llx_extra_fields.sql @@ -24,7 +24,7 @@ create table llx_extra_fields tms timestamp, entity integer DEFAULT 1 NOT NULL, -- multi company id - object varchar(64) NOT NULL, -- type of link 'invoice', 'order', 'proposal', 'supplier_invoice', 'supplier_order' + object varchar(64) NOT NULL, -- type of link 'invoice', 'order', 'proposal', 'invoice_supplier', 'order_supplier' name varchar(64) NOT NULL, -- code name of field label varchar(64) NOT NULL, format varchar(8) NOT NULL, -- date, string, integer, float diff --git a/htdocs/lib/fourn.lib.php b/htdocs/lib/fourn.lib.php index 2892c33f4a3..6bda9e0101b 100644 --- a/htdocs/lib/fourn.lib.php +++ b/htdocs/lib/fourn.lib.php @@ -62,10 +62,10 @@ function facturefourn_prepare_head($fac) // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__'); - if (is_array($conf->tabs_modules['supplier_invoice'])) + if (is_array($conf->tabs_modules['invoice_supplier'])) { $i=0; - foreach ($conf->tabs_modules['supplier_invoice'] as $value) + foreach ($conf->tabs_modules['invoice_supplier'] as $value) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); @@ -127,10 +127,10 @@ function ordersupplier_prepare_head($commande) // Show more tabs from modules // Entries must be declared in modules descriptor with line // $this->tabs = array('entity:MyModule:@mymodule:/mymodule/mypage.php?id=__ID__'); - if (is_array($conf->tabs_modules['supplier_order'])) + if (is_array($conf->tabs_modules['order_supplier'])) { $i=0; - foreach ($conf->tabs_modules['supplier_order'] as $value) + foreach ($conf->tabs_modules['order_supplier'] as $value) { $values=explode(':',$value); if ($values[2]) $langs->load($values[2]); diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index a2578a90aa4..9910d5efa6d 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -283,7 +283,8 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole, &$tasksrole, $ $var=true; - for ($i = 0 ; $i < sizeof($lines) ; $i++) + $numlines=sizeof($lines); + for ($i = 0 ; $i < $numlines ; $i++) { if ($parent == 0) $level = 0; @@ -395,7 +396,8 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole $projectsArrayId=explode(',',$projectsListId); - for ($i = 0 ; $i < sizeof($lines) ; $i++) + $numlines=sizeof($lines); + for ($i = 0 ; $i < $numlines ; $i++) { if ($parent == 0) $level = 0; @@ -528,7 +530,8 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole function SearchTaskInChild(&$inc, $parent, &$lines, &$taskrole) { //print 'Search in line with parent id = '.$parent.'
'; - for ($i = 0 ; $i < sizeof($lines) ; $i++) + $numlines=sizeof($lines); + for ($i = 0 ; $i < $numlines ; $i++) { // Process line $lines[$i] if ($lines[$i]->fk_parent == $parent && $lines[$i]->id != $lines[$i]->fk_parent)