Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW : add default warehouse for dispatch #11093

Merged
merged 13 commits into from Dec 19, 2019
38 changes: 35 additions & 3 deletions htdocs/fourn/commande/dispatch.php
Expand Up @@ -8,6 +8,7 @@
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2019 Christophe Battarel <christophe@altairis.fr>
*
* 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
Expand Down Expand Up @@ -51,6 +52,8 @@
$ref = GETPOST('ref');
$lineid = GETPOST('lineid', 'int');
$action = GETPOST('action', 'aZ09');
$fk_default_warehouse = GETPOST('fk_default_warehouse', 'int');

if ($user->socid)
$socid = $user->socid;
$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
Expand Down Expand Up @@ -236,6 +239,7 @@
$prod = "product_".$reg[1].'_'.$reg[2];
$qty = "qty_".$reg[1].'_'.$reg[2];
$ent = "entrepot_".$reg[1].'_'.$reg[2];
if (empty(GETPOST($ent))) $ent = $fk_default_warehouse;
$pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount
$fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2];

Expand Down Expand Up @@ -484,9 +488,11 @@

if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT
|| $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY
|| $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) {
$entrepot = new Entrepot($db);
$listwarehouses = $entrepot->list_array(1);
|| $object->statut == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY)
{
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
$formproduct = new FormProduct($db);
$formproduct->loadWarehouses();

if (empty($conf->reception->enabled))print '<form method="POST" action="dispatch.php?id='.$object->id.'">';
else print '<form method="post" action="'.dol_buildpath('/reception/card.php', 1).'?originid='.$object->id.'&origin=supplierorder">';
Expand Down Expand Up @@ -561,6 +567,23 @@
$i = 0;

if ($num) {
$entrepot = new Entrepot($db);
$listwarehouses=$entrepot->list_array(1);
// entrepot par défaut
print $langs->trans("Warehouse").' : ';
if (count($listwarehouses)>1)
{
print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 1, 0, 0, '', 0, 0, $disabled);
}
elseif (count($listwarehouses)==1)
{
print $form->selectarray('fk_default_warehouse', $listwarehouses, $fk_default_warehouse, 0, 0, 0, '', 0, 0, $disabled);
}
else
{
print $langs->trans("NoWarehouseDefined");
}

print '<tr class="liste_titre">';

print '<td>'.$langs->trans("Description").'</td>';
Expand Down Expand Up @@ -897,6 +920,15 @@

dol_fiche_end();

// traitement entrepot par défaut
print '<script type="text/javascript">
$(document).ready(function () {
$("select[name=fk_default_warehouse]").change(function() {
var fk_default_warehouse = $("option:selected", this).val();
$("select[name^=entrepot_]").val(fk_default_warehouse).change();
});
});
</script>';

// List of lines already dispatched
$sql = "SELECT p.ref, p.label,";
Expand Down