Add possibility to add linked object block in object card for external module
Fix: templates integration
This commit is contained in:
parent
9b2f724ea7
commit
8774e69ea9
@ -42,7 +42,6 @@ $langs->load('orders');
|
||||
$langs->load('products');
|
||||
|
||||
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/project.class.php');
|
||||
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/comm/propal/propal.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/comm/action/actioncomm.class.php');
|
||||
|
||||
@ -1965,43 +1964,12 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
foreach($propal->linked_object as $object => $objectid)
|
||||
{
|
||||
// TODO en attendant que tout soit correct
|
||||
if($conf->$object->enabled && $object == 'commande')
|
||||
if($conf->$object->enabled)
|
||||
{
|
||||
$propal->showLinkedObjectBlock($object,$objectid,$somethingshown);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if($conf->commande->enabled)
|
||||
{
|
||||
$propal->loadOrders();
|
||||
$coms = $propal->commandes;
|
||||
if (sizeof($coms) > 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>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Date").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
$var=true;
|
||||
for ($i = 0 ; $i < sizeof($coms) ; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n";
|
||||
print '<td align="center">'.dol_print_date($coms[$i]->date,'day').'</td>';
|
||||
print '<td align="right">'.price($coms[$i]->total_ttc).'</td>';
|
||||
print '<td align="right">'.$coms[$i]->getLibStatut(3).'</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
print '</td><td valign="top" width="50%">';
|
||||
|
||||
// List of actions on element
|
||||
|
||||
@ -2357,44 +2357,6 @@ class Commande extends CommonObject
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
function getLinkedObjectBlock($object,$objectid,$somethingshown=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$num = sizeof($objectid);
|
||||
|
||||
if ($num > 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>'.$langs->trans("Ref").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Date").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Status").'</td>';
|
||||
print '</tr>';
|
||||
$var=true;
|
||||
for ($i = 0 ; $i < $num ; $i++)
|
||||
{
|
||||
$this->fetch($objectid[$i]);
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'><td>';
|
||||
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$this->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$this->ref."</a></td>\n";
|
||||
print '<td align="center">'.dol_print_date($this->date,'day').'</td>';
|
||||
print '<td align="right">'.price($this->total_ttc).'</td>';
|
||||
print '<td align="right">'.$this->getLibStatut(3).'</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
51
htdocs/commande/tpl/linkedobjectblock.tpl.php
Normal file
51
htdocs/commande/tpl/linkedobjectblock.tpl.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?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>'; $somethingshown=1; }
|
||||
print_titre($langs->trans('RelatedOrders'));
|
||||
?>
|
||||
<table class="noborder" width="100%">
|
||||
<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("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.'/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 $linkedObjectBlock->getLibStatut(3); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
60
htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
Normal file
60
htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?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>'; $somethingshown=1; }
|
||||
if ($num > 1) print_titre($langs->trans("RelatedBills"));
|
||||
else print_titre($langs->trans("RelatedBill"));
|
||||
?>
|
||||
<table class="noborder" width="100%">
|
||||
<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("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/facture.php?facid='.$linkedObjectBlock->id.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$linkedObjectBlock->ref; ?></a></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;
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
<tr class="liste_total"><td align="right" colspan="2"><?php echo $langs->trans("TotalHT"); ?></td>
|
||||
<td align="right"><?php echo price($total); ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- END PHP TEMPLATE -->
|
||||
@ -1019,10 +1019,20 @@ class CommonObject
|
||||
*/
|
||||
function showLinkedObjectBlock($object,$objectid,$somethingshown=0)
|
||||
{
|
||||
$class = ucfirst($object);
|
||||
if(!class_exists($class)) require(DOL_DOCUMENT_ROOT."/".$object."/class/".$object.".class.php");
|
||||
$linkedObjectBlock = new $class($this->db);
|
||||
$linkedObjectBlock->getLinkedObjectBlock($object,$objectid,$somethingshown);
|
||||
global $langs;
|
||||
|
||||
$num = sizeof($objectid);
|
||||
if ($num)
|
||||
{
|
||||
// TODO uniformiser emplacement classe
|
||||
require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
|
||||
require_once(DOL_DOCUMENT_ROOT.'/compta/facture/facture.class.php');
|
||||
$class = ucfirst($object);
|
||||
if(!class_exists($class)) require(DOL_DOCUMENT_ROOT."/".$object."/class/".$object.".class.php");
|
||||
$linkedObjectBlock = new $class($this->db);
|
||||
if ($object == 'facture') $object = 'compta/'.$object;
|
||||
include(DOL_DOCUMENT_ROOT.'/'.$object.'/tpl/linkedobjectblock.tpl.php');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user