Fix: Avoid warning in expense report validation

Fix: navigation in expense report
This commit is contained in:
Laurent Destailleur 2015-06-08 13:49:09 +02:00
parent 1e0218bb9b
commit 4a18b730b5
9 changed files with 179 additions and 156 deletions

View File

@ -4964,7 +4964,7 @@ class Form
* @param string $paramid Name of parameter to use to name the id into the URL link * @param string $paramid Name of parameter to use to name the id into the URL link
* @param string $morehtml More html content to output just before the nav bar * @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1) * @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param string $morehtmlref Code html supplementaire a afficher apres ref * @param string $morehtmlref Code html supplementaire a afficher apres ref
* @param string $moreparam More param to add in nav link url. * @param string $moreparam More param to add in nav link url.
@ -4990,7 +4990,7 @@ class Form
//print "xx".$previous_ref."x".$next_ref; //print "xx".$previous_ref."x".$next_ref;
//if ($previous_ref || $next_ref || $morehtml) { //if ($previous_ref || $next_ref || $morehtml) {
//$ret.='<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">'; //$ret.='<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
$ret.='<div style="vertical-align: middle"><div class="inline-block floatleft refid">'; $ret.='<div style="vertical-align: middle"><div class="inline-block floatleft refid'.(($shownav && ($previous_ref || $next_ref))?' refidpadding':'').'">';
//} //}
$ret.=dol_htmlentities($object->$fieldref); $ret.=dol_htmlentities($object->$fieldref);

View File

