diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index d25c2f5b307..4be8b18b41c 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1959,8 +1959,19 @@ if ($id > 0 || ! empty($ref))
/*
- * Commandes rattachees
+ * Linked object block
*/
+ $propal->load_object_linked($propal->id,$propal->element);
+
+ foreach($propal->linked_object as $object => $objectid)
+ {
+ // TODO en attendant que tout soit correct
+ if($conf->$object->enabled && $object == 'commande')
+ {
+ $propal->showLinkedObjectBlock($object,$objectid,$somethingshown);
+ }
+ }
+/*
if($conf->commande->enabled)
{
$propal->loadOrders();
@@ -1990,7 +2001,7 @@ if ($id > 0 || ! empty($ref))
print '';
}
}
-
+*/
print '
';
// List of actions on element
diff --git a/htdocs/comm/propal/propal.class.php b/htdocs/comm/propal/propal.class.php
index 433089203ff..f033cf25e2b 100644
--- a/htdocs/comm/propal/propal.class.php
+++ b/htdocs/comm/propal/propal.class.php
@@ -1506,20 +1506,26 @@ class Propal extends CommonObject
$linkedInvoices = array();
$this->load_object_linked($id,$this->element);
- foreach($this->linked_object as $key => $object)
+ foreach($this->linked_object as $object => $objectid)
{
- // Cas des factures liees directement
- if ($object['type'] == 'facture')
+ for ($i = 0; $iload_object_linked($object['linkid'],$object['type']);
- foreach($this->linked_object as $key => $object)
+ // Cas des factures liees directement
+ if ($object == 'facture')
{
- $linkedInvoices[] = $object['linkid'];
+ $linkedInvoices[] = $object[$i];
+ }
+ // Cas des factures liees via la commande
+ else
+ {
+ $this->load_object_linked($object[$i],$object);
+ foreach($this->linked_object as $object => $objectid)
+ {
+ for ($j = 0; $j 0)
+ {
+ if ($somethingshown) { print ' '; $somethingshown=1; }
+ print_titre($langs->trans('RelatedOrders'));
+ print '';
+ print '';
+ print '| '.$langs->trans("Ref").' | ';
+ print ''.$langs->trans("Date").' | ';
+ print ''.$langs->trans("Price").' | ';
+ print ''.$langs->trans("Status").' | ';
+ print ' ';
+ $var=true;
+ for ($i = 0 ; $i < $num ; $i++)
+ {
+ $this->fetch($objectid[$i]);
+
+ $var=!$var;
+ print '| ';
+ print ''.img_object($langs->trans("ShowOrder"),"order").' '.$this->ref." | \n";
+ print ''.dol_print_date($this->date,'day').' | ';
+ print ''.price($this->total_ttc).' | ';
+ print ''.$this->getLibStatut(3).' | ';
+ print " \n";
+ }
+ print ' ';
+ }
+ }
}
-
/**
* \class OrderLine
* \brief Classe de gestion des lignes de commande
diff --git a/htdocs/core/commonobject.class.php b/htdocs/core/commonobject.class.php
index 447d82fd6ae..f993babf490 100644
--- a/htdocs/core/commonobject.class.php
+++ b/htdocs/core/commonobject.class.php
@@ -922,11 +922,11 @@ class CommonObject
$obj = $this->db->fetch_object($resql);
if ($obj->fk_source == $sourceid)
{
- $this->linked_object[]=array('linkid'=>$obj->fk_target, 'type'=>$obj->targettype);
+ $this->linked_object[$obj->targettype][]=$obj->fk_target;
}
if ($obj->fk_target == $targetid)
{
- $this->linked_object[]=array('linkid'=>$obj->fk_source, 'type'=>$obj->sourcetype);
+ $this->linked_object[$obj->sourcetype][]=$obj->fk_source;
}
$i++;
}
@@ -1013,6 +1013,17 @@ class CommonObject
print $sql;
}
}
+
+ /**
+ *
+ */
+ function showLinkedObjectBlock($object,$objectid,$somethingshown=0)
+ {
+ $class = ucfirst($object);
+ if(!class_exists($class)) require(DOL_DOCUMENT_ROOT."/".$object."/class/".$object.".class.php");
+ $linkedObjectBlock = new $class($this->db);
+ $linkedObjectBlock->getLinkedObjectBlock($object,$objectid,$somethingshown);
+ }
}
diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
index 3a8d160328f..4865f45a4b3 100644
--- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
+++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php
@@ -402,18 +402,21 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'commande')
+ if ($key == 'commande')
{
- $newobject=new Commande($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY($Xoff,$Yoff);
- $pdf->SetFont('Arial','',8);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ $newobject=new Commande($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $Yoff = $Yoff+4;
+ $pdf->SetXY($Xoff,$Yoff);
+ $pdf->SetFont('Arial','',8);
+ $text=$newobject->ref;
+ if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
+ $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ }
}
}
}
diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
index ab9a33fd787..b6c75637bb7 100644
--- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
+++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php
@@ -195,19 +195,22 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'order')
+ if ($key == 'commande')
{
- $newobject=new Commande($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY($Xoff,$Yoff);
- $pdf->SetFont('Arial','',8);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->Text($posx, $Yoff, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text));
- $pdf->Text($posx, $Yoff+4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true));
+ $newobject=new Commande($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $Yoff = $Yoff+8;
+ $pdf->SetXY($Xoff,$Yoff);
+ $pdf->SetFont('Arial','',8);
+ $text=$newobject->ref;
+ if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
+ $pdf->Text($posx, $Yoff, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text));
+ $pdf->Text($posx, $Yoff+4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"%d %b %Y",false,$outputlangs,true));
+ }
}
}
}
diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php
index 24ea39ab072..c68c4ebc35b 100644
--- a/htdocs/includes/modules/facture/pdf_crabe.modules.php
+++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php
@@ -1009,6 +1009,7 @@ class pdf_crabe extends ModelePDFFactures
}
// Add list of linked orders and proposals
+ // TODO mutualiser
$object->load_object_linked();
if ($conf->propal->enabled)
@@ -1016,38 +1017,45 @@ class pdf_crabe extends ModelePDFFactures
$outputlangs->load('propal');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'propal')
+ if ($key == 'propal')
{
- $newobject=new Propal($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY(100,$posy);
- $pdf->SetFont('Arial','',9);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R');
+ $newobject=new Propal($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY(100,$posy);
+ $pdf->SetFont('Arial','',9);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref), '', 'R');
+ }
}
}
}
}
- if ($conf->commande->enabled)
+ // TODO mutualiser
+ if ($conf->commande->enabled)
{
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'commande')
+ if ($key == 'commande')
{
- $newobject=new Commande($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY(100,$posy);
- $pdf->SetFont('Arial','',9);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ $newobject=new Commande($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY(100,$posy);
+ $pdf->SetFont('Arial','',9);
+ $text=$newobject->ref;
+ if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ }
}
}
}
diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php
index b97d189620c..198660e7fb5 100644
--- a/htdocs/includes/modules/facture/pdf_oursin.modules.php
+++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php
@@ -977,43 +977,51 @@ class pdf_oursin extends ModelePDFFactures
// Add list of linked orders and proposals
$object->load_object_linked();
+ // TODO mutualiser
if ($conf->propal->enabled)
{
$outputlangs->load('propal');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'propal')
+ if ($key == 'propal')
{
- $newobject=new Propal($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY($this->marges['g'],$posy);
- $pdf->SetFont('Arial','',9);
- $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref));
+ $newobject=new Propal($this->db);
+ $result=$newobject->fetch($val['linkid']);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY($this->marges['g'],$posy);
+ $pdf->SetFont('Arial','',9);
+ $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefProposal")." : ".$outputlangs->transnoentities($newobject->ref));
+ }
}
}
}
}
- if ($conf->commande->enabled)
+ // TODO mutualiser
+ if ($conf->commande->enabled)
{
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'commande')
+ if ($key == 'commande')
{
- $newobject=new Propal($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY($this->marges['g'],$posy);
- $pdf->SetFont('Arial','',9);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->MultiCell(60, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text));
+ $newobject=new Propal($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY($this->marges['g'],$posy);
+ $pdf->SetFont('Arial','',9);
+ $text=$newobject->ref;
+ if ($newobject->ref_client) $text.=' ('.$newobject->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 9e54ff685ad..8f23bbf8502 100644
--- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php
+++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php
@@ -425,6 +425,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$pdf->SetFont('Arial','B',9);
// Add list of linked orders
+ // TODO mutualiser
$object->load_object_linked();
if ($conf->commande->enabled)
@@ -432,18 +433,21 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'commande')
+ if ($key == 'commande')
{
- $newobject=new Commande($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY(102,$posy);
- $pdf->SetFont('Arial','',9);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->Text(11, 94, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ $newobject=new Commande($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY(102,$posy);
+ $pdf->SetFont('Arial','',9);
+ $text=$newobject->ref;
+ if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
+ $pdf->Text(11, 94, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ }
}
}
}
diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php
index 6363623e29a..93355ca49e7 100644
--- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php
+++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php
@@ -358,7 +358,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->_pagefoot($pdf,$object,$outputlangs);
// Check product remaining to be delivered
- $waitingDelivery = $object->getRemainingDelivered();
+ // TODO doit etre modifie
+ //$waitingDelivery = $object->getRemainingDelivered();
if (is_array($waitingDelivery) & !empty($waitingDelivery))
{
@@ -543,6 +544,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0,0,60);
// Add list of linked orders
+ // TODO mutualiser
$object->load_object_linked();
if ($conf->commande->enabled)
@@ -550,18 +552,21 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'commande')
+ if ($key == 'commande')
{
- $newobject=new Commande($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY(100,$posy);
- $pdf->SetFont('Arial','',9);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ $newobject=new Commande($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY(100,$posy);
+ $pdf->SetFont('Arial','',9);
+ $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/includes/modules/project/pdf/pdf_baleine.modules.php b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
index 4b97b1a23d3..361079dfe7e 100644
--- a/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/includes/modules/project/pdf/pdf_baleine.modules.php
@@ -369,6 +369,7 @@ class pdf_baleine extends ModelePDFProjects
$pdf->SetTextColor(0,0,60);
// Add list of linked orders
+ // TODO mutualiser
$object->load_object_linked();
if ($conf->commande->enabled)
@@ -376,18 +377,21 @@ class pdf_baleine extends ModelePDFProjects
$outputlangs->load('orders');
foreach($object->linked_object as $key => $val)
{
- if ($val['type'] == 'commande')
+ if ($key == 'commande')
{
- $newobject=new Commande($this->db);
- $result=$newobject->fetch($val['linkid']);
- if ($result >= 0)
+ for ($i = 0; $iSetXY(100,$posy);
- $pdf->SetFont('Arial','',9);
- $text=$newobject->ref;
- if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')';
- $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R');
+ $newobject=new Commande($this->db);
+ $result=$newobject->fetch($val[$i]);
+ if ($result >= 0)
+ {
+ $posy+=4;
+ $pdf->SetXY(100,$posy);
+ $pdf->SetFont('Arial','',9);
+ $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 fc7015d1be2..e461af411ea 100644
--- a/htdocs/lib/sendings.lib.php
+++ b/htdocs/lib/sendings.lib.php
@@ -40,9 +40,9 @@ function shipping_prepare_head($object)
$head[$h][2] = 'shipping';
$h++;
- if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && $object->linked_object[0]['linkid'])
+ if ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire && $object->linked_object['delivery'][0])
{
- $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linked_object[0]['linkid'];
+ $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$object->linked_object['delivery'][0];
$head[$h][1] = $langs->trans("DeliveryCard");
$head[$h][2] = 'delivery';
$h++;
|