From eb7a4c5ccf4e1110315841ce045659c822081dbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 4 Jun 2016 02:39:13 +0200 Subject: [PATCH] FIX Creating a supplier order from proposal order --- htdocs/fourn/commande/card.php | 9 +++++---- htdocs/supplier_proposal/card.php | 11 ++++++----- .../supplier_proposal/tpl/linkedobjectblock.tpl.php | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 81e7c93c3c3..8e486dc232b 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1030,7 +1030,7 @@ if (empty($reshook)) $num = count($lines); $productsupplier = new ProductFournisseur($db); - + for($i = 0; $i < $num; $i ++) { @@ -1040,7 +1040,7 @@ if (empty($reshook)) $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); - + // Reset fk_parent_line for no child products and special product if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) { $fk_parent_line = 0; @@ -1055,7 +1055,8 @@ if (empty($reshook)) } $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty); - if ($result>0) + + if ($result>=0) { $tva_tx = $lines[$i]->tva_tx; @@ -1073,7 +1074,7 @@ if (empty($reshook)) $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, - $lines[$i]->fk_product, + $lines[$i]->fk_product > 0 ? $lines[$i]->fk_product : 0, $productsupplier->product_fourn_price_id, $productsupplier->ref_supplier, $lines[$i]->remise_percent, diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 78bde5d1ea5..8e8c69b0ce9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1076,31 +1076,32 @@ if ($action == 'create') // Terms of payment print '' . $langs->trans('PaymentConditionsShort') . ''; - $form->select_conditions_paiements($soc->cond_reglement_id, 'cond_reglement_id', -1, 1); + $form->select_conditions_paiements(GETPOST('cond_reglement_id') > 0 ? GETPOST('cond_reglement_id') : $soc->cond_reglement_id, 'cond_reglement_id', -1, 1); print ''; // Mode of payment print '' . $langs->trans('PaymentMode') . ''; - $form->select_types_paiements($soc->mode_reglement_id, 'mode_reglement_id'); + $form->select_types_paiements(GETPOST('mode_reglement_id') > 0 ? GETPOST('mode_reglement_id') : $soc->mode_reglement_id, 'mode_reglement_id'); print ''; // Bank Account if (! empty($conf->global->BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL) && $conf->banque->enabled) { print '' . $langs->trans('BankAccount') . ''; - $form->select_comptes($fk_account, 'fk_account', 0, '', 1); + $form->select_comptes(GETPOST('fk_account')>0 ? GETPOST('fk_account','int') : $fk_account, 'fk_account', 0, '', 1); print ''; } // Shipping Method if (! empty($conf->expedition->enabled)) { print '' . $langs->trans('SendingMethod') . ''; - print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1); + print $form->selectShippingMethod(GETPOST('shipping_method_id') > 0 ? GETPOST('shipping_method_id', 'int') : $shipping_method_id, 'shipping_method_id', '', 1); print ''; } // Delivery date (or manufacturing) print '' . $langs->trans("DeliveryDate") . ''; print ''; + $datedelivery = dol_mktime(0, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); @@ -1108,7 +1109,7 @@ if ($action == 'create') $sday = date("d", $tmpdte); $form->select_date($syear."-".$smonth."-".$sday, 'liv_', '', '', '', "addask"); } else { - $form->select_date(-1, 'liv_', '', '', '', "addask", 1, 1); + $form->select_date($datedelivery ? $datedelivery : -1, 'liv_', '', '', '', "addask", 1, 1); } print ''; diff --git a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php index d0b1b19278a..8f72744486a 100644 --- a/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/supplier_proposal/tpl/linkedobjectblock.tpl.php @@ -19,7 +19,7 @@ ?> - + $objectlink) $var=!$var; ?> > - trans("SupplierProposal"); ?> + trans("SupplierProposal"); ?> trans("ShowSupplierProposal"),"supplier_proposal").' '.$objectlink->ref; ?> datec,'day'); ?>