diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php
index f608f13a314..b6ad3690452 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 5d2da968f27..44efe37695d 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 '
';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 806b105d8b9..71749ff7043 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; $iload_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
+/* Copyright (C) 2010-2011 Regis Houssin
*
* 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 @@
linkedObjectBlock;
-$objectid = $GLOBALS['object']->objectid;
-$num = count($objectid);
-if ($somethingshown) { echo ' '; }
+echo ' ';
print_titre($langs->trans('RelatedCommercialProposals'));
?>
@@ -42,20 +39,19 @@ print_titre($langs->trans('RelatedCommercialProposals'));
fetch($objectid[$i]);
$var=!$var;
?>
>|
- trans("ShowPropal"),"propal").' '.$linkedObjectBlock->ref; ?> |
- ref_client; ?> |
- date,'day'); ?> |
- total_ht); ?> |
- getLibStatut(3); ?> |
+ trans("ShowPropal"),"propal").' '.$object->ref; ?>
+ ref_client; ?> |
+ date,'day'); ?> |
+ total_ht); ?> |
+ getLibStatut(3); ?> |
total_ht;
+$total = $total + $object->total_ht;
}
?>
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index 982ed2b76f1..93db1b1dacb 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 '';
diff --git a/htdocs/commande/liste.php b/htdocs/commande/liste.php
index 907a9e91f1a..38ec280b719 100644
--- a/htdocs/commande/liste.php
+++ b/htdocs/commande/liste.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2001-2005 Rodolphe Quiedeville
* Copyright (C) 2004-2008 Laurent Destailleur
* Copyright (C) 2005 Marc Barilley / Ocebo
- * Copyright (C) 2005-2010 Regis Houssin
+ * Copyright (C) 2005-2011 Regis Houssin
*
* 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 a149e6dbde9..50bf6f657aa 100644
--- a/htdocs/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2010-2011 Regis Houssin
*
* 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 @@
linkedObjectBlock;
-$objectid = $GLOBALS['object']->objectid;
-$num = count($objectid);
$langs->load("orders");
-if ($somethingshown) { echo ' '; }
+echo ' ';
print_titre($langs->trans('RelatedOrders'));
?>
@@ -43,19 +40,18 @@ print_titre($langs->trans('RelatedOrders'));
fetch($objectid[$i]);
$var=!$var;
?>
>|
- trans("ShowOrder"),"order").' '.$linkedObjectBlock->ref; ?> |
- date,'day'); ?> |
- total_ht); ?> |
- getLibStatut(3); ?> |
+ trans("ShowOrder"),"order").' '.$object->ref; ?>
+ date,'day'); ?> |
+ total_ht); ?> |
+ getLibStatut(3); ?> |
total_ht;
+$total = $total + $object->total_ht;
}
?>
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index c2106eab306..9ca28ef8430 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 ' | ';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 4e6684b80df..4122565ac4b 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 9ae24b91c0a..14886dfea6a 100644
--- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2010-2011 Regis Houssin
*
* 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 @@
linkedObjectBlock;
-$objectid = $GLOBALS['object']->objectid;
-$num = count($objectid);
$langs->load("bills");
-if ($somethingshown) { echo ' '; }
+echo ' ';
if ($num > 1) print_titre($langs->trans("RelatedBills"));
else print_titre($langs->trans("RelatedBill"));
?>
@@ -43,19 +40,18 @@ else print_titre($langs->trans("RelatedBill"));
fetch($objectid[$i]);
$var=!$var;
?>
>|
- trans("ShowBill"),"bill").' '.$linkedObjectBlock->ref; ?> |
- date,'day'); ?> |
- total_ht); ?> |
- getLibStatut(3); ?> |
+ trans("ShowBill"),"bill").' '.$object->ref; ?>
+ date,'day'); ?> |
+ total_ht); ?> |
+ getLibStatut(3); ?> |
total_ht;
+$total = $total + $object->total_ht;
}
?>
diff --git a/htdocs/compta/journal/index.php b/htdocs/compta/journal/index.php
index 6bda394af3f..025d672f094 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 06e2d8607d3..9b534dc4a04 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 ' | '.$langs->trans('Ref').' | ';
- print $html->showrefnav($propal,'ref',$linkback,1,'ref','ref','');
+ print $html->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print ' | ';
// Ref client
@@ -149,10 +147,10 @@ if ($id > 0 || ! empty($ref))
print '';
print ' | ';
- print $propal->ref_client;
+ print $object->ref_client;
print ' | ';
print '';
@@ -174,7 +172,7 @@ if ($id > 0 || ! empty($ref))
// Dates
print '| '.$langs->trans('Date').' | ';
- print dol_print_date($propal->date,'daytext');
+ print dol_print_date($object->date,'daytext');
print ' | ';
if ($conf->projet->enabled) $rowspan++;
@@ -187,16 +185,16 @@ if ($id > 0 || ! empty($ref))
}
// Note
- print ''.$langs->trans('NotePublic').' : '. nl2br($propal->note_public).' | ';
+ print ''.$langs->trans('NotePublic').' : '. nl2br($object->note_public).' | ';
print ' ';
// Date fin propal
print '';
print '| '.$langs->trans('DateEndPropal').' | ';
- 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 '';
print ' | ';
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 ' | ';
@@ -229,16 +227,16 @@ if ($id > 0 || ! empty($ref))
print '';
print '';
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 ' | ';
@@ -251,28 +249,28 @@ if ($id > 0 || ! empty($ref))
print $langs->trans('Project').'';
if (1 == 2 && $user->rights->propale->creer)
{
- if ($_GET['action'] != 'classer') print ''.img_edit($langs->trans('SetProject')).' | ';
+ if ($_GET['action'] != 'classer') print ''.img_edit($langs->trans('SetProject')).' | ';
print ' ';
print ' | ';
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 ' | ';
}
else
{
print '';
- if (!empty($propal->fk_project))
+ if (!empty($object->fk_project))
{
print '';
$project = new Project($db);
- $project->fetch($propal->fk_project);
- print '';
+ $project->fetch($object->fk_project);
+ print '';
print $project->ref;
print '';
print ' | ';
@@ -287,10 +285,10 @@ if ($id > 0 || ! empty($ref))
// Amount
print '| '.$langs->trans('AmountHT').' | ';
- print ''.price($propal->total_ht).' | ';
+ print ''.price($object->total_ht).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
- print '| '.$langs->trans('AmountVAT').' | '.price($propal->total_tva).' | ';
+ print '
| '.$langs->trans('AmountVAT').' | '.price($object->total_tva).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
// Amount Local Taxes
@@ -299,24 +297,24 @@ if ($id > 0 || ! empty($ref))
if ($mysoc->localtax1_assuj=="1") //Localtax1 RE
{
print '| '.$langs->transcountry("AmountLT1",$mysoc->pays_code).' | ';
- print ''.price($propal->total_localtax1).' | ';
+ print ''.price($object->total_localtax1).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
}
if ($mysoc->localtax2_assuj=="1") //Localtax2 IRPF
{
print '| '.$langs->transcountry("AmountLT2",$mysoc->pays_code).' | ';
- print ''.price($propal->total_localtax2).' | ';
+ print ''.price($object->total_localtax2).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
}
}
- print '| '.$langs->trans('AmountTTC').' | '.price($propal->total_ttc).' | ';
+ print '
| '.$langs->trans('AmountTTC').' | '.price($object->total_ttc).' | ';
print ''.$langs->trans("Currency".$conf->monnaie).' |
';
// Statut
- print '| '.$langs->trans('Status').' | '.$propal->getLibStatut(4).' |
';
+ print '| '.$langs->trans('Status').' | '.$object->getLibStatut(4).' |
';
print '
';
/*
@@ -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 ''; // ancre pour retourner sur la ligne
if (($objp->info_bits & 2) == 2)
{
- print '';
+ print '';
print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount");
print '';
if ($objp->description)
@@ -477,17 +475,17 @@ if ($id > 0 || ! empty($ref))
*/
print '";
@@ -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 '';
// 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 ' | ';
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 77488a72e1a..f3e6b5090bc 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -1259,28 +1259,16 @@ else
print "";
print '
';
}
+
+ print '';
/*
* Linked object block
*/
- $object->load_object_linked($object->id,$object->element);
-
- if (! empty($object->linked_object))
- {
- print '| ';
-
- 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 ' | ';
- print ' | ';
- }
-
+ $somethingshown=$object->showLinkedObjectBlock();
+
+ print ' | ';
+ print ' |
';
}
}
diff --git a/htdocs/contrat/tpl/linkedobjectblock.tpl.php b/htdocs/contrat/tpl/linkedobjectblock.tpl.php
index b5d87016ecb..065fdbe377d 100644
--- a/htdocs/contrat/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/contrat/tpl/linkedobjectblock.tpl.php
@@ -1,5 +1,5 @@
+/* Copyright (C) 2010-2011 Regis Houssin
*
* 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 @@
linkedObjectBlock;
-$objectid = $GLOBALS['object']->objectid;
-$num = count($objectid);
$langs->load("contracts");
-if ($somethingshown) { echo '
'; }
+echo '
';
print_titre($langs->trans('RelatedContracts'));
?>
@@ -42,17 +39,16 @@ print_titre($langs->trans('RelatedContracts'));
fetch($objectid[$i]);
- $linkedObjectBlock->fetch_lines();
+ $object->fetch_lines();
$var=!$var;
?>
>|
- trans("ShowContract"),"contract").' '.$linkedObjectBlock->ref; ?> |
- date_contrat,'day'); ?> |
+ trans("ShowContract"),"contract").' '.$object->ref; ?>
+ date_contrat,'day'); ?> |
|
- getLibStatut(6); ?> |
+ getLibStatut(6); ?> |
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 75528b07824..6873b20b1ce 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,74 +1203,65 @@ 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++;
}
+
+ if (! empty($this->linkedObjectsIds))
+ {
+ foreach($this->linkedObjectsIds as $objecttype => $objectids)
+ {
+ // Parse element/subelement (ex: project_task)
+ $module = $element = $subelement = $objecttype;
+ if (preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
+ {
+ $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);
}
}
-
- /**
- * 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++)
- {
- $object = new $classname($this->db);
- $ret = $object->fetch($objects[$i]);
- if ($ret >= 0)
- {
- $this->linkedObjects[$objecttype][$i] = $object;
- }
- }
- }
- }
- }
/**
* Set statut of an object
@@ -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.'
';
-/*
- $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 cdb219773f3..dc1f2f3928b 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 ''.$langs->trans("DeliveryOrder").'';
}
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index 00baf722bd7..dffd2222e98 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -247,7 +247,7 @@ if ($id > 0 || ! empty($ref))
print '';
print '';
- // Delivery date planed
+ // Delivery date planned
print '';
print '| ';
print $langs->trans('DateDeliveryPlanned');
@@ -655,10 +655,8 @@ if ($id > 0 || ! empty($ref))
print '';
}
}
-
-
+
show_list_sending_receive('commande',$commande->id);
-
}
else
{
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index 44691317db8..beae15b6466 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 ' | ';
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 72fa990c967..c37087c9a1b 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 ' | ';
print ' ';
diff --git a/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php b/htdocs/includes/modules/facture/doc/pdf_crabe.modules.php
index 1c601d446d2..1085d89baa0 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; $idb);
- $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; $idb);
- $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 e22f877febb..5caec8e66e1 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; $idb);
- $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; $idb);
- $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 17cab6b2bd2..6adce5b8d05 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 @@
* Copyright (C) 2004-2008 Laurent Destailleur
- * Copyright (C) 2005-2006 Regis Houssin
+ * Copyright (C) 2005-2011 Regis Houssin
* Copyright (C) 2007 Franky Van Liedekerke
*
* 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 35cb1029295..a38b7ae2bb7 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 1b989cb76d5..b3170d2f77d 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; $idb);
- $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 73ccbaf5d98..d41b1e81898 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 3c37d9212c8..973864348b6 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'];
|
|