*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
/**
* \file htdocs/compta/salaries/index.php
* \ingroup salaries
* \brief List of salaries payments
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
$langs->load("compta");
$langs->load("salaries");
$langs->load("bills");
// Security check
$socid = GETPOST("socid","int");
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'salaries', '', '', '');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');
if ($page == -1) { $page = 0; }
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$limit = $conf->liste_limit;
if (! $sortfield) $sortfield="s.datev";
if (! $sortorder) $sortorder="DESC";
$filtre=$_GET["filtre"];
if (empty($_REQUEST['typeid']))
{
$newfiltre=str_replace('filtre=','',$filtre);
$filterarray=explode('-',$newfiltre);
foreach($filterarray as $val)
{
$part=explode(':',$val);
if ($part[0] == 's.fk_typepayment') $typeid=$part[1];
}
}
else
{
$typeid=$_REQUEST['typeid'];
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$salstatic = new PaymentSalary($db);
$userstatic = new User($db);
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev as dm, s.fk_typepayment as type, s.num_payment,";
$sql.= " pst.code as payment_code";
$sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON s.fk_typepayment = pst.id,";
$sql.= " ".MAIN_DB_PREFIX."user as u";
$sql.= " WHERE u.rowid = s.fk_user";
$sql.= " AND s.entity = ".$conf->entity;
if (GETPOST("search_label")) $sql.=" AND s.label LIKE '%".$db->escape(GETPOST("search_label"))."%'";
if (GETPOST("search_amount")) $sql.=" AND s.amount = ".price2num(GETPOST("search_amount"));
if ($filtre) {
$filtre=str_replace(":","=",$filtre);
$sql .= " AND ".$filtre;
}
if ($typeid) {
$sql .= " AND s.fk_typepayment=".$typeid;
}
//$sql.= " GROUP BY u.rowid, u.lastname, u.firstname, s.rowid, s.fk_user, s.amount, s.label, s.datev, s.fk_typepayment, s.num_payment, pst.code";
$sql.= $db->order($sortfield,$sortorder);
$sql.= $db->plimit($limit+1,$offset);
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
$total = 0 ;
$var=true;
$param='';
if ($typeid) $param.='&typeid='.$typeid;
print_barre_liste($langs->trans("SalariesPayments"),$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$totalnboflines);
dol_htmloutput_mesg($mesg);
print '
';
$db->free($result);
}
else
{
dol_print_error($db);
}
llxFooter();
$db->close();