Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2013-08-24 19:36:17 +02:00
commit 75bd05d212
10 changed files with 278 additions and 55 deletions

View File

@ -101,6 +101,9 @@ parameter. All methods addline in this case were modified to remove this paramet
***** ChangeLog for 3.4.1 compared to 3.4.0 ***** ***** ChangeLog for 3.4.1 compared to 3.4.0 *****
Fix: Display buying price on line edit when no supplier price is defined
Fix: Retrieving of margin info when invoice created automatically from order
Fix: Reordering supplier products in list by supplier or supplier ref was crashing
Fix: [ bug #1029 ] Tulip numbering mask Fix: [ bug #1029 ] Tulip numbering mask
Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card Fix: Supplier invoice and supplier order are not displayed into object link into agenda event card
Fix: [ bug #1033 ] SUPPLIER REF disappeared Fix: [ bug #1033 ] SUPPLIER REF disappeared
@ -108,7 +111,8 @@ Fix: update extrafield do not display immediatly after update
Fix: Fix bug with canvas thirdparty Fix: Fix bug with canvas thirdparty
Fix: [ bug #1037 ] Consumption> Supplier invoices related Fix: [ bug #1037 ] Consumption> Supplier invoices related
Fix: User group name do not display in card (view or edit mode) Fix: User group name do not display in card (view or edit mode)
Fix: Link "Show all supplier invoice" on suplier card not working
Fix: [ bug #1039 ] Pre-defined invoices conversion
***** ChangeLog for 3.4 compared to 3.3.* ***** ***** ChangeLog for 3.4 compared to 3.3.* *****
For users: For users:

View File

@ -2,7 +2,8 @@
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -115,7 +116,7 @@ if ($action == 'create')
{ {
print_fiche_titre($langs->trans("CreateRepeatableInvoice")); print_fiche_titre($langs->trans("CreateRepeatableInvoice"));
$object = new FactureRec($db); // Source invoice $object = new Facture($db); // Source invoice
$product_static = new Product($db); $product_static = new Product($db);
if ($object->fetch($id) > 0) if ($object->fetch($id) > 0)
@ -602,4 +603,4 @@ else
llxFooter(); llxFooter();
$db->close(); $db->close();
?> ?>

View File

@ -41,17 +41,31 @@ if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td> <td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
<?php <?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { if ($user->rights->margins->creer)
$colspan++; {
$colspan2++; if(! empty($conf->global->DISPLAY_MARGIN_RATES))
} {
if (! empty($conf->global->DISPLAY_MARK_RATES)) { echo '<td align="right">'.$langs->trans('MarginRate').'</td>';
$colspan++; }
$colspan2++; if(! empty($conf->global->DISPLAY_MARK_RATES))
} {
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { echo '<td align="right">'.$langs->trans('MarkRate').'</td>';
$colspan2++; }
} }
else
{
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
$colspan++;
$colspan2++;
}
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
$colspan++;
$colspan2++;
}
}
if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$colspan2++;
}
} }
?> ?>
<td colspan="<?php echo $colspan; ?>">&nbsp;</td> <td colspan="<?php echo $colspan; ?>">&nbsp;</td>
@ -164,21 +178,35 @@ if (! empty($conf->margin->enabled)) {
<input type="text" size="1" value="<?php echo $buyer->remise_percent; ?>" id="remise_percent" name="remise_percent">% <input type="text" size="1" value="<?php echo $buyer->remise_percent; ?>" id="remise_percent" name="remise_percent">%
<input type="hidden" id="origin_remise_percent" name="origin_remise_percent" value="<?php echo $buyer->remise_percent; ?>" /> <input type="hidden" id="origin_remise_percent" name="origin_remise_percent" value="<?php echo $buyer->remise_percent; ?>" />
</td> </td>
<?php <?php
$colspan = 4; $colspan = 4;
if (! empty($conf->margin->enabled)) { if (! empty($conf->margin->enabled)) {
?> ?>
<td align="right"> <td align="right">
<select id="fournprice" name="fournprice" style="display: none;"></select> <select id="fournprice" name="fournprice" style="display: none;"></select>
<input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (GETPOST('buying_price')?GETPOST('buying_price'):''); ?>"> <input type="text" size="5" id="buying_price" name="buying_price" value="<?php echo (GETPOST('buying_price')?GETPOST('buying_price'):''); ?>">
</td> </td>
<?php <?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) if ($user->rights->margins->creer)
$colspan++; {
if (! empty($conf->global->DISPLAY_MARK_RATES)) if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
$colspan++; echo '<td align="right"><input type="text" size="2" name="np_marginRate" value="'.(isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:'').'">%</td>';
} }
?> elseif (! empty($conf->global->DISPLAY_MARK_RATES)) {
echo '<td align="right"><input type="text" size="2" name="np_markRate" value="'.(isset($_POST["np_markRate"])?$_POST["np_markRate"]:'').'">%</td>';
}
}
else
{
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) {
$colspan++;
}
if (! empty($conf->global->DISPLAY_MARK_RATES)) {
$colspan++;
}
}
}
?>
<td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" id="addlinebutton" name="addline" value="<?php echo $langs->trans('Add'); ?>"></td> <td align="center" valign="middle" colspan="<?php echo $colspan; ?>"><input type="submit" class="button" id="addlinebutton" name="addline" value="<?php echo $langs->trans('Add'); ?>"></td>
</tr> </tr>
@ -188,12 +216,7 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
$colspan = 12; $colspan = 12;
else else
$colspan = 11; $colspan = 11;
if (! empty($conf->margin->enabled)) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
$colspan++;
if (! empty($conf->global->DISPLAY_MARK_RATES))
$colspan++;
}
?> ?>
<tr id="service_duration_area" <?php echo $bcnd[$var]; ?>> <tr id="service_duration_area" <?php echo $bcnd[$var]; ?>>
<td colspan="<?php echo $colspan; ?>"> <td colspan="<?php echo $colspan; ?>">
@ -491,11 +514,7 @@ $(document).ready(function() {
}); });
<?php } ?> <?php } ?>
});
</script>
<?php if (! empty($conf->margin->enabled)) { ?> <?php if (! empty($conf->margin->enabled)) { ?>
<script type="text/javascript">
$("#idprod").change(function() { $("#idprod").change(function() {
$("#fournprice").empty(); $("#fournprice").empty();
$("#buying_price").show(); $("#buying_price").show();
@ -536,6 +555,99 @@ $("#idprod").change(function() {
$('#buying_price').val(''); $('#buying_price').val('');
} }
}); });
</script> var npRate = null;
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
npRate = "np_marginRate";
<?php }
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
npRate = "np_markRate";
<?php }
?>
$("form#addproduct").submit(function(e) {
if (npRate) return checkFreeLine(e, npRate);
else return true;
});
if (npRate == 'np_marginRate') {
$("input[name='np_marginRate']:first").blur(function(e) {
return checkFreeLine(e, npRate);
});
}
else {
if (npRate == 'np_markRate') {
$("input[name='np_markRate']:first").blur(function(e) {
return checkFreeLine(e, npRate);
});
}
}
function checkFreeLine(e, npRate)
{
var buying_price = $("input[name='buying_price']:first");
var remise = $("input[name='remise_percent']:first");
var rate = $("input[name='"+npRate+"']:first");
if (rate.val() == '')
return true;
if (! $.isNumeric(rate.val().replace(',','.')))
{
alert('<?php echo $langs->trans("rateMustBeNumeric"); ?>');
e.stopPropagation();
setTimeout(function () { rate.focus() }, 50);
return false;
}
if (npRate == "np_markRate" && rate.val() >= 100)
{
alert('<?php echo $langs->trans("markRateShouldBeLesserThan100"); ?>');
e.stopPropagation();
setTimeout(function () { rate.focus() }, 50);
return false;
}
var np_price = 0;
if (remise.val().replace(',','.') != 100)
{
if (npRate == "np_marginRate")
np_price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
else {
if (npRate == "np_markRate")
np_price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
}
}
$("input[name='price_ht']:first").val(formatFloat(np_price));
update_price('price_ht', 'price_ttc');
return true;
}
function roundFloat(num) {
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
var main_rounding = <?php echo min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>;
var amount = num.toString().replace(',','.'); // should be useless
var nbdec = 0;
var rounding = main_rounding;
var pos = amount.indexOf('.');
var decpart = '';
if (pos >= 0)
decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
nbdec = decpart.length;
if (nbdec > rounding)
rounding = nbdec;
// Si on depasse max
if (rounding > main_max_dec_shown)
{
rounding = main_max_dec_shown;
}
//amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors
return parseFloat(amount).toFixed(rounding);
}
function formatFloat(num) {
return roundFloat(num).replace('.', ',');
}
<?php } ?> <?php } ?>
});
</script>
<!-- END PHP TEMPLATE objectline_add.tpl.php --> <!-- END PHP TEMPLATE objectline_add.tpl.php -->

