mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-24 10:21:32 +01:00
Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into
develop_dict Conflicts: htdocs/install/mysql/migration/6.0.0-7.0.0.sql
This commit is contained in:
@@ -1157,7 +1157,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
// insert products details into database
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$result = $this->addline( // This include test on qty if option SUPPLIERORDER_WITH_NOPRICEDEFINED is not set
|
||||
$result = $this->addline( // This include test on qty if option SUPPLIER_ORDER_WITH_NOPRICEDEFINED is not set
|
||||
$this->lines[$i]->desc,
|
||||
$this->lines[$i]->subprice,
|
||||
$this->lines[$i]->qty,
|
||||
@@ -1393,7 +1393,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
if ($fk_product > 0)
|
||||
{
|
||||
if (empty($conf->global->SUPPLIERORDER_WITH_NOPRICEDEFINED))
|
||||
if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
|
||||
{
|
||||
// Check quantity is enough
|
||||
dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." fourn_ref=".$fourn_ref);
|
||||
@@ -2842,8 +2842,9 @@ class CommandeFournisseur extends CommonOrder
|
||||
$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;
|
||||
$filter['t.status']=1; // Restrict to lines with status validated
|
||||
}
|
||||
|
||||
$ret=$supplierorderdispatch->fetchAll('','',0,0,$filter);
|
||||
if ($ret<0)
|
||||
{
|
||||
@@ -2854,20 +2855,27 @@ class CommandeFournisseur extends CommonOrder
|
||||
{
|
||||
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) {
|
||||
$qtydelivered[$line->fk_product]+=$line->qty;
|
||||
}
|
||||
foreach($this->lines as $line) {
|
||||
$qtywished[$line->fk_product]+=$line->qty;
|
||||
}
|
||||
|
||||
$date_liv = dol_now();
|
||||
|
||||
//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)
|
||||
{
|
||||
|
||||
@@ -365,21 +365,29 @@ if (empty($reshook))
|
||||
{
|
||||
$productsupplier = new ProductFournisseur($db);
|
||||
|
||||
if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
|
||||
if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) // TODO this test seems useless
|
||||
{
|
||||
$idprod=0;
|
||||
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
|
||||
}
|
||||
|
||||
if (GETPOST('idprodfournprice') > 0)
|
||||
if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
|
||||
{
|
||||
$idprod=$reg[1];
|
||||
$res=$productsupplier->fetch($idprod);
|
||||
// Call to init properties of $productsupplier
|
||||
// So if a supplier price already exists for another thirdparty (first one found), we use it as reference price
|
||||
$productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist
|
||||
}
|
||||
elseif (GETPOST('idprodfournprice') > 0)
|
||||
{
|
||||
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
|
||||
$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat.
|
||||
//$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist
|
||||
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch);
|
||||
$res=$productsupplier->fetch($idprod);
|
||||
}
|
||||
|
||||
if ($idprod > 0)
|
||||
{
|
||||
$res=$productsupplier->fetch($idprod);
|
||||
|
||||
$label = $productsupplier->label;
|
||||
|
||||
$desc = $productsupplier->description;
|
||||
@@ -400,8 +408,8 @@ if (empty($reshook))
|
||||
$tva_tx,
|
||||
$localtax1_tx,
|
||||
$localtax2_tx,
|
||||
$idprod,
|
||||
$productsupplier->id,
|
||||
GETPOST('idprodfournprice'),
|
||||
$productsupplier->fourn_ref,
|
||||
$remise_percent,
|
||||
'HT',
|
||||
@@ -2105,6 +2113,7 @@ elseif (! empty($object->id))
|
||||
// Add free products/services form
|
||||
global $forceall, $senderissupplier, $dateSelector;
|
||||
$forceall=1; $senderissupplier=1; $dateSelector=0;
|
||||
if (! empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) $senderissupplier=2; // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum.
|
||||
|
||||
// Show object lines
|
||||
$inputalsopricewithtax=0;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
* \ingroup commande
|
||||
* \brief Page to dispatch receiving
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/modules/supplier_order/modules_commandefournisseur.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
|
||||
@@ -84,17 +85,33 @@ if ($id > 0 || ! empty($ref)) {
|
||||
* 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);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$result = $supplierorderdispatch->fetch($lineid);
|
||||
if (! $result)
|
||||
dol_print_error($db);
|
||||
$result = $supplierorderdispatch->setStatut(1);
|
||||
if ($result < 0) {
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||
$error ++;
|
||||
$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);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@@ -102,19 +119,42 @@ if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED
|
||||
$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);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$result = $supplierorderdispatch->fetch($lineid);
|
||||
if (! $result)
|
||||
dol_print_error($db);
|
||||
$result = $supplierorderdispatch->setStatut(0);
|
||||
if ($result < 0) {
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||
$error ++;
|
||||
$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);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@@ -122,19 +162,42 @@ if ($action == 'uncheckdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANC
|
||||
$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);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$result = $supplierorderdispatch->fetch($lineid);
|
||||
if (! $result)
|
||||
dol_print_error($db);
|
||||
$result = $supplierorderdispatch->setStatut(2);
|
||||
if ($result < 0) {
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($supplierorderdispatch->error, $supplierorderdispatch->errors, 'errors');
|
||||
$error ++;
|
||||
$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);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@@ -142,6 +205,14 @@ if ($action == 'denydispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_
|
||||
$action = '';
|
||||
}
|
||||
}
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) {
|
||||
@@ -743,7 +814,8 @@ if ($id > 0 || ! empty($ref)) {
|
||||
|
||||
// Add button to check/uncheck disaptching
|
||||
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)) {
|
||||
print '<a class="button buttonRefused" href="#">' . $langs->trans("Approve") . '</a>';
|
||||
print '<a class="button buttonRefused" href="#">' . $langs->trans("Deny") . '</a>';
|
||||
|
||||
@@ -976,21 +976,30 @@ if (empty($reshook))
|
||||
|
||||
if ($prod_entry_mode != 'free' && empty($error)) // With combolist mode idprodfournprice is > 0 or -1. With autocomplete, idprodfournprice is > 0 or ''
|
||||
{
|
||||
$idprod=0;
|
||||
$productsupplier=new ProductFournisseur($db);
|
||||
|
||||
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1)
|
||||
$idprod=0;
|
||||
if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...)
|
||||
|
||||
if (GETPOST('idprodfournprice') > 0)
|
||||
if (preg_match('/^idprod_([0-9]+)$/',GETPOST('idprodfournprice'), $reg))
|
||||
{
|
||||
$idprod=$reg[1];
|
||||
$res=$productsupplier->fetch($idprod);
|
||||
// Call to init properties of $productsupplier
|
||||
// So if a supplier price already exists for another thirdparty (first one found), we use it as reference price
|
||||
$productsupplier->get_buyprice(0, -1, $idprod, 'none'); // We force qty to -1 to be sure to find if a supplier price exist
|
||||
}
|
||||
elseif (GETPOST('idprodfournprice') > 0)
|
||||
{
|
||||
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
|
||||
$qtytosearch=$qty; // Just to see if a price exists for the quantity. Not used to found vat.
|
||||
//$qtytosearch=-1; // We force qty to -1 to be sure to find if a supplier price exist
|
||||
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qtytosearch);
|
||||
$res=$productsupplier->fetch($idprod);
|
||||
}
|
||||
|
||||
//Replaces $fk_unit with the product's
|
||||
if ($idprod > 0)
|
||||
{
|
||||
$result=$productsupplier->fetch($idprod);
|
||||
|
||||
$label = $productsupplier->label;
|
||||
|
||||
$desc = $productsupplier->description;
|
||||
@@ -1005,10 +1014,29 @@ if (empty($reshook))
|
||||
$type = $productsupplier->type;
|
||||
$price_base_type = 'HT';
|
||||
|
||||
// TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first)
|
||||
$result=$object->addline($desc, $productsupplier->fourn_pu, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, $idprod, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $productsupplier->fk_unit);
|
||||
// TODO Save the product supplier ref into database (like done for supplier propal and order) into field ref_supplier (must rename field ref into ref_supplier first)
|
||||
$result=$object->addline(
|
||||
$desc,
|
||||
$productsupplier->fourn_pu,
|
||||
$tva_tx,
|
||||
$localtax1_tx,
|
||||
$localtax2_tx,
|
||||
$qty,
|
||||
$idprod,
|
||||
$remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$tva_npr,
|
||||
$price_base_type,
|
||||
$type,
|
||||
-1,
|
||||
0,
|
||||
$array_options,
|
||||
$productsupplier->fk_unit
|
||||
);
|
||||
}
|
||||
if ($idprod == -2 || $idprod == 0)
|
||||
if ($idprod == -99 || $idprod == 0)
|
||||
{
|
||||
// Product not selected
|
||||
$error++;
|
||||
|
||||
Reference in New Issue
Block a user