Fix: mutualize code, more simple

This commit is contained in:
Regis Houssin 2011-05-06 18:27:18 +00:00
parent cd2d5ddd73
commit 67fe35e67b
26 changed files with 262 additions and 486 deletions

View File

@ -110,15 +110,7 @@ $form=new Form($db);
* *
* Put here code to view linked object * Put here code to view linked object
****************************************************/ ****************************************************/
$myobject->load_object_linked($myobject->id,$myobject->element); $somethingshown=$myobject->showLinkedObjectBlock();
foreach($myobject->linked_object as $linked_object => $linked_objectid)
{
if ($conf->$linked_object->enabled)
{
$somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
// End of page // End of page
$db->close(); $db->close();

View File

@ -1646,22 +1646,7 @@ if ($id > 0 || ! empty($ref))
/* /*
* Linked object block * Linked object block
*/ */
$object->load_object_linked($object->id,$object->element); $somethingshown=$object->showLinkedObjectBlock();
//var_dump($object->linked_object);
foreach($object->linked_object as $linked_object => $linked_objectid)
{
$element = $subelement = $linked_object;
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
if($conf->$element->enabled && $element != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';

View File

@ -1637,25 +1637,27 @@ class Propal extends CommonObject
$ga = array(); $ga = array();
$linkedInvoices = array(); $linkedInvoices = array();
$this->load_object_linked($id,$this->element); $this->fetchObjectLinked($id,$this->element);
foreach($this->linked_object as $object => $objectid) foreach($this->linkedObjectsIds as $objecttype => $objectid)
{ {
for ($i = 0; $i<sizeof($objectid);$i++) $numi=sizeof($objectid);
for ($i=0;$i<$numi;$i++)
{ {
// Cas des factures liees directement // Cas des factures liees directement
if ($object == 'facture') if ($objecttype == 'facture')
{ {
$linkedInvoices[] = $objectid[$i]; $linkedInvoices[] = $objectid[$i];
} }
// Cas des factures liees via la commande // Cas des factures liees via la commande
else else
{ {
$this->load_object_linked($objectid[$i],$object,-1,-1); $this->fetchObjectLinked($objectid[$i],$objecttype);
foreach($this->linked_object as $object => $objectid) foreach($this->linkedObjectsIds as $subobjecttype => $subobjectid)
{ {
for ($j = 0; $j<sizeof($objectid);$j++) $numj=sizeof($subobjectid);
for ($j=0;$j<$numj;$j++)
{ {
$linkedInvoices[] = $objectid[$j]; $linkedInvoices[] = $subobjectid[$j];
} }
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,12 +24,9 @@
<?php <?php
$langs = $GLOBALS['langs']; $langs = $GLOBALS['langs'];
$somethingshown = $GLOBALS['somethingshown'];
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
$objectid = $GLOBALS['object']->objectid;
$num = count($objectid);
if ($somethingshown) { echo '<br>'; } echo '<br />';
print_titre($langs->trans('RelatedCommercialProposals')); print_titre($langs->trans('RelatedCommercialProposals'));
?> ?>
<table class="noborder" width="100%"> <table class="noborder" width="100%">
@ -42,20 +39,19 @@ print_titre($langs->trans('RelatedCommercialProposals'));
</tr> </tr>
<?php <?php
$var=true; $var=true;
for ($i = 0 ; $i < $num ; $i++) foreach($linkedObjectBlock as $object)
{ {
$linkedObjectBlock->fetch($objectid[$i]);
$var=!$var; $var=!$var;
?> ?>
<tr <?php echo $bc[$var]; ?> ><td> <tr <?php echo $bc[$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/comm/propal.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowPropal"),"propal").' '.$linkedObjectBlock->ref; ?></a></td> <a href="<?php echo DOL_URL_ROOT.'/comm/propal.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowPropal"),"propal").' '.$object->ref; ?></a></td>
<td><?php echo $linkedObjectBlock->ref_client; ?></td> <td><?php echo $object->ref_client; ?></td>
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td> <td align="right"><?php echo price($object->total_ht); ?></td>
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td>
</tr> </tr>
<?php <?php
$total = $total + $linkedObjectBlock->total_ht; $total = $total + $object->total_ht;
} }
?> ?>

View File

@ -2025,21 +2025,7 @@ else
/* /*
* Linked object block * Linked object block
*/ */
$object->load_object_linked(); $somethingshown=$object->showLinkedObjectBlock();
foreach($object->linked_object as $linked_object => $linked_objectid)
{
$element = $subelement = $linked_object;
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
if($conf->$element->enabled && $element != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,13 +24,10 @@
<?php <?php
$langs = $GLOBALS['langs']; $langs = $GLOBALS['langs'];
$somethingshown = $GLOBALS['somethingshown'];
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
$objectid = $GLOBALS['object']->objectid;
$num = count($objectid);
$langs->load("orders"); $langs->load("orders");
if ($somethingshown) { echo '<br>'; } echo '<br />';
print_titre($langs->trans('RelatedOrders')); print_titre($langs->trans('RelatedOrders'));
?> ?>
@ -43,19 +40,18 @@ print_titre($langs->trans('RelatedOrders'));
</tr> </tr>
<?php <?php
$var=true; $var=true;
for ($i = 0 ; $i < $num ; $i++) foreach($linkedObjectBlock as $object)
{ {
$linkedObjectBlock->fetch($objectid[$i]);
$var=!$var; $var=!$var;
?> ?>
<tr <?php echo $GLOBALS['bc'][$var]; ?> ><td> <tr <?php echo $GLOBALS['bc'][$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/commande/fiche.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$linkedObjectBlock->ref; ?></a></td> <a href="<?php echo DOL_URL_ROOT.'/commande/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowOrder"),"order").' '.$object->ref; ?></a></td>
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td> <td align="right"><?php echo price($object->total_ht); ?></td>
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td>
</tr> </tr>
<?php <?php
$total = $total + $linkedObjectBlock->total_ht; $total = $total + $object->total_ht;
} }
?> ?>

View File

@ -2793,21 +2793,7 @@ else
/* /*
* Linked object block * Linked object block
*/ */
$object->load_object_linked($object->id,$object->element); $somethingshown=$object->showLinkedObjectBlock();
foreach($object->linked_object as $linked_object => $linked_objectid)
{
$element = $subelement = $linked_object;
if (preg_match('/^([^_]+)_([^_]+)/i',$linked_object,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
}
if($conf->$element->enabled && $element != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';

View File

@ -2445,8 +2445,8 @@ class Facture extends CommonObject
} }
else else
{ {
dol_print_error($db,"Facture::getNextNumRef ".$obj->error); //dol_print_error($db,"Facture::getNextNumRef ".$obj->error);
return ''; return false;
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,13 +24,10 @@
<?php <?php
$langs = $GLOBALS['langs']; $langs = $GLOBALS['langs'];
$somethingshown = $GLOBALS['somethingshown'];
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
$objectid = $GLOBALS['object']->objectid;
$num = count($objectid);
$langs->load("bills"); $langs->load("bills");
if ($somethingshown) { echo '<br>'; } echo '<br />';
if ($num > 1) print_titre($langs->trans("RelatedBills")); if ($num > 1) print_titre($langs->trans("RelatedBills"));
else print_titre($langs->trans("RelatedBill")); else print_titre($langs->trans("RelatedBill"));
?> ?>
@ -43,19 +40,18 @@ else print_titre($langs->trans("RelatedBill"));
</tr> </tr>
<?php <?php
$var=true; $var=true;
for ($i = 0 ; $i < $num ; $i++) foreach($linkedObjectBlock as $object)
{ {
$linkedObjectBlock->fetch($objectid[$i]);
$var=!$var; $var=!$var;
?> ?>
<tr <?php echo $GLOBALS['bc'][$var]; ?> ><td> <tr <?php echo $GLOBALS['bc'][$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/compta/facture.php?facid='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$linkedObjectBlock->ref; ?></a></td> <a href="<?php echo DOL_URL_ROOT.'/compta/facture.php?facid='.$object->id ?>"><?php echo img_object($langs->trans("ShowBill"),"bill").' '.$object->ref; ?></a></td>
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date,'day'); ?></td> <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
<td align="right"><?php echo price($linkedObjectBlock->total_ht); ?></td> <td align="right"><?php echo price($object->total_ht); ?></td>
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(3); ?></td> <td align="right"><?php echo $object->getLibStatut(3); ?></td>
</tr> </tr>
<?php <?php
$total = $total + $linkedObjectBlock->total_ht; $total = $total + $object->total_ht;
} }
?> ?>
<tr class="liste_total"> <tr class="liste_total">

View File

@ -59,15 +59,8 @@ $form=new Form($db);
****************************************************/ ****************************************************/
/* /*
$myobject->load_object_linked($myobject->id,$myobject->element); $somethingshown=$myobject->showLinkedObjectBlock();
foreach($myobject->linked_object as $linked_object => $linked_objectid)
{
if ($conf->$linked_object->enabled)
{
$somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
*/ */
// End of page // End of page

View File

@ -74,6 +74,7 @@ else if (! empty($_GET["id"]))
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, $module, $objectid, $dbtable); $result = restrictedArea($user, $module, $objectid, $dbtable);
$object = new Propal($db);
/******************************************************************************/ /******************************************************************************/
@ -83,18 +84,16 @@ $result = restrictedArea($user, $module, $objectid, $dbtable);
if ($_GET["action"] == 'setstatut') if ($_GET["action"] == 'setstatut')
{ {
// Close proposal // Close proposal
$propal = new Propal($db); $object->id = $_GET["id"];
$propal->id = $_GET["id"]; $object->cloture($user, $_GET["statut"], $note);
$propal->cloture($user, $_GET["statut"], $note);
} }
// Set project // Set project
if ($_POST['action'] == 'classin') if ($_POST['action'] == 'classin')
{ {
$propal = new Propal($db); $object->fetch($_GET["id"]);
$propal->fetch($_GET["id"]); $object->setProject($_POST['projectid']);
$propal->setProject($_POST['projectid']);
} }
@ -122,13 +121,12 @@ if ($id > 0 || ! empty($ref))
$product_static=new Product($db); $product_static=new Product($db);
$propal = new Propal($db); $object->fetch($_GET["id"],$_GET["ref"]);
$propal->fetch($_GET["id"],$_GET["ref"]);
$societe = new Societe($db); $societe = new Societe($db);
$societe->fetch($propal->socid); $societe->fetch($object->socid);
$head = propal_prepare_head($propal); $head = propal_prepare_head($object);
dol_fiche_head($head, 'compta', $langs->trans('Proposal'), 0, 'propal'); dol_fiche_head($head, 'compta', $langs->trans('Proposal'), 0, 'propal');
@ -141,7 +139,7 @@ if ($id > 0 || ! empty($ref))
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="5">'; print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="5">';
print $html->showrefnav($propal,'ref',$linkback,1,'ref','ref',''); print $html->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>'; print '</td></tr>';
// Ref client // Ref client
@ -149,10 +147,10 @@ if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">'; print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>'; print '</td>';
if ($_GET['action'] != 'refclient' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$propal->id.'">'.img_edit($langs->trans('Modify')).'</a></td>'; if ($_GET['action'] != 'refclient' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&amp;id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="5">'; print '</td><td colspan="5">';
print $propal->ref_client; print $object->ref_client;
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -174,7 +172,7 @@ if ($id > 0 || ! empty($ref))
// Dates // Dates
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">'; print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
print dol_print_date($propal->date,'daytext'); print dol_print_date($object->date,'daytext');
print '</td>'; print '</td>';
if ($conf->projet->enabled) $rowspan++; if ($conf->projet->enabled) $rowspan++;
@ -187,16 +185,16 @@ if ($id > 0 || ! empty($ref))
} }
// Note // Note
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($propal->note_public).'</td>'; print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('NotePublic').' :<br>'. nl2br($object->note_public).'</td>';
print '</tr>'; print '</tr>';
// Date fin propal // Date fin propal
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">'; print '<td>'.$langs->trans('DateEndPropal').'</td><td colspan="3">';
if ($propal->fin_validite) if ($object->fin_validite)
{ {
print dol_print_date($propal->fin_validite,'daytext'); print dol_print_date($object->fin_validite,'daytext');
if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
} }
else else
{ {
@ -210,16 +208,16 @@ if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditionsShort'); print $langs->trans('PaymentConditionsShort');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editconditions' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$propal->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; if ($_GET['action'] != 'editconditions' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editconditions') if ($_GET['action'] == 'editconditions')
{ {
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->cond_reglement_id,'cond_reglement_id'); $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id');
} }
else else
{ {
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->cond_reglement_id,'none'); $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none');
} }
print '</td>'; print '</td>';
@ -229,16 +227,16 @@ if ($id > 0 || ! empty($ref))
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode'); print $langs->trans('PaymentMode');
print '</td>'; print '</td>';
if ($_GET['action'] != 'editmode' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$propal->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; if ($_GET['action'] != 'editmode' && $object->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'editmode') if ($_GET['action'] == 'editmode')
{ {
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->mode_reglement_id,'mode_reglement_id'); $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id');
} }
else else
{ {
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$propal->id,$propal->mode_reglement_id,'none'); $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none');
} }
print '</td></tr>'; print '</td></tr>';
@ -251,28 +249,28 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('Project').'</td>'; print $langs->trans('Project').'</td>';
if (1 == 2 && $user->rights->propale->creer) if (1 == 2 && $user->rights->propale->creer)
{ {
if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&amp;id='.$propal->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>'; if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&amp;id='.$object->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td><td colspan="3">'; print '</td><td colspan="3">';
if ($_GET['action'] == 'classer') if ($_GET['action'] == 'classer')
{ {
$html->form_project($_SERVER['PHP_SELF'].'?id='.$propal->id, $propal->socid, $propal->fk_project, 'projectid'); $html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid');
} }
else else
{ {
$html->form_project($_SERVER['PHP_SELF'].'?id='.$propal->id, $propal->socid, $propal->fk_project, 'none'); $html->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none');
} }
print '</td></tr>'; print '</td></tr>';
} }
else else
{ {
print '</td></tr></table>'; print '</td></tr></table>';
if (!empty($propal->fk_project)) if (!empty($object->fk_project))
{ {
print '<td colspan="3">'; print '<td colspan="3">';
$project = new Project($db); $project = new Project($db);
$project->fetch($propal->fk_project); $project->fetch($object->fk_project);
print '<a href="../projet/fiche.php?id='.$propal->fk_project.'" title="'.$langs->trans('ShowProject').'">'; print '<a href="../projet/fiche.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
print $project->ref; print $project->ref;
print '</a>'; print '</a>';
print '</td>'; print '</td>';
@ -287,10 +285,10 @@ if ($id > 0 || ! empty($ref))
// Amount // Amount
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>'; print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2"><b>'.price($propal->total_ht).'</b></td>'; print '<td align="right" colspan="2"><b>'.price($object->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($propal->total_tva).'</td>'; print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($object->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Amount Local Taxes // Amount Local Taxes
@ -299,24 +297,24 @@ if ($id > 0 || ! empty($ref))
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{ {
print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT1",$mysoc->pays_code).'</td>';
print '<td align="right" colspan="2">'.price($propal->total_localtax1).'</td>'; print '<td align="right" colspan="2">'.price($object->total_localtax1).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
} }
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{ {
print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT2",$mysoc->pays_code).'</td>';
print '<td align="right" colspan="2">'.price($propal->total_localtax2).'</td>'; print '<td align="right" colspan="2">'.price($object->total_localtax2).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
} }
} }
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($propal->total_ttc).'</td>'; print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($object->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Statut // Statut
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$propal->getLibStatut(4).'</td></tr>'; print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$object->getLibStatut(4).'</td></tr>';
print '</table><br>'; print '</table><br>';
/* /*
@ -332,7 +330,7 @@ if ($id > 0 || ! empty($ref))
$sql.= ' p.description as product_desc'; $sql.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql.= ' WHERE pt.fk_propal = '.$propal->id; $sql.= ' WHERE pt.fk_propal = '.$object->id;
$sql.= ' ORDER BY pt.rang ASC, pt.rowid'; $sql.= ' ORDER BY pt.rang ASC, pt.rowid';
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -402,7 +400,7 @@ if ($id > 0 || ! empty($ref))
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
if (($objp->info_bits & 2) == 2) if (($objp->info_bits & 2) == 2)
{ {
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socid.'">'; print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$object->socid.'">';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '</a>'; print '</a>';
if ($objp->description) if ($objp->description)
@ -477,17 +475,17 @@ if ($id > 0 || ! empty($ref))
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($propal->statut <> 4 && $user->societe_id == 0) if ($object->statut <> 4 && $user->societe_id == 0)
{ {
if ($propal->statut == 2 && $user->rights->facture->creer) if ($object->statut == 2 && $user->rights->facture->creer)
{ {
print '<a class="butAction" href="facture.php?action=create&origin='.$propal->element.'&originid='.$propal->id.'&socid='.$propal->socid.'">'.$langs->trans("BuildBill").'</a>'; print '<a class="butAction" href="facture.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("BuildBill").'</a>';
} }
$arraypropal=$propal->getInvoiceArrayList(); $arraypropal=$object->getInvoiceArrayList();
if ($propal->statut == 2 && is_array($arraypropal) && sizeof($arraypropal) > 0) if ($object->statut == 2 && is_array($arraypropal) && sizeof($arraypropal) > 0)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$propal->id.'&action=setstatut&statut=4&socid='.$propal->socid.'">'.$langs->trans("ClassifyBilled").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=setstatut&statut=4&socid='.$object->socid.'">'.$langs->trans("ClassifyBilled").'</a>';
} }
} }
print "</div>"; print "</div>";
@ -500,9 +498,9 @@ if ($id > 0 || ! empty($ref))
/* /*
* Documents generes * Documents generes
*/ */
$filename=dol_sanitizeFileName($propal->ref); $filename=dol_sanitizeFileName($object->ref);
$filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref); $filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref);
$urlsource=$_SERVER["PHP_SELF"]."?id=".$propal->id; $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed=0; $genallowed=0;
$delallowed=0; $delallowed=0;
@ -514,22 +512,14 @@ if ($id > 0 || ! empty($ref))
/* /*
* Linked object block * Linked object block
*/ */
$propal->load_object_linked($propal->id,$propal->element); $somethingshown=$object->showLinkedObjectBlock();
foreach($propal->linked_object as $linked_object => $linked_objectid)
{
if($conf->$linked_object->enabled && $linked_object != $propal->element)
{
$somethingshown=$propal->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
// List of actions on element // List of actions on element
include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php');
$formactions=new FormActions($db); $formactions=new FormActions($db);
$somethingshown=$formactions->showactions($propal,'propal',$socid); $somethingshown=$formactions->showactions($object,'propal',$socid);
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -1260,28 +1260,16 @@ else
print '<br>'; print '<br>';
} }
print '<table width="100%"><tr><td width="50%" valign="top">';
/* /*
* Linked object block * Linked object block
*/ */
$object->load_object_linked($object->id,$object->element); $somethingshown=$object->showLinkedObjectBlock();
if (! empty($object->linked_object))
{
print '<table width="100%"><tr><td width="50%" valign="top">';
foreach($object->linked_object as $linked_object => $linked_objectid)
{
if($conf->$linked_object->enabled && $linked_object != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
print '</td></tr></table>'; print '</td></tr></table>';
} }
}
} }
$db->close(); $db->close();

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2010 Regis Houssin <regis@dolibarr.fr> /* Copyright (C) 2010-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -24,13 +24,10 @@
<?php <?php
$langs = $GLOBALS['langs']; $langs = $GLOBALS['langs'];
$somethingshown = $GLOBALS['somethingshown'];
$linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock;
$objectid = $GLOBALS['object']->objectid;
$num = count($objectid);
$langs->load("contracts"); $langs->load("contracts");
if ($somethingshown) { echo '<br>'; } echo '<br />';
print_titre($langs->trans('RelatedContracts')); print_titre($langs->trans('RelatedContracts'));
?> ?>
<table class="noborder" width="100%"> <table class="noborder" width="100%">
@ -42,17 +39,16 @@ print_titre($langs->trans('RelatedContracts'));
</tr> </tr>
<?php <?php
$var=true; $var=true;
for ($i = 0 ; $i < $num ; $i++) foreach($linkedObjectBlock as $object)
{ {
$linkedObjectBlock->fetch($objectid[$i]); $object->fetch_lines();
$linkedObjectBlock->fetch_lines();
$var=!$var; $var=!$var;
?> ?>
<tr <?php echo $bc[$var]; ?> ><td> <tr <?php echo $bc[$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/contrat/fiche.php?id='.$linkedObjectBlock->id ?>"><?php echo img_object($langs->trans("ShowContract"),"contract").' '.$linkedObjectBlock->ref; ?></a></td> <a href="<?php echo DOL_URL_ROOT.'/contrat/fiche.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowContract"),"contract").' '.$object->ref; ?></a></td>
<td align="center"><?php echo dol_print_date($linkedObjectBlock->date_contrat,'day'); ?></td> <td align="center"><?php echo dol_print_date($object->date_contrat,'day'); ?></td>
<td align="right">&nbsp;</td> <td align="right">&nbsp;</td>
<td align="right"><?php echo $linkedObjectBlock->getLibStatut(6); ?></td> <td align="right"><?php echo $object->getLibStatut(6); ?></td>
</tr> </tr>
<?php } ?> <?php } ?>

View File

@ -1151,16 +1151,19 @@ class CommonObject
} }
/** /**
* Load array of objects linked to current object. Links are loaded into this->linked_object array. * Fetch array of objects linked to current object. Links are loaded into this->linked_object array.
* @param sourceid * @param sourceid
* @param sourcetype * @param sourcetype
* @param targetid * @param targetid
* @param targettype * @param targettype
* @param clause OR, AND * @param clause OR, AND
*/ */
function load_object_linked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR') function fetchObjectLinked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
{ {
$this->linked_object=array(); global $conf;
$this->linkedObjectsIds=array();
$this->linkedObjects=array();
$justsource=false; $justsource=false;
$justtarget=false; $justtarget=false;
@ -1170,7 +1173,7 @@ class CommonObject
$sourceid = (! empty($sourceid) ? $sourceid : $this->id ); $sourceid = (! empty($sourceid) ? $sourceid : $this->id );
$targetid = (! empty($targetid) ? $targetid : $this->id ); $targetid = (! empty($targetid) ? $targetid : $this->id );
$sourcetype = (!empty($sourcetype)?$sourcetype:$this->origin); $sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element ) );
$targettype = (! empty($targettype) ? $targettype : $this->element ); $targettype = (! empty($targettype) ? $targettype : $this->element );
// Links beetween objects are stored in this table // Links beetween objects are stored in this table
@ -1187,8 +1190,9 @@ class CommonObject
$sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; $sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')";
$sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; $sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')";
} }
//print $sql;
dol_syslog("CommonObject::load_object_linked sql=".$sql); dol_syslog("CommonObject::fetchObjectLink sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -1199,39 +1203,24 @@ class CommonObject
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj->fk_source == $sourceid) if ($obj->fk_source == $sourceid)
{ {
$this->linked_object[$obj->targettype][]=$obj->fk_target; $this->linkedObjectsIds[$obj->targettype][]=$obj->fk_target;
} }
if ($obj->fk_target == $targetid) if ($obj->fk_target == $targetid)
{ {
$this->linked_object[$obj->sourcetype][]=$obj->fk_source; $this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source;
} }
$i++; $i++;
} }
}
else if (! empty($this->linkedObjectsIds))
{ {
dol_print_error($this->db); foreach($this->linkedObjectsIds as $objecttype => $objectids)
}
}
/**
* Fetch objects linked
*/
function fetch_object_linked($sourceid='',$sourcetype='',$targetid='',$targettype='',$clause='OR')
{
global $conf;
$this->linkedObjects=array();
$this->load_object_linked($sourceid,$sourcetype,$targetid,$targettype,$clause);
foreach($this->linked_object as $objecttype => $objects)
{ {
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $subelement = $objecttype; $module = $element = $subelement = $objecttype;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{ {
$element = $regs[1]; $module = $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
} }
@ -1240,8 +1229,8 @@ class CommonObject
// To work with non standard path // To work with non standard path
if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; }
if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; }
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; } if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; }
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; } if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; }
if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; } if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; }
if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; } if ($objecttype == 'order_supplier') { $classpath = 'fourn/class'; }
@ -1249,16 +1238,16 @@ class CommonObject
if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; } if ($objecttype == 'invoice_supplier') { $classfile = 'fournisseur.facture'; $classname='FactureFournisseur'; }
if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; } if ($objecttype == 'order_supplier') { $classfile = 'fournisseur.commande'; $classname='CommandeFournisseur'; }
if ($conf->$element->enabled) if ($conf->$module->enabled && $element != $this->element)
{ {
dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
$num=sizeof($objects); $num=sizeof($objectids);
for ($i=0;$i<$num;$i++) for ($i=0;$i<$num;$i++)
{ {
$object = new $classname($this->db); $object = new $classname($this->db);
$ret = $object->fetch($objects[$i]); $ret = $object->fetch($objectids[$i]);
if ($ret >= 0) if ($ret >= 0)
{ {
$this->linkedObjects[$objecttype][$i] = $object; $this->linkedObjects[$objecttype][$i] = $object;
@ -1267,6 +1256,12 @@ class CommonObject
} }
} }
} }
}
else
{
dol_print_error($this->db);
}
}
/** /**
* Set statut of an object * Set statut of an object
@ -1443,20 +1438,16 @@ class CommonObject
/* This is to show linked object block */ /* This is to show linked object block */
/** /**
* Show linked object block * Show linked object block
* TODO Move this into html.class.php * TODO Move this into html.class.php
* But for the moment we don't know if it'st possible as we keep a method available on overloaded objects. * But for the moment we don't know if it'st possible as we keep a method available on overloaded objects.
* @param $objecttype Type of object (invoice, propal, order, invoice_supplier, order_supplier, ...)
* @param $objectid
* @param $somethingshown
*/ */
function showLinkedObjectBlock($somethingshown=0) function showLinkedObjectBlock()
{ {
global $langs,$bc; global $langs,$bc;
$this->fetch_object_linked(); $this->fetchObjectLinked();
$num = sizeof($this->linkedObjects); $num = sizeof($this->linkedObjects);
@ -1485,49 +1476,6 @@ class CommonObject
} }
return $num; return $num;
//print 'objecttype='.$objecttype.'<br>';
/*
$this->objectid = $objectid;
$num = sizeof($this->objectid);
if ($num)
{
$element = $subelement = $objecttype;
$tplpath = $element;
if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
{
$element = $regs[1];
$subelement = $regs[2];
$tplpath = $element.'/'.$subelement;
}
$classpath = $element.'/class';
// To work with non standard path
if ($objecttype == 'facture') { $tplpath = 'compta/'.$element; $classpath = $tplpath.'/class'; }
if ($objecttype == 'propal') { $tplpath = 'comm/'.$element; $classpath = $tplpath.'/class'; }
if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; }
if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; }
if ($objecttype == 'invoice_supplier') { $tplpath = 'fourn/facture'; $classpath = 'fourn/class'; }
if ($objecttype == 'order_supplier') { $tplpath = 'fourn/commande'; $classpath = 'fourn/class'; }
$classfile = strtolower($subelement); $classname = ucfirst($subelement);
if ($objecttype == 'invoice_supplier') { $classfile='fournisseur.facture'; $classname='FactureFournisseur'; }
if ($objecttype == 'order_supplier') { $classfile='fournisseur.commande'; $classname='CommandeFournisseur'; }
//print $classfile." - ".$classpath." - ".$tplpath;
if(!class_exists($classname))
{
dol_include_once("/".$classpath."/".$classfile.".class.php");
}
$this->linkedObjectBlock = new $classname($this->db);
dol_include_once('/'.$tplpath.'/tpl/linkedobjectblock.tpl.php');
return $num;
}
*/
} }

View File

@ -681,7 +681,7 @@ else
$soc->fetch($expedition->socid); $soc->fetch($expedition->socid);
// delivery link // delivery link
$expedition->load_object_linked($expedition->id,$expedition->element,-1,-1); $expedition->fetchObjectLinked($expedition->id,$expedition->element,-1,-1);
$head=shipping_prepare_head($expedition); $head=shipping_prepare_head($expedition);
dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending'); dol_fiche_head($head, 'shipping', $langs->trans("Sending"), 0, 'sending');
@ -1076,7 +1076,7 @@ else
} }
} }
if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && empty($expedition->linked_object)) if ($conf->livraison_bon->enabled && $expedition->statut == 1 && $user->rights->expedition->livraison->creer && empty($expedition->linkedObjectsIds))
{ {
print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>'; print '<a class="butAction" href="fiche.php?id='.$expedition->id.'&amp;action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>';
} }

View File

@ -247,7 +247,7 @@ if ($id > 0 || ! empty($ref))
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Delivery date planed // Delivery date planned
print '<tr><td height="10">'; print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateDeliveryPlanned'); print $langs->trans('DateDeliveryPlanned');
@ -656,9 +656,7 @@ if ($id > 0 || ! empty($ref))
} }
} }
show_list_sending_receive('commande',$commande->id); show_list_sending_receive('commande',$commande->id);
} }
else else
{ {

View File

@ -1430,18 +1430,7 @@ if ($id > 0 || ! empty($ref))
/* /*
* Linked object block * Linked object block
*/ */
$object->load_object_linked($object->id,$object->element); $somethingshown=$object->showLinkedObjectBlock();
foreach($object->linked_object as $linked_object => $linked_objectid)
{
$tmpmodule=$linked_object;
if ($linked_object == 'invoice_supplier') $tmpmodule='fournisseur';
if ($linked_object == 'order_supplier') $tmpmodule='fournisseur';
if($conf->$tmpmodule->enabled && $linked_object != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';

View File

@ -1847,18 +1847,7 @@ else
/* /*
* Linked object block * Linked object block
*/ */
$object->load_object_linked($object->id,$object->element); $somethingshown=$object->showLinkedObjectBlock();
foreach($object->linked_object as $linked_object => $linked_objectid)
{
$tmpmodule=$linked_object;
if ($linked_object == 'invoice_supplier') $tmpmodule='fournisseur';
if ($linked_object == 'order_supplier') $tmpmodule='fournisseur';
if($conf->$tmpmodule->enabled && $linked_object != $object->element)
{
$somethingshown=$object->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown);
}
}
print '</td><td valign="top" width="50%">'; print '</td><td valign="top" width="50%">';
print '<br>'; print '<br>';

View File

@ -1092,60 +1092,37 @@ class pdf_crabe extends ModelePDFFactures
// Add list of linked orders and proposals // Add list of linked orders and proposals
// TODO mutualiser // TODO mutualiser
$object->load_object_linked(); $object->fetchObjectLinked();
if ($conf->propal->enabled) foreach($object->linkedObjects as $objecttype => $objects)
{
if ($objecttype == 'propal')
{ {
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
$outputlangs->load('propal'); $outputlangs->load('propal');
foreach($object->linked_object as $key => $val) $num=sizeof($objects);
{ for ($i=0;$i<$num;$i++)
if ($key == 'propal')
{
for ($i = 0; $i<sizeof($val);$i++)
{
$newobject=new Propal($this->db);
$result=$newobject->fetch($val[$i]);
if ($result >= 0)
{ {
$posy+=4; $posy+=4;
$pdf->SetXY(100,$posy); $pdf->SetXY(100,$posy);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R');
} }
} }
} else if ($objecttype == 'commande')
}
}
// TODO mutualiser
if ($conf->commande->enabled)
{ {
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
$outputlangs->load('orders'); $outputlangs->load('orders');
foreach($object->linked_object as $key => $val) $num=sizeof($objects);
{ for ($i=0;$i<$num;$i++)
if ($key == 'commande')
{
for ($i = 0; $i<sizeof($val);$i++)
{
$newobject=new Commande($this->db);
$result=$newobject->fetch($val[$i]);
if ($result >= 0)
{ {
$posy+=4; $posy+=4;
$pdf->SetXY(100,$posy); $pdf->SetXY(100,$posy);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$text=$newobject->ref; $text=$objects[$i]->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
} }
} }
} }
}
}
if ($showaddress) if ($showaddress)
{ {

View File

@ -962,61 +962,37 @@ class pdf_oursin extends ModelePDFFactures
} }
// Add list of linked orders and proposals // Add list of linked orders and proposals
$object->load_object_linked();
// TODO mutualiser // TODO mutualiser
if ($conf->propal->enabled) $object->fectObjectLinked();
{
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
foreach($object->linkedObjects as $objecttype => $objects)
{
if ($objecttype == 'propal')
{
$outputlangs->load('propal'); $outputlangs->load('propal');
foreach($object->linked_object as $key => $val) $num=sizeof($objects);
{ for ($i=0;$i<$num;$i++)
if ($key == 'propal')
{
for ($i = 0; $i<sizeof($val);$i++)
{
$newobject=new Propal($this->db);
$result=$newobject->fetch($val['linkid']);
if ($result >= 0)
{ {
$posy+=4; $posy+=4;
$pdf->SetXY($this->marges['g'],$posy); $pdf->SetXY($this->marges['g'],$posy);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref)); $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref));
} }
} }
} else if ($objecttype == 'commande')
}
}
// TODO mutualiser
if ($conf->commande->enabled)
{ {
require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); $num=sizeof($objects);
for ($i=0;$i<$num;$i++)
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
if ($key == 'commande')
{
for ($i = 0; $i<sizeof($val);$i++)
{
$newobject=new Propal($this->db);
$result=$newobject->fetch($val[$i]);
if ($result >= 0)
{ {
$posy+=4; $posy+=4;
$pdf->SetXY($this->marges['g'],$posy); $pdf->SetXY($this->marges['g'],$posy);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$text=$newobject->ref; $text=$objects[$i]->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
$pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text)); $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text));
} }
} }
} }
}
}
// Amount in (at tab_top - 1) // Amount in (at tab_top - 1)
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -420,7 +420,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
// Add origin linked objects // Add origin linked objects
// TODO extend to other objects // TODO extend to other objects
$object->fetch_object_linked('','',$object->id,'delivery'); $object->getObjectLinked('','',$object->id,'delivery');
if (! empty($object->linkedObjects)) if (! empty($object->linkedObjects))
{ {
@ -428,7 +428,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
foreach($object->linkedObjects as $elementtype => $objects) foreach($object->linkedObjects as $elementtype => $objects)
{ {
$object->fetch_object_linked('','',$objects[0]->id,$objects[0]->element); $object->getObjectLinked('','',$objects[0]->id,$objects[0]->element);
foreach($object->linkedObjects as $elementtype => $objects) foreach($object->linkedObjects as $elementtype => $objects)
{ {

View File

@ -549,7 +549,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
// Add origin linked objects // Add origin linked objects
// TODO extend to other objects // TODO extend to other objects
$object->fetch_object_linked('','',$object->id,'delivery'); $object->getObjectLinked('','',$object->id,'delivery');
if (! empty($object->linkedObjects)) if (! empty($object->linkedObjects))
{ {
@ -557,7 +557,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
foreach($object->linkedObjects as $elementtype => $objects) foreach($object->linkedObjects as $elementtype => $objects)
{ {
$object->fetch_object_linked('','',$objects[0]->id,$objects[0]->element); $object->getObjectLinked('','',$objects[0]->id,$objects[0]->element);
foreach($object->linkedObjects as $elementtype => $objects) foreach($object->linkedObjects as $elementtype => $objects)
{ {

View File

@ -385,32 +385,26 @@ class pdf_baleine extends ModelePDFProjects
// Add list of linked orders // Add list of linked orders
// TODO mutualiser // TODO mutualiser
$object->load_object_linked(); $object->fecthObjectLinked();
if ($conf->commande->enabled) foreach($object->linkedObjects as $objecttype => $objects)
{
if ($objecttype == 'commande')
{ {
$outputlangs->load('orders'); $outputlangs->load('orders');
foreach($object->linked_object as $key => $val) $num=sizeof($objects);
{ for ($i=0;$i<$num;$i++)
if ($key == 'commande')
{
for ($i = 0; $i<sizeof($val);$i++)
{
$newobject=new Commande($this->db);
$result=$newobject->fetch($val[$i]);
if ($result >= 0)
{ {
$posy+=4; $posy+=4;
$pdf->SetXY(100,$posy); $pdf->SetXY(100,$posy);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$text=$newobject->ref; $text=$objects[$i]->ref;
if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')';
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
} }
} }
} }
}
}
} }

View File

@ -41,9 +41,9 @@ function shipping_prepare_head($object)
$head[$h][2] = 'shipping'; $head[$h][2] = 'shipping';
$h++; $h++;
if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && $object->linked_object['delivery'][0]) if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && ! empty($object->linkedObjectsIds['delivery'][0]))
{ {
$head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linked_object['delivery'][0]; $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linkedObjectsIds['delivery'][0];
$head[$h][1] = $langs->trans("DeliveryCard"); $head[$h][1] = $langs->trans("DeliveryCard");
$head[$h][2] = 'delivery'; $head[$h][2] = 'delivery';
$h++; $h++;
@ -216,14 +216,12 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
{ {
include_once(DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'); include_once(DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php');
$expedition->id=$objp->sendingid; $expedition->id=$objp->sendingid;
$expedition->load_object_linked($expedition->id,$expedition->element,-1,-1); $expedition->fetchObjectLinked($expedition->id,$expedition->element);
$livraison_id=$expedition->linked_object['delivery'][0]; //var_dump($expedition->linkedObjects);
$receiving=$expedition->linkedObjects['delivery'][0];
if ($livraison_id) if (! empty($receiving))
{ {
$receiving=new Livraison($db);
$receiving->fetch($livraison_id);
// $expedition->fk_origin_line = id of det line of order // $expedition->fk_origin_line = id of det line of order
// $receiving->fk_origin_line = id of det line of order // $receiving->fk_origin_line = id of det line of order
// $receiving->origin may be 'shipping' // $receiving->origin may be 'shipping'

View File

@ -798,18 +798,19 @@ class Livraison extends CommonObject
/** /**
* \brief Renvoie la quantite de produit restante a livrer pour une commande * \brief Renvoie la quantite de produit restante a livrer pour une commande
* \return array Product remaining to be delivered * \return array Product remaining to be delivered
* TODO use new function
*/ */
function getRemainingDelivered() function getRemainingDelivered()
{ {
global $langs; global $langs;
// Get the linked object // Get the linked object
$this->load_object_linked(-1,-1,$this->id,$this->element); $this->fetchObjectLinked(-1,-1,$this->id,$this->element);
//var_dump($this->linkedObjectIds);
// Get the product ref and qty in source // Get the product ref and qty in source
$sqlSourceLine = "SELECT st.rowid, st.description, st.qty"; $sqlSourceLine = "SELECT st.rowid, st.description, st.qty";
$sqlSourceLine.= ", p.ref, p.label"; $sqlSourceLine.= ", p.ref, p.label";
$sqlSourceLine.= " FROM ".MAIN_DB_PREFIX.$this->linked_object[0]['type']."det as st"; $sqlSourceLine.= " FROM ".MAIN_DB_PREFIX.$this->linkedObjectIds[0]['type']."det as st";
$sqlSourceLine.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid"; $sqlSourceLine.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON st.fk_product = p.rowid";
$sqlSourceLine.= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid']; $sqlSourceLine.= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];