@ -46,6 +46,7 @@ $date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth'), GETPOST('date_debu
$date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth'), GETPOST('date_finday'), GETPOST('date_finyear')); $date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth'), GETPOST('date_finday'), GETPOST('date_finyear'));
$date = dol_mktime(0, 0, 0, GETPOST('datemonth'), GETPOST('dateday'), GETPOST('dateyear')); $date = dol_mktime(0, 0, 0, GETPOST('datemonth'), GETPOST('dateday'), GETPOST('dateyear'));
$fk_projet=GETPOST('fk_projet'); $fk_projet=GETPOST('fk_projet');
$ref=GETPOST("ref",'alpha');
// If socid provided by ajax company selector // If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id'])) if (! empty($_REQUEST['socid_id']))
@ -92,7 +93,7 @@ if ($cancel) $action='';
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer) if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->supprimer)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$result=$object->delete($id); $result=$object->delete($id, $user);
if ($result >= 0) if ($result >= 0)
{ {
header("Location: index.php"); header("Location: index.php");
@ -214,6 +215,8 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
$expediteur->fetch($object->fk_user_author); $expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email; $emailFrom = $expediteur->email;
if ($emailTo && $emailFrom)
{
// SUBJECT // SUBJECT
$subject = $langs->trans("ExpenseReportWaitingForApproval"); $subject = $langs->trans("ExpenseReportWaitingForApproval");
@ -271,6 +274,12 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
} }
} }
else else
{
setEventMessage($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), 'warnings');
$action='';
}
}
else
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
@ -304,14 +313,17 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
if ($result > 0) if ($result > 0)
{ {
// Send mail
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
{ {
// Send mail
// TO // TO
$destinataire = new User($db); $destinataire = new User($db);
$destinataire->fetch($object->fk_user_validator); $destinataire->fetch($object->fk_user_validator);
$emailTo = $destinataire->email; $emailTo = $destinataire->email;
if ($emailTo)
{
// FROM // FROM
$expediteur = new User($db); $expediteur = new User($db);
$expediteur->fetch($object->fk_user_author); $expediteur->fetch($object->fk_user_author);
@ -335,7 +347,8 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
$object->setDocModel($user,""); $object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs); $resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
if($resultPDF): if($resultPDF)
{
// ATTACHMENT // ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array(); $filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf"); array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
@ -345,25 +358,28 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename); $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if(!$mailfile->error): if (! $mailfile->error)
{
// SEND // SEND
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result): if ($result)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
endif; }
else
else: {
$mesg=$mailfile->error;
$mesg="Impossible d'envoyer l'email."; }
endif;
// END - Send mail // END - Send mail
else: }
else
{
dol_print_error($db,$resultPDF); dol_print_error($db,$resultPDF);
exit; exit;
endif; }
}
}
} }
} }
else else
@ -1168,10 +1184,10 @@ if ($action == 'create')
} }
else else
{ {
if($id > 0) if($id > 0 || $ref)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$result = $object->fetch($id); $result = $object->fetch($id, $ref);
if ($result > 0) if ($result > 0)
{ {
@ -1218,7 +1234,7 @@ else
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
@ -1376,7 +1392,7 @@ else
// Ref // Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'ref', 'ref', ''); print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', '');
print '</td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
@ -1450,6 +1466,7 @@ else
print '</tr>'; print '</tr>';
} }
// User to inform
if($object->fk_statut<3) // informed if($object->fk_statut<3) // informed
{ {
print '<tr>'; print '<tr>';
@ -1460,6 +1477,7 @@ else
$userfee=new User($db); $userfee=new User($db);
$userfee->fetch($object->fk_user_validator); $userfee->fetch($object->fk_user_validator);
print $userfee->getNomUrl(1); print $userfee->getNomUrl(1);
if (empty($userfee->email) || ! isValidEmail($userfee->email)) print img_warning($langs->trans("EmailNotValid"));
} }
print '</td></tr>'; print '</td></tr>';
} }
@ -1530,7 +1548,7 @@ else
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
$sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id'; $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'c_type_fees as ctf ON fde.fk_c_type_fees=ctf.id';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pjt ON fde.fk_projet=pjt.rowid';
$sql.= ' WHERE fde.fk_expensereport = '.$id; $sql.= ' WHERE fde.fk_expensereport = '.$object->id;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
@ -1692,8 +1710,8 @@ else
print_fiche_titre($langs->trans("AddLine"),'',''); print_fiche_titre($langs->trans("AddLine"),'','');
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="addline">'; print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="addline">';
print '<input type="hidden" name="id" value="'.$id.'">'; print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$id.'" />'; print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
print '<input type="hidden" name="action" value="addline" />'; print '<input type="hidden" name="action" value="addline" />';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
@ -1789,7 +1807,7 @@ print '<div class="tabsAction">';
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit')
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id, $ref);
/* Si l'état est "Brouillon" /* Si l'état est "Brouillon"
@ -1802,18 +1820,18 @@ if ($action != 'create' && $action != 'edit')
if ($object->fk_user_author == $user->id) if ($object->fk_user_author == $user->id)
{ {
// Modify // Modify
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a>';
// Validate // Validate
if (count($object->lines) > 0 || count($object->lignes) > 0) if (count($object->lines) > 0 || count($object->lignes) > 0)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save&id='.$id.'">'.$langs->trans('ValidateAndSubmit').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save&id='.$object->id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
} }
if ($user->rights->expensereport->supprimer) if ($user->rights->expensereport->supprimer)
{ {
// Delete // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
} }
} }
} }
@ -1828,17 +1846,17 @@ if ($action != 'create' && $action != 'edit')
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Modify // Modify
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$object->id.'">'.$langs->trans('Modify').'</a>';
// Brouillonner (le statut refusée est identique à brouillon) // Brouillonner (le statut refusée est identique à brouillon)
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('BROUILLONNER').'</a>'; //print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('BROUILLONNER').'</a>';
// Enregistrer depuis le statut "Refusée" // Enregistrer depuis le statut "Refusée"
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save_from_refuse&id='.$id.'">'.$langs->trans('ValidateAndSubmit').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=save_from_refuse&id='.$object->id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
if ($user->rights->expensereport->supprimer) if ($user->rights->expensereport->supprimer)
{ {
// Delete // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
} }
} }
} }
@ -1848,7 +1866,7 @@ if ($action != 'create' && $action != 'edit')
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Brouillonner // Brouillonner
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('SetToDraft').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a>';
} }
} }
@ -1862,7 +1880,7 @@ if ($action != 'create' && $action != 'edit')
if ($object->fk_user_author == $user->id) if ($object->fk_user_author == $user->id)
{ {
// Brouillonner // Brouillonner
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('SetToDraft').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('SetToDraft').'</a>';
} }
} }
@ -1871,21 +1889,21 @@ if ($action != 'create' && $action != 'edit')
//if($object->fk_user_validator==$user->id) //if($object->fk_user_validator==$user->id)
//{ //{
// Validate // Validate
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Approve').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$object->id.'">'.$langs->trans('Approve').'</a>';
// Deny // Deny
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Deny').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$object->id.'">'.$langs->trans('Deny').'</a>';
//} //}
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Cancel // Cancel
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
} }
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Delete // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@ -1896,18 +1914,18 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->to_paid && $object->fk_statut == 5) if ($user->rights->expensereport->to_paid && $object->fk_statut == 5)
{ {
// Pay // Pay
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$object->id.'">'.$langs->trans('TO_PAID').'</a>';
// Cancel // Cancel
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
} }
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Delete // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@ -1919,11 +1937,11 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6) if ($user->rights->expensereport->approve && $user->rights->expensereport->to_paid && $object->fk_statut==6)
{ {
// Cancel // Cancel
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('Cancel').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$object->id.'">'.$langs->trans('Cancel').'</a>';
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Delete // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
} }
} }
@ -1937,11 +1955,11 @@ if ($action != 'create' && $action != 'edit')
if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Brouillonner // Brouillonner
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('ReOpen').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$object->id.'">'.$langs->trans('ReOpen').'</a>';
} }
// Delete // Delete
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>'; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$object->id.'">'.$langs->trans('Delete').'</a>';
} }
} }

View File

@ -348,7 +348,8 @@ class ExpenseReport extends CommonObject
$this->code_statut = $obj->code_statut; $this->code_statut = $obj->code_statut;
$this->code_paiement = $obj->code_paiement; $this->code_paiement = $obj->code_paiement;
$this->lignes = array(); $this->lignes = array(); // deprecated
$this->lines = array();
$result=$this->fetch_lines(); $result=$this->fetch_lines();
@ -772,9 +773,10 @@ class ExpenseReport extends CommonObject
* delete * delete
* *
* @param int $rowid Id to delete (optional) * @param int $rowid Id to delete (optional)
* @param User $fuser User that delete
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function delete($rowid=0) function delete($rowid=0, User $fuser=null)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@ -810,10 +812,10 @@ class ExpenseReport extends CommonObject
/** /**
* Set to status validate * Set to status validate
* *
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setValidate($user) function setValidate($fuser)
{ {
global $conf,$langs; global $conf,$langs;
@ -836,13 +838,13 @@ class ExpenseReport extends CommonObject
{ {
$prefix="ER"; $prefix="ER";
if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX; if (! empty($conf->global->EXPENSE_REPORT_PREFIX)) $prefix=$conf->global->EXPENSE_REPORT_PREFIX;
$this->ref = strtoupper($user->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d'); $this->ref = strtoupper($fuser->login).$expld_car.$prefix.$this->ref.$expld_car.dol_print_date($this->date_debut,'%y%m%d');
} }
if ($this->fk_statut != 2) if ($this->fk_statut != 2)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$user->id.","; $sql.= " SET ref = '".$this->ref."', fk_statut = 2, fk_user_valid = ".$fuser->id.",";
$sql.= " ref_number_int = ".$ref_number_int; $sql.= " ref_number_int = ".$ref_number_int;
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
@ -867,10 +869,10 @@ class ExpenseReport extends CommonObject
/** /**
* set_save_from_refuse * set_save_from_refuse
* *
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_save_from_refuse($user) function set_save_from_refuse($fuser)
{ {
global $conf,$langs; global $conf,$langs;
@ -912,10 +914,10 @@ class ExpenseReport extends CommonObject
/** /**
* Set status to approved * Set status to approved
* *
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setApproved($user) function setApproved($fuser)
{ {
$now=dol_now(); $now=dol_now();
@ -924,7 +926,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 5) if ($this->fk_statut != 5)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 5, fk_user_approve = ".$user->id.","; $sql.= " SET ref = '".$this->ref."', fk_statut = 5, fk_user_approve = ".$fuser->id.",";
$sql.= " date_approve='".$this->date_approve."'"; $sql.= " date_approve='".$this->date_approve."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql)) if ($this->db->query($sql))
@ -946,10 +948,10 @@ class ExpenseReport extends CommonObject
/** /**
* setDeny * setDeny
* *
* @param User $user User * @param User $fuser User
* @param Details $details Details * @param Details $details Details
*/ */
function setDeny($user,$details) function setDeny($fuser,$details)
{ {
$now = dol_now(); $now = dol_now();
@ -957,7 +959,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 99) if ($this->fk_statut != 99)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_statut = 99, fk_user_refuse = ".$user->id.","; $sql.= " SET ref = '".$this->ref."', fk_statut = 99, fk_user_refuse = ".$fuser->id.",";
$sql.= " date_refuse='".$this->db->idate($now)."',"; $sql.= " date_refuse='".$this->db->idate($now)."',";
$sql.= " detail_refuse='".$this->db->escape($details)."'"; $sql.= " detail_refuse='".$this->db->escape($details)."'";
$sql.= " fk_user_approve=NULL,"; $sql.= " fk_user_approve=NULL,";
@ -965,7 +967,7 @@ class ExpenseReport extends CommonObject
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
$this->fk_statut = 99; $this->fk_statut = 99;
$this->fk_user_refuse = $user->id; $this->fk_user_refuse = $fuser->id;
$this->detail_refuse = $details; $this->detail_refuse = $details;
$this->date_refuse = $now; $this->date_refuse = $now;
return 1; return 1;
@ -985,10 +987,10 @@ class ExpenseReport extends CommonObject
/** /**
* setPaid * setPaid
* *
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setPaid($user) function setPaid($fuser)
{ {
$now= dol_now(); $now= dol_now();
@ -996,7 +998,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 6) if ($this->fk_statut != 6)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_statut = 6, fk_user_paid = ".$user->id.","; $sql.= " SET fk_statut = 6, fk_user_paid = ".$fuser->id.",";
$sql.= " date_paiement='".$this->db->idate($this->date_paiement)."'"; $sql.= " date_paiement='".$this->db->idate($this->date_paiement)."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
@ -1020,10 +1022,10 @@ class ExpenseReport extends CommonObject
/** /**
* set_unpaid * set_unpaid
* *
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_unpaid($user) function set_unpaid($fuser)
{ {
if ($this->fk_c_deplacement_statuts != 5) if ($this->fk_c_deplacement_statuts != 5)
{ {
@ -1049,17 +1051,17 @@ class ExpenseReport extends CommonObject
/** /**
* set_cancel * set_cancel
* *
* @param User $user User * @param User $fuser User
* @param string $detail Detail * @param string $detail Detail
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_cancel($user,$detail) function set_cancel($fuser,$detail)
{ {
$this->date_cancel = $this->db->idate(gmmktime()); $this->date_cancel = $this->db->idate(gmmktime());
if ($this->fk_statut != 4) if ($this->fk_statut != 4)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_statut = 4, fk_user_cancel = ".$user->id; $sql.= " SET fk_statut = 4, fk_user_cancel = ".$fuser->id;
$sql.= ", date_cancel='".$this->date_cancel."'"; $sql.= ", date_cancel='".$this->date_cancel."'";
$sql.= " ,detail_cancel='".$this->db->escape($detail)."'"; $sql.= " ,detail_cancel='".$this->db->escape($detail)."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
@ -1271,10 +1273,10 @@ class ExpenseReport extends CommonObject
* deleteline * deleteline
* *
* @param int $rowid Row id * @param int $rowid Row id
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function deleteline($rowid, $user='') function deleteline($rowid, $fuser='')
{ {
$this->db->begin(); $this->db->begin();
@ -1299,16 +1301,16 @@ class ExpenseReport extends CommonObject
/** /**
* periode_existe * periode_existe
* *
* @param User $user User * @param User $fuser User
* @param Date $date_debut Start date * @param Date $date_debut Start date
* @param Date $date_fin End date * @param Date $date_fin End date
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function periode_existe($user, $date_debut, $date_fin) function periode_existe($fuser, $date_debut, $date_fin)
{ {
$sql = "SELECT rowid, date_debut, date_fin"; $sql = "SELECT rowid, date_debut, date_fin";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
$sql.= " WHERE fk_user_author = '{$user->id}'"; $sql.= " WHERE fk_user_author = '{$fuser->id}'";
dol_syslog(get_class($this)."::periode_existe sql=".$sql); dol_syslog(get_class($this)."::periode_existe sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
@ -1617,12 +1619,12 @@ class ExpenseReportLine
/** /**
* update * update
* *
* @param User $user User * @param User $fuser User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function update($user) function update($fuser)
{ {
global $user,$langs,$conf; global $fuser,$langs,$conf;
$error=0; $error=0;

View File

@ -107,7 +107,7 @@ print_fiche_titre($langs->trans("ExpensesArea"));
print '<div class="fichecenter"><div class="fichethirdleft">'; print '<div class="fichecenter"><div class="fichethirdleft">';
print '<table class="noborder" width="100%">'; print '<table class="noborder nohover" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("Statistics").'</td>'; print '<td colspan="4">'.$langs->trans("Statistics").'</td>';
print "</tr>\n"; print "</tr>\n";

View File

@ -180,6 +180,7 @@ if ($resql)
print_barre_liste($langs->trans("ListTripsAndExpenses"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords); print_barre_liste($langs->trans("ListTripsAndExpenses"), $page, $_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n"; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","",$param,'',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","",$param,'',$sortfield,$sortorder);
@ -190,7 +191,7 @@ if ($resql)
print_liste_field_titre($langs->trans("TotalVAT"),$_SERVER["PHP_SELF"],"d.total_tva","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("TotalVAT"),$_SERVER["PHP_SELF"],"d.total_tva","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("TotalTTC"),$_SERVER["PHP_SELF"],"d.total_ttc","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("TotalTTC"),$_SERVER["PHP_SELF"],"d.total_ttc","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Statut"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Statut"),$_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder);
print '<td class="liste_titre">&nbsp;</td>'; print_liste_field_titre('');
print "</tr>\n"; print "</tr>\n";
// Filters // Filters

View File

@ -1045,7 +1045,7 @@ class Societe extends CommonObject
$num=$this->db->num_rows($resql); $num=$this->db->num_rows($resql);
if ($num > 1) if ($num > 1)
{ {
$this->error='Fetch several records found for ref='.$ref; $this->error='Fetch several records found request';
dol_syslog($this->error, LOG_ERR); dol_syslog($this->error, LOG_ERR);
$result = -2; $result = -2;
} }

View File

@ -338,7 +338,7 @@ if ($resql)
print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$params,'class="nowrap"',$sortfield,$sortorder); print_liste_field_titre($form->textwithpicto($langs->trans("ProfId2Short"),$textprofid[2],1,0),$_SERVER["PHP_SELF"],"s.siret","",$params,'class="nowrap"',$sortfield,$sortorder);
print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$params,'class="nowrap"',$sortfield,$sortorder); print_liste_field_titre($form->textwithpicto($langs->trans("ProfId3Short"),$textprofid[3],1,0),$_SERVER["PHP_SELF"],"s.ape","",$params,'class="nowrap"',$sortfield,$sortorder);
print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$params,'class="nowrap"',$sortfield,$sortorder); print_liste_field_titre($form->textwithpicto($langs->trans("ProfId4Short"),$textprofid[4],1,0),$_SERVER["PHP_SELF"],"s.idprof4","",$params,'class="nowrap"',$sortfield,$sortorder);
print '<td></td>'; print_liste_field_titre('');
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder);
print "</tr>\n"; print "</tr>\n";

View File

@ -1974,8 +1974,11 @@ table.liste td {
/* Pagination */ /* Pagination */
div.refid { div.refidpadding {
padding-top: <?php print empty($conf->dol_use_jmobile)?'8':'12'; ?>px; padding-top: <?php print empty($conf->dol_use_jmobile)?'8':'12'; ?>px;
}
div.refid {
padding-top: <?php print empty($conf->dol_use_jmobile)?'5':'12'; ?>px;
font-weight: bold; font-weight: bold;
color: #766; color: #766;
font-size: 120%; font-size: 120%;

View File

@ -1833,7 +1833,6 @@ class User extends CommonObject
$label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'',''); $label.= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs,'','');
if (! empty($this->login)) if (! empty($this->login))
$label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login; $label.= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
if (! empty($this->email))
$label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email; $label.= '<br><b>' . $langs->trans("EMail").':</b> '.$this->email;
if (! empty($this->admin)) if (! empty($this->admin))
$label.= '<br><b>' . $langs->trans("Administrator").'</b>: '.yn($this->admin); $label.= '<br><b>' . $langs->trans("Administrator").'</b>: '.yn($this->admin);