better management of dispatch status
This commit is contained in:
parent
0780188f4e
commit
1e929e647d
@ -2686,6 +2686,63 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calc status regarding dispatch stock
|
||||||
|
*
|
||||||
|
* @param User $user
|
||||||
|
* @return int <0 si ko, >0 si ok
|
||||||
|
*/
|
||||||
|
public function calcAndSetStatusDispatch(User $user) {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
if (! empty($conf->commande->enabled) && ! empty($conf->fournisseur->enabled))
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
|
||||||
|
|
||||||
|
$qtydelivered=array();
|
||||||
|
$qtywished=array();
|
||||||
|
|
||||||
|
$supplierorderdispatch = new CommandeFournisseurDispatch($this->db);
|
||||||
|
$filter=array('t.fk_commande'=>$this->id);
|
||||||
|
if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) {
|
||||||
|
$filter['t.status']=1;
|
||||||
|
}
|
||||||
|
$ret=$supplierorderdispatch->fetchAll('','',0,0,$filter);
|
||||||
|
if ($ret<0) {
|
||||||
|
$this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors;
|
||||||
|
return $ret;
|
||||||
|
} else {
|
||||||
|
if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) {
|
||||||
|
//Build array with quantity deliverd by product
|
||||||
|
foreach($supplierorderdispatch->lines as $line) {
|
||||||
|
$qtydelivered[$line->fk_product]+=$line->qty;
|
||||||
|
}
|
||||||
|
foreach($this->lines as $line) {
|
||||||
|
$qtywished[$line->fk_product]+=$line->qty;
|
||||||
|
}
|
||||||
|
//Compare array
|
||||||
|
$diff_array=array_diff_assoc($qtydelivered,$qtywished);
|
||||||
|
if (count($diff_array)==0) {
|
||||||
|
//No diff => mean everythings is received
|
||||||
|
$ret=$this->setStatus($user,5);
|
||||||
|
if ($ret<0) {
|
||||||
|
$this->error=$object->error; $this->errors=$object->errors;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Diff => received partially
|
||||||
|
$ret=$this->setStatus($user,4);
|
||||||
|
if ($ret<0) {
|
||||||
|
$this->error=$object->error; $this->errors=$object->errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3056,62 +3113,5 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calc status regarding dispatch stock
|
|
||||||
*
|
|
||||||
* @param User $user
|
|
||||||
* @return int <0 si ko, >0 si ok
|
|
||||||
*/
|
|
||||||
public function calcAndSetStatusDispatch(User $user) {
|
|
||||||
global $conf;
|
|
||||||
|
|
||||||
if (! empty($conf->commande->enabled) && ! empty($conf->fournisseur->enabled) && ! empty($conf->global->WORKFLOW_SUPPLIER_ORDER_CLASSIFY_RECEIPT_ORDER))
|
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php';
|
|
||||||
|
|
||||||
$qtydelivered=array();
|
|
||||||
$qtywished=array();
|
|
||||||
|
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($this->db);
|
|
||||||
$filter=array('t.fk_commande'=>$this->id);
|
|
||||||
if (!empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) {
|
|
||||||
$filter['t.status']=1;
|
|
||||||
}
|
|
||||||
$ret=$supplierorderdispatch->fetchAll('','',0,0,$filter);
|
|
||||||
if ($ret<0) {
|
|
||||||
$this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors;
|
|
||||||
return $ret;
|
|
||||||
} else {
|
|
||||||
if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) {
|
|
||||||
//Build array with quantity deliverd by product
|
|
||||||
foreach($supplierorderdispatch->lines as $line) {
|
|
||||||
$qtydelivered[$line->fk_product]+=$line->qty;
|
|
||||||
}
|
|
||||||
foreach($this->lines as $line) {
|
|
||||||
$qtywished[$line->fk_product]+=$line->qty;
|
|
||||||
}
|
|
||||||
//Compare array
|
|
||||||
$diff_array=array_diff_assoc($qtydelivered,$qtywished);
|
|
||||||
if (count($diff_array)==0) {
|
|
||||||
//No diff => mean everythings is received
|
|
||||||
$ret=$this->setStatus($user,5);
|
|
||||||
if ($ret<0) {
|
|
||||||
$this->error=$object->error; $this->errors=$object->errors;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//Diff => received partially
|
|
||||||
$ret=$this->setStatus($user,4);
|
|
||||||
if ($ret<0) {
|
|
||||||
$this->error=$object->error; $this->errors=$object->errors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||||
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
|
* Copyright (C) 2014 Cedric Gross <c.gross@kreiz-it.fr>
|
||||||
|
* Copyright (C) 2016 Florian Henry <florian.henry@atm-consulting.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,7 +27,6 @@
|
|||||||
* \ingroup commande
|
* \ingroup commande
|
||||||
* \brief Page to dispatch receiving
|
* \brief Page to dispatch receiving
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_order/modules_commandefournisseur.php';
|
require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_order/modules_commandefournisseur.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
|
||||||
@ -34,7 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.dispatch.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.dispatch.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
|
require_once DOL_DOCUMENT_ROOT . '/product/class/html.formproduct.class.php';
|
||||||
if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
if (! empty($conf->projet->enabled))
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
|
||||||
|
|
||||||
$langs->load('orders');
|
$langs->load('orders');
|
||||||
$langs->load('sendings');
|
$langs->load('sendings');
|
||||||
@ -43,96 +44,112 @@ $langs->load('bills');
|
|||||||
$langs->load('deliveries');
|
$langs->load('deliveries');
|
||||||
$langs->load('products');
|
$langs->load('products');
|
||||||
$langs->load('stocks');
|
$langs->load('stocks');
|
||||||
if (! empty($conf->productbatch->enabled)) $langs->load('productbatch');
|
if (! empty($conf->productbatch->enabled))
|
||||||
|
$langs->load('productbatch');
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$id = GETPOST("id", 'int');
|
$id = GETPOST("id", 'int');
|
||||||
|
$ref = GETPOST('ref');
|
||||||
$lineid = GETPOST('lineid', 'int');
|
$lineid = GETPOST('lineid', 'int');
|
||||||
$action = GETPOST('action');
|
$action = GETPOST('action');
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id)
|
||||||
|
$socid = $user->societe_id;
|
||||||
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
|
$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
|
||||||
|
|
||||||
if (empty($conf->stock->enabled))
|
if (empty($conf->stock->enabled)) {
|
||||||
{
|
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recuperation de l'id de projet
|
// Recuperation de l'id de projet
|
||||||
$projectid = 0;
|
$projectid = 0;
|
||||||
if ($_GET["projectid"]) $projectid = GETPOST("projectid",'int');
|
if ($_GET["projectid"])
|
||||||
|
$projectid = GETPOST("projectid", 'int');
|
||||||
$mesg='';
|
|
||||||
|
|
||||||
|
$commande = new CommandeFournisseur($db);
|
||||||
|
|
||||||
|
if ($id > 0 || ! empty($ref)) {
|
||||||
|
$result = $commande->fetch($id, $ref);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
|
}
|
||||||
|
$result = $commande->fetch_thirdparty();
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'checkdispatchline' &&
|
if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) {
|
||||||
! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner))
|
|
||||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
$result = $supplierorderdispatch->fetch($lineid);
|
$result = $supplierorderdispatch->fetch($lineid);
|
||||||
if (! $result) dol_print_error($db);
|
if (! $result)
|
||||||
|
dol_print_error($db);
|
||||||
$result = $supplierorderdispatch->setStatut(1);
|
$result = $supplierorderdispatch->setStatut(1);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
$action = '';
|
$action = '';
|
||||||
|
} else {
|
||||||
|
$result = $commande->calcAndSetStatusDispatch($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
|
$error ++;
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'uncheckdispatchline' &&
|
if ($action == 'uncheckdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) {
|
||||||
! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner))
|
|
||||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
$result = $supplierorderdispatch->fetch($lineid);
|
$result = $supplierorderdispatch->fetch($lineid);
|
||||||
if (! $result) dol_print_error($db);
|
if (! $result)
|
||||||
|
dol_print_error($db);
|
||||||
$result = $supplierorderdispatch->setStatut(0);
|
$result = $supplierorderdispatch->setStatut(0);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
$action = '';
|
$action = '';
|
||||||
|
} else {
|
||||||
|
$result = $commande->calcAndSetStatusDispatch($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
|
$error ++;
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'denydispatchline' &&
|
if ($action == 'denydispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) {
|
||||||
! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner))
|
|
||||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
$result = $supplierorderdispatch->fetch($lineid);
|
$result = $supplierorderdispatch->fetch($lineid);
|
||||||
if (! $result) dol_print_error($db);
|
if (! $result)
|
||||||
|
dol_print_error($db);
|
||||||
$result = $supplierorderdispatch->setStatut(2);
|
$result = $supplierorderdispatch->setStatut(2);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
$action = '';
|
$action = '';
|
||||||
|
} else {
|
||||||
|
$result = $commande->calcAndSetStatusDispatch($user);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
|
$error ++;
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) {
|
||||||
{
|
|
||||||
$commande = new CommandeFournisseur($db);
|
|
||||||
$commande->fetch($id);
|
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$pos = 0;
|
$pos = 0;
|
||||||
foreach($_POST as $key => $value)
|
foreach ( $_POST as $key => $value ) {
|
||||||
{
|
// without batch module enabled
|
||||||
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) // without batch module enabled
|
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
|
||||||
{
|
|
||||||
$pos ++;
|
$pos ++;
|
||||||
|
|
||||||
// $numline=$reg[2] + 1; // line of product
|
// $numline=$reg[2] + 1; // line of product
|
||||||
@ -143,29 +160,26 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
|||||||
$pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount
|
$pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount
|
||||||
$fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2];
|
$fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2];
|
||||||
|
|
||||||
if (GETPOST($qty) > 0) // We ask to move a qty
|
// We ask to move a qty
|
||||||
{
|
if (GETPOST($qty) > 0) {
|
||||||
if (! (GETPOST($ent,'int') > 0))
|
if (! (GETPOST($ent, 'int') > 0)) {
|
||||||
{
|
|
||||||
dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
|
dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
|
||||||
$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline);
|
$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline);
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error) {
|
||||||
{
|
|
||||||
$result = $commande->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
|
$result = $commande->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), '', '', '', GETPOST($fk_commandefourndet, 'int'), $notrigger);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) // with batch module enabled
|
// with batch module enabled
|
||||||
{
|
if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) {
|
||||||
$pos ++;
|
$pos ++;
|
||||||
|
|
||||||
// eat-by date dispatch
|
// eat-by date dispatch
|
||||||
@ -182,29 +196,25 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
|||||||
|
|
||||||
$fk_commandefourndet = 'fk_commandefourndet_' . $reg[1] . '_' . $reg[2];
|
$fk_commandefourndet = 'fk_commandefourndet_' . $reg[1] . '_' . $reg[2];
|
||||||
|
|
||||||
if (GETPOST($qty) > 0) // We ask to move a qty
|
// We ask to move a qty
|
||||||
{
|
if (GETPOST($qty) > 0) {
|
||||||
if (! (GETPOST($ent,'int') > 0))
|
if (! (GETPOST($ent, 'int') > 0)) {
|
||||||
{
|
|
||||||
dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
|
dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed');
|
||||||
$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1);
|
$text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1);
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (GETPOST($lot, 'alpha') || $dDLUO || $dDLC))
|
if (! (GETPOST($lot, 'alpha') || $dDLUO || $dDLC)) {
|
||||||
{
|
|
||||||
dol_syslog('No dispatch for line ' . $key . ' as serial/eat-by/sellby date are not set');
|
dol_syslog('No dispatch for line ' . $key . ' as serial/eat-by/sellby date are not set');
|
||||||
$text = $langs->transnoentities('atleast1batchfield') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1);
|
$text = $langs->transnoentities('atleast1batchfield') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline) . '-' . ($reg[1] + 1);
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $text), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error) {
|
||||||
{
|
|
||||||
$result = $commande->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger);
|
$result = $commande->dispatchProduct($user, GETPOST($prod, 'int'), GETPOST($qty), GETPOST($ent, 'int'), GETPOST($pu), GETPOST('comment'), $dDLC, $dDLUO, GETPOST($lot, 'alpha'), GETPOST($fk_commandefourndet, 'int'), $notrigger);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
@ -215,42 +225,35 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
|
|||||||
|
|
||||||
if (! $error) {
|
if (! $error) {
|
||||||
$result = $commande->calcAndSetStatusDispatch($user);
|
$result = $commande->calcAndSetStatusDispatch($user);
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $notrigger && ! $error)
|
if (! $notrigger && ! $error) {
|
||||||
{
|
|
||||||
global $conf, $langs, $user;
|
global $conf, $langs, $user;
|
||||||
// Call trigger
|
// Call trigger
|
||||||
|
|
||||||
$result = $commande->call_trigger('ORDER_SUPPLIER_DISPATCH', $user);
|
$result = $commande->call_trigger('ORDER_SUPPLIER_DISPATCH', $user);
|
||||||
// End call triggers
|
// End call triggers
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
setEventMessages($commande->error, $commande->errors, 'errors');
|
setEventMessages($commande->error, $commande->errors, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result >= 0 && ! $error)
|
if ($result >= 0 && ! $error) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|
||||||
header("Location: dispatch.php?id=" . $id);
|
header("Location: dispatch.php?id=" . $id);
|
||||||
exit;
|
exit();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$db->rollback();
|
$db->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
@ -260,23 +263,14 @@ $formproduct = new FormProduct($db);
|
|||||||
$warehouse_static = new Entrepot($db);
|
$warehouse_static = new Entrepot($db);
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
|
|
||||||
|
|
||||||
$help_url = 'EN:CommandeFournisseur';
|
$help_url = 'EN:CommandeFournisseur';
|
||||||
llxHeader('',$langs->trans("OrderCard"),$help_url,'',0,0,array('/fourn/js/lib_dispatch.js'));
|
llxHeader('', $langs->trans("OrderCard"), $help_url, '', 0, 0, array(
|
||||||
|
'/fourn/js/lib_dispatch.js'
|
||||||
|
));
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
$id = GETPOST('id','int');
|
if ($id > 0 || ! empty($ref)) {
|
||||||
$ref= GETPOST('ref');
|
|
||||||
if ($id > 0 || ! empty($ref))
|
|
||||||
{
|
|
||||||
//if ($mesg) print $mesg.'<br>';
|
|
||||||
|
|
||||||
$commande = new CommandeFournisseur($db);
|
|
||||||
|
|
||||||
$result=$commande->fetch($id,$ref);
|
|
||||||
if ($result >= 0)
|
|
||||||
{
|
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->socid);
|
$soc->fetch($commande->socid);
|
||||||
|
|
||||||
@ -313,17 +307,14 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
if ($commande->methode_commande_id > 0)
|
if ($commande->methode_commande_id > 0) {
|
||||||
{
|
|
||||||
print '<tr><td>' . $langs->trans("Date") . '</td><td colspan="2">';
|
print '<tr><td>' . $langs->trans("Date") . '</td><td colspan="2">';
|
||||||
if ($commande->date_commande)
|
if ($commande->date_commande) {
|
||||||
{
|
|
||||||
print dol_print_date($commande->date_commande, "dayhourtext") . "\n";
|
print dol_print_date($commande->date_commande, "dayhourtext") . "\n";
|
||||||
}
|
}
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
if ($commande->methode_commande)
|
if ($commande->methode_commande) {
|
||||||
{
|
|
||||||
print '<tr><td>' . $langs->trans("Method") . '</td><td colspan="2">' . $commande->methode_commande . '</td></tr>';
|
print '<tr><td>' . $langs->trans("Method") . '</td><td colspan="2">' . $commande->methode_commande . '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,20 +329,18 @@ if ($id > 0 || ! empty($ref))
|
|||||||
// if ($mesg) print $mesg;
|
// if ($mesg) print $mesg;
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
$disabled = 1;
|
$disabled = 1;
|
||||||
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) $disabled=0;
|
if (! empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER))
|
||||||
|
$disabled = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lignes de commandes
|
* Lignes de commandes
|
||||||
*/
|
*/
|
||||||
if ($commande->statut <= 2 || $commande->statut >= 6)
|
if ($commande->statut <= 2 || $commande->statut >= 6) {
|
||||||
{
|
|
||||||
print $langs->trans("OrderStatusNotReadyToDispatch");
|
print $langs->trans("OrderStatusNotReadyToDispatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5)
|
if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5) {
|
||||||
{
|
|
||||||
$entrepot = new Entrepot($db);
|
$entrepot = new Entrepot($db);
|
||||||
$listwarehouses = $entrepot->list_array(1);
|
$listwarehouses = $entrepot->list_array(1);
|
||||||
|
|
||||||
@ -369,15 +358,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql .= " GROUP BY l.rowid, cfd.fk_product";
|
$sql .= " GROUP BY l.rowid, cfd.fk_product";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num) {
|
||||||
{
|
while ( $i < $num ) {
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$objd = $db->fetch_object($resql);
|
$objd = $db->fetch_object($resql);
|
||||||
$products_dispatched[$objd->rowid] = price2num($objd->qty, 5);
|
$products_dispatched[$objd->rowid] = price2num($objd->qty, 5);
|
||||||
$i ++;
|
$i ++;
|
||||||
@ -391,18 +377,17 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l";
|
$sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as l";
|
||||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid";
|
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON l.fk_product=p.rowid";
|
||||||
$sql .= " WHERE l.fk_commande = " . $commande->id;
|
$sql .= " WHERE l.fk_commande = " . $commande->id;
|
||||||
if(empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND l.product_type = 0";
|
if (empty($conf->global->STOCK_SUPPORTS_SERVICES))
|
||||||
|
$sql .= " AND l.product_type = 0";
|
||||||
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
|
$sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product
|
||||||
$sql .= " ORDER BY p.ref, p.label";
|
$sql .= " ORDER BY p.ref, p.label";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if ($num)
|
if ($num) {
|
||||||
{
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|
||||||
print '<td>' . $langs->trans("Description") . '</td>';
|
print '<td>' . $langs->trans("Description") . '</td>';
|
||||||
@ -415,8 +400,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
|
print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if (! empty($conf->productbatch->enabled))
|
if (! empty($conf->productbatch->enabled)) {
|
||||||
{
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
print '<td>' . $langs->trans("batch_number") . '</td>';
|
print '<td>' . $langs->trans("batch_number") . '</td>';
|
||||||
@ -425,29 +409,24 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<td colspan="4"> </td>';
|
print '<td colspan="4"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nbfreeproduct = 0;
|
$nbfreeproduct = 0;
|
||||||
$nbproduct = 0;
|
$nbproduct = 0;
|
||||||
|
|
||||||
$var = false;
|
$var = false;
|
||||||
while ($i < $num)
|
while ( $i < $num ) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
// On n'affiche pas les produits personnalises
|
// On n'affiche pas les produits personnalises
|
||||||
if (! $objp->fk_product > 0)
|
if (! $objp->fk_product > 0) {
|
||||||
{
|
|
||||||
$nbfreeproduct ++;
|
$nbfreeproduct ++;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$remaintodispatch = price2num($objp->qty - (( float ) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched
|
$remaintodispatch = price2num($objp->qty - (( float ) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched
|
||||||
if ($remaintodispatch < 0) $remaintodispatch=0;
|
if ($remaintodispatch < 0)
|
||||||
|
$remaintodispatch = 0;
|
||||||
|
|
||||||
if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
|
if ($remaintodispatch || empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) {
|
||||||
{
|
|
||||||
$nbproduct ++;
|
$nbproduct ++;
|
||||||
|
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
@ -464,16 +443,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$linktoprod = '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
|
$linktoprod = '<a href="' . DOL_URL_ROOT . '/product/fournisseurs.php?id=' . $objp->fk_product . '">' . img_object($langs->trans("ShowProduct"), 'product') . ' ' . $objp->ref . '</a>';
|
||||||
$linktoprod .= ' - ' . $objp->label . "\n";
|
$linktoprod .= ' - ' . $objp->label . "\n";
|
||||||
|
|
||||||
if (! empty($conf->productbatch->enabled))
|
if (! empty($conf->productbatch->enabled)) {
|
||||||
{
|
if ($objp->tobatch) {
|
||||||
if ($objp->tobatch)
|
|
||||||
{
|
|
||||||
print '<td colspan="4">';
|
print '<td colspan="4">';
|
||||||
print $linktoprod;
|
print $linktoprod;
|
||||||
print "</td>";
|
print "</td>";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td>';
|
print '<td>';
|
||||||
print $linktoprod;
|
print $linktoprod;
|
||||||
print "</td>";
|
print "</td>";
|
||||||
@ -481,9 +456,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print $langs->trans("ProductDoesNotUseBatchSerial");
|
print $langs->trans("ProductDoesNotUseBatchSerial");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<td colspan="4">';
|
print '<td colspan="4">';
|
||||||
print $linktoprod;
|
print $linktoprod;
|
||||||
print "</td>";
|
print "</td>";
|
||||||
@ -491,7 +464,8 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
$var = ! $var;
|
$var = ! $var;
|
||||||
$up_ht_disc = $objp->subprice;
|
$up_ht_disc = $objp->subprice;
|
||||||
if (! empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) $up_ht_disc=price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU');
|
if (! empty($objp->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP))
|
||||||
|
$up_ht_disc = price2num($up_ht_disc * (100 - $objp->remise_percent) / 100, 'MU');
|
||||||
|
|
||||||
// Qty ordered
|
// Qty ordered
|
||||||
print '<td align="right">' . $objp->qty . '</td>';
|
print '<td align="right">' . $objp->qty . '</td>';
|
||||||
@ -499,8 +473,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
// Already dispatched
|
// Already dispatched
|
||||||
print '<td align="right">' . $products_dispatched[$objp->rowid] . '</td>';
|
print '<td align="right">' . $products_dispatched[$objp->rowid] . '</td>';
|
||||||
|
|
||||||
if (! empty($conf->productbatch->enabled) && $objp->tobatch==1)
|
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
|
||||||
{
|
|
||||||
$type = 'batch';
|
$type = 'batch';
|
||||||
print '<td align="right">' . img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column
|
print '<td align="right">' . img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column
|
||||||
print '<td></td>'; // Warehouse column
|
print '<td></td>'; // Warehouse column
|
||||||
@ -528,9 +501,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$form->select_date($dluodatesuffix, 'dluo' . $suffix, '', '', 1, "");
|
$form->select_date($dluodatesuffix, 'dluo' . $suffix, '', '', 1, "");
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td colspan="2"> </td>'; // Qty ordered + qty already dispatached
|
print '<td colspan="2"> </td>'; // Qty ordered + qty already dispatached
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$type = 'dispatch';
|
$type = 'dispatch';
|
||||||
print '<td align="right">' . img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column
|
print '<td align="right">' . img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
@ -552,16 +523,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
// Warehouse
|
// Warehouse
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
if (count($listwarehouses)>1)
|
if (count($listwarehouses) > 1) {
|
||||||
{
|
|
||||||
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 1, 0, $objp->fk_product);
|
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 1, 0, $objp->fk_product);
|
||||||
}
|
} elseif (count($listwarehouses) == 1) {
|
||||||
elseif (count($listwarehouses)==1)
|
|
||||||
{
|
|
||||||
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product);
|
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
print $langs->trans("NoWarehouseDefined");
|
print $langs->trans("NoWarehouseDefined");
|
||||||
}
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
@ -572,17 +538,14 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print "<br/>\n";
|
print "<br/>\n";
|
||||||
|
|
||||||
if ($nbproduct)
|
if ($nbproduct) {
|
||||||
{
|
|
||||||
print $langs->trans("Comment") . ' : ';
|
print $langs->trans("Comment") . ' : ';
|
||||||
print '<input type="text" size="60" maxlength="128" name="comment" value="';
|
print '<input type="text" size="60" maxlength="128" name="comment" value="';
|
||||||
print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $commande->ref);
|
print $_POST["comment"] ? GETPOST("comment") : $langs->trans("DispatchSupplierOrder", $commande->ref);
|
||||||
@ -591,12 +554,12 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
// print '<div class="center">';
|
// print '<div class="center">';
|
||||||
print '<input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"';
|
print '<input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"';
|
||||||
if (count($listwarehouses) <= 0) print ' disabled';
|
if (count($listwarehouses) <= 0)
|
||||||
|
print ' disabled';
|
||||||
print '>';
|
print '>';
|
||||||
// print '</div>';
|
// print '</div>';
|
||||||
}
|
}
|
||||||
if (! $nbproduct && $nbfreeproduct)
|
if (! $nbproduct && $nbfreeproduct) {
|
||||||
{
|
|
||||||
print $langs->trans("NoPredefinedProductToDispatch");
|
print $langs->trans("NoPredefinedProductToDispatch");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,7 +568,6 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
dol_fiche_end();
|
dol_fiche_end();
|
||||||
|
|
||||||
|
|
||||||
// List of lines already dispatched
|
// List of lines already dispatched
|
||||||
$sql = "SELECT p.ref, p.label,";
|
$sql = "SELECT p.ref, p.label,";
|
||||||
$sql .= " e.rowid as warehouse_id, e.label as entrepot,";
|
$sql .= " e.rowid as warehouse_id, e.label as entrepot,";
|
||||||
@ -618,13 +580,11 @@ if ($id > 0 || ! empty($ref))
|
|||||||
$sql .= " ORDER BY cfd.rowid ASC";
|
$sql .= " ORDER BY cfd.rowid ASC";
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0) {
|
||||||
{
|
|
||||||
print "<br/>\n";
|
print "<br/>\n";
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("ReceivingForSameOrder"));
|
print load_fiche_titre($langs->trans("ReceivingForSameOrder"));
|
||||||
@ -633,8 +593,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>' . $langs->trans("Description") . '</td>';
|
print '<td>' . $langs->trans("Description") . '</td>';
|
||||||
if (! empty($conf->productbatch->enabled))
|
if (! empty($conf->productbatch->enabled)) {
|
||||||
{
|
|
||||||
print '<td>' . $langs->trans("batch_number") . '</td>';
|
print '<td>' . $langs->trans("batch_number") . '</td>';
|
||||||
print '<td>' . $langs->trans("l_eatby") . '</td>';
|
print '<td>' . $langs->trans("l_eatby") . '</td>';
|
||||||
print '<td>' . $langs->trans("l_sellby") . '</td>';
|
print '<td>' . $langs->trans("l_sellby") . '</td>';
|
||||||
@ -643,13 +602,13 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
print '<td>' . $langs->trans("Warehouse") . '</td>';
|
print '<td>' . $langs->trans("Warehouse") . '</td>';
|
||||||
print '<td>' . $langs->trans("Comment") . '</td>';
|
print '<td>' . $langs->trans("Comment") . '</td>';
|
||||||
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) print '<td align="center" colspan="2">'.$langs->trans("Status").'</td>';
|
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS))
|
||||||
|
print '<td align="center" colspan="2">' . $langs->trans("Status") . '</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$var = false;
|
$var = false;
|
||||||
|
|
||||||
while ($i < $num)
|
while ( $i < $num ) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
print "<tr " . $bc[$var] . ">";
|
print "<tr " . $bc[$var] . ">";
|
||||||
@ -658,8 +617,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print ' - ' . $objp->label;
|
print ' - ' . $objp->label;
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
if (! empty($conf->productbatch->enabled))
|
if (! empty($conf->productbatch->enabled)) {
|
||||||
{
|
|
||||||
print '<td>' . $objp->batch . '</td>';
|
print '<td>' . $objp->batch . '</td>';
|
||||||
print '<td>' . dol_print_date($db->jdate($objp->eatby), 'day') . '</td>';
|
print '<td>' . dol_print_date($db->jdate($objp->eatby), 'day') . '</td>';
|
||||||
print '<td>' . dol_print_date($db->jdate($objp->sellby), 'day') . '</td>';
|
print '<td>' . dol_print_date($db->jdate($objp->sellby), 'day') . '</td>';
|
||||||
@ -680,8 +638,7 @@ if ($id > 0 || ! empty($ref))
|
|||||||
print '<td>' . dol_trunc($objp->comment) . '</td>';
|
print '<td>' . dol_trunc($objp->comment) . '</td>';
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS))
|
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) {
|
||||||
{
|
|
||||||
print '<td align="right">';
|
print '<td align="right">';
|
||||||
$supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
|
$supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status);
|
||||||
// print $supplierorderdispatch->status;
|
// print $supplierorderdispatch->status;
|
||||||
@ -690,37 +647,27 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
// Add button to check/uncheck disaptching
|
// Add button to check/uncheck disaptching
|
||||||
print '<td align="center">';
|
print '<td align="center">';
|
||||||
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner))
|
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) {
|
||||||
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))
|
if (empty($objp->status)) {
|
||||||
)
|
|
||||||
{
|
|
||||||
if (empty($objp->status))
|
|
||||||
{
|
|
||||||
print '<a class="button buttonRefused" href="#">' . $langs->trans("Approve") . '</a>';
|
print '<a class="button buttonRefused" href="#">' . $langs->trans("Approve") . '</a>';
|
||||||
print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
|
print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<a class="button buttonRefused" href="#">' . $langs->trans("Disapprove") . '</a>';
|
print '<a class="button buttonRefused" href="#">' . $langs->trans("Disapprove") . '</a>';
|
||||||
print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
|
print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$disabled = '';
|
$disabled = '';
|
||||||
if ($commande->statut == 5) $disabled=1;
|
if ($commande->statut == 5)
|
||||||
if (empty($objp->status))
|
$disabled = 1;
|
||||||
{
|
if (empty($objp->status)) {
|
||||||
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
|
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
|
||||||
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=denydispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Deny") . '</a>';
|
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=denydispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Deny") . '</a>';
|
||||||
}
|
}
|
||||||
if ($objp->status == 1)
|
if ($objp->status == 1) {
|
||||||
{
|
|
||||||
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=uncheckdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Reinit") . '</a>';
|
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=uncheckdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Reinit") . '</a>';
|
||||||
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=denydispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Deny") . '</a>';
|
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=denydispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Deny") . '</a>';
|
||||||
}
|
}
|
||||||
if ($objp->status == 2)
|
if ($objp->status == 2) {
|
||||||
{
|
|
||||||
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=uncheckdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Reinit") . '</a>';
|
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=uncheckdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Reinit") . '</a>';
|
||||||
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
|
print '<a class="button' . ($disabled ? ' buttonRefused' : '') . '" href="' . $_SERVER["PHP_SELF"] . "?id=" . $id . "&action=checkdispatchline&lineid=" . $objp->dispatchlineid . '">' . $langs->trans("Approve") . '</a>';
|
||||||
}
|
}
|
||||||
@ -737,19 +684,10 @@ if ($id > 0 || ! empty($ref))
|
|||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
dol_print_error($db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Commande non trouvee
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user