Qual: Uniformize a lot of code (supplier_invoice => invoice_supplier, same for order)

New: Add link between supplier invoices and supplier orders.
This commit is contained in:
Laurent Destailleur 2010-12-13 13:16:02 +00:00
parent 81183e5ef0
commit 86ffc32195
27 changed files with 289 additions and 101 deletions

View File

@ -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

View File

@ -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";

View File

@ -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

View File

@ -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 '<br>';
$somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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)
{

View File

@ -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")); }
//***********************

View File

@ -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")); }
//***********************

View File

@ -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)';

View File

@ -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 '</td><td valign="top" width="50%">';
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 '<br>';
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
$formactions=new FormActions($db);
$somethingshown=$formactions->showactions($commande,'order_supplier',$socid);
*/
print '</td></tr></table>';
}

View File

@ -0,0 +1,61 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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$
*/
?>
<!-- BEGIN PHP TEMPLATE -->
<?php
$langs->load("orders");
if ($somethingshown) { echo '<br>'; }
print_titre($langs->trans('RelatedOrders'));
?>
<table class="noborder" width="100%">
<tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td>
<td align="center"><?php echo $langs->trans("Date"); ?></td>
<td align="right"><?php echo $langs->trans("AmountHTShort"); ?></td>
<td align="right"><?php echo $langs->trans("Status"); ?></td>
</tr>
<?php
$var=true;
for ($i = 0 ; $i < $num ; $i++)
{
$linkedObjectBlock->fetch($objectid[$i]);
$var=!$var;
?>
<tr <?php echo $bc[$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$linkedObjectBlock->ref; ?></a></td>
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td>
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td>
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td>
</tr>
<?php
$total = $total + $linkedObjectBlock->total_ht;
}
?>
<tr class="liste_total">
<td align="left" colspan="2"><?php echo $langs->trans('TotalHT'); ?></td>
<td align="right"><?php echo price($total); ?></td>
<td>&nbsp;</td>
</tr>
</table>
<!-- END PHP TEMPLATE -->

View File

@ -202,7 +202,7 @@ if ($id > 0)
/*
* Ajouter une ligne de contact
* Non affich<EFBFBD> en mode modification de ligne
* Non affiche en mode modification de ligne
*/
if ($_GET["action"] != 'editline' && $user->rights->facture->creer)
{

View File

@ -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 '<br>';
$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 '</td><td valign="top" width="50%">';
print '<br>';
// 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 '</td></tr></table>';
}

View File

@ -0,0 +1,61 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr>
*
* 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$
*/
?>
<!-- BEGIN PHP TEMPLATE -->
<?php
$langs->load("bills");
if ($somethingshown) { echo '<br>'; }
if ($num > 1) print_titre($langs->trans("RelatedBills"));
else print_titre($langs->trans("RelatedBill"));
?>
<table class="noborder" width="100%">
<tr class="liste_titre">
<td><?php echo $langs->trans("Ref"); ?></td>
<td align="center"><?php echo $langs->trans("Date"); ?></td>
<td align="right"><?php echo $langs->trans("AmountHTShort"); ?></td>
<td align="right"><?php echo $langs->trans("Status"); ?></td>
</tr>
<?php
$var=true;
for ($i = 0 ; $i < $num ; $i++)
{
$linkedObjectBlock->fetch($objectid[$i]);
$var=!$var;
?>
<tr <?php echo $bc[$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$linkedObjectBlock->ref; ?></a></td>
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td>
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td>
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td>
</tr>
<?php
$total = $total + $linkedObjectBlock->total_ht;
}
?>
<tr class="liste_total">
<td align="left" colspan="2"><?php echo $langs->trans("TotalHT"); ?></td>
<td align="right"><?php echo price($total); ?></td>
<td>&nbsp;</td>
</tr>
</table>
<!-- END PHP TEMPLATE -->

View File

@ -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

View File

@ -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])

View File

@ -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');

View File

@ -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');

View File

@ -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);

View File

@ -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);

View File

@ -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;
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';

View File

@ -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

View File

@ -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]);

View File

@ -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.'<br>';
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)