View File

@ -28,7 +28,7 @@
?> ?>
<!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php --> <!-- BEGIN PHP TEMPLATE objectline_edit.tpl.php -->
<form action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST"> <form id="editproduct" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$this->id.'#'.$line->id; ?>" method="POST">
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>"> <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="updateligne"> <input type="hidden" name="action" value="updateligne">
<input type="hidden" name="usenewupdatelineform" value="1" /> <input type="hidden" name="usenewupdatelineform" value="1" />
@ -133,11 +133,25 @@ if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
</td> </td>
<?php if (! empty($conf->margin->enabled)) { ?> <?php if (! empty($conf->margin->enabled)) { ?>
<td align="right"><?php $coldisplay++; ?> <td align="right"><?php $coldisplay++; ?>
<select id="fournprice" name="fournprice" class="hideobject"></select> <select id="fournprice" name="fournprice" class="hideobject"></select>
<input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>"> <input type="text" size="5" id="buying_price" name="buying_price" class="hideobject" value="<?php echo price($line->pa_ht,0,'',0); ?>">
</td> </td>
<?php } ?> <?php if ($user->rights->margins->creer) {
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
{
$margin_rate = (isset($_POST["marginRate"])?$_POST["marginRate"]:(($line->pa_ht == 0)?'':price($line->marge_tx)));
echo '<td align="right"><input type="text" size="2" name="marginRate" value="'.$margin_rate.'">%</td>';
$coldisplay++;
}
elseif (! empty($conf->global->DISPLAY_MARK_RATES))
{
$mark_rate = (isset($_POST["markRate"])?$_POST["markRate"]:price($line->marque_tx));
echo '<td align="right"><input type="text" size="2" name="markRate" value="'.$mark_rate.'">%</td>';
$coldisplay++;
}
}
} ?>
<td align="center" colspan="5" valign="middle"> <td align="center" colspan="5" valign="middle">
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br> <input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
@ -386,5 +400,96 @@ $(document).ready(function() {
}, 'json'); }, 'json');
<?php } ?> <?php } ?>
}); });
var npRate = null;
<?php
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { ?>
npRate = "marginRate";
<?php }
elseif (! empty($conf->global->DISPLAY_MARK_RATES)) { ?>
npRate = "markRate";
<?php }
?>
$("form#editproduct").submit(function(e) {
if (npRate) return checkEditLine(e, npRate);
else return true;
});
if (npRate == 'marginRate') {
$("input[name='marginRate']:first").blur(function(e) {
return checkEditLine(e, npRate);
});
}
else {
if (npRate == 'markRate') {
$("input[name='markRate']:first").blur(function(e) {
return checkEditLine(e, npRate);
});
}
}
function checkEditLine(e, npRate)
{
var buying_price = $("input[name='buying_price']:first");
var remise = $("input[name='remise_percent']:first");
var rate = $("input[name='"+npRate+"']:first");
if (rate.val() == '')
return true;
if (! $.isNumeric(rate.val().replace(',','.')))
{
alert('<?php echo $langs->trans("rateMustBeNumeric"); ?>');
e.stopPropagation();
setTimeout(function () { rate.focus() }, 50);
return false;
}
if (npRate == "markRate" && rate.val() >= 100)
{
alert('<?php echo $langs->trans("markRateShouldBeLesserThan100"); ?>');
e.stopPropagation();
setTimeout(function () { rate.focus() }, 50);
return false;
}
var price = 0;
if (remise.val().replace(',','.') != 100)
{
if (npRate == "marginRate")
price = ((buying_price.val().replace(',','.') * (1 + rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
else {
if (npRate == "markRate")
price = ((buying_price.val().replace(',','.') / (1 - rate.val().replace(',','.') / 100)) / (1 - remise.val().replace(',','.') / 100));
}
}
$("input[name='price_ht']:first").val(formatFloat(price));
return true;
}
function roundFloat(num) {
var main_max_dec_shown = <?php echo $conf->global->MAIN_MAX_DECIMALS_SHOWN; ?>;
var main_rounding = <?php echo min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?>;
var amount = num.toString().replace(',','.'); // should be useless
var nbdec = 0;
var rounding = main_rounding;
var pos = amount.indexOf('.');
var decpart = '';
if (pos >= 0)
decpart = amount.substr(pos+1).replace('/0+$/i',''); // Supprime les 0 de fin de partie decimale
nbdec = decpart.length;
if (nbdec > rounding)
rounding = nbdec;
// Si on depasse max
if (rounding > main_max_dec_shown)
{
rounding = main_max_dec_shown;
}
//amount = parseFloat(amount) + (1 / Math.pow(100, rounding)); // to avoid floating-point errors
return parseFloat(amount).toFixed(rounding);
}
function formatFloat(num) {
return roundFloat(num).replace('.', ',');
}
</script> </script>
<!-- END PHP TEMPLATE objectline_edit.tpl.php --> <!-- END PHP TEMPLATE objectline_edit.tpl.php -->

View File

@ -755,7 +755,7 @@ class Export
global $conf, $langs; global $conf, $langs;
$sql = "SELECT em.rowid, em.field, em.label, em.type, em.filter"; $sql = "SELECT em.rowid, em.field, em.label, em.type, em.filter";
$sql.= " FROM ".MAIN_DB_PREFIX."export_model"; $sql.= " FROM ".MAIN_DB_PREFIX."export_model as em";
$sql.= " ORDER BY rowid"; $sql.= " ORDER BY rowid";
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -114,8 +114,8 @@ if (! empty($idprod))
$db->free($result); $db->free($result);
} }
} }
echo json_encode($prices);
} }
echo json_encode($prices);
?> ?>

View File

@ -396,7 +396,7 @@ if ($object->fetch($id))
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4">'; print '<td colspan="4">';
print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="facture/list.php?socid='.$object->id.'">'.$langs->trans('AllBills').' ('.$num.')</td>'; print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).'</td><td align="right"><a href="facture/index.php?socid='.$object->id.'">'.$langs->trans('AllBills').' ('.$num.')</td>';
print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>'; print '<td width="20px" align="right"><a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$object->id.'">'.img_picto($langs->trans("Statistics"),'stats').'</a></td>';
print '</tr></table>'; print '</tr></table>';
print '</td></tr>'; print '</td></tr>';

View File

@ -160,7 +160,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr
if ($agentid > 0) if ($agentid > 0)
$sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname, f.type"; $sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, u.rowid, u.login, u.lastname, u.firstname, f.type";
else else
$sql.= " GROUP BY u.rowid, s.nom, s.rowid, s.code_client, s.client, u.login, u.lastname, u.firstname, f.type "; $sql.= " GROUP BY u.rowid";
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= " ORDER BY $sortfield $sortorder ";
// TODO: calculate total to display then restore pagination // TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset); //$sql.= $db->plimit($conf->liste_limit +1, $offset);

View File

@ -178,7 +178,7 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr
if ($client) if ($client)
$sql.= " GROUP BY f.rowid, s.rowid, s.nom, s.code_client, s.client, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.type "; $sql.= " GROUP BY f.rowid, s.rowid, s.nom, s.code_client, s.client, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.type ";
else else
$sql.= " GROUP BY s.rowid, s.nom, s.code_client, s.client, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.rowid, f.type "; $sql.= " GROUP BY s.rowid";
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= " ORDER BY $sortfield $sortorder ";
// TODO: calculate total to display then restore pagination // TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset); //$sql.= $db->plimit($conf->liste_limit +1, $offset);
@ -293,7 +293,7 @@ $db->close();
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("div.fiche form input.button['type=submit']").hide(); $("div.fiche form input.button[type=submit]").hide();
$("#socid").change(function() { $("#socid").change(function() {
$("div.fiche form").submit(); $("div.fiche form").submit();

View File

@ -182,7 +182,8 @@ if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPr
if ($id > 0) if ($id > 0)
$sql.= " GROUP BY f.rowid, d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.type"; $sql.= " GROUP BY f.rowid, d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.type";
else else
$sql.= " GROUP BY d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref, f.facnumber, f.total, f.datef, f.paye, f.fk_statut, f.rowid, f.type"; $sql.= " GROUP BY d.fk_product";
$sql.= " ORDER BY $sortfield $sortorder "; $sql.= " ORDER BY $sortfield $sortorder ";
// TODO: calculate total to display then restore pagination // TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset); //$sql.= $db->plimit($conf->liste_limit +1, $offset);