From eb40118ed22cdffc7ca8b5e06fec76688e511ba6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 21 Jul 2009 12:03:30 +0000 Subject: [PATCH] Add hidden option COMMANDE_ADD_DELIVERY_ADDRESS to continue to have the delivery addresse asked in the old way. For using the new way, just add a contact of type "delivery" on the contacts tab of order. --- htdocs/commande/fiche.php | 48 +++++++++++++++++--------------- htdocs/compta/commande/fiche.php | 38 +++++++++++++------------ htdocs/expedition/commande.php | 35 ++++++++++++----------- htdocs/expedition/fiche.php | 40 +++++++++++++++----------- 4 files changed, 88 insertions(+), 73 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index b5487f074ff..c468d48cdc9 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -987,17 +987,16 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) } print ""; - // Adresse de livraison - print ''.$langs->trans('DeliveryAddress').''; - $numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1); - - if ($numaddress==0) + // Delivery address + if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) { + // Link to edit: $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?action=create','',$soc->id,'adresse_livraison_id','commande',''); + print ''.$langs->trans('DeliveryAddress').''; + $numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1); print '   '.$langs->trans("AddAddress").''; + print ''; } - print ''; - // Conditions de reglement print ''.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1); @@ -1396,24 +1395,27 @@ else print ''; // Delivery address - print ''; - print ''; - - if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print ''; - - if ($_GET['action'] == 'editdelivery_adress') + if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + print ''; + print ''; + + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; + print ''; + + if ($_GET['action'] == 'editdelivery_adress') + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + } + else + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); + } + print ''; } - else - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); - } - print ''; // Terms of payment print ''; diff --git a/htdocs/compta/commande/fiche.php b/htdocs/compta/commande/fiche.php index 530626533aa..99765c91a78 100644 --- a/htdocs/compta/commande/fiche.php +++ b/htdocs/compta/commande/fiche.php @@ -260,26 +260,28 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - - // Adresse de livraison - print ''; - print ''; - - if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print ''; - - if ($_GET['action'] == 'editdelivery_adress') + // Delivery address + if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + print ''; + print ''; + + if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; + print ''; + + if ($_GET['action'] == 'editdelivery_adress') + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + } + else + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); + } + print ''; } - else - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); - } - print ''; // Conditions et modes de règlement print ''; diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index 74faa167050..56d7cba3faa 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -278,24 +278,27 @@ if ($id > 0 || ! empty($ref)) print ''; // Delivery address - print ''; - print ''; - - if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print ''; - - if ($_GET['action'] == 'editdelivery_adress') + if ($conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + print ''; + print ''; + + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; + print ''; + + if ($_GET['action'] == 'editdelivery_adress') + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); + } + else + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); + } + print ''; } - else - { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); - } - print ''; // Terms of payment print ''; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 1590379cc8f..c9972d5c808 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -284,13 +284,17 @@ if ($_GET["action"] == 'create') print ''.dol_print_date($object->date,"day")."\n"; // Delivery address - print ''.$langs->trans('DeliveryAddress').''; - print ''; - if (!empty($object->fk_delivery_address)) + if (($origin == 'commande' && $conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) + || ($origin == 'propal' && $conf->global->PROPAL_ADD_DELIVERY_ADDRESS)) { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$_GET['socid'],'none','commande',$object->id); + print ''.$langs->trans('DeliveryAddress').''; + print ''; + if (!empty($object->fk_delivery_address)) + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$object->id,$object->fk_delivery_address,$_GET['socid'],'none','commande',$object->id); + } + print ''."\n"; } - print ''."\n"; // Warehouse (id forced) if ($conf->stock->enabled && $_GET["entrepot_id"]) @@ -532,6 +536,7 @@ else if ($expedition->id > 0) { $typeobject = $expedition->origin; + $origin = $expedition->origin; $expedition->fetch_object(); if (strlen($expedition->tracking_number)) @@ -617,24 +622,23 @@ else // Linked documents print ''; - if ($conf->commande->enabled) + if ($origin == 'commande') { $order=new Commande($db); - $order->fetch($expedition->$typeobject->id); + $order->fetch($expedition->$origin->id); print $langs->trans("RefOrder").''; print ''; print $order->getNomUrl(1,'commande'); - print "\n"; } - else + if ($origin == 'propal') { $propal=new Propal($db); - $propal->fetch($livraison->origin_id); + $propal->fetch($expedition->$origin->id); print $langs->trans("RefProposal").''; print ''; print $propal->getNomUrl(1,'expedition'); - print "\n"; } + print "\n"; print ''; // Ref customer @@ -648,13 +652,17 @@ else print ''; // Delivery address - print ''.$langs->trans('DeliveryAddress').''; - print ''; - if (!empty($expedition->fk_delivery_address)) + if (($origin == 'commande' && $conf->global->COMMANDE_ADD_DELIVERY_ADDRESS) + || ($origin == 'propal' && $conf->global->PROPAL_ADD_DELIVERY_ADDRESS)) { - $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$expedition->id,$expedition->fk_delivery_address,$expedition->deliveryaddress->socid,'none','shipment',$expedition->id); + print ''.$langs->trans('DeliveryAddress').''; + print ''; + if (!empty($expedition->fk_delivery_address)) + { + $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$expedition->id,$expedition->fk_delivery_address,$expedition->deliveryaddress->socid,'none','shipment',$expedition->id); + } + print ''."\n"; } - print ''."\n"; // Weight print ''.$langs->trans("TotalWeight").'';