diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index 4e33bd05af7..65aac8dbf39 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -592,8 +592,9 @@ class Expedition extends CommonObject
* Lit le document associé
*
*/
- function fetch_object($object)
+ function fetch_object()
{
+ $object = $this->origin;
$class = ucfirst($object);
$this->$object = & new $class($this->db);
$this->$object->fetch($this->origin_id);
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 0b38593e79a..5b50e5bdfe0 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -194,7 +194,7 @@ if ($_GET["action"] == 'create')
print $mesg.'
';
}
- $class = ucfirst($origin);
+ $class = ucfirst($origin);
$object = new $class($db);
$object->loadExpeditions();
@@ -439,8 +439,8 @@ else
if ($expedition->id > 0)
{
- $object = New Commande($db);
- $object->fetch($expedition->origin_id);
+ $object = $expedition->origin;
+ $expedition->fetch_object();
$soc = new Societe($db);
$soc->fetch($expedition->socid);
@@ -466,7 +466,7 @@ else
*/
if ($_GET["action"] == 'delete')
{
- $html->form_confirm("fiche.php?id=$expedition->id",$langs->trans("DeleteSending"),"Etes-vous sûr de vouloir supprimer cette expedition ?","confirm_delete");
+ $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('DeleteSending'),'Etes-vous sûr de vouloir supprimer cette expedition ?','confirm_delete');
print '
';
}
@@ -476,7 +476,7 @@ else
*/
if ($_GET["action"] == 'valid')
{
- $html->form_confirm("fiche.php?id=$expedition->id",$langs->trans("ValidateSending"),"Etes-vous sûr de vouloir valider cette expédition ?","confirm_valid");
+ $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('ValidateSending'),'Etes-vous sûr de vouloir valider cette expédition ?','confirm_valid');
print '
';
}
/*
@@ -485,7 +485,7 @@ else
*/
if ($_GET["action"] == 'annuler')
{
- $html->form_confirm("fiche.php?id=$expedition->id",$langs->trans("CancelSending"),"Etes-vous sûr de vouloir annuler cette commande ?","confirm_cancel");
+ $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$expedition->id,$langs->trans('CancelSending'),'Etes-vous sûr de vouloir annuler cette commande ?','confirm_cancel');
print '
';
}
@@ -517,12 +517,12 @@ else
if ($conf->commande->enabled)
{
print $langs->trans("RefOrder").'';
- print '
'.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref;
+ print ' | '.img_object($langs->trans("ShowOrder"),'order').' '.$expedition->$object->ref;
}
else
{
print $langs->trans("RefProposal").' | ';
- print ''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref;
+ print ' | '.img_object($langs->trans("ShowProposal"),'propal').' '.$expedition->$object->ref;
}
print " | \n";
print '';
diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php
index 5f0172e9b3d..5544217ea20 100644
--- a/htdocs/livraison/fiche.php
+++ b/htdocs/livraison/fiche.php
@@ -361,7 +361,13 @@ else
{
$livraison = new Livraison($db);
$result = $livraison->fetch($_GET["id"]);
-
+
+ if ($livraison->origin_id)
+ {
+ $object = $livraison->origin;
+ $livraison->fetch_object();
+ }
+
if ( $livraison->id > 0)
{
$soc = new Societe($db);
@@ -389,7 +395,7 @@ else
if ($_GET["action"] == 'delete')
{
$expedition_id = $_GET["expid"];
- $html->form_confirm("fiche.php?id=$livraison->id&expid=$expedition_id","Supprimer le bon de livraison","Etes-vous sûr de vouloir supprimer ce bon de livraison ?","confirm_delete");
+ $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id.'&expid='.$expedition_id,'Supprimer le bon de livraison','Etes-vous sûr de vouloir supprimer ce bon de livraison ?','confirm_delete');
print '
';
}
@@ -399,7 +405,7 @@ else
*/
if ($_GET["action"] == 'valid')
{
- $html->form_confirm("fiche.php?id=$livraison->id","Valider le bon de livraison","Etes-vous sûr de vouloir valider ce bon de livraison ?","confirm_valid");
+ $html->form_confirm($_SERVER['PHP_SELF'].'?id='.$livraison->id,'Valider le bon de livraison','Etes-vous sûr de vouloir valider ce bon de livraison ?','confirm_valid');
print '
';
}
@@ -419,12 +425,21 @@ else
print "";
// Document origine
- print '| '.$langs->trans("RefOrder").' | ';
- print ''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref." | \n";
- print '
';
+ if ($conf->commande->enabled)
+ {
+ print '| '.$langs->trans("RefOrder").' | ';
+ print ''.img_object($langs->trans("ShowOrder"),'order').' '.$livraison->$object->ref." | \n";
+ print '
';
+ }
+ else
+ {
+ print '| '.$langs->trans("RefProposal").' | ';
+ print ''.img_object($langs->trans("ShowProposal"),'propal').' '.$livraison->$object->ref." | \n";
+ print '
';
+ }
- // Commande liée
- print '| '.$langs->trans("RefCustomerOrderShort").' | ';
+ // Ref client
+ print '
| '.$langs->trans("RefCustomer").' | ';
print ''.$livraison->ref_client." | \n";
print '
';
diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php
index d8016b91347..c624f67431b 100644
--- a/htdocs/livraison/livraison.class.php
+++ b/htdocs/livraison/livraison.class.php
@@ -31,6 +31,8 @@
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
require_once(DOL_DOCUMENT_ROOT."/expedition/expedition.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/mouvementstock.class.php");
+if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
+if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
/**
@@ -583,15 +585,17 @@ class Livraison extends CommonObject
}
}
-
+
/*
- * Lit la commande associée
+ * Lit le document associé
*
*/
- function fetch_commande()
+ function fetch_object()
{
- $this->commande =& new Commande($this->db);
- $this->commande->fetch($this->commande_id);
+ $object = $this->origin;
+ $class = ucfirst($this->origin);
+ $this->$object = & new $class($this->db);
+ $this->$object->fetch($this->origin_id);
}
/**