Merge pull request #3102 from aspangaro/develop-patch42

HRM area : Show Ref instead of id for expense report
This commit is contained in:
Laurent Destailleur 2015-07-04 03:40:13 +02:00
commit a49c9c299e
4 changed files with 1622 additions and 1595 deletions

View File

@ -203,7 +203,7 @@ if (! empty($conf->deplacement->enabled) && $user->rights->deplacement->lire)
if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire) 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, x.fk_statut as status"; $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, x.rowid, x.ref, x.date_debut as date, x.tms as dm, x.total_ttc, x.fk_statut as status";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as x, ".MAIN_DB_PREFIX."user as u"; $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"; 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.= " WHERE u.rowid = x.fk_user_author";
@ -238,8 +238,8 @@ if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire
while ($i < $num && $i < $max) while ($i < $num && $i < $max)
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$expensereportstatic->ref=$obj->rowid;
$expensereportstatic->id=$obj->rowid; $expensereportstatic->id=$obj->rowid;
$expensereportstatic->ref=$obj->ref;
$userstatic->id=$obj->uid; $userstatic->id=$obj->uid;
$userstatic->lastname=$obj->lastname; $userstatic->lastname=$obj->lastname;
$userstatic->firstname=$obj->firstname; $userstatic->firstname=$obj->firstname;

View File

@ -1074,6 +1074,11 @@ class ExpenseReport extends CommonObject
} }
} }
/**
* Return next reference of expense report not already used
*
* @return string free ref
*/
function getNextNumRef() function getNextNumRef()
{ {
global $conf; global $conf;
@ -1109,12 +1114,11 @@ class ExpenseReport extends CommonObject
endif; endif;
} }
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @return string Chaine avec URL * @return string String with URL
*/ */
function getNomUrl($withpicto=0) function getNomUrl($withpicto=0)
{ {
@ -1135,8 +1139,15 @@ class ExpenseReport extends CommonObject
return $result; return $result;
} }
/**
function update_totaux_add($ligne_total_ht,$ligne_total_tva){ * Update total of an expense report when you add a line.
*
* @param string $ligne_total_ht Amount without taxes
* @param string $ligne_total_tva Amount of all taxes
* @return void
*/
function update_totaux_add($ligne_total_ht,$ligne_total_tva)
{
$this->total_ht = $this->total_ht + $ligne_total_ht; $this->total_ht = $this->total_ht + $ligne_total_ht;
$this->total_tva = $this->total_tva + $ligne_total_tva; $this->total_tva = $this->total_tva + $ligne_total_tva;
$this->total_ttc = $this->total_ht + $this->total_tva; $this->total_ttc = $this->total_ht + $this->total_tva;
@ -1156,7 +1167,15 @@ class ExpenseReport extends CommonObject
endif; endif;
} }
function update_totaux_del($ligne_total_ht,$ligne_total_tva){ /**
* Update total of an expense report when you delete a line.
*
* @param string $ligne_total_ht Amount without taxes
* @param string $ligne_total_tva Amount of all taxes
* @return void
*/
function update_totaux_del($ligne_total_ht,$ligne_total_tva)
{
$this->total_ht = $this->total_ht - $ligne_total_ht; $this->total_ht = $this->total_ht - $ligne_total_ht;
$this->total_tva = $this->total_tva - $ligne_total_tva; $this->total_tva = $this->total_tva - $ligne_total_tva;
$this->total_ttc = $this->total_ht + $this->total_tva; $this->total_ttc = $this->total_ht + $this->total_tva;
@ -1490,12 +1509,12 @@ class ExpenseReportLine
/** /**
* fetch record * fetch record
* *
* @param int $rowid Row id to fetch * @param int $rowid Id of object to load
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($rowid) function fetch($rowid)
{ {
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; $sql = 'SELECT fde.rowid, fde.ref, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
$sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' fde.tva_tx as vatrate, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,';
$sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql.= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
@ -1511,6 +1530,8 @@ class ExpenseReportLine
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid; $this->rowid = $objp->rowid;
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->fk_expensereport = $objp->fk_expensereport; $this->fk_expensereport = $objp->fk_expensereport;
$this->comments = $objp->comments; $this->comments = $objp->comments;
$this->qty = $objp->qty; $this->qty = $objp->qty;

View File

@ -246,15 +246,20 @@ if ($resql)
$total_total_ttc = 0; $total_total_ttc = 0;
$total_total_tva = 0; $total_total_tva = 0;
$expensereportstatic=new ExpenseReport($db);
if($num > 0) if($num > 0)
{ {
while ($i < min($num,$limit)) while ($i < min($num,$limit))
{ {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$expensereportstatic->id=$objp->rowid;
$expensereportstatic->ref=$objp->ref;
$var=!$var; $var=!$var;
print "<tr ".$bc[$var].">"; print "<tr ".$bc[$var].">";
print '<td><a href="card.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowTrip"),"trip").' '.$objp->ref.'</a></td>'; print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
print '<td align="center">'.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').'</td>'; print '<td align="center">'.($objp->date_debut > 0 ? dol_print_date($objp->date_debut, 'day') : '').'</td>';
print '<td align="center">'.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').'</td>'; print '<td align="center">'.($objp->date_fin > 0 ? dol_print_date($objp->date_fin, 'day') : '').'</td>';
print '<td align="left"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$objp->id_user.'">'.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>'; print '<td align="left"><a href="'.DOL_URL_ROOT.'/user/card.php?id='.$objp->id_user.'">'.img_object($langs->trans("ShowUser"),"user").' '.dolGetFirstLastname($objp->firstname, $objp->lastname).'</a></td>';

View File

@ -9,6 +9,7 @@ TripCard=Expense report card
AddTrip=Create expense report AddTrip=Create expense report
ListOfTrips=List of expense reports ListOfTrips=List of expense reports
ListOfFees=List of fees ListOfFees=List of fees
ShowTrip=Show expense report
NewTrip=New expense report NewTrip=New expense report
CompanyVisited=Company/foundation visited CompanyVisited=Company/foundation visited
Kilometers=Kilometers Kilometers=Kilometers