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 $morehtml More html content to output just before the nav bar
* @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 $morehtmlref Code html supplementaire a afficher apres ref
* @param string $moreparam More param to add in nav link url.
@ -4990,7 +4990,7 @@ class Form
//print "xx".$previous_ref."x".$next_ref;
//if ($previous_ref || $next_ref || $morehtml) {
//$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);

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 = dol_mktime(0, 0, 0, GETPOST('datemonth'), GETPOST('dateday'), GETPOST('dateyear'));
$fk_projet=GETPOST('fk_projet');
$ref=GETPOST("ref",'alpha');
// If socid provided by ajax company selector
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)
{
$object = new ExpenseReport($db);
$result=$object->delete($id);
$result=$object->delete($id, $user);
if ($result >= 0)
{
header("Location: index.php");
@ -214,59 +215,67 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
// SUBJECT
$subject = $langs->trans("ExpenseReportWaitingForApproval");
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);
// Rebuild pdf
/*
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs);
if($resultPDF):
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf");
array_push($mimetype,"application/pdf");
*/
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if ($mailfile)
if ($emailTo && $emailFrom)
{
// SEND
$result=$mailfile->sendfile();
if ($result)
// SUBJECT
$subject = $langs->trans("ExpenseReportWaitingForApproval");
// CONTENT
$link = $urlwithroot.'/expensereport/card.php?id='.$object->id;
$message = $langs->trans("ExpenseReportWaitingForApprovalMessage", $expediteur->getFullName($langs), get_date_range($object->date_debut,$object->date_fin,'',$langs), $link);
// Rebuild pdf
/*
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$id,'',"",$langs);
if($resultPDF):
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref).".pdf");
array_push($mimetype,"application/pdf");
*/
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if ($mailfile)
{
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
setEventMessage($mesg);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$langs->load("other");
if ($mailfile->error)
// SEND
$result=$mailfile->sendfile();
if ($result)
{
$mesg='';
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
setEventMessage($mesg,'errors');
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
setEventMessage($mesg);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
setEventMessage('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', 'warnings');
$langs->load("other");
if ($mailfile->error)
{
$mesg='';
$mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto);
$mesg.='<br>'.$mailfile->error;
setEventMessage($mesg,'errors');
}
else
{
setEventMessage('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', 'warnings');
}
}
}
else
{
setEventMessages($mailfile->error,$mailfile->errors,'errors');
$action='';
}
}
else
{
setEventMessages($mailfile->error,$mailfile->errors,'errors');
setEventMessage($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), 'warnings');
$action='';
}
}
@ -304,66 +313,73 @@ if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id
if ($result > 0)
{
// Send mail
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
{
// Send mail
// TO
$destinataire = new User($db);
$destinataire->fetch($object->fk_user_validator);
$emailTo = $destinataire->email;
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
if ($emailTo)
{
// FROM
$expediteur = new User($db);
$expediteur->fetch($object->fk_user_author);
$emailFrom = $expediteur->email;
// SUBJECT
$subject = "' ERP - Note de frais à re-approuver";
// SUBJECT
$subject = "' ERP - Note de frais à re-approuver";
// CONTENT
$dateRefusEx = explode(" ",$object->date_refuse);
// CONTENT
$dateRefusEx = explode(" ",$object->date_refuse);
$message = "Bonjour {$destinataire->firstname},\n\n";
$message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n";
$message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n";
$message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n";
$message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n";
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
$message.= "Bien cordialement,\n' SI";
$message = "Bonjour {$destinataire->firstname},\n\n";
$message.= "Le {$dateRefusEx[0]} à {$dateRefusEx[1]} vous avez refusé d'approuver la note de frais \"{$object->ref}\". Vous aviez émis le motif suivant : {$object->detail_refuse}\n\n";
$message.= "L'auteur vient de modifier la note de frais, veuillez trouver la nouvelle version en pièce jointe.\n";
$message.= "- Déclarant : {$expediteur->firstname} {$expediteur->lastname}\n";
$message.= "- Période : du {$object->date_debut} au {$object->date_fin}\n";
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
$message.= "Bien cordialement,\n' SI";
// Génération du pdf avant attachement
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
// Génération du pdf avant attachement
$object->setDocModel($user,"");
$resultPDF = expensereport_pdf_create($db,$object,'',"",$langs);
if($resultPDF):
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf");
array_push($mimetype,"application/pdf");
if($resultPDF)
{
// ATTACHMENT
$filename=array(); $filedir=array(); $mimetype=array();
array_push($filename,dol_sanitizeFileName($object->ref).".pdf");
array_push($filedir,$conf->expensereport->dir_output . "/" . dol_sanitizeFileName($object->ref) . "/" . dol_sanitizeFileName($object->ref_number).".pdf");
array_push($mimetype,"application/pdf");
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
// PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message,$filedir,$mimetype,$filename);
if(!$mailfile->error):
// SEND
$result=$mailfile->sendfile();
if ($result):
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
endif;
else:
$mesg="Impossible d'envoyer l'email.";
endif;
// END - Send mail
else:
dol_print_error($db,$resultPDF);
exit;
endif;
if (! $mailfile->error)
{
// SEND
$result=$mailfile->sendfile();
if ($result)
{
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit;
}
else
{
$mesg=$mailfile->error;
}
// END - Send mail
}
else
{
dol_print_error($db,$resultPDF);
exit;
}
}
}
}
}
else
@ -1168,10 +1184,10 @@ if ($action == 'create')
}
else
{
if($id > 0)
if($id > 0 || $ref)
{
$object = new ExpenseReport($db);
$result = $object->fetch($id);
$result = $object->fetch($id, $ref);
if ($result > 0)
{
@ -1218,7 +1234,7 @@ else
// Ref
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 '<tr>';
@ -1376,7 +1392,7 @@ else
// Ref
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 '<tr>';
@ -1450,6 +1466,7 @@ else
print '</tr>';
}
// User to inform
if($object->fk_statut<3) // informed
{
print '<tr>';
@ -1460,6 +1477,7 @@ else
$userfee=new User($db);
$userfee->fetch($object->fk_user_validator);
print $userfee->getNomUrl(1);
if (empty($userfee->email) || ! isValidEmail($userfee->email)) print img_warning($langs->trans("EmailNotValid"));
}
print '</td></tr>';
}
@ -1530,7 +1548,7 @@ else
$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.= ' 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);
if ($resql)
@ -1692,8 +1710,8 @@ else
print_fiche_titre($langs->trans("AddLine"),'','');
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="addline">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$id.'" />';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<input type="hidden" name="fk_expensereport" value="'.$object->id.'" />';
print '<input type="hidden" name="action" value="addline" />';
print '<table class="noborder" width="100%">';
@ -1789,7 +1807,7 @@ print '<div class="tabsAction">';
if ($action != 'create' && $action != 'edit')
{
$object = new ExpenseReport($db);
$object->fetch($id);
$object->fetch($id, $ref);
/* Si l'état est "Brouillon"
@ -1802,18 +1820,18 @@ if ($action != 'create' && $action != 'edit')
if ($object->fk_user_author == $user->id)
{
// 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
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)
{
// 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)
{
// 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)
//print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('BROUILLONNER').'</a>';
// 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)
{
// 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)
{
// 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)
{
// 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)
//{
// 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
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)
{
// 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)
{
// 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)
{
// 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
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)
{
// 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)
{
// 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)
{
// 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)
{
// 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
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_paiement = $obj->code_paiement;
$this->lignes = array();
$this->lignes = array(); // deprecated
$this->lines = array();
$result=$this->fetch_lines();
@ -772,9 +773,10 @@ class ExpenseReport extends CommonObject
* delete
*
* @param int $rowid Id to delete (optional)
* @param User $fuser User that delete
* @return int <0 if KO, >0 if OK
*/
function delete($rowid=0)
function delete($rowid=0, User $fuser=null)
{
global $user,$langs,$conf;
@ -810,10 +812,10 @@ class ExpenseReport extends CommonObject
/**
* Set to status validate
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function setValidate($user)
function setValidate($fuser)
{
global $conf,$langs;
@ -836,13 +838,13 @@ class ExpenseReport extends CommonObject
{
$prefix="ER";
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)
{
$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.= ' WHERE rowid = '.$this->id;
@ -867,10 +869,10 @@ class ExpenseReport extends CommonObject
/**
* set_save_from_refuse
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function set_save_from_refuse($user)
function set_save_from_refuse($fuser)
{
global $conf,$langs;
@ -912,10 +914,10 @@ class ExpenseReport extends CommonObject
/**
* Set status to approved
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function setApproved($user)
function setApproved($fuser)
{
$now=dol_now();
@ -924,7 +926,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 5)
{
$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.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
@ -946,10 +948,10 @@ class ExpenseReport extends CommonObject
/**
* setDeny
*
* @param User $user User
* @param User $fuser User
* @param Details $details Details
*/
function setDeny($user,$details)
function setDeny($fuser,$details)
{
$now = dol_now();
@ -957,7 +959,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 99)
{
$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.= " detail_refuse='".$this->db->escape($details)."'";
$sql.= " fk_user_approve=NULL,";
@ -965,7 +967,7 @@ class ExpenseReport extends CommonObject
if ($this->db->query($sql))
{
$this->fk_statut = 99;
$this->fk_user_refuse = $user->id;
$this->fk_user_refuse = $fuser->id;
$this->detail_refuse = $details;
$this->date_refuse = $now;
return 1;
@ -985,10 +987,10 @@ class ExpenseReport extends CommonObject
/**
* setPaid
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function setPaid($user)
function setPaid($fuser)
{
$now= dol_now();
@ -996,7 +998,7 @@ class ExpenseReport extends CommonObject
if ($this->fk_statut != 6)
{
$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.= ' WHERE rowid = '.$this->id;
@ -1020,10 +1022,10 @@ class ExpenseReport extends CommonObject
/**
* set_unpaid
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function set_unpaid($user)
function set_unpaid($fuser)
{
if ($this->fk_c_deplacement_statuts != 5)
{
@ -1049,17 +1051,17 @@ class ExpenseReport extends CommonObject
/**
* set_cancel
*
* @param User $user User
* @param User $fuser User
* @param string $detail Detail
* @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());
if ($this->fk_statut != 4)
{
$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.= " ,detail_cancel='".$this->db->escape($detail)."'";
$sql.= ' WHERE rowid = '.$this->id;
@ -1271,10 +1273,10 @@ class ExpenseReport extends CommonObject
* deleteline
*
* @param int $rowid Row id
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function deleteline($rowid, $user='')
function deleteline($rowid, $fuser='')
{
$this->db->begin();
@ -1299,16 +1301,16 @@ class ExpenseReport extends CommonObject
/**
* periode_existe
*
* @param User $user User
* @param User $fuser User
* @param Date $date_debut Start date
* @param Date $date_fin End date
* @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.= " 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);
$result = $this->db->query($sql);
@ -1617,12 +1619,12 @@ class ExpenseReportLine
/**
* update
*
* @param User $user User
* @param User $fuser User
* @return int <0 if KO, >0 if OK
*/
function update($user)
function update($fuser)
{
global $user,$langs,$conf;
global $fuser,$langs,$conf;
$error=0;

View File

@ -107,7 +107,7 @@ print_fiche_titre($langs->trans("ExpensesArea"));
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 '<td colspan="4">'.$langs->trans("Statistics").'</td>';
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 '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
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("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 '<td class="liste_titre">&nbsp;</td>';
print_liste_field_titre('');
print "</tr>\n";
// Filters

View File

@ -1045,7 +1045,7 @@ class Societe extends CommonObject
$num=$this->db->num_rows($resql);
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);
$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("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 '<td></td>';
print_liste_field_titre('');
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$params,'align="right"',$sortfield,$sortorder);
print "</tr>\n";

View File

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

View File

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