Add possibility to add linked object block in object card for external module
Fix: templates integration
This commit is contained in:
parent
47f2586070
commit
7b1c726424
62
htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
Normal file
62
htdocs/comm/propal/tpl/linkedobjectblock.tpl.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?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
|
||||
if ($somethingshown) { echo '<br>'; }
|
||||
print_titre($langs->trans('RelatedCommercialProposals'));
|
||||
?>
|
||||
<table class="noborder" width="100%">
|
||||
<tr class="liste_titre">
|
||||
<td><?php echo $langs->trans("Ref"); ?></td>
|
||||
<td><?php echo $langs->trans('RefCustomer'); ?></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.'/compta/propal.php?propalid='.$linkedObjectBlock->id.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$linkedObjectBlock->ref; ?></a></td>
|
||||
<td><?php echo $linkedObjectBlock->ref_client; ?></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="3"><?php echo $langs->trans('TotalHT'); ?></td>
|
||||
<td align="right"><?php echo price($total); ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -29,7 +29,7 @@ print_titre($langs->trans('RelatedOrders'));
|
||||
<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("Price"); ?></td>
|
||||
<td align="right"><?php echo $langs->trans("AmountHTShort"); ?></td>
|
||||
<td align="right"><?php echo $langs->trans("Status"); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
@ -42,10 +42,19 @@ for ($i = 0 ; $i < $num ; $i++)
|
||||
<tr <?php echo $bc[$var]; ?> ><td>
|
||||
<a href="<?php echo DOL_URL_ROOT.'/commande/fiche.php?id='.$linkedObjectBlock->id.'">'.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_ttc); ?></td>
|
||||
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td>
|
||||
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?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> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -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 '<br>';
|
||||
$somethingshown=1;
|
||||
print_titre($langs->trans('RelatedCommercialProposals'));
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="150">'.$langs->trans('Ref').'</td>';
|
||||
print '<td>'.$langs->trans('RefCustomer').'</td>';
|
||||
print '<td align="center">'.$langs->trans('Date').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountHTShort').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref.'</a></td>';
|
||||
print '<td>'.$objp->ref_client.'</td>';
|
||||
print '<td align="center">'.dol_print_date($objp->dp,'day').'</td>';
|
||||
print '<td align="right">'.price($objp->total_ht).'</td>';
|
||||
print '</tr>';
|
||||
$total = $total + $objp->total_ht;
|
||||
$i++;
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="left">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.price($total).'</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
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 '<br>';
|
||||
$somethingshown=1;
|
||||
print_titre($langs->trans('RelatedOrders'));
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="150">'.$langs->trans('Ref').'</td>';
|
||||
print '<td>'.$langs->trans('RefCustomerOrderShort').'</td>';
|
||||
print '<td align="center">'.$langs->trans('Date').'</td>';
|
||||
print '<td align="right">'.$langs->trans('AmountHTShort').'</td>';
|
||||
print '</tr>';
|
||||
$var=true;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$objp->id.'">'.img_object($langs->trans('ShowOrder'), 'order').' '.$objp->ref."</a></td>\n";
|
||||
print '<td>'.$objp->ref_client.'</td>';
|
||||
print '<td align="center">'.dol_print_date($objp->date_commande,'day').'</td>';
|
||||
print '<td align="right">'.price($objp->total_ht).'</td>';
|
||||
print "</tr>\n";
|
||||
$total = $total + $objp->total_ht;
|
||||
$i++;
|
||||
}
|
||||
print '<tr class="liste_total">';
|
||||
print '<td align="left">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right">'.price($total).'</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
$somethingshown=$fac->showLinkedObjectBlock($object,$objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ else print_titre($langs->trans("RelatedBill"));
|
||||
<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("Price"); ?></td>
|
||||
<td align="right"><?php echo $langs->trans("AmountHTShort"); ?></td>
|
||||
<td align="right"><?php echo $langs->trans("Status"); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
@ -51,7 +51,8 @@ $total = $total + $linkedObjectBlock->total_ht;
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
<tr class="liste_total"><td align="right" colspan="2"><?php echo $langs->trans("TotalHT"); ?></td>
|
||||
<tr class="liste_total">
|
||||
<td align="left" colspan="2"><?php echo $langs->trans("TotalHT"); ?></td>
|
||||
<td align="right"><?php echo price($total); ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user