diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index f608f13a31432d9fa7ec6c9e260f42b83d018305..b6ad369045275c971bea7f72eb8a5a863c6668cc 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -110,15 +110,7 @@ $form=new Form($db); * * Put here code to view linked object ****************************************************/ -$myobject->load_object_linked($myobject->id,$myobject->element); - -foreach($myobject->linked_object as $linked_object => $linked_objectid) -{ - if ($conf->$linked_object->enabled) - { - $somethingshown=$myobject->showLinkedObjectBlock($linked_object,$linked_objectid,$somethingshown); - } -} +$somethingshown=$myobject->showLinkedObjectBlock(); // End of page $db->close(); diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5d2da968f2728e3e38dffe80eee08bb7063b24c1..44efe37695da409d5b45100ed0dfaaf449771d9f 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1646,22 +1646,7 @@ if ($id > 0 || ! empty($ref)) /* * Linked object block */ - $object->load_object_linked($object->id,$object->element); - //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); - } - } + $somethingshown=$object->showLinkedObjectBlock(); print '</td><td valign="top" width="50%">'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 806b105d8b911b0a2d2098a4b60236a441e09088..71749ff7043b2a0ce5bdab4577a564e453377228 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1637,25 +1637,27 @@ class Propal extends CommonObject $ga = array(); $linkedInvoices = array(); - $this->load_object_linked($id,$this->element); - foreach($this->linked_object as $object => $objectid) + $this->fetchObjectLinked($id,$this->element); + 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 - if ($object == 'facture') + if ($objecttype == 'facture') { $linkedInvoices[] = $objectid[$i]; } // Cas des factures liees via la commande else { - $this->load_object_linked($objectid[$i],$object,-1,-1); - foreach($this->linked_object as $object => $objectid) + $this->fetchObjectLinked($objectid[$i],$objecttype); + 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]; } } } diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 6f3bcab5ca71ef0bb481e3a7802b88b71001b394..a938d5f01f47ea434c7c54fc16f78f6ddad8efb3 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,5 @@ <?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 * it under the terms of the GNU General Public License as published by @@ -24,12 +24,9 @@ <?php $langs = $GLOBALS['langs']; -$somethingshown = $GLOBALS['somethingshown']; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; -$objectid = $GLOBALS['object']->objectid; -$num = count($objectid); -if ($somethingshown) { echo '<br>'; } +echo '<br />'; print_titre($langs->trans('RelatedCommercialProposals')); ?> <table class="noborder" width="100%"> @@ -42,20 +39,19 @@ print_titre($langs->trans('RelatedCommercialProposals')); </tr> <?php $var=true; -for ($i = 0 ; $i < $num ; $i++) +foreach($linkedObjectBlock as $object) { - $linkedObjectBlock->fetch($objectid[$i]); $var=!$var; ?> <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> - <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> + <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 $object->ref_client; ?></td> + <td align="center"><?php echo dol_print_date($object->date,'day'); ?></td> + <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $linkedObjectBlock->total_ht; +$total = $total + $object->total_ht; } ?> diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 982ed2b76f1c594f04a4a87108483f05cd4c903c..93db1b1dacb3e5c036f9fb14e54562752438de19 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -2025,21 +2025,7 @@ else /* * Linked object block */ - $object->load_object_linked(); - - 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); - } - } + $somethingshown=$object->showLinkedObjectBlock(); print '</td><td valign="top" width="50%">'; diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php index 907a9e91f1a4b687485c88268149dbf2988158c0..38ec280b7192874d1db9b159c9753c086169a858 100644 --- a/htdocs/commande/liste.php +++ b/htdocs/commande/liste.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * 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 * it under the terms of the GNU General Public License as published by diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index a149e6dbde92d7bd83b32b8034f1e243a5f43992..50bf6f657aa1d7f9b01e8cb67fae6efd56f974d0 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,5 @@ <?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 * it under the terms of the GNU General Public License as published by @@ -24,13 +24,10 @@ <?php $langs = $GLOBALS['langs']; -$somethingshown = $GLOBALS['somethingshown']; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; -$objectid = $GLOBALS['object']->objectid; -$num = count($objectid); $langs->load("orders"); -if ($somethingshown) { echo '<br>'; } +echo '<br />'; print_titre($langs->trans('RelatedOrders')); ?> @@ -43,19 +40,18 @@ print_titre($langs->trans('RelatedOrders')); </tr> <?php $var=true; -for ($i = 0 ; $i < $num ; $i++) +foreach($linkedObjectBlock as $object) { - $linkedObjectBlock->fetch($objectid[$i]); $var=!$var; ?> <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> - <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> + <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($object->date,'day'); ?></td> + <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $linkedObjectBlock->total_ht; +$total = $total + $object->total_ht; } ?> diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c2106eab3069be1cf95a1fbda5b3b3b44daa19c9..9ca28ef8430360014039918e0c2c9dc6764d31aa 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2793,21 +2793,7 @@ else /* * Linked object block */ - $object->load_object_linked($object->id,$object->element); - - 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); - } - } + $somethingshown=$object->showLinkedObjectBlock(); print '</td><td valign="top" width="50%">'; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4e6684b80df01657bc529243d59ddd6253d03a85..4122565ac4bff0b52da947ad4a33d9ff33dc028b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2435,7 +2435,7 @@ class Facture extends CommonObject } $obj = new $classname(); - + $numref = ""; $numref = $obj->getNumRef($soc,$this,$mode); @@ -2445,8 +2445,8 @@ class Facture extends CommonObject } else { - dol_print_error($db,"Facture::getNextNumRef ".$obj->error); - return ''; + //dol_print_error($db,"Facture::getNextNumRef ".$obj->error); + return false; } } diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 9ae24b91c0a0a7fcf6fe04524d12b8427721f468..14886dfea6a821bf98d529a6cbd93f6d0e8e66dc 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,5 @@ <?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 * it under the terms of the GNU General Public License as published by @@ -24,13 +24,10 @@ <?php $langs = $GLOBALS['langs']; -$somethingshown = $GLOBALS['somethingshown']; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; -$objectid = $GLOBALS['object']->objectid; -$num = count($objectid); $langs->load("bills"); -if ($somethingshown) { echo '<br>'; } +echo '<br />'; if ($num > 1) print_titre($langs->trans("RelatedBills")); else print_titre($langs->trans("RelatedBill")); ?> @@ -43,19 +40,18 @@ else print_titre($langs->trans("RelatedBill")); </tr> <?php $var=true; -for ($i = 0 ; $i < $num ; $i++) +foreach($linkedObjectBlock as $object) { - $linkedObjectBlock->fetch($objectid[$i]); $var=!$var; ?> <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> - <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> + <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($object->date,'day'); ?></td> + <td align="right"><?php echo price($object->total_ht); ?></td> + <td align="right"><?php echo $object->getLibStatut(3); ?></td> </tr> <?php -$total = $total + $linkedObjectBlock->total_ht; +$total = $total + $object->total_ht; } ?> <tr class="liste_total"> diff --git a/htdocs/compta/journal/index.php b/htdocs/compta/journal/index.php index 6bda394af3f4a4689a9bdc7dee5ec3cb90144bfa..025d672f09424d59ed3395f3b73a683405fa22a2 100755 --- a/htdocs/compta/journal/index.php +++ b/htdocs/compta/journal/index.php @@ -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 diff --git a/htdocs/compta/propal.php b/htdocs/compta/propal.php index 06e2d8607d3ff3447a723fa246f0d2091e6fdc85..9b534dc4a0406235548ff60167ad30cea91ed541 100644 --- a/htdocs/compta/propal.php +++ b/htdocs/compta/propal.php @@ -74,6 +74,7 @@ else if (! empty($_GET["id"])) if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, $module, $objectid, $dbtable); +$object = new Propal($db); /******************************************************************************/ @@ -83,18 +84,16 @@ $result = restrictedArea($user, $module, $objectid, $dbtable); if ($_GET["action"] == 'setstatut') { // Close proposal - $propal = new Propal($db); - $propal->id = $_GET["id"]; - $propal->cloture($user, $_GET["statut"], $note); + $object->id = $_GET["id"]; + $object->cloture($user, $_GET["statut"], $note); } // Set project if ($_POST['action'] == 'classin') { - $propal = new Propal($db); - $propal->fetch($_GET["id"]); - $propal->setProject($_POST['projectid']); + $object->fetch($_GET["id"]); + $object->setProject($_POST['projectid']); } @@ -122,13 +121,12 @@ if ($id > 0 || ! empty($ref)) $product_static=new Product($db); - $propal = new Propal($db); - $propal->fetch($_GET["id"],$_GET["ref"]); + $object->fetch($_GET["id"],$_GET["ref"]); $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'); @@ -141,7 +139,7 @@ if ($id > 0 || ! empty($ref)) // Ref 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>'; // Ref client @@ -149,10 +147,10 @@ if ($id > 0 || ! empty($ref)) print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; print $langs->trans('RefCustomer').'</td><td align="left">'; print '</td>'; - if ($_GET['action'] != 'refclient' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refclient&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&id='.$object->id.'">'.img_edit($langs->trans('Modify')).'</a></td>'; print '</tr></table>'; print '</td><td colspan="5">'; - print $propal->ref_client; + print $object->ref_client; print '</td>'; print '</tr>'; @@ -174,7 +172,7 @@ if ($id > 0 || ! empty($ref)) // Dates 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>'; if ($conf->projet->enabled) $rowspan++; @@ -187,16 +185,16 @@ if ($id > 0 || ! empty($ref)) } // 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>'; // Date fin propal print '<tr>'; 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'); - if ($propal->statut == 1 && $propal->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + print dol_print_date($object->fin_validite,'daytext'); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); } else { @@ -210,16 +208,16 @@ if ($id > 0 || ! empty($ref)) print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('PaymentConditionsShort'); print '</td>'; - if ($_GET['action'] != 'editconditions' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&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&id='.$object->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; 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 { - $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>'; @@ -229,16 +227,16 @@ if ($id > 0 || ! empty($ref)) print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('PaymentMode'); print '</td>'; - if ($_GET['action'] != 'editmode' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&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&id='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; 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 { - $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>'; @@ -251,28 +249,28 @@ if ($id > 0 || ! empty($ref)) print $langs->trans('Project').'</td>'; if (1 == 2 && $user->rights->propale->creer) { - if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&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&id='.$object->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>'; print '</tr></table>'; print '</td><td colspan="3">'; 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 { - $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>'; } else { print '</td></tr></table>'; - if (!empty($propal->fk_project)) + if (!empty($object->fk_project)) { print '<td colspan="3">'; $project = new Project($db); - $project->fetch($propal->fk_project); - print '<a href="../projet/fiche.php?id='.$propal->fk_project.'" title="'.$langs->trans('ShowProject').'">'; + $project->fetch($object->fk_project); + print '<a href="../projet/fiche.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; print $project->ref; print '</a>'; print '</td>'; @@ -287,10 +285,10 @@ if ($id > 0 || ! empty($ref)) // Amount 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 '<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>'; // Amount Local Taxes @@ -299,24 +297,24 @@ if ($id > 0 || ! empty($ref)) if ($mysoc->localtax1_assuj=="1") //Localtax1 RE { 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>'; } if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF { 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 '<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>'; // 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>'; /* @@ -332,7 +330,7 @@ if ($id > 0 || ! empty($ref)) $sql.= ' p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; $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'; $resql = $db->query($sql); if ($resql) @@ -402,7 +400,7 @@ if ($id > 0 || ! empty($ref)) print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne 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 '</a>'; if ($objp->description) @@ -477,17 +475,17 @@ if ($id > 0 || ! empty($ref)) */ 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(); - if ($propal->statut == 2 && is_array($arraypropal) && sizeof($arraypropal) > 0) + $arraypropal=$object->getInvoiceArrayList(); + 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>"; @@ -500,9 +498,9 @@ if ($id > 0 || ! empty($ref)) /* * Documents generes */ - $filename=dol_sanitizeFileName($propal->ref); - $filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($propal->ref); - $urlsource=$_SERVER["PHP_SELF"]."?id=".$propal->id; + $filename=dol_sanitizeFileName($object->ref); + $filedir=$conf->propale->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=0; $delallowed=0; @@ -514,22 +512,14 @@ if ($id > 0 || ! empty($ref)) /* * Linked object block */ - $propal->load_object_linked($propal->id,$propal->element); - - 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); - } - } + $somethingshown=$object->showLinkedObjectBlock(); print '</td><td valign="top" width="50%">'; // List of actions on element include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($propal,'propal',$socid); + $somethingshown=$formactions->showactions($object,'propal',$socid); print '</td></tr></table>'; diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index 77488a72e1af2c52d468d5953624ac6d600a85bb..f3e6b5090bc24ee5218e4022bcae0b4ee1b96d57 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -1259,28 +1259,16 @@ else print "</div>"; print '<br>'; } + + print '<table width="100%"><tr><td width="50%" valign="top">'; /* * Linked object block */ - $object->load_object_linked($object->id,$object->element); - - 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></tr></table>'; - } - + $somethingshown=$object->showLinkedObjectBlock(); + + print '</td><td valign="top" width="50%">'; + print '</td></tr></table>'; } } diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php index b5d87016ecbfe058dfdef99e5c4a509bc175820d..065fdbe377dd35ee53b016d58850457b687c0e2b 100644 --- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php +++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php @@ -1,5 +1,5 @@ <?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 * it under the terms of the GNU General Public License as published by @@ -24,13 +24,10 @@ <?php $langs = $GLOBALS['langs']; -$somethingshown = $GLOBALS['somethingshown']; $linkedObjectBlock = $GLOBALS['object']->linkedObjectBlock; -$objectid = $GLOBALS['object']->objectid; -$num = count($objectid); $langs->load("contracts"); -if ($somethingshown) { echo '<br>'; } +echo '<br />'; print_titre($langs->trans('RelatedContracts')); ?> <table class="noborder" width="100%"> @@ -42,17 +39,16 @@ print_titre($langs->trans('RelatedContracts')); </tr> <?php $var=true; -for ($i = 0 ; $i < $num ; $i++) +foreach($linkedObjectBlock as $object) { - $linkedObjectBlock->fetch($objectid[$i]); - $linkedObjectBlock->fetch_lines(); + $object->fetch_lines(); $var=!$var; ?> <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> - <td align="center"><?php echo dol_print_date($linkedObjectBlock->date_contrat,'day'); ?></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($object->date_contrat,'day'); ?></td> <td align="right"> </td> - <td align="right"><?php echo $linkedObjectBlock->getLibStatut(6); ?></td> + <td align="right"><?php echo $object->getLibStatut(6); ?></td> </tr> <?php } ?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 75528b078245800ecf74b829b724161b11c7f554..6873b20b1ceeacf9ff3cd0032e56e57cc6e523e3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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 sourcetype * @param targetid * @param targettype * @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; $justtarget=false; @@ -1168,10 +1171,10 @@ class CommonObject if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $justsource=true; if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $justtarget=true; - $sourceid = (!empty($sourceid)?$sourceid:$this->id); - $targetid = (!empty($targetid)?$targetid:$this->id); - $sourcetype = (!empty($sourcetype)?$sourcetype:$this->origin); - $targettype = (!empty($targettype)?$targettype:$this->element); + $sourceid = (! empty($sourceid) ? $sourceid : $this->id ); + $targetid = (! empty($targetid) ? $targetid : $this->id ); + $sourcetype = (! empty($sourcetype) ? $sourcetype : (! empty($this->origin) ? $this->origin : $this->element ) ); + $targettype = (! empty($targettype) ? $targettype : $this->element ); // Links beetween objects are stored in this table $sql = 'SELECT fk_source, sourcetype, fk_target, targettype'; @@ -1187,8 +1190,9 @@ class CommonObject $sql.= "(fk_source = '".$sourceid."' AND sourcetype = '".$sourcetype."')"; $sql.= " ".$clause." (fk_target = '".$targetid."' AND targettype = '".$targettype."')"; } - - dol_syslog("CommonObject::load_object_linked sql=".$sql); + //print $sql; + + dol_syslog("CommonObject::fetchObjectLink sql=".$sql); $resql = $this->db->query($sql); if ($resql) { @@ -1199,72 +1203,63 @@ class CommonObject $obj = $this->db->fetch_object($resql); 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) { - $this->linked_object[$obj->sourcetype][]=$obj->fk_source; + $this->linkedObjectsIds[$obj->sourcetype][]=$obj->fk_source; } $i++; } - } - else - { - dol_print_error($this->db); - } - } - - /** - * 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) - $element = $subelement = $objecttype; - if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - } - $classpath = $element.'/class'; - - // To work with non standard path - if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } - if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } - if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; } - if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; } - if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; } - if ($objecttype == 'order_supplier') { $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'; } - - if ($conf->$element->enabled) - { - dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); - - $num=sizeof($objects); - - for ($i=0;$i<$num;$i++) + if (! empty($this->linkedObjectsIds)) + { + foreach($this->linkedObjectsIds as $objecttype => $objectids) { - $object = new $classname($this->db); - $ret = $object->fetch($objects[$i]); - if ($ret >= 0) + // Parse element/subelement (ex: project_task) + $module = $element = $subelement = $objecttype; + if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs)) { - $this->linkedObjects[$objecttype][$i] = $object; + $module = $element = $regs[1]; + $subelement = $regs[2]; } + + $classpath = $element.'/class'; + + // To work with non standard path + if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } + if ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } + if ($objecttype == 'shipping') { $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; } + if ($objecttype == 'delivery') { $classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon'; } + if ($objecttype == 'invoice_supplier') { $classpath = 'fourn/class'; } + if ($objecttype == 'order_supplier') { $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'; } + + if ($conf->$module->enabled && $element != $this->element) + { + dol_include_once('/'.$classpath.'/'.$classfile.'.class.php'); + + $num=sizeof($objectids); + + for ($i=0;$i<$num;$i++) + { + $object = new $classname($this->db); + $ret = $object->fetch($objectids[$i]); + if ($ret >= 0) + { + $this->linkedObjects[$objecttype][$i] = $object; + } + } + } } - } + } + } + else + { + dol_print_error($this->db); } } @@ -1443,23 +1438,19 @@ class CommonObject /* This is to show linked object block */ - /** * Show linked object block * 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. - * @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; - $this->fetch_object_linked(); + $this->fetchObjectLinked(); $num = sizeof($this->linkedObjects); - + foreach($this->linkedObjects as $objecttype => $objects) { $tplpath = $element = $subelement = $objecttype; @@ -1485,49 +1476,6 @@ class CommonObject } 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; - } - */ } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index cdb219773f34ffcb218849ad7f1a887256040466..dc1f2f3928b0fb512b19386c959f9d40abeb811b 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -681,7 +681,7 @@ else $soc->fetch($expedition->socid); // 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); 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.'&action=create_delivery">'.$langs->trans("DeliveryOrder").'</a>'; } diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 00baf722bd7910dc6734f6eff3ade1ecae4f0ef0..dffd2222e98b70d9174df3fa6611be75a3d7b503 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -247,7 +247,7 @@ if ($id > 0 || ! empty($ref)) print '</td>'; print '</tr>'; - // Delivery date planed + // Delivery date planned print '<tr><td height="10">'; print '<table class="nobordernopadding" width="100%"><tr><td>'; print $langs->trans('DateDeliveryPlanned'); @@ -655,10 +655,8 @@ if ($id > 0 || ! empty($ref)) print '</div>'; } } - - + show_list_sending_receive('commande',$commande->id); - } else { diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 44691317db8683d17b65f3cd4da5c65b6eaa0152..beae15b6466c8e168e6c5fa08f70dfb137ba2136 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1430,18 +1430,7 @@ if ($id > 0 || ! empty($ref)) /* * Linked object block */ - $object->load_object_linked($object->id,$object->element); - - 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); - } - } + $somethingshown=$object->showLinkedObjectBlock(); print '</td><td valign="top" width="50%">'; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 72fa990c967d8a07526b6ae3f4143e5f02446582..c37087c9a1b018e4805d305f18b5f9b74a5bf5bb 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1847,18 +1847,7 @@ else /* * Linked object block */ - $object->load_object_linked($object->id,$object->element); - - 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); - } - } + $somethingshown=$object->showLinkedObjectBlock(); print '</td><td valign="top" width="50%">'; print '<br>'; diff --git a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php index 1c601d446d248e8ab6f5c4916e989937d12cd2f0..1085d89baa0e45534c04d9d649a5605b96c48533 100755 --- a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php @@ -1092,59 +1092,36 @@ class pdf_crabe extends ModelePDFFactures // Add list of linked orders and proposals // TODO mutualiser - $object->load_object_linked(); - - if ($conf->propal->enabled) - { - require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); - - $outputlangs->load('propal'); - foreach($object->linked_object as $key => $val) - { - 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; - $pdf->SetXY(100,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R'); - } - } - } + $object->fetchObjectLinked(); + + foreach($object->linkedObjects as $objecttype => $objects) + { + if ($objecttype == 'propal') + { + $outputlangs->load('propal'); + $num=sizeof($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY(100,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref), '', 'R'); + } } - } - - // TODO mutualiser - if ($conf->commande->enabled) - { - require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); - - $outputlangs->load('orders'); - foreach($object->linked_object as $key => $val) + else if ($objecttype == 'commande') { - 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; - $pdf->SetXY(100,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $text=$newobject->ref; - if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); - } - } - } - } + $outputlangs->load('orders'); + $num=sizeof($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY(100,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $text=$objects[$i]->ref; + if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); + } + } } if ($showaddress) diff --git a/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php b/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php index e22f877febbbd0e0643679b4c3879ca36641deb8..5caec8e66e116b3350d078771d9a74325896b890 100755 --- a/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/doc/pdf_oursin.modules.php @@ -962,59 +962,35 @@ class pdf_oursin extends ModelePDFFactures } // Add list of linked orders and proposals - $object->load_object_linked(); - - // TODO mutualiser - if ($conf->propal->enabled) - { - require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); - - $outputlangs->load('propal'); - foreach($object->linked_object as $key => $val) - { - 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; - $pdf->SetXY($this->marges['g'],$posy); - $pdf->SetFont('','', $default_font_size - 1); - $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref)); - } - } - } + // TODO mutualiser + $object->fectObjectLinked(); + + foreach($object->linkedObjects as $objecttype => $objects) + { + if ($objecttype == 'propal') + { + $outputlangs->load('propal'); + $num=sizeof($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY($this->marges['g'],$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($objects[$i]->ref)); + } } - } - - // TODO mutualiser - if ($conf->commande->enabled) - { - require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php"); - - $outputlangs->load('orders'); - foreach($object->linked_object as $key => $val) + else if ($objecttype == 'commande') { - 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; - $pdf->SetXY($this->marges['g'],$posy); - $pdf->SetFont('','', $default_font_size - 1); - $text=$newobject->ref; - if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; - $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text)); - } - } - } + $num=sizeof($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY($this->marges['g'],$posy); + $pdf->SetFont('','', $default_font_size - 1); + $text=$objects[$i]->ref; + if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; + $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text)); + } } } diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index 17cab6b2bd277370f64d00e64cd1f603fd885ef2..6adce5b8d0570985589af509bb1504d09ef0d43d 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> * 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> * * 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 // TODO extend to other objects - $object->fetch_object_linked('','',$object->id,'delivery'); + $object->getObjectLinked('','',$object->id,'delivery'); if (! empty($object->linkedObjects)) { @@ -428,7 +428,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder 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) { diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index 35cb1029295005fe894e2c3966ccc2355050f883..a38b7ae2bb7e61abbc8091e48257e7dbb14a0323 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -549,7 +549,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Add origin linked objects // TODO extend to other objects - $object->fetch_object_linked('','',$object->id,'delivery'); + $object->getObjectLinked('','',$object->id,'delivery'); if (! empty($object->linkedObjects)) { @@ -557,7 +557,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder 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) { diff --git a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php index 1b989cb76d548316b5af46f3988bbe515a47128d..b3170d2f77d2ede52661d570e7466bdadff67757 100644 --- a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php +++ b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php @@ -385,32 +385,26 @@ class pdf_baleine extends ModelePDFProjects // Add list of linked orders // TODO mutualiser - $object->load_object_linked(); + $object->fecthObjectLinked(); + + foreach($object->linkedObjects as $objecttype => $objects) + { + if ($objecttype == 'commande') + { + $outputlangs->load('orders'); + $num=sizeof($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY(100,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $text=$objects[$i]->ref; + if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); + } + } + } - if ($conf->commande->enabled) - { - $outputlangs->load('orders'); - foreach($object->linked_object as $key => $val) - { - 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; - $pdf->SetXY(100,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $text=$newobject->ref; - if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); - } - } - } - } - } } diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php index 73ccbaf5d98fcf9a94326438830e4f63d2ecad43..d41b1e818981522463e964aab7a31d709677ffa4 100644 --- a/htdocs/lib/sendings.lib.php +++ b/htdocs/lib/sendings.lib.php @@ -41,9 +41,9 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $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][2] = 'delivery'; $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'); $expedition->id=$objp->sendingid; - $expedition->load_object_linked($expedition->id,$expedition->element,-1,-1); - $livraison_id=$expedition->linked_object['delivery'][0]; + $expedition->fetchObjectLinked($expedition->id,$expedition->element); + //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 // $receiving->fk_origin_line = id of det line of order // $receiving->origin may be 'shipping' diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 3c37d9212c862b03acdc58b4d2436001b7b0ece7..973864348b680b5d40a541083217006356f0e85b 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -798,18 +798,19 @@ class Livraison extends CommonObject /** * \brief Renvoie la quantite de produit restante a livrer pour une commande * \return array Product remaining to be delivered + * TODO use new function */ function getRemainingDelivered() { global $langs; // 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 $sqlSourceLine = "SELECT st.rowid, st.description, st.qty"; $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.= " WHERE fk_".$this->linked_object[0]['type']." = ".$this->linked_object[0]['linkid'];