From 7b1c7264247badeb8dcb816a1ac58c766e273d49 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Apr 2010 07:23:32 +0000 Subject: [PATCH] Add possibility to add linked object block in object card for external module Fix: templates integration --- .../comm/propal/tpl/linkedobjectblock.tpl.php | 62 ++++++++++ htdocs/commande/tpl/linkedobjectblock.tpl.php | 15 ++- htdocs/compta/facture.php | 116 +----------------- .../facture/tpl/linkedobjectblock.tpl.php | 5 +- htdocs/core/commonobject.class.php | 1 + 5 files changed, 84 insertions(+), 115 deletions(-) create mode 100644 htdocs/comm/propal/tpl/linkedobjectblock.tpl.php 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')); +?> + + + + + + + + +fetch($objectid[$i]); + $var=!$var; +?> + > + + + + + +total_ht; +} + +?> + + + + + +
trans("Ref"); ?>trans('RefCustomer'); ?>trans("Date"); ?>trans("AmountHTShort"); ?>trans("Status"); ?>
+ '.img_object($langs->trans("ShowPropal"),"propal").' '.$linkedObjectBlock->ref; ?>ref_client; ?>date,'day'); ?>total_ht); ?>getLibStatut(3); ?>
trans('TotalHT'); ?> 
+ + \ 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 ''; - print ''; - print ''; - print ''; - print ''; - - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $total = $total + $objp->total_ht; - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('Ref').''.$langs->trans('RefCustomer').''.$langs->trans('Date').''.$langs->trans('AmountHTShort').'
'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref.''.$objp->ref_client.''.dol_print_date($objp->dp,'day').''.price($objp->total_ht).'
'.$langs->trans('TotalHT').'  '.price($total).'
'; - } - } - 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 ''; - print ''; - print ''; - print ''; - print ''; - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print '\n"; - print ''; - print ''; - print ''; - print "\n"; - $total = $total + $objp->total_ht; - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans('Ref').''.$langs->trans('RefCustomerOrderShort').''.$langs->trans('Date').''.$langs->trans('AmountHTShort').'
'; - print ''.img_object($langs->trans('ShowOrder'), 'order').' '.$objp->ref."'.$objp->ref_client.''.dol_print_date($objp->date_commande,'day').''.price($objp->total_ht).'
'.$langs->trans('TotalHT').'  '.price($total).'
'; - } - } - 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; }