diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 670f3dae788..c943f8de4cc 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -2217,49 +2217,18 @@ else
$somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/*
- * Liste des factures
+ * Linked object block
*/
- $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate('f.datef')." as df";
- $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
- $sql.= ", ".MAIN_DB_PREFIX."element_element as el";
- $sql.= " WHERE f.rowid = el.fk_target";
- $sql.= " AND el.targettype = 'facture'";
- $sql.= " AND el.fk_source = ".$commande->id;
- $sql.= " AND el.sourcetype = '".$commande->element."'";
-
- $result = $db->query($sql);
- if ($result)
+ $commande->load_object_linked($commande->id,$commande->element);
+
+ foreach($commande->linked_object as $object => $objectid)
{
- $num = $db->num_rows($result);
- if ($num)
+ if($conf->$object->enabled)
{
- print '
';
- print_titre($langs->trans('RelatedBills'));
- $i = 0; $total = 0;
- print '
';
- print '| '.$langs->trans('Ref')." | ";
- print ''.$langs->trans('Date').' | ';
- print ''.$langs->trans('Price').' | ';
- print '
';
-
- $var=True;
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
- $var=!$var;
- print '';
- print '| '.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber.' | ';
- print ''.dol_print_date($objp->df,'day').' | ';
- print ''.price($objp->total_ttc).' |
';
- $i++;
- }
- print '
';
+ $somethingshown=$commande->showLinkedObjectBlock($object,$objectid,$somethingshown);
}
}
- else
- {
- dol_print_error($db);
- }
+
print '';
// List of actions on element
diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php
index 9e1a70f1360..964e1a31ad7 100644
--- a/htdocs/compta/commande/fiche.php
+++ b/htdocs/compta/commande/fiche.php
@@ -1,7 +1,7 @@
* Copyright (C) 2004-2009 Laurent Destailleur
- * Copyright (C) 2005-2009 Regis Houssin
+ * Copyright (C) 2005-2010 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
@@ -552,49 +552,17 @@ if ($id > 0 || ! empty($ref))
$somethingshown=$formfile->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
/*
- * Liste des factures
+ * Linked object block
*/
- $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate("f.datef")." as df";
- $sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
- $sql.= ", ".MAIN_DB_PREFIX."element_element as el";
- $sql.= " WHERE f.rowid = el.fk_target";
- $sql.= " AND el.targettype = 'facture'";
- $sql.= " AND el.fk_source = ". $commande->id;
- $sql.= " AND el.sourcetype = '".$commande->element."'";
-
- $result = $db->query($sql);
- if ($result)
+ $commande->load_object_linked($commande->id,$commande->element);
+
+ foreach($commande->linked_object as $object => $objectid)
{
- $num = $db->num_rows($result);
- if ($num)
+ if($conf->$object->enabled)
{
- if ($somethingshown) print ' ';
- print_titre($langs->trans("RelatedBills"));
- $i = 0; $total = 0;
- print '';
- print '| '.$langs->trans("Ref")." | ";
- print ''.$langs->trans("Date").' | ';
- print ''.$langs->trans("Price").' | ';
- print " \n";
-
- $var=True;
- while ($i < $num)
- {
- $objp = $db->fetch_object($result);
- $var=!$var;
- print "";
- print '| '.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.' | ';
- print ''.dol_print_date($objp->df).' | ';
- print ''.price($objp->total_ttc).' | ';
- $i++;
- }
- print " ";
+ $somethingshown=$commande->showLinkedObjectBlock($object,$objectid,$somethingshown);
}
}
- else
- {
- dol_print_error($db);
- }
print ' | ';
|