diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
new file mode 100644
index 00000000000..f4bfb77d5a8
--- /dev/null
+++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
@@ -0,0 +1,62 @@
+
+ *
+ * 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$
+ */
+?>
+
+
+
+'; }
+print_titre($langs->trans('RelatedCommercialProposals'));
+?>
+
+
+
\ No newline at end of file
diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php
index 9a34bf4d3a1..1e71ff6d5c6 100644
--- a/htdocs/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php
@@ -29,7 +29,7 @@ print_titre($langs->trans('RelatedOrders'));
| trans("Ref"); ?> |
trans("Date"); ?> |
- trans("Price"); ?> |
+ trans("AmountHTShort"); ?> |
trans("Status"); ?> |
>
'.img_object($langs->trans("ShowOrder"),"order").' '.$linkedObjectBlock->ref; ?> |
date,'day'); ?> |
- total_ttc); ?> |
+ total_ht); ?> |
getLibStatut(3); ?> |
-
+total_ht;
+}
+
+?>
+
+ | trans('TotalHT'); ?> |
+ |
+ |
+
\ No newline at end of file
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 6dfa9f0040b..051977bbea1 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -3505,119 +3505,15 @@ else
$somethingshown=$formfile->show_documents('facture',$filename,$filedir,$urlsource,$genallowed,$delallowed,$fac->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
/*
- * Propales rattachees
+ * Linked object block
*/
- $sql = 'SELECT '.$db->pdate('p.datep').' as dp, p.total_ht, p.ref, p.ref_client, p.rowid as propalid';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'propal as p';
- $sql.= ", ".MAIN_DB_PREFIX."element_element as el";
- $sql.= " WHERE el.fk_source = p.rowid";
- $sql.= " AND el.sourcetype = 'propal'";
- $sql.= " AND el.fk_target = ".$fac->id;
- $sql.= " AND el.targettype = '".$fac->element."'";
-
- dol_syslog("facture.php: sql=".$sql);
- $resql = $db->query($sql);
- if ($resql)
+ $fac->load_object_linked($fac->id,$fac->element);
+
+ foreach($fac->linked_object as $object => $objectid)
{
- $num = $db->num_rows($resql);
- if ($num)
+ if($conf->$object->enabled)
{
- $i = 0; $total = 0;
- if ($somethingshown) print '
';
- $somethingshown=1;
- print_titre($langs->trans('RelatedCommercialProposals'));
- print '';
- print '';
- print '| '.$langs->trans('Ref').' | ';
- print ''.$langs->trans('RefCustomer').' | ';
- print ''.$langs->trans('Date').' | ';
- print ''.$langs->trans('AmountHTShort').' | ';
- print '
';
-
- $var=True;
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
- $var=!$var;
- print '';
- print '| '.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref.' | ';
- print ''.$objp->ref_client.' | ';
- print ''.dol_print_date($objp->dp,'day').' | ';
- print ''.price($objp->total_ht).' | ';
- print '
';
- $total = $total + $objp->total_ht;
- $i++;
- }
- print '';
- print '| '.$langs->trans('TotalHT').' | ';
- print ' | ';
- print ' | ';
- print ''.price($total).' |
';
- print '
';
- }
- }
- else
- {
- dol_print_error($db);
- }
-
- /*
- * Commandes rattachees
- */
- if($conf->commande->enabled)
- {
- $sql = 'SELECT '.$db->pdate('c.date_commande').' as date_commande, c.total_ht, c.ref, c.ref_client, c.rowid as id';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
- $sql.= ', '.MAIN_DB_PREFIX.'element_element as el';
- $sql.= ' WHERE el.fk_source = c.rowid';
- $sql.= " AND el.sourcetype = 'commande'";
- $sql.= " AND el.fk_target = ".$fac->id;
- $sql.= " AND el.targettype = '".$fac->element."'";
-
- $resql = $db->query($sql);
- if ($resql)
- {
- $num = $db->num_rows($resql);
- if ($num)
- {
- $langs->load("orders");
-
- $i = 0; $total = 0;
- if ($somethingshown) print '
';
- $somethingshown=1;
- print_titre($langs->trans('RelatedOrders'));
- print '';
- print '';
- print '| '.$langs->trans('Ref').' | ';
- print ''.$langs->trans('RefCustomerOrderShort').' | ';
- print ''.$langs->trans('Date').' | ';
- print ''.$langs->trans('AmountHTShort').' | ';
- print '
';
- $var=true;
- while ($i < $num)
- {
- $objp = $db->fetch_object($resql);
- $var=!$var;
- print '| ';
- print ''.img_object($langs->trans('ShowOrder'), 'order').' '.$objp->ref." | \n";
- print ''.$objp->ref_client.' | ';
- print ''.dol_print_date($objp->date_commande,'day').' | ';
- print ''.price($objp->total_ht).' | ';
- print "
\n";
- $total = $total + $objp->total_ht;
- $i++;
- }
- print '';
- print '| '.$langs->trans('TotalHT').' | ';
- print ' | ';
- print ' | ';
- print ''.price($total).' |
';
- print '
';
- }
- }
- else
- {
- dol_print_error($db);
+ $somethingshown=$fac->showLinkedObjectBlock($object,$objectid,$somethingshown);
}
}
diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
index 9255038b494..90aeeda8ae0 100644
--- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
@@ -30,7 +30,7 @@ else print_titre($langs->trans("RelatedBill"));
| trans("Ref"); ?> |
trans("Date"); ?> |
- trans("Price"); ?> |
+ trans("AmountHTShort"); ?> |
trans("Status"); ?> |
total_ht;
$i++;
}
?>
-| trans("TotalHT"); ?> |
+
+ | trans("TotalHT"); ?> |
|
|
diff --git a/htdocs/core/commonobject.class.php b/htdocs/core/commonobject.class.php
index 9f2da3f7e45..c9ca4494eeb 100644
--- a/htdocs/core/commonobject.class.php
+++ b/htdocs/core/commonobject.class.php
@@ -1031,6 +1031,7 @@ class CommonObject
if(!class_exists($class)) require(DOL_DOCUMENT_ROOT."/".$object."/class/".$object.".class.php");
$linkedObjectBlock = new $class($this->db);
if ($object == 'facture') $object = 'compta/'.$object;
+ if ($object == 'propal') $object = 'comm/'.$object;
include(DOL_DOCUMENT_ROOT.'/'.$object.'/tpl/linkedobjectblock.tpl.php');
return $num;
}