Enhance sorting of field for lists on field with several sort criterias
This commit is contained in:
parent
2241418b33
commit
e72c2e6a11
@ -395,9 +395,10 @@ class Account extends CommonObject
|
||||
* @param string $emetteur Name of cheque writer
|
||||
* @param string $banque Bank of cheque writer
|
||||
* @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on.
|
||||
* @param int $datevalue Date value
|
||||
* @return int Rowid of added entry, <0 if KO
|
||||
*/
|
||||
function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='')
|
||||
function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='', $datev=null)
|
||||
{
|
||||
// Deprecatîon warning
|
||||
if (is_numeric($oper)) {
|
||||
@ -447,7 +448,7 @@ class Account extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$datev = $date;
|
||||
if (is_null($datev) || empty($datev)) $datev = $date;
|
||||
|
||||
$accline = new AccountLine($this->db);
|
||||
$accline->datec = $now;
|
||||
|
||||
@ -388,7 +388,11 @@ class PaymentSalary extends CommonObject
|
||||
-abs($this->amount),
|
||||
$this->num_payment,
|
||||
'',
|
||||
$user
|
||||
$user,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$this->datev
|
||||
);
|
||||
|
||||
// Update fk_bank into llx_paiement.
|
||||
|
||||
@ -28,10 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php';
|
||||
|
||||
$langs->load("compta");
|
||||
$langs->load("salaries");
|
||||
$langs->load("bills");
|
||||
$langs->load("hrm");
|
||||
$langs->loadLangs(array("compta","salaries","bills","hrm"));
|
||||
|
||||
// Security check
|
||||
$socid = GETPOST("socid","int");
|
||||
@ -52,8 +49,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
|
||||
$offset = $conf->liste_limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield) $sortfield="s.datep";
|
||||
if (! $sortorder) $sortorder="DESC";
|
||||
if (! $sortfield) $sortfield="s.datep,s.rowid";
|
||||
if (! $sortorder) $sortorder="DESC,DESC";
|
||||
$optioncss = GETPOST('optioncss','alpha');
|
||||
|
||||
$filtre=$_GET["filtre"];
|
||||
@ -208,7 +205,7 @@ if ($result)
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep,s.rowid","",$param,'align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder);
|
||||
if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder);
|
||||
print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder);
|
||||
|
||||
@ -59,6 +59,7 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear;
|
||||
$startyear=$year-1;
|
||||
$endyear=$year;
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -231,11 +232,11 @@ print '</form>';
|
||||
print '<br><br>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr height="24">';
|
||||
print '<tr>';
|
||||
print '<td align="center">'.$langs->trans("Year").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Number").'</td>';
|
||||
print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
|
||||
print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Number").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AmountTotal").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AmountAverage").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$oldyear=0;
|
||||
|
||||
@ -221,8 +221,8 @@ abstract class DoliDB implements Database
|
||||
/**
|
||||
* Define sort criteria of request
|
||||
*
|
||||
* @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb'
|
||||
* @param string $sortorder Sort order, separated by comma. Example: 'ASC, DESC';
|
||||
* @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb'
|
||||
* @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC';
|
||||
* @return string String to provide syntax of a sort sql string
|
||||
*/
|
||||
function order($sortfield=null,$sortorder=null)
|
||||
|
||||
@ -141,15 +141,18 @@ print '
|
||||
/* Set handler to add page_y param on output (click on href links or submit button) */
|
||||
jQuery(".reposition").click(function() {
|
||||
var page_y = $(document).scrollTop();
|
||||
if (this.href)
|
||||
if (page_y > 0)
|
||||
{
|
||||
this.href=this.href+\'&page_y=\'+page_y;
|
||||
console.log("We click on tag with .reposition class. this.ref is now "+this.href);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update form field page_y with value "+page_y);
|
||||
jQuery("input[type=hidden][name=page_y]").val(page_y);
|
||||
if (this.href)
|
||||
{
|
||||
this.href=this.href+\'&page_y=\'+page_y;
|
||||
console.log("We click on tag with .reposition class. this.ref is now "+this.href);
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log("We click on tag with .reposition class but element is not an <a> html tag, so we try to update form field page_y with value "+page_y);
|
||||
jQuery("input[type=hidden][name=page_y]").val(page_y);
|
||||
}
|
||||
}
|
||||
});
|
||||
});'."\n";
|
||||
|
||||
@ -3964,7 +3964,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar
|
||||
* @param string $name Translation key of field
|
||||
* @param int $thead 0=To use with standard table format, 1=To use inside <thead><tr>, 2=To use with <div>
|
||||
* @param string $file Url used when we click on sort picto
|
||||
* @param string $field Field to use for new sorting. Empty if this field is not sortable.
|
||||
* @param string $field Field to use for new sorting. Empty if this field is not sortable. Example "t.abc" or "t.abc,t.def"
|
||||
* @param string $begin ("" by defaut)
|
||||
* @param string $moreparam Add more parameters on sort url links ("" by default)
|
||||
* @param string $moreattrib Add more attributes on th ("" by defaut, example: 'align="center"'). To add more css class, use param $prefix.
|
||||
@ -4005,16 +4005,31 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m
|
||||
$options=preg_replace('/&+/i','&',$options);
|
||||
if (! preg_match('/^&/',$options)) $options='&'.$options;
|
||||
|
||||
if ($field1 != $sortfield1) // We are on another field
|
||||
$sortordertouseinlink='';
|
||||
if ($field1 != $sortfield1) // We are on another field than current sorted field
|
||||
{
|
||||
if (preg_match('/^DESC/', $sortorder)) $out.= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">';
|
||||
else $out.= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">';
|
||||
if (preg_match('/^DESC/i', $sortorder))
|
||||
{
|
||||
$sortordertouseinlink.=str_repeat('desc,', count(explode(',',$field)));
|
||||
}
|
||||
else // We reverse the var $sortordertouseinlink
|
||||
{
|
||||
$sortordertouseinlink.=str_repeat('asc,', count(explode(',',$field)));
|
||||
}
|
||||
}
|
||||
else // We are of first sorting criteria
|
||||
else // We are on field that is the first current sorting criteria
|
||||
{
|
||||
if (preg_match('/^ASC/', $sortorder)) $out.= '<a class="reposition" href="'.$file.'?sortfield='.$sortfield.'&sortorder=desc&begin='.$begin.$options.'">';
|
||||
else $out.= '<a class="reposition" href="'.$file.'?sortfield='.$sortfield.'&sortorder=asc&begin='.$begin.$options.'">';
|
||||
if (preg_match('/^ASC/i', $sortorder)) // We reverse the var $sortordertouseinlink
|
||||
{
|
||||
$sortordertouseinlink.=str_repeat('desc,', count(explode(',',$field)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortordertouseinlink.=str_repeat('asc,', count(explode(',',$field)));
|
||||
}
|
||||
}
|
||||
$sortordertouseinlink=preg_replace('/,$/', '', $sortordertouseinlink);
|
||||
$out.= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder='.$sortordertouseinlink.'&begin='.$begin.$options.'">';
|
||||
}
|
||||
|
||||
if ($tooltip) $out.=$form->textwithpicto($langs->trans($name), $langs->trans($tooltip));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user