diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php
index 290a94908c0..e5f21b5095f 100644
--- a/htdocs/margin/customerMargins.php
+++ b/htdocs/margin/customerMargins.php
@@ -43,8 +43,6 @@ $result = restrictedArea($user, 'societe', '', '');
$result = restrictedArea($user, 'margins');
-$mesg = '';
-
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@@ -64,18 +62,18 @@ if (!$sortorder) {
}
$startdate = $enddate = '';
-
-if (!empty($_POST['startdatemonth'])) {
- $startdate = dol_mktime(0, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear']);
+if (GETPOST('startdatemonth')) {
+ $startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
}
-if (!empty($_POST['enddatemonth'])) {
- $enddate = dol_mktime(23, 59, 59, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear']);
+if (GETPOST('enddatemonth')) {
+ $enddate = dol_mktime(23, 59, 59, GETPOST('enddatemonth', 'int'), GETPOST('enddateday', 'int'), GETPOST('enddateyear'));
}
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new Societe($db);
$hookmanager->initHooks(array('margincustomerlist'));
+
/*
* View
*/
@@ -188,7 +186,7 @@ print '
';
// Total Margin
print '| '.$langs->trans("TotalMargin").' | ';
-print ''; // set by jquery (see below)
+print ' '.$langs->getCurrencySymbol($conf->currency).''; // set by jquery (see below)
print ' |
';
// Margin Rate
@@ -271,6 +269,30 @@ $sql .= $db->order($sortfield, $sortorder);
// TODO: calculate total to display then restore pagination
//$sql.= $db->plimit($conf->liste_limit +1, $offset);
+$param = '&socid='.((int) $socid);
+if (GETPOST('startdatemonth', 'int')) {
+ $param .= '&startdateyear='.GETPOST('startdateyear', 'int');
+ $param .= '&startdatemonth='.GETPOST('startdatemonth', 'int');
+ $param .= '&startdateday='.GETPOST('startdateday', 'int');
+}
+if (GETPOST('enddatemonth', 'int')) {
+ $param .= '&enddateyear='.GETPOST('enddateyear', 'int');
+ $param .= '&enddatemonth='.GETPOST('enddatemonth', 'int');
+ $param .= '&enddateday='.GETPOST('enddateday', 'int');
+}
+$listofproducts = GETPOST('products', 'array:int');
+if (is_array($listofproducts)) {
+ foreach ($listofproducts as $val) {
+ $param .= '&products[]='.$val;
+ }
+}
+$listofcateg = GETPOST('categories', 'array:int');
+if (is_array($listofcateg)) {
+ foreach ($listofcateg as $val) {
+ $param .= '&categories[]='.$val;
+ }
+}
+
dol_syslog('margin::customerMargins.php', LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
@@ -293,19 +315,19 @@ if ($result) {
print '';
if (!empty($client)) {
- print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", "&socid=".$socid, '', $sortfield, $sortorder);
- print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", "&socid=".$socid, 'align="center"', $sortfield, $sortorder);
+ print_liste_field_titre("Invoice", $_SERVER["PHP_SELF"], "f.ref", "", $param, '', $sortfield, $sortorder);
+ print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $param, 'align="center"', $sortfield, $sortorder);
} else {
- print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=".$socid, '', $sortfield, $sortorder);
+ print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder);
}
- print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
- print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
- print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder);
if (!empty($conf->global->DISPLAY_MARGIN_RATES)) {
- print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
}
if (!empty($conf->global->DISPLAY_MARK_RATES)) {
- print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&socid=".$socid, 'align="right"', $sortfield, $sortorder);
+ print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder);
}
print "
\n";
diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php
index a47ec246aaf..48e0d50cd4c 100644
--- a/htdocs/margin/productMargins.php
+++ b/htdocs/margin/productMargins.php
@@ -73,7 +73,6 @@ if (!$sortfield) {
}
$startdate = $enddate = '';
-
if (GETPOST('startdatemonth')) {
$startdate = dol_mktime(0, 0, 0, GETPOST('startdatemonth', 'int'), GETPOST('startdateday', 'int'), GETPOST('startdateyear', 'int'));
}
@@ -150,7 +149,7 @@ print '';
// Total Margin
print '| '.$langs->trans("TotalMargin").' | ';
-print ''; // set by jquery (see below)
+print ' '.$langs->getCurrencySymbol($conf->currency).''; // set by jquery (see below)
print ' |
';
// Margin Rate