From f9c4c30ec564689b0135503e60311e5e81821177 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Apr 2010 09:30:40 +0000 Subject: [PATCH] Add possibility to add linked object block in object card for external module Fix: templates integration --- htdocs/commande/fiche.php | 45 +++++-------------------------- htdocs/compta/commande/fiche.php | 46 +++++--------------------------- 2 files changed, 14 insertions(+), 77 deletions(-) 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 '"; - print ''; - print ''; - print ''; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ''; - print ''; - print ''; - print ''; - $i++; - } - print '
'.$langs->trans('Ref')."'.$langs->trans('Date').''.$langs->trans('Price').'
'.img_object($langs->trans('ShowBill'),'bill').' '.$objp->facnumber.''.dol_print_date($objp->df,'day').''.price($objp->total_ttc).'
'; + $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 '"; - print ''; - print ''; - print "\n"; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - print ''; - print ''; - print ''; - $i++; - } - print "
'.$langs->trans("Ref")."'.$langs->trans("Date").''.$langs->trans("Price").'
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.''.dol_print_date($objp->df).''.price($objp->total_ttc).'
"; + $somethingshown=$commande->showLinkedObjectBlock($object,$objectid,$somethingshown); } } - else - { - dol_print_error($db); - } print '';