Merge pull request #1 from Dolibarr/develop

Develop
This commit is contained in:
Maxime Kohlhaas 2012-08-07 03:36:24 -07:00
commit b03c1aed6b
13 changed files with 240 additions and 139 deletions

View File

@ -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.

View File

@ -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))

View File

@ -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;
}

View File

@ -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
{

View File

@ -1,20 +0,0 @@
<!DOCTYPE HTML>
<!--
/*
* jQuery Iframe Transport Plugin Redirect Page 2.0
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Iframe Transport Plugin Redirect Page</title>
</head>
<body><script>document.body.innerHTML=decodeURIComponent(window.location.search.slice(1));</script></body>
</html>

View File

@ -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 () {

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1006,7 +1006,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui.js"></script>'."\n";
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-jui.js"></script>'."\n";
print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->'."\n";
'<!--[if gte IE 8]><script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport.js"></script><![endif]-->'."\n";
print '<!--[if gte IE 8]><script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport.js"></script><![endif]-->'."\n";
}
// jQuery DataTables
if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES))

View File

@ -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);

View File

@ -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&oacute;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 '<table class="border" width="100%">';
// Ref
@ -327,6 +354,20 @@ if ($_GET["id"] || $_GET["ref"])
*/
if ($action == "correction")
{
print '<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
function init_price()
{
if (jQuery("#mouvement").val() == \'0\') jQuery("#unitprice").removeAttr(\'disabled\');
else jQuery("#unitprice").attr(\'disabled\',\'disabled\');
}
init_price();
jQuery("#mouvement").change(function() {
init_price();
});
});
</script>';
print_titre($langs->trans("StockCorrection"));
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -335,24 +376,25 @@ if ($_GET["id"] || $_GET["ref"])
// Warehouse
print '<tr>';
print '<td width="20%">'.$langs->trans("Warehouse").'</td>';
print '<td width="20%" class="fieldrequired">'.$langs->trans("Warehouse").'</td>';
print '<td width="20%">';
print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot','',1);
print $formproduct->selectWarehouses(($_GET["dwid"]?$_GET["dwid"]:GETPOST('id_entrepot')),'id_entrepot','',1);
print '</td>';
print '<td width="20%">';
print '<select name="mouvement" class="flat">';
print '<select name="mouvement" id="mouvement" class="flat">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1">'.$langs->trans("Delete").'</option>';
print '</select></td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" size="10" value=""></td>';
print '<td width="20%" class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input class="flat" name="nbpiece" id="nbpiece" size="10" value="'.GETPOST("nbpiece").'"></td>';
print '</tr>';
// Label
print '<tr>';
print '<td width="20%">'.$langs->trans("Label").'</td>';
print '<td colspan="4">';
print '<input type="text" name="label" size="40" value="">';
print '<td colspan="2">';
print '<input type="text" name="label" size="40" value="'.GETPOST("label").'">';
print '</td>';
print '<td width="20%">'.$langs->trans("UnitPurchaseValue").'</td><td width="20%"><input class="flat" name="price" id="unitprice" size="10" value="'.GETPOST("unitprice").'"></td>';
print '</tr>';
print '</table>';
@ -374,20 +416,20 @@ if ($_GET["id"] || $_GET["ref"])
print '<table class="border" width="100%">';
print '<tr>';
print '<td width="20%">'.$langs->trans("WarehouseSource").'</td><td width="20%">';
print $formproduct->selectWarehouses($_GET["dwid"],'id_entrepot_source','',1);
print '<td width="20%" class="fieldrequired">'.$langs->trans("WarehouseSource").'</td><td width="20%">';
print $formproduct->selectWarehouses(($_GET["dwid"]?$_GET["dwid"]:GETPOST('id_entrepot_source')),'id_entrepot_source','',1);
print '</td>';
print '<td width="20%">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
print $formproduct->selectWarehouses('','id_entrepot_destination','',1);
print '<td width="20%" class="fieldrequired">'.$langs->trans("WarehouseTarget").'</td><td width="20%">';
print $formproduct->selectWarehouses(GETPOST('id_entrepot_destination'),'id_entrepot_destination','',1);
print '</td>';
print '<td width="20%">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value=""></td>';
print '<td width="20%" class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td width="20%"><input name="nbpiece" size="10" value="'.GETPOST("nbpiece").'"></td>';
print '</tr>';
// Label
print '<tr>';
print '<td width="20%">'.$langs->trans("Label").'</td>';
print '<td colspan="5">';
print '<input type="text" name="label" size="40" value="">';
print '<input type="text" name="label" size="40" value="'.GETPOST("label").'">';
print '</td>';
print '</tr>';
@ -533,9 +575,7 @@ print "</tr>";
print "</table>";
llxFooter();
$db->close();
llxFooter();
?>