From 78af862c1913d147b3610af344018e5064944460 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 28 Feb 2015 08:46:40 +0100 Subject: [PATCH 1/2] NEW: Add a search field and report on hrm area --- htdocs/compta/hrm.php | 190 ++++++++++++++++++++++++---------- htdocs/expensereport/list.php | 11 +- 2 files changed, 142 insertions(+), 59 deletions(-) diff --git a/htdocs/compta/hrm.php b/htdocs/compta/hrm.php index 6252f0f6ef7..191fb34d2e8 100644 --- a/htdocs/compta/hrm.php +++ b/htdocs/compta/hrm.php @@ -2,6 +2,7 @@ /* Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2013-2014 Laurent Destailleur * Copyright (C) 2012-2014 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -31,7 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; $langs->load('users'); @@ -107,6 +109,20 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) print "
"; } +if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) +{ + $langs->load("trips"); + print '
'; + print ''; + print ''; + print ''; + print ""; + print "'; + print ''; + //print "'; + print ''; + print "
'.$langs->trans("SearchATripAndExpense").'
:
:

"; +} print '
'; @@ -115,65 +131,131 @@ $max=10; $langs->load("boxes"); // Last trips -$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE u.rowid = d.fk_user"; -$sql.= " AND d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; -if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if (!empty($socid)) $sql.= " AND d.fk_soc = ".$socid; -$sql.= $db->order("d.tms","DESC"); -$sql.= $db->plimit($max, 0); - -$result = $db->query($sql); -if ($result) +if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire) { - $var=false; - $num = $db->num_rows($result); + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE u.rowid = d.fk_user"; + $sql.= " AND d.entity = ".$conf->entity; + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!empty($socid)) $sql.= " AND d.fk_soc = ".$socid; + $sql.= $db->order("d.tms","DESC"); + $sql.= $db->plimit($max, 0); - $i = 0; + $result = $db->query($sql); + if ($result) + { + $var=false; + $num = $db->num_rows($result); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($num) - { - $total_ttc = $totalam = $total = 0; + $i = 0; - $deplacementstatic=new Deplacement($db); - $userstatic=new User($db); - while ($i < $num && $i < $max) - { - $obj = $db->fetch_object($result); - $deplacementstatic->ref=$obj->rowid; - $deplacementstatic->id=$obj->rowid; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - $var=!$var; - $i++; - } + print '
'.$langs->trans("BoxTitleLastModifiedExpenses",min($max,$num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->km.''.dol_print_date($db->jdate($obj->dm),'day').''.$deplacementstatic->LibStatut($obj->fk_statut,3).'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + $total_ttc = $totalam = $total = 0; - } - else - { - print ''; - } - print '
'.$langs->trans("BoxTitleLastModifiedExpenses",min($max,$num)).''.$langs->trans("FeesKilometersOrAmout").''.$langs->trans("DateModificationShort").' 
'.$langs->trans("None").'

'; + $deplacementstatic=new Deplacement($db); + $userstatic=new User($db); + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + $deplacementstatic->ref=$obj->rowid; + $deplacementstatic->id=$obj->rowid; + $userstatic->id=$obj->uid; + $userstatic->lastname=$obj->lastname; + $userstatic->firstname=$obj->firstname; + print ''; + print ''.$deplacementstatic->getNomUrl(1).''; + print ''.$userstatic->getNomUrl(1).''; + print ''.$obj->km.''; + print ''.dol_print_date($db->jdate($obj->dm),'day').''; + print ''.$deplacementstatic->LibStatut($obj->fk_statut,3).''; + print ''; + $var=!$var; + $i++; + } + + } + else + { + print ''.$langs->trans("None").''; + } + print '
'; + } + else dol_print_error($db); +} + +if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) +{ + $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.date_debut as date, x.tms as dm, x.total_ttc"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE u.rowid = x.fk_user_author"; + $sql.= " AND x.entity = ".$conf->entity; + if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $sql.=' AND x.fk_user_author IN ('.join(',',$childids).')'; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND x.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + //if (!empty($socid)) $sql.= " AND x.fk_soc = ".$socid; + $sql.= $db->order("x.tms","DESC"); + $sql.= $db->plimit($max, 0); + + $result = $db->query($sql); + if ($result) + { + $var=false; + $num = $db->num_rows($result); + + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($num) + { + $total_ttc = $totalam = $total = 0; + + $expensereportstatic=new ExpenseReport($db); + $userstatic=new User($db); + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + $expensereportstatic->ref=$obj->rowid; + $expensereportstatic->id=$obj->rowid; + $userstatic->id=$obj->uid; + $userstatic->lastname=$obj->lastname; + $userstatic->firstname=$obj->firstname; + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + $var=!$var; + $i++; + } + + } + else + { + print ''; + } + print '
'.$langs->trans("BoxTitleLastModifiedExpenses",min($max,$num)).''.$langs->trans("FeesAmount").''.$langs->trans("DateModificationShort").' 
'.$expensereportstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).''.$obj->total_ttc.''.dol_print_date($db->jdate($obj->dm),'day').''.$expensereportstatic->LibStatut($obj->fk_statut,3).'
'.$langs->trans("None").'

'; + } + else dol_print_error($db); } -else dol_print_error($db); print '
'; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index a8e10f40464..1499662cc1a 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -1,8 +1,9 @@ - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -302,7 +303,7 @@ if ($resql) print ""; print ''; $db->free($resql); From 105dcde7aa7916d348e90fd570d8d1620950998c Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 28 Feb 2015 08:50:47 +0100 Subject: [PATCH 2/2] Key language --- htdocs/expensereport/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 1499662cc1a..d6700ac26a2 100755 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -64,7 +64,7 @@ $html = new Form($db); $formother = new FormOther($db); $expensereporttmp=new ExpenseReport($db); -llxHeader('', $langs->trans("ListOfExpenseReports")); +llxHeader('', $langs->trans("ListOfTrips")); $max_year = 5; $min_year = 5;