FIX #7226
This commit is contained in:
parent
29e656ec7e
commit
52a8692a85
@ -2832,8 +2832,9 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($this->db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($this->db);
|
||||||
$filter=array('t.fk_commande'=>$this->id);
|
$filter=array('t.fk_commande'=>$this->id);
|
||||||
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) {
|
if (! empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) {
|
||||||
$filter['t.status']=1;
|
$filter['t.status']=1; // Restrict to lines with status validated
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret=$supplierorderdispatch->fetchAll('','',0,0,$filter);
|
$ret=$supplierorderdispatch->fetchAll('','',0,0,$filter);
|
||||||
if ($ret<0)
|
if ($ret<0)
|
||||||
{
|
{
|
||||||
@ -2844,20 +2845,27 @@ class CommandeFournisseur extends CommonOrder
|
|||||||
{
|
{
|
||||||
if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0)
|
if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0)
|
||||||
{
|
{
|
||||||
//Build array with quantity deliverd by product
|
$date_liv = dol_now();
|
||||||
|
|
||||||
|
// Build array with quantity deliverd by product
|
||||||
foreach($supplierorderdispatch->lines as $line) {
|
foreach($supplierorderdispatch->lines as $line) {
|
||||||
$qtydelivered[$line->fk_product]+=$line->qty;
|
$qtydelivered[$line->fk_product]+=$line->qty;
|
||||||
}
|
}
|
||||||
foreach($this->lines as $line) {
|
foreach($this->lines as $line) {
|
||||||
$qtywished[$line->fk_product]+=$line->qty;
|
$qtywished[$line->fk_product]+=$line->qty;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date_liv = dol_now();
|
|
||||||
|
|
||||||
//Compare array
|
//Compare array
|
||||||
$diff_array=array_diff_assoc($qtydelivered,$qtywished);
|
$diff_array=array_diff_assoc($qtydelivered,$qtywished); // Warning: $diff_array is done only on common keys.
|
||||||
|
$keysinwishednotindelivered=array_diff(array_keys($qtywished),array_keys($qtydelivered)); // To check we also have same number of keys
|
||||||
|
$keysindeliverednotinwished=array_diff(array_keys($qtydelivered),array_keys($qtywished)); // To check we also have same number of keys
|
||||||
|
/*var_dump(array_keys($qtydelivered));
|
||||||
|
var_dump(array_keys($qtywished));
|
||||||
|
var_dump($diff_array);
|
||||||
|
var_dump($keysinwishednotindelivered);
|
||||||
|
var_dump($keysindeliverednotinwished);
|
||||||
|
exit;*/
|
||||||
|
|
||||||
if (count($diff_array)==0) //No diff => mean everythings is received
|
if (count($diff_array)==0 && count($keysinwishednotindelivered)==0 && count($keysindeliverednotinwished)==0) //No diff => mean everythings is received
|
||||||
{
|
{
|
||||||
if ($closeopenorder)
|
if ($closeopenorder)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
* \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';
|
||||||
@ -84,17 +85,33 @@ if ($id > 0 || ! empty($ref)) {
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
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)))) {
|
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))))
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$result = $supplierorderdispatch->fetch($lineid);
|
$result = $supplierorderdispatch->fetch($lineid);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
dol_print_error($db);
|
{
|
||||||
$result = $supplierorderdispatch->setStatut(1);
|
$error++;
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
$error ++;
|
|
||||||
$action = '';
|
$action = '';
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$result = $supplierorderdispatch->setStatut(1);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
|
$error++;
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$result = $object->calcAndSetStatusDispatch($user);
|
$result = $object->calcAndSetStatusDispatch($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
@ -102,19 +119,42 @@ if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED
|
|||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)))) {
|
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))))
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$result = $supplierorderdispatch->fetch($lineid);
|
$result = $supplierorderdispatch->fetch($lineid);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
dol_print_error($db);
|
{
|
||||||
$result = $supplierorderdispatch->setStatut(0);
|
$error++;
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
$error ++;
|
|
||||||
$action = '';
|
$action = '';
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$result = $supplierorderdispatch->setStatut(0);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
|
$error ++;
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$result = $object->calcAndSetStatusDispatch($user);
|
$result = $object->calcAndSetStatusDispatch($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
@ -122,19 +162,42 @@ if ($action == 'uncheckdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANC
|
|||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)))) {
|
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))))
|
||||||
|
{
|
||||||
|
$error=0;
|
||||||
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
$result = $supplierorderdispatch->fetch($lineid);
|
$result = $supplierorderdispatch->fetch($lineid);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
dol_print_error($db);
|
{
|
||||||
$result = $supplierorderdispatch->setStatut(2);
|
$error++;
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
$error ++;
|
|
||||||
$action = '';
|
$action = '';
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$result = $supplierorderdispatch->setStatut(2);
|
||||||
|
if ($result < 0) {
|
||||||
|
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||||
|
$error ++;
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
$result = $object->calcAndSetStatusDispatch($user);
|
$result = $object->calcAndSetStatusDispatch($user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
@ -142,6 +205,14 @@ if ($action == 'denydispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_
|
|||||||
$action = '';
|
$action = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) {
|
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) {
|
||||||
@ -699,7 +770,8 @@ 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)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check))) {
|
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)))
|
||||||
|
{
|
||||||
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>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user