diff --git a/ChangeLog b/ChangeLog
index 42cf4d14f1e..3b418404736 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -662,7 +662,7 @@ NEW: Disabled users are striked.
NEW: Enhance navigation of project module
NEW: fichinter lines ordered by rang AND DATE
NEW: hidden conf to use input file multiple from mail form
-NEW: hidden feature: SUPPLIERORDER_WITH_NOPRICEDEFINED allow supplier order even if no supplier price defined
+NEW: hidden feature: SUPPLIER_ORDER_WITH_NOPRICEDEFINED allow supplier order even if no supplier price defined
NEW: Hidden option MAIN_LANDING_PAGE to choose the first page to show after login works as a "global" option (llx_const) and as a "per user" option (llx_user_param).
NEW: Holiday is a now a RH module. All RH module provides by default visilibity on users of its hierarchy.
NEW: If error is reported during migration process, you can ignore it to avoid to be locked.
diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php
index 49987648910..a5e37f620f7 100644
--- a/htdocs/admin/agenda_other.php
+++ b/htdocs/admin/agenda_other.php
@@ -42,7 +42,7 @@ $action = GETPOST('action','alpha');
$value = GETPOST('value','alpha');
$param = GETPOST('param','alpha');
$cancel = GETPOST('cancel','alpha');
-$scandir = GETPOST('scandir','alpha');
+$scandir = GETPOST('scan_dir','alpha');
$type = 'action';
@@ -273,7 +273,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
print '
';
if (! $i) $totalarray['nbfield']++;
}
diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php
index 0d9a9a94aea..1f3ca1cde8e 100644
--- a/htdocs/compta/bank/transfer.php
+++ b/htdocs/compta/bank/transfer.php
@@ -55,7 +55,7 @@ if ($action == 'add_confirm')
if (! $label)
{
-
+ $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Description")), null, 'errors');
}
if (! $amount)
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 79090526dc0..ec5db92414a 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2322,10 +2322,6 @@ class Form
unset($producttmpselect);
}
- if (!empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
- {
- print '';
- }
// mode=2 means suppliers products
$urloption=($socid > 0?'socid='.$socid.'&':'').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
@@ -2333,11 +2329,6 @@ class Form
}
else
{
- if (!empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
- {
- print '';
- print '';
- }
print $this->select_produits_fournisseurs_list($socid,$selected,$htmlname,$filtertype,$filtre,'',-1,0,0,$alsoproductwithnosupplierprice);
}
}
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 76a1458b913..dc86a2ef9f3 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -40,6 +40,7 @@
* Ex: array('disabled'=> )
* Ex: array('show'=> )
* Ex: array('update_textarea'=> )
+ * Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
* @return string Script
*/
function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array())
@@ -146,6 +147,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
$("#'.$htmlname.'").val(ui.item.id).trigger("change"); // Select new value
// Disable an element
if (options.option_disabled) {
+ console.log("Make action option_disabled on #"+options.option_disabled+" with disabled="+ui.item.disabled)
if (ui.item.disabled) {
$("#" + options.option_disabled).prop("disabled", true);
if (options.error) {
@@ -154,28 +156,32 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
if (options.warning) {
$.jnotify(options.warning, "warning", false); // Output with jnotify the warning message
}
- } else {
+ } else {
$("#" + options.option_disabled).removeAttr("disabled");
}
}
if (options.disabled) {
+ console.log("Make action disabled on each "+options.option_disabled)
$.each(options.disabled, function(key, value) {
$("#" + value).prop("disabled", true);
});
}
if (options.show) {
+ console.log("Make action show on each "+options.show)
$.each(options.show, function(key, value) {
$("#" + value).show().trigger("show");
});
}
// Update an input
if (ui.item.update) {
+ console.log("Make action update on each ui.item.update")
// loop on each "update" fields
$.each(ui.item.update, function(key, value) {
$("#" + key).val(value).trigger("change");
});
}
if (ui.item.textarea) {
+ console.log("Make action textarea on each ui.item.textarea")
$.each(ui.item.textarea, function(key, value) {
if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined" && CKEDITOR.instances[key] != "undefined") {
CKEDITOR.instances[key].setData(value);
@@ -192,7 +198,6 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
}
,delay: 500
}).data("'.$dataforrenderITem.'")._renderItem = function( ul, item ) {
-
return $("
")
.data( "'.$dataforitem.'", item ) // jQuery UI > 1.10.0
.append( \'\' + item.label + "" )
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 19a97cbf9cf..5f0c1ead5f6 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -193,8 +193,9 @@ function getBrowserInfo($user_agent)
}
// OS
- if (preg_match('/linux/i', $user_agent)) { $os='linux'; }
+ if (preg_match('/linux/i', $user_agent)) { $os='linux'; }
elseif (preg_match('/macintosh/i', $user_agent)) { $os='macintosh'; }
+ elseif (preg_match('/windows/i', $user_agent)) { $os='windows'; }
// Name
if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='firefox'; $version=$reg[2]; }
@@ -204,7 +205,8 @@ function getBrowserInfo($user_agent)
elseif (preg_match('/epiphany/i', $user_agent)) { $name='epiphany'; }
elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='safari'; $version=$reg[2]; } // Safari is often present in string for mobile but its not.
elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; }
- elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];\srv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end
+ elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end
+ elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end
elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; }
if ($tablet) {
@@ -1193,10 +1195,10 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$nophoto='';
$morehtmlleft.='';
}
- elseif ($conf->browser->layout != 'phone') { // Show no photo link
+ //elseif ($conf->browser->layout != 'phone') { // Show no photo link
$nophoto='/public/theme/common/nophoto.png';
$morehtmlleft.='
';
- }
+ //}
}
}
else
@@ -1273,7 +1275,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
}
}
- if (! $phototoshow && $conf->browser->layout != 'phone') // Show No photo link (picto of pbject)
+ if (! $phototoshow) // Show No photo link (picto of pbject)
{
$morehtmlleft.='
';
if ($object->element == 'action')
@@ -1291,6 +1293,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
}
$morehtmlleft.='';
$morehtmlleft.='
';
+
$morehtmlleft.='
';
}
}
@@ -6460,7 +6463,7 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
/**
* Return value from dictionary
- *
+ *
* @param string $tablename name of dictionary
* @param string $field the value to return
* @param int $id id of line
@@ -6470,13 +6473,13 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield='rowid')
{
global $dictvalues,$db,$langs;
-
+
if (!isset($dictvalues[$tablename]))
{
$dictvalues[$tablename] = array();
$sql = 'SELECT * FROM '.$tablename.' WHERE 1';
if ($checkentity) $sql.= ' entity IN (0,'.getEntity('').')';
-
+
$resql = $db->query($sql);
if ($resql)
{
@@ -6490,7 +6493,7 @@ function getDictvalue($tablename, $field, $id, $checkentity=false, $rowidfield='
dol_print_error($db);
}
}
-
+
if (!empty($dictvalues[$tablename][$id])) return $dictvalues[$tablename][$id]->{$field}; // Found
else // Not found
{
diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php
index 1be45a27f7d..97f50498fb0 100644
--- a/htdocs/core/tpl/objectline_create.tpl.php
+++ b/htdocs/core/tpl/objectline_create.tpl.php
@@ -26,7 +26,7 @@
* $langs
* $dateSelector
* $forceall (0 by default, 1 for supplier invoices/orders)
- * $senderissupplier (0 by default, 1 for supplier invoices/orders)
+ * $senderissupplier (0 by default, 1 or 2 for supplier invoices/orders)
* $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax)
*/
@@ -208,12 +208,13 @@ else {
}
else
{
+ // $senderissupplier=2 is same than 1 but disable test on minimum qty and disable autofill qty with minimum
if ($senderissupplier != 2)
{
$ajaxoptions=array(
'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key
- 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done
- 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error'
+ 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done
+ 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo)
);
$alsoproductwithnosupplierprice=0;
}
@@ -222,6 +223,7 @@ else {
$ajaxoptions = array();
$alsoproductwithnosupplierprice=1;
}
+
$form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice);
}
echo '';
diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php
index 2ca1cba1083..69e48248d57 100644
--- a/htdocs/don/admin/donation.php
+++ b/htdocs/don/admin/donation.php
@@ -42,6 +42,8 @@ $typeconst=array('yesno','texte','chaine');
$action = GETPOST('action','alpha');
$value = GETPOST('value');
+$label = GETPOST('label','alpha');
+$scandir = GETPOST('scan_dir','alpha');
$type='donation';
@@ -287,14 +289,14 @@ if (is_resource($handle))
else
{
print "
';
}
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 23e3b260c73..6ca854bf319 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -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)
{
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index 4e3362d36ac..56566438206 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -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;
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index c0465a61658..f4f05f96b78 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -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 '
';
- 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 '' . $langs->trans("Approve") . '';
print '' . $langs->trans("Deny") . '';
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 48afcbd3d06..439780d560a 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -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++;
diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
index 90c2a6bc8cf..cc28940863b 100644
--- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
+++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
@@ -191,6 +191,9 @@ ALTER TABLE llx_extrafields ADD COLUMN fk_user_modif integer;
ALTER TABLE llx_extrafields ADD COLUMN datec datetime;
ALTER TABLE llx_extrafields ADD COLUMN tms timestamp;
+ALTER TABLE llx_holiday_config MODIFY COLUMN name varchar(128);
+ALTER TABLE llx_holiday_config ADD UNIQUE INDEX idx_holiday_config (name);
+
ALTER TABLE llx_c_paiement DROP PRIMARY KEY;
ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id;
ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement;
@@ -199,3 +202,4 @@ ALTER TABLE llx_c_paiement ADD UNIQUE INDEX uk_c_paiement(id, entity, code);
ALTER TABLE llx_c_payment_term DROP PRIMARY KEY;
ALTER TABLE llx_c_payment_term ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER rowid;
ALTER TABLE llx_c_payment_term ADD UNIQUE INDEX uk_c_payment_term(rowid, entity, code);
+
diff --git a/htdocs/install/mysql/tables/llx_holiday_config.key.sql b/htdocs/install/mysql/tables/llx_holiday_config.key.sql
new file mode 100644
index 00000000000..cda95c87f39
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_holiday_config.key.sql
@@ -0,0 +1,20 @@
+-- ===================================================================
+-- Copyright (C) 2012 Laurent Destailleur
+--
+-- 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
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+--
+-- ===================================================================
+
+ALTER TABLE llx_holiday_config ADD UNIQUE INDEX idx_holiday_config (name);
+
diff --git a/htdocs/install/mysql/tables/llx_holiday_config.sql b/htdocs/install/mysql/tables/llx_holiday_config.sql
index 2f08bf5aa41..4ef6f15c7df 100644
--- a/htdocs/install/mysql/tables/llx_holiday_config.sql
+++ b/htdocs/install/mysql/tables/llx_holiday_config.sql
@@ -19,7 +19,7 @@
CREATE TABLE llx_holiday_config
(
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
-name VARCHAR( 255 ) NOT NULL UNIQUE,
+name VARCHAR(128) NOT NULL,
value TEXT NULL
)
ENGINE=innodb;
\ No newline at end of file
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index f2f0aba9579..ce7512f52c2 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1075,10 +1075,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print ''."\n"; // Do not index
print ''; // Scale for mobile device
print ''."\n";
- // Favicon. Note, even if we remove this meta, the browser and android webview try to find a favicon.ico
+ // Favicon
$favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1);
if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL;
- print ''."\n";
+ if (empty($conf->dol_use_jmobile)) print ''."\n"; // Not required into an Android webview
//if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser','int')) print ''."\n";
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser','int')) print ''."\n";
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && ! GETPOST('textbrowser','int')) print ''."\n";
diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php
index 172bdd9354c..78829e489a6 100644
--- a/htdocs/product/admin/product.php
+++ b/htdocs/product/admin/product.php
@@ -46,7 +46,7 @@ if (! $user->admin || (empty($conf->product->enabled) && empty($conf->service->e
$action = GETPOST('action','alpha');
$value = GETPOST('value','alpha');
$label = GETPOST('label','alpha');
-$scandir = GETPOST('scandir','alpha');
+$scandir = GETPOST('scan_dir','alpha');
$type='product';
// Pricing Rules
@@ -460,7 +460,7 @@ foreach ($dirmodels as $reldir)
else
{
print '