diff --git a/ChangeLog b/ChangeLog
index c071f0e3628..63952957652 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -26,11 +26,13 @@ For users:
- New: Suggest a method to generate a backup file for user with no access
to mysqldump binary.
- New: Can correct stock of a warehouse from warehouse card.
-- New: [ task #454 ] Add "No category" into filters on category.
-- New: Update language files (de, tr, pt).
+- New: [ task #185 ]: Can input amount when correcting stock to recalculate PMP.
+- New: [ task #454 ]: Add "No category" into filters on category.
+- New: Update language files (de, tr, pt, ca_ES, es_ES).
- New: Auto check box on page to edit interface options of user.
+- New: More surface control on stock correction page.
- New: Add great britain provinces.
-- New: Update libs/tools for DoliWamp.
+- New: Update libs/tools/logo for DoliWamp.
- Fix: No images into product description lines as PDF generation does
not work with this.
diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php
index d7e024990d0..d36a075bcc2 100644
--- a/htdocs/commissions/index.php
+++ b/htdocs/commissions/index.php
@@ -160,8 +160,6 @@ else
$sql.= " AND f.fk_statut > 1";
$sql.= " AND s.entity = ".$conf->entity;
$sql.= " AND d.fk_facture = f.rowid";
-if ($conf->global->COMMISSION_BASE == "MARGIN")
- $sql.= " AND d.buy_price_ht IS NOT NULL AND d.buy_price_ht <> 0";
if ($agentid > 0)
$sql.= " AND sc.fk_user = $agentid";
if (!empty($startdate))
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index c61c16e108f..48e02b5b6fc 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3472,6 +3472,7 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
*/
function setEventMessage($mesgstring, $style='mesgs')
{
+ if (! in_array($style,array('mesgs','warnings','errors'))) dol_print_error('','Bad parameter for setEventMessage');
$_SESSION['dol_events'][$style][] = $mesgstring;
}
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 67f93a6d6f5..1ab1f99dbbc 100755
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -262,11 +262,16 @@ class pdf_crabe extends ModelePDFFactures
{
$curY = $nexY;
+ $pageposbefore=$pdf->getPage();
+
// Description of product line
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
+ $pageposafter=$pdf->getPage();
+ $pdf->setPage($pageposbefore);
+
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY();
@@ -324,6 +329,21 @@ class pdf_crabe extends ModelePDFFactures
$nexY+=2; // Passe espace entre les lignes
+ // Detect if some page were added automatically and output _tableau for past pages
+ while ($pagenb < $pageposafter)
+ {
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $tab_height + 40, 0, $outputlangs);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, 0, $outputlangs);
+ }
+ $pagenb++;
+ $pdf->setPage($pagenb);
+ }
+
// Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1) && empty($hidedesc)) // If it's not last line
{
diff --git a/htdocs/includes/jquery/plugins/fileupload/cors/result.html b/htdocs/includes/jquery/plugins/fileupload/cors/result.html
deleted file mode 100644
index 7c98026846f..00000000000
--- a/htdocs/includes/jquery/plugins/fileupload/cors/result.html
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-jQuery Iframe Transport Plugin Redirect Page
-
-
-
\ No newline at end of file
diff --git a/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js b/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js
index e330fe16a36..4c36f00865b 100644
--- a/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js
+++ b/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload User Interface Plugin 6.9.1
+ * jQuery File Upload User Interface Plugin 6.9.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -89,7 +89,7 @@
files = data.files;
$(this).fileupload('process', data).done(function () {
that._adjustMaxNumberOfFiles(-files.length);
- data.isAdjusted = true;
+ data.maxNumberOfFilesAdjusted = true;
data.files.valid = data.isValidated = that._validate(files);
data.context = that._renderUpload(files).data('data', data);
options.filesContainer[
@@ -112,8 +112,9 @@
send: function (e, data) {
var that = $(this).data('fileupload');
if (!data.isValidated) {
- if (!data.isAdjusted) {
+ if (!data.maxNumberOfFilesAdjusted) {
that._adjustMaxNumberOfFiles(-data.files.length);
+ data.maxNumberOfFilesAdjusted = true;
}
if (!that._validate(data.files)) {
return false;
@@ -151,7 +152,6 @@
function () {
var node = $(this);
template = that._renderDownload([file])
- .css('height', node.height())
.replaceAll(node);
that._forceReflow(template);
that._transition(template).done(
@@ -164,6 +164,17 @@
);
});
} else {
+ if ($.isArray(data.result)) {
+ $.each(data.result, function (index, file) {
+ if (data.maxNumberOfFilesAdjusted && file.error) {
+ that._adjustMaxNumberOfFiles(1);
+ } else if (!data.maxNumberOfFilesAdjusted &&
+ !file.error) {
+ that._adjustMaxNumberOfFiles(-1);
+ }
+ });
+ data.maxNumberOfFilesAdjusted = true;
+ }
template = that._renderDownload(data.result)
.appendTo(that.options.filesContainer);
that._forceReflow(template);
@@ -179,7 +190,9 @@
fail: function (e, data) {
var that = $(this).data('fileupload'),
template;
- that._adjustMaxNumberOfFiles(data.files.length);
+ if (data.maxNumberOfFilesAdjusted) {
+ that._adjustMaxNumberOfFiles(data.files.length);
+ }
if (data.context) {
data.context.each(function (index) {
if (data.errorThrown !== 'abort') {
@@ -210,7 +223,6 @@
}
});
} else if (data.errorThrown !== 'abort') {
- that._adjustMaxNumberOfFiles(-data.files.length);
data.context = that._renderUpload(data.files)
.appendTo(that.options.filesContainer)
.data('data', data);
@@ -664,10 +676,32 @@
}
},
+ _stringToRegExp: function (str) {
+ var parts = str.split('/'),
+ modifiers = parts.pop();
+ parts.shift();
+ return new RegExp(parts.join('/'), modifiers);
+ },
+
+ _initRegExpOptions: function () {
+ var options = this.options;
+ if ($.type(options.acceptFileTypes) === 'string') {
+ options.acceptFileTypes = this._stringToRegExp(
+ options.acceptFileTypes
+ );
+ }
+ if ($.type(options.previewSourceFileTypes) === 'string') {
+ options.previewSourceFileTypes = this._stringToRegExp(
+ options.previewSourceFileTypes
+ );
+ }
+ },
+
_initSpecialOptions: function () {
parentWidget.prototype._initSpecialOptions.call(this);
this._initFilesContainer();
this._initTemplates();
+ this._initRegExpOptions();
},
_create: function () {
diff --git a/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload.js b/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload.js
index 05a654bf2e2..4bbd287295a 100644
--- a/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload.js
+++ b/htdocs/includes/jquery/plugins/fileupload/js/jquery.fileupload.js
@@ -1,5 +1,5 @@
/*
- * jQuery File Upload Plugin 5.11.2
+ * jQuery File Upload Plugin 5.13
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
@@ -530,6 +530,10 @@
ub + i * mcs,
ub + (i + 1) * mcs
);
+ // Expose the chunk index:
+ o.chunkIndex = i;
+ // Expose the number of chunks:
+ o.chunksNumber = n;
// Store the current chunk size, as the blob itself
// will be dereferenced after data processing:
o.chunkSize = o.blob.size;
@@ -776,19 +780,30 @@
}
},
- _onChange: function (e) {
- var that = e.data.fileupload,
- data = {
- files: $.each($.makeArray(e.target.files), that._normalizeFile),
- fileInput: $(e.target),
- form: $(e.target.form)
- };
- if (!data.files.length) {
+ _getFileInputFiles: function (fileInput) {
+ fileInput = $(fileInput);
+ var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
+ value;
+ if (!files.length) {
+ value = fileInput.prop('value');
+ if (!value) {
+ return [];
+ }
// If the files property is not available, the browser does not
// support the File API and we add a pseudo File object with
// the input value as name with path information removed:
- data.files = [{name: e.target.value.replace(/^.*\\/, '')}];
+ files = [{name: value.replace(/^.*\\/, '')}];
}
+ return files;
+ },
+
+ _onChange: function (e) {
+ var that = e.data.fileupload,
+ data = {
+ fileInput: $(e.target),
+ form: $(e.target.form)
+ };
+ data.files = that._getFileInputFiles(data.fileInput);
if (that.options.replaceFileInput) {
that._replaceFileInput(data.fileInput);
}
@@ -838,7 +853,7 @@
return false;
}
if (dataTransfer) {
- dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
+ dataTransfer.dropEffect = 'copy';
}
e.preventDefault();
},
@@ -925,7 +940,11 @@
if (!data || this.options.disabled) {
return;
}
- data.files = $.each($.makeArray(data.files), this._normalizeFile);
+ if (data.fileInput && !data.files) {
+ data.files = this._getFileInputFiles(data.fileInput);
+ } else {
+ data.files = $.each($.makeArray(data.files), this._normalizeFile);
+ }
this._onAdd(null, data);
},
@@ -936,7 +955,11 @@
// The method returns a Promise object for the file upload call.
send: function (data) {
if (data && !this.options.disabled) {
- data.files = $.each($.makeArray(data.files), this._normalizeFile);
+ if (data.fileInput && !data.files) {
+ data.files = this._getFileInputFiles(data.fileInput);
+ } else {
+ data.files = $.each($.makeArray(data.files), this._normalizeFile);
+ }
if (data.files.length) {
return this._onSend(null, data);
}
diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang
index 823cb5cc04f..1654d4bb197 100644
--- a/htdocs/langs/en_US/stocks.lang
+++ b/htdocs/langs/en_US/stocks.lang
@@ -33,6 +33,7 @@ StockCorrection=Correct stock
StockMovement=Transfer
StockMovements=Stock transfers
NumberOfUnit=Number of units
+UnitPurchaseValue=Unit purchase price
TotalStock=Total in stock
StockTooLow=Stock too low
EnhancedValue=Value
diff --git a/htdocs/langs/es_ES/stocks.lang b/htdocs/langs/es_ES/stocks.lang
index f9cbb5ededd..061d01ed587 100644
--- a/htdocs/langs/es_ES/stocks.lang
+++ b/htdocs/langs/es_ES/stocks.lang
@@ -33,6 +33,7 @@ StockCorrection=Corrección stock
StockMovement=Transferencia
StockMovements=Movimientos de stock
NumberOfUnit=Número de piezas
+UnitPurchaseValue=Precio de compra unitario
TotalStock=Total en stock
StockTooLow=Stock insuficiente
EnhancedValue=Valor
diff --git a/htdocs/langs/fr_FR/stocks.lang b/htdocs/langs/fr_FR/stocks.lang
index 4aacdedaead..6549d8a4afc 100644
--- a/htdocs/langs/fr_FR/stocks.lang
+++ b/htdocs/langs/fr_FR/stocks.lang
@@ -33,6 +33,7 @@ StockCorrection=Corriger stock
StockMovement=Transférer
StockMovements=Mouvements de stock
NumberOfUnit=Nombre de pièces
+UnitPurchaseValue=Prix d'achat unitaire
TotalStock=Total en stock
StockTooLow=Stock insuffisant
EnhancedValue=Valorisation
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index f26d9481dfc..e45040779c4 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1006,7 +1006,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print ''."\n";
print ''."\n";
print ''."\n";
- ''."\n";
+ print ''."\n";
}
// jQuery DataTables
if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES))
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 47f985bff2f..7c85be67781 100755
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -82,7 +82,7 @@ if ($action=='delete')
{
$langs->load("other");
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
- $ret=dol_delete_file($file);
+ $ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php
index a3cdf0f7dc9..714a8d71291 100644
--- a/htdocs/product/stock/product.php
+++ b/htdocs/product/stock/product.php
@@ -42,12 +42,12 @@ $cancel=GETPOST('cancel');
// Security check
$id = GETPOST('id')?GETPOST('id'):GETPOST('ref');
$ref = GETPOST('ref');
+$stocklimit = GETPOST('stocklimit');
+$cancel = GETPOST('cancel');
$fieldid = isset($_GET["ref"])?'ref':'rowid';
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit&stock',$id,'product&product','','',$fieldid);
-$mesg = '';
-
/*
* Actions
@@ -59,94 +59,123 @@ if ($cancel) $action='';
if ($action == 'setstocklimit')
{
$product = new Product($db);
- $result=$product->fetch($_POST['id']);
- $product->seuil_stock_alerte=$_POST["stocklimit"];
+ $result=$product->fetch($id);
+ $product->seuil_stock_alerte=$stocklimit;
$result=$product->update($product->id,$user,1,0,1);
if ($result < 0)
- {
- $mesg=join(',',$product->errors);
- }
- $POST["action"]="";
- $id=$_POST["id"];
- $_GET["id"]=$_POST["id"];
+ setEventMessage($product->error, 'errors');
+ $action='';
}
// Correct stock
-if ($action == "correct_stock" && ! $_POST["cancel"])
+if ($action == "correct_stock" && ! $cancel)
{
- if (is_numeric($_POST["nbpiece"]) && $id)
+ if (! (GETPOST("id_entrepot") > 0))
{
- $product = new Product($db);
- $result=$product->fetch($id);
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Warehouse")), 'errors');
+ $error++;
+ $action='correction';
+ }
+ if (! GETPOST("nbpiece"))
+ {
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("NumberOfUnit")), 'errors');
+ $error++;
+ $action='correction';
+ }
- $result=$product->correct_stock(
- $user,
- $_POST["id_entrepot"],
- $_POST["nbpiece"],
- $_POST["mouvement"],
- $_POST["label"],
- 0
- ); // We do not change value of stock for a correction
-
- if ($result > 0)
+ if (! $error)
+ {
+ $priceunit=price2num(GETPOST("price"));
+ if (is_numeric(GETPOST("nbpiece")) && $id)
{
- header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id);
- exit;
+ $product = new Product($db);
+ $result=$product->fetch($id);
+
+ $result=$product->correct_stock(
+ $user,
+ GETPOST("id_entrepot"),
+ GETPOST("nbpiece"),
+ GETPOST("mouvement"),
+ GETPOST("label"),
+ $priceunit
+ ); // We do not change value of stock for a correction
+
+ if ($result > 0)
+ {
+ header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id);
+ exit;
+ }
}
}
}
// Transfer stock from a warehouse to another warehouse
-if ($action == "transfert_stock" && ! $_POST["cancel"])
+if ($action == "transfert_stock" && ! $cancel)
{
- if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"])
- {
- if (is_numeric($_POST["nbpiece"]) && $id)
+ if (! (GETPOST("id_entrepot_source") > 0) || ! (GETPOST("id_entrepot_destination") > 0))
+ {
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Warehouse")), 'errors');
+ $error++;
+ $action='transfert';
+ }
+ if (! GETPOST("nbpiece"))
+ {
+ setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("NumberOfUnit")), 'errors');
+ $error++;
+ $action='transfert';
+ }
+
+ if (! $error)
+ {
+ if (GETPOST("id_entrepot_source") <> GETPOST("id_entrepot_destination"))
{
- $product = new Product($db);
- $result=$product->fetch($id);
-
- $db->begin();
-
- $product->load_stock(); // Load array product->stock_warehouse
-
- // Define value of products moved
- $pricesrc=0;
- if (isset($product->stock_warehouse[$_POST["id_entrepot_source"]]->pmp)) $pricesrc=$product->stock_warehouse[$_POST["id_entrepot_source"]]->pmp;
- $pricedest=$pricesrc;
-
- //print 'price src='.$pricesrc.', price dest='.$pricedest;exit;
-
- // Remove stock
- $result1=$product->correct_stock(
- $user,
- $_POST["id_entrepot_source"],
- $_POST["nbpiece"],
- 1,
- $_POST["label"],
- $pricesrc
- );
-
- // Add stock
- $result2=$product->correct_stock(
- $user,
- $_POST["id_entrepot_destination"],
- $_POST["nbpiece"],
- 0,
- $_POST["label"],
- $pricedest
- );
-
- if ($result1 >= 0 && $result2 >= 0)
+ if (is_numeric(GETPOST("nbpiece")) && $id)
{
- $db->commit();
- header("Location: product.php?id=".$product->id);
- exit;
- }
- else
- {
- $mesg=$product->error;
- $db->rollback();
+ $product = new Product($db);
+ $result=$product->fetch($id);
+
+ $db->begin();
+
+ $product->load_stock(); // Load array product->stock_warehouse
+
+ // Define value of products moved
+ $pricesrc=0;
+ if (isset($product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp)) $pricesrc=$product->stock_warehouse[GETPOST("id_entrepot_source")]->pmp;
+ $pricedest=$pricesrc;
+
+ //print 'price src='.$pricesrc.', price dest='.$pricedest;exit;
+
+ // Remove stock
+ $result1=$product->correct_stock(
+ $user,
+ GETPOST("id_entrepot_source"),
+ GETPOST("nbpiece"),
+ 1,
+ GETPOST("label"),
+ $pricesrc
+ );
+
+ // Add stock
+ $result2=$product->correct_stock(
+ $user,
+ GETPOST("id_entrepot_destination"),
+ GETPOST("nbpiece"),
+ 0,
+ GETPOST("label"),
+ $pricedest
+ );
+
+ if ($result1 >= 0 && $result2 >= 0)
+ {
+ $db->commit();
+ header("Location: product.php?id=".$product->id);
+ exit;
+ }
+ else
+ {
+ setEventMessage($product->error, 'errors');
+ $db->rollback();
+ }
}
}
}
@@ -160,11 +189,11 @@ if ($action == "transfert_stock" && ! $_POST["cancel"])
$formproduct=new FormProduct($db);
-if ($_GET["id"] || $_GET["ref"])
+if ($id > 0 || $ref)
{
$product = new Product($db);
- if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
- if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
+ if ($ref) $result = $product->fetch('',$ref);
+ if ($id > 0) $result = $product->fetch($id);
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
llxHeader("",$langs->trans("CardProduct".$product->type),$help_url);
@@ -178,8 +207,6 @@ if ($_GET["id"] || $_GET["ref"])
$form = new Form($db);
- print($mesg);
-
print '