Work on new module expense report

This commit is contained in:
Laurent Destailleur 2015-02-21 12:57:17 +01:00
parent bc88917b81
commit 070accd1e0
17 changed files with 450 additions and 647 deletions

View File

@ -2121,7 +2121,7 @@ abstract class CommonObject
* *
* @param int $status Status to set * @param int $status Status to set
* @param int $elementId Id of element to force (use this->id by default) * @param int $elementId Id of element to force (use this->id by default)
* @param string $elementType Type of element to force (use ->this->element by default) * @param string $elementType Type of element to force (use this->table_element by default)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function setStatut($status,$elementId='',$elementType='') function setStatut($status,$elementId='',$elementType='')
@ -2135,9 +2135,12 @@ abstract class CommonObject
$fieldstatus="fk_statut"; $fieldstatus="fk_statut";
if ($elementTable == 'user') $fieldstatus="statut"; if ($elementTable == 'user') $fieldstatus="statut";
if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts";
$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
$sql.= " SET ".$fieldstatus." = ".$status; $sql.= " SET ".$fieldstatus." = ".$status;
// If status = 1 = validated, update also fk_user_valid
if ($status == 1 && $elementTable == 'expensereport') $sql.=", fk_user_valid = ".$user->id;
$sql.= " WHERE rowid=".$elementId; $sql.= " WHERE rowid=".$elementId;
dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); dol_syslog(get_class($this)."::setStatut", LOG_DEBUG);

View File

@ -3042,7 +3042,7 @@ class Form
if (! empty($more)) { if (! empty($more)) {
$formconfirm.= '<div>'.$more.'</div>'; $formconfirm.= '<div>'.$more.'</div>';
} }
$formconfirm.= img_help('','').' '.$question; $formconfirm.= ($question ? img_help('','').' '.$question : '');
$formconfirm.= '</div>'."\n"; $formconfirm.= '</div>'."\n";
$formconfirm.= "\n<!-- begin ajax form_confirm page=".$page." -->\n"; $formconfirm.= "\n<!-- begin ajax form_confirm page=".$page." -->\n";

View File

@ -273,7 +273,7 @@ class FormFile
} }
$printer=0; $printer=0;
if (in_array($modulepart,array('facture','propal','proposal','order','commande','expedition'))) // This feature is implemented only for such elements if (in_array($modulepart,array('facture','propal','proposal','order','commande','expedition'))) // The direct print feature is implemented only for such elements
{ {
$printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false; $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled))?true:false;
} }
@ -440,7 +440,6 @@ class FormFile
} }
else if ($modulepart != 'agenda') else if ($modulepart != 'agenda')
{ {
// For normalized standard modules // For normalized standard modules
$file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0);
if (file_exists($file)) if (file_exists($file))
@ -449,7 +448,7 @@ class FormFile
} }
// For normalized external modules // For normalized external modules
else else
{ {
$file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0);
$res=include_once $file; $res=include_once $file;
} }

View File

@ -86,6 +86,8 @@ class FormProjets
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$minmax='';
// Use select2 selector // Use select2 selector
$nodatarole=''; $nodatarole='';
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
@ -94,10 +96,11 @@ class FormProjets
$comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus);
$out.=$comboenhancement; $out.=$comboenhancement;
$nodatarole=($comboenhancement?' data-role="none"':''); $nodatarole=($comboenhancement?' data-role="none"':'');
$minmax='minwidth100 maxwidth300';
} }
if (empty($option_only)) { if (empty($option_only)) {
$out.= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>'; $out.= '<select class="flat'.($minmax?' '.$minmax:'').'" id="'.$htmlname.'" name="'.$htmlname.'"'.$nodatarole.'>';
} }
if (!empty($show_empty)) { if (!empty($show_empty)) {
$out.= '<option value="0">&nbsp;</option>'; $out.= '<option value="0">&nbsp;</option>';

View File

@ -20,6 +20,7 @@
$langs->load("link"); $langs->load("link");
if (empty($relativepathwithnofile)) $relativepathwithnofile=''; if (empty($relativepathwithnofile)) $relativepathwithnofile='';
/* /*
* Confirm form to delete * Confirm form to delete
*/ */
@ -46,7 +47,7 @@ $savingdocmask='';
if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX))
{ {
//var_dump($modulepart); //var_dump($modulepart);
if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','ficheinter','contract','project','project_task'))) if (in_array($modulepart,array('facture_fournisseur','commande_fournisseur','facture','commande','propal','ficheinter','contract','project','project_task','expensereport')))
{ {
$savingdocmask=$object->ref.'___file__'; $savingdocmask=$object->ref.'___file__';
} }

View File

@ -32,6 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formprojet.class.php");
require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'); require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/expensereport.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/expensereport.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php");
dol_include_once('/expensereport/core/modules/expensereport/modules_expensereport.php'); dol_include_once('/expensereport/core/modules/expensereport/modules_expensereport.php');
dol_include_once("/expensereport/class/expensereport.class.php"); dol_include_once("/expensereport/class/expensereport.class.php");
@ -99,9 +100,9 @@ if ($action == 'add' && $user->rights->expensereport->creer)
$object->date_debut = $date_start; $object->date_debut = $date_start;
$object->date_fin = $date_end; $object->date_fin = $date_end;
$object->fk_user_validator = GETPOST('fk_user_validator','int');
$object->fk_c_expensereport_statuts = 1; $object->fk_c_expensereport_statuts = 1;
$object->fk_c_paiement = GETPOST('fk_c_paiement','int'); $object->fk_c_paiement = GETPOST('fk_c_paiement','int');
$object->fk_user_validator = GETPOST('fk_user_validator','int');
$object->note = GETPOST('note'); $object->note = GETPOST('note');
if ($object->periode_existe($user,dol_print_date($object->date_debut, 'dayrfc'),dol_print_date($object->date_fin, 'dayrfc'))) if ($object->periode_existe($user,dol_print_date($object->date_debut, 'dayrfc'),dol_print_date($object->date_fin, 'dayrfc')))
@ -164,7 +165,7 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
$result = $object->set_save($user); $result = $object->setValidate($user);
if ($result > 0) if ($result > 0)
{ {
// Send mail // Send mail
@ -234,7 +235,7 @@ if ($action == "confirm_save" && GETPOST("confirm") == "yes" && $id > 0 && $user
} }
} }
if ($action == "confirm_save_from_refuse" && $_GET["confirm"] == "yes" && $id > 0 && $user->rights->expensereport->creer) if ($action == "confirm_save_from_refuse" && GETPOST("confirm") == "yes" && $id > 0 && $user->rights->expensereport->creer)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
@ -315,7 +316,7 @@ if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
$result = $object->set_valide($user); $result = $object->setApproved($user);
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@ -393,12 +394,12 @@ if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $
} }
} }
if ($action == "confirm_refuse" && $_POST['confirm']=="yes" && !empty($_POST['detail_refuse']) && $id > 0 && $user->rights->expensereport->to_validate) if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->to_validate)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
$result = $object->set_refuse($user,$_POST['detail_refuse']); $result = $object->set_refuse($user,GETPOST('detail_refuse'));
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@ -454,35 +455,35 @@ if ($action == "confirm_refuse" && $_POST['confirm']=="yes" && !empty($_POST['de
} }
} }
if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && !empty($_POST['detail_cancel']) && $id > 0 && $user->rights->expensereport->to_validate) //var_dump($user->id == $object->fk_user_validator);exit;
if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && !empty($_POST['detail_cancel']) && $id > 0 && $user->rights->expensereport->creer)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
if($user->id == $object->fk_user_validator) if ($user->id == $object->fk_user_valid || $user->id == $object->fk_user_author)
{ {
$result = $object->set_cancel($user,$_POST['detail_cancel']); $result = $object->set_cancel($user,$_POST['detail_cancel']);
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
{ {
// Send mail // Send mail
// TO // TO
$destinataire = new User($db); $destinataire = new User($db);
$destinataire->fetch($object->fk_user_author); $destinataire->fetch($object->fk_user_author);
$emailTo = $destinataire->email; $emailTo = $destinataire->email;
// FROM // FROM
$expediteur = new User($db); $expediteur = new User($db);
$expediteur->fetch($object->fk_user_cancel); $expediteur->fetch($object->fk_user_cancel);
$emailFrom = $expediteur->email; $emailFrom = $expediteur->email;
// SUBJECT // SUBJECT
$subject = "' ERP - Note de frais annulée"; $subject = "' ERP - Note de frais annulée";
// CONTENT // CONTENT
$message = "Bonjour {$destinataire->firstname},\n\n"; $message = "Bonjour {$destinataire->firstname},\n\n";
$message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n"; $message.= "Votre note de frais \"{$object->ref}\" vient d'être annulée.\n";
@ -490,10 +491,10 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && !empty($_POST['d
$message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n"; $message.= "- Motif d'annulation : {$_POST['detail_cancel']}\n";
$message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; $message.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n";
$message.= "Bien cordialement,\n' SI"; $message.= "Bien cordialement,\n' SI";
// PREPARE SEND // PREPARE SEND
$mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message);
if(!$mailfile->error) if(!$mailfile->error)
{ {
// SEND // SEND
@ -520,10 +521,6 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && !empty($_POST['d
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else
{
setEventMessages($langs->transnoentitiesnoconv("NOT_VALIDATOR"), '', 'errors');
}
} }
if ($action == "confirm_paid" && $_GET['confirm']=="yes" && $id > 0 && $user->rights->expensereport->to_paid) if ($action == "confirm_paid" && $_GET['confirm']=="yes" && $id > 0 && $user->rights->expensereport->to_paid)
@ -531,7 +528,7 @@ if ($action == "confirm_paid" && $_GET['confirm']=="yes" && $id > 0 && $user->ri
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id,$user); $object->fetch($id,$user);
$result = $object->set_paid($user); $result = $object->setPaid($user);
if ($result > 0) if ($result > 0)
{ {
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@ -622,13 +619,13 @@ if ($action == "confirm_paid" && $_GET['confirm']=="yes" && $id > 0 && $user->ri
} }
} }
if ($action == "confirm_brouillonner" && $_GET['confirm']=="yes" && $id > 0 && $user->rights->expensereport->creer) if ($action == "confirm_brouillonner" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->creer)
{ {
$object = new ExpenseReport($db); $object = new ExpenseReport($db);
$object->fetch($id); $object->fetch($id);
if($user->id == $object->fk_user_author OR $user->id == $object->fk_user_validator) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
$result = $object->set_draft($user); $result = $object->setStatut(0);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id);
@ -654,19 +651,21 @@ if ($action == "addline")
$object_ligne = new ExpenseReportLine($db); $object_ligne = new ExpenseReportLine($db);
$object_ligne->comments = GETPOST('comments'); $object_ligne->comments = GETPOST('comments');
$object_ligne->qty = empty($_POST['qty'])?1:$_POST['qty']; $qty = GETPOST('qty','int');
if (empty($qty)) $qty=1;
$object_ligne->qty = $qty;
$object_ligne->value_unit = price2num(GETPOST('value_unit')); $up=price2num(GETPOST('value_unit'),'MU');
$object_ligne->value_unit = price2num($object_ligne->value_unit,'MU'); $object_ligne->value_unit = $up;
$object_ligne->date = $date; $object_ligne->date = $date;
$object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees'); $object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees');
$tva=GETPOST('vatrate'); $vatrate=GETPOST('vatrate');
$object_ligne->fk_c_tva = $vatrate;
$object_ligne->fk_c_tva = $tva; $object_ligne->vatrate = $vatrate;
$object_ligne->fk_projet = $fk_projet; $object_ligne->fk_projet = $fk_projet;
if (! GETPOST('fk_c_type_fees') > 0) if (! GETPOST('fk_c_type_fees') > 0)
@ -682,7 +681,7 @@ if ($action == "addline")
$action=''; $action='';
} }
// Si aucun projet n'est défini /* Projects are never required. To force them, check module forceproject
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1) if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1)
@ -690,7 +689,7 @@ if ($action == "addline")
$error++; $error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Project")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Project")), 'errors');
} }
} }*/
// Si aucune date n'est rentrée // Si aucune date n'est rentrée
if (empty($object_ligne->date) || $object_ligne->date=="--") if (empty($object_ligne->date) || $object_ligne->date=="--")
@ -698,7 +697,6 @@ if ($action == "addline")
$error++; $error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
} }
// Si aucun prix n'est rentré // Si aucun prix n'est rentré
if($object_ligne->value_unit==0) if($object_ligne->value_unit==0)
{ {
@ -711,25 +709,19 @@ if ($action == "addline")
{ {
$object_ligne->fk_expensereport = $_POST['fk_expensereport']; $object_ligne->fk_expensereport = $_POST['fk_expensereport'];
// Calculs des totos $type = 0; // TODO What if service
$object_ligne->total_ttc = $object_ligne->value_unit * $object_ligne->qty; $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type);
$object_ligne->total_ttc = price2num($object_ligne->total_ttc,'MT');
$object_ligne->total_ttc = $tmp[2];
$object_ligne->tva_taux = GETPOST('vatrate'); $object_ligne->tva_taux = GETPOST('vatrate');
$object_ligne->total_ht = $tmp[0];
$tx_tva = $object_ligne->tva_taux / 100; $object_ligne->total_tva = $tmp[1];
$tx_tva = $tx_tva + 1;
$object_ligne->total_ht = $object_ligne->total_ttc / $tx_tva;
$object_ligne->total_ht = price2num($object_ligne->total_ht,'MT');
$object_ligne->total_tva = $object_ligne->total_ttc - $object_ligne->total_ht;
$result = $object_ligne->insert(); $result = $object_ligne->insert();
if ($result > 0) if ($result > 0)
{ {
$db->commit(); $db->commit();
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} }
else else
@ -910,10 +902,7 @@ if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
} }
/* // Create
* Create
*/
if ($action == 'create') if ($action == 'create')
{ {
print print_fiche_titre($langs->trans("NewTrip")); print print_fiche_titre($langs->trans("NewTrip"));
@ -1002,11 +991,6 @@ else
} }
$head = expensereport_prepare_head($object); $head = expensereport_prepare_head($object);
/*
$head[0][0] = $_SERVER['PHP_SELF'].'?id='.$object->id;
$head[0][1] = $langs->trans('Card');
$head[0][2] = 'card';
$h++;*/
if ($action == 'edit' && ($object->fk_c_expensereport_statuts < 3 || $object->fk_c_expensereport_statuts==99)) if ($action == 'edit' && ($object->fk_c_expensereport_statuts < 3 || $object->fk_c_expensereport_statuts==99))
{ {
@ -1062,10 +1046,10 @@ else
if($object->fk_c_expensereport_statuts<3) if($object->fk_c_expensereport_statuts<3)
{ {
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>'; print '<td>'.$langs->trans("VALIDATOR").'</td>'; // Approbator
print '<td>'; print '<td>';
$include_users = $object->fetch_users_approver_expensereport(); $include_users = $object->fetch_users_approver_expensereport();
$s=$form->select_dolusers($object->fk_user_validator,"fk_user_validator",0,"",0,$include_users); $s=$form->select_dolusers($object->fk_user_validator,"fk_user_validator",1,"",0,$include_users);
print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate"));
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
@ -1146,7 +1130,7 @@ else
endif; endif;
if ($action == 'cancel'): if ($action == 'cancel'):
$array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif d'annulation :",'name'=>"detail_cancel",'size'=>"50",'value'=>"")); $array_input = array(array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_cancel",'size'=>"50",'value'=>""));
$ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("ConfirmCancelTrip"),"","confirm_cancel",$array_input,"",0); $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("ConfirmCancelTrip"),"","confirm_cancel",$array_input,"",0);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
endif; endif;
@ -1157,14 +1141,14 @@ else
endif; endif;
if ($action == 'refuse'): if ($action == 'refuse'):
$array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif de refus :",'name'=>"detail_refuse",'size'=>"50",'value'=>"")); $array_input = array('text'=>$langs->trans("ConfirmRefuseTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_refuse",'size'=>"50",'value'=>""));
$ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("ConfirmRefuseTrip"),"","confirm_refuse",$array_input,"yes",0); $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("Deny"),'',"confirm_refuse",$array_input,"yes",1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
endif; endif;
if ($action == 'delete_line') if ($action == 'delete_line')
{ {
$ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$_GET['id']."&amp;rowid=".$_GET['rowid'],$langs->trans("DeleteLine"),$langs->trans("ConfirmDeleteLine"),"confirm_delete_line"); $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id."&amp;rowid=".$_GET['rowid'],$langs->trans("DeleteLine"),$langs->trans("ConfirmDeleteLine"),"confirm_delete_line",'','yes',1);
if ($ret == 'html') print '<br>'; if ($ret == 'html') print '<br>';
} }
@ -1190,9 +1174,10 @@ else
print '<td>'.$object->libelle_paiement.'</td>'; print '<td>'.$object->libelle_paiement.'</td>';
print '</tr>'; print '</tr>';
} }
// Status
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Statut").'</td>'; print '<td>'.$langs->trans("Statut").'</td>';
print '<td style="font-weight:bold;">'.$object->getLibStatut(4).'</td>'; print '<td>'.$object->getLibStatut(4).'</td>';
print '</tr>'; print '</tr>';
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Note").'</td>'; print '<td>'.$langs->trans("Note").'</td>';
@ -1211,58 +1196,7 @@ else
print '<td>'.price($object->total_ttc).'</td>'; print '<td>'.price($object->total_ttc).'</td>';
print '</tr>'; print '</tr>';
if($object->fk_c_expensereport_statuts<3) // Author
{
print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>';
print '<td>';
if ($object->fk_user_validator > 0)
{
$userfee=new User($db);
$userfee->fetch($object->fk_user_validator);
print $userfee->getNomUrl(1);
}
print '</td></tr>';
}
elseif($object->fk_c_expensereport_statuts==4)
{
print '<tr>';
print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("CANCEL_USER").'</span></td>';
print '<td><span style="font-weight:bold;color:red;">';
if ($object->fk_user_cancel > 0)
{
$userfee=new User($db);
$userfee->fetch($object->fk_user_cancel);
print $userfee->getNomUrl(1);
}
print '</span></td></tr>';
print '<tr>';
print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("MOTIF_CANCEL").'</span></td>';
print '<td><span style="font-weight:bold;color:red;">'.$object->detail_cancel.'</span></td></tr>';
print '</tr>';
print '<tr>';
print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("DATE_CANCEL").'</span></td>';
print '<td><span style="font-weight:bold;color:red;">'.$object->date_cancel.'</span></td></tr>';
print '</tr>';
}
else
{
print '<tr>';
print '<td>'.$langs->trans("VALIDOR").'</td>';
print '<td>';
if ($object->fk_user_valid > 0)
{
$userfee=new User($db);
$userfee->fetch($object->fk_user_valid);
print $userfee->getNomUrl(1);
}
print '</td></tr>';
print '<tr>';
print '<td>'.$langs->trans("DATE_VALIDE").'</td>';
print '<td>'.$object->date_valide.'</td></tr>';
print '</tr>';
}
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("AUTHOR").'</td>'; print '<td>'.$langs->trans("AUTHOR").'</td>';
print '<td>'; print '<td>';
@ -1293,31 +1227,82 @@ else
print '<td>'.$object->date_paiement.'</td></tr>'; print '<td>'.$object->date_paiement.'</td></tr>';
print '</tr>'; print '</tr>';
} }
if($object->fk_c_expensereport_statuts<3)
{
print '<tr>';
print '<td>'.$langs->trans("VALIDATOR").'</td>';
print '<td>';
if ($object->fk_user_validator > 0)
{
$userfee=new User($db);
$userfee->fetch($object->fk_user_validator);
print $userfee->getNomUrl(1);
}
print '</td></tr>';
}
elseif($object->fk_c_expensereport_statuts==4)
{
print '<tr>';
print '<td>'.$langs->trans("CANCEL_USER").'</span></td>';
print '<td>';
if ($object->fk_user_cancel > 0)
{
$userfee=new User($db);
$userfee->fetch($object->fk_user_cancel);
print $userfee->getNomUrl(1);
}
print '</td></tr>';
print '<tr>';
print '<td>'.$langs->trans("MOTIF_CANCEL").'</td>';
print '<td>'.$object->detail_cancel.'</td></tr>';
print '</tr>';
print '<tr>';
print '<td>'.$langs->trans("DATE_CANCEL").'</td>';
print '<td>'.$object->date_cancel.'</td></tr>';
print '</tr>';
}
else
{
print '<tr>';
print '<td>'.$langs->trans("VALIDOR").'</td>';
print '<td>';
if ($object->fk_user_valid > 0)
{
$userfee=new User($db);
$userfee->fetch($object->fk_user_valid);
print $userfee->getNomUrl(1);
}
print '</td></tr>';
print '<tr>';
print '<td>'.$langs->trans("DATE_VALIDE").'</td>';
print '<td>'.$object->date_valide.'</td></tr>';
print '</tr>';
}
if($object->fk_c_expensereport_statuts==99 || !empty($object->detail_refuse)) if($object->fk_c_expensereport_statuts==99 || !empty($object->detail_refuse))
{ {
print '<tr>'; print '<tr>';
print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("REFUSEUR").'</span></td>'; print '<td>'.$langs->trans("REFUSEUR").'</td>';
print '<td><span style="font-weight:bold;color:red;">'; print '<td>';
$userfee=new User($db); $userfee=new User($db);
$userfee->fetch($object->fk_user_refuse); $userfee->fetch($object->fk_user_refuse);
print $userfee->getNomUrl(1); print $userfee->getNomUrl(1);
print '</span></td></tr>'; print '</td></tr>';
print '<tr>'; print '<tr>';
print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("MOTIF_REFUS").'</span></td>'; print '<td>'.$langs->trans("DATE_REFUS").'</td>';
print '<td><span style="font-weight:bold;color:red;">'.$object->detail_refuse.'</span></td></tr>'; print '<td>'.$object->date_refuse;
print '</tr>'; if ($object->detail_refuse) print ' - '.$object->detail_refuse;
print '<tr>'; print '</td>';
print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("DATE_REFUS").'</span></td>';
print '<td><span style="font-weight:bold;color:red;">'.$object->date_refuse.'</span></td></tr>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
print '<br>'; print '<br>';
// Fetch Lines of current ndf // Fetch Lines of current expense report
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,'; $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_projet, fde.date,';
$sql.= ' fde.fk_c_tva, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; $sql.= ' fde.fk_c_tva 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';
$sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde';
@ -1357,7 +1342,7 @@ else
print '<td style="text-align:right;">'.$langs->trans('AmountTTC').'</td>'; print '<td style="text-align:right;">'.$langs->trans('AmountTTC').'</td>';
} }
// Ajout des boutons de modification/suppression // Ajout des boutons de modification/suppression
if ($object->fk_c_expensereport_statuts<2 OR $object->fk_c_expensereport_statuts==99) if ($object->fk_c_expensereport_statuts < 2 || $object->fk_c_expensereport_statuts==99)
{ {
print '<td style="text-align:right;"></td>'; print '<td style="text-align:right;"></td>';
} }
@ -1370,25 +1355,34 @@ else
$piece_comptable = $i + 1; $piece_comptable = $i + 1;
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
$var=!$var; $var=!$var;
if ($action != 'editline') if ($action != 'editline' || $objp->rowid != GETPOST('rowid'))
{ {
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td style="text-align:center;width:9%;">'; if ($action != 'editline')
print img_picto($langs->trans("Document"), "object_generic"); {
print ' <span style="color:red;font-weight:bold;font-size:14px;">'.$piece_comptable.'</span></td>'; print '<td style="text-align:center;">';
print img_picto($langs->trans("Document"), "object_generic");
print ' <span>'.$piece_comptable.'</span></td>';
}
print '<td style="text-align:center;">'.$objp->date.'</td>'; print '<td style="text-align:center;">'.$objp->date.'</td>';
print '<td style="text-align:center;">'; print '<td style="text-align:center;">';
$projecttmp->id=$objp->projet_id; if ($objp->projet_id > 0)
$projecttmp->ref=$objp->projet_ref; {
print $projecttmp->getNomUrl(1); $projecttmp->id=$objp->projet_id;
$projecttmp->ref=$objp->projet_ref;
print $projecttmp->getNomUrl(1);
}
print '</td>'; print '</td>';
print '<td style="text-align:center;">'.$langs->trans("TF_".strtoupper($objp->type_fees_libelle)).'</td>'; print '<td style="text-align:center;">'.$langs->trans("TF_".strtoupper($objp->type_fees_libelle)).'</td>';
print '<td style="text-align:left;">'.$objp->comments.'</td>'; print '<td style="text-align:left;">'.$objp->comments.'</td>';
print '<td style="text-align:right;">'.vatrate($objp->tva_taux,true).'</td>'; print '<td style="text-align:right;">'.vatrate($objp->vatrate,true).'</td>';
print '<td style="text-align:right;">'.price($objp->value_unit).'</td>'; print '<td style="text-align:right;">'.price($objp->value_unit).'</td>';
print '<td style="text-align:right;">'.$objp->qty.'</td>'; print '<td style="text-align:right;">'.$objp->qty.'</td>';
print '<td style="text-align:right;">'.price($objp->total_ht).'</td>'; if ($action != 'editline')
print '<td style="text-align:right;">'.price($objp->total_ttc).'</td>'; {
print '<td style="text-align:right;">'.price($objp->total_ht).'</td>';
print '<td style="text-align:right;">'.price($objp->total_ttc).'</td>';
}
// Ajout des boutons de modification/suppression // Ajout des boutons de modification/suppression
if($object->fk_c_expensereport_statuts<2 OR $object->fk_c_expensereport_statuts==99) if($object->fk_c_expensereport_statuts<2 OR $object->fk_c_expensereport_statuts==99)
@ -1404,45 +1398,44 @@ else
} }
print '</tr>'; print '</tr>';
} }
else
if ($action == 'editline' && $objp->rowid == GETPOST('rowid'))
{ {
if($objp->rowid==$_GET['rowid'])
{
//modif ligne!!!!! //modif ligne!!!!!
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
// Sélection date // Sélection date
print '<td style="text-align:center;width:10%;">'; print '<td style="text-align:center;">';
$form->select_date($objp->date,'date'); $form->select_date($objp->date,'date');
print '</td>'; print '</td>';
// Sélection projet // Select project
print '<td style="text-align:center;width:10%;">'; print '<td>';
print select_projet($objp->fk_projet,'','fk_projet'); $formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 0, 1);
print '</td>'; print '</td>';
// Sélection type // Sélect type
print '<td style="text-align:center;width:10%;">'; print '<td style="text-align:center;">';
select_type_fees_id($objp->type_fees_code,'fk_c_type_fees'); select_type_fees_id($objp->type_fees_code,'fk_c_type_fees');
print '</td>'; print '</td>';
// Add comments // Add comments
print '<td style="text-align:left;width:35%;">'; print '<td>';
print '<textarea class="flat_ndf" name="comments" class="centpercent">'.$objp->comments.'</textarea>'; print '<textarea class="flat_ndf" name="comments" class="centpercent">'.$objp->comments.'</textarea>';
print '</td>'; print '</td>';
// Sélection TVA // Sélection TVA
print '<td style="text-align:right;width:10%;">'; print '<td style="text-align:right;">';
print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->tva_taux), $mysoc, ''); print $form->load_tva('fk_c_tva', (isset($_POST["fk_c_tva"])?$_POST["fk_c_tva"]:$objp->tva_taux), $mysoc, '');
print '</td>'; print '</td>';
// Prix unitaire // Prix unitaire
print '<td style="text-align:right;width:10%;">'; print '<td style="text-align:right;">';
print '<input type="text" size="10" name="value_unit" value="'.$objp->value_unit.'" />'; print '<input type="text" size="6" name="value_unit" value="'.$objp->value_unit.'" />';
print '</td>'; print '</td>';
// Quantité // Quantité
print '<td style="text-align:right;width:10%;">'; print '<td style="text-align:right;">';
print '<input type="text" size="10" name="qty" value="'.$objp->qty.'" />'; print '<input type="text" size="4" name="qty" value="'.$objp->qty.'" />';
print '</td>'; print '</td>';
print '<td style="text-align:center;">'; print '<td style="text-align:center;">';
@ -1450,7 +1443,6 @@ else
print '<input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">'; print '<input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">'; print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'">';
print '</td>'; print '</td>';
}
} }
$i++; $i++;
@ -1503,7 +1495,7 @@ else
// Sélection projet // Sélection projet
print '<td>'; print '<td>';
$formproject->select_projects('', GETPOST('fk_projet'), 'fk_projet', 0, 0, 1, 1); $formproject->select_projects(-1, GETPOST('fk_projet'), 'fk_projet', 0, 0, 1, 1);
print '</td>'; print '</td>';
// Sélection type // Sélection type
@ -1528,7 +1520,7 @@ else
// Prix unitaire // Prix unitaire
print '<td style="text-align:right;">'; print '<td style="text-align:right;">';
print '<input type="text" size="10" name="value_unit" value="'.GETPOST('value_unit').'">'; print '<input type="text" size="6" name="value_unit" value="'.GETPOST('value_unit').'">';
print '</td>'; print '</td>';
// Quantité // Quantité
@ -1593,7 +1585,7 @@ if ($action != 'create' && $action != 'edit')
// 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="'.$_SEVER["PHP_SELF"].'?action=save&id='.$id.'">'.$langs->trans('Validate').'</a>'; print '<a class="butAction" href="'.$_SEVER["PHP_SELF"].'?action=save&id='.$id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
} }
if ($user->rights->expensereport->supprimer) if ($user->rights->expensereport->supprimer)
@ -1611,7 +1603,7 @@ if ($action != 'create' && $action != 'edit')
*/ */
if($user->rights->expensereport->creer && $object->fk_c_expensereport_statuts==99) if($user->rights->expensereport->creer && $object->fk_c_expensereport_statuts==99)
{ {
if ($object->fk_user_author == $user->id) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Modifier // Modifier
print '<a class="butAction" href="'.$_SEVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('ModifyInfoGen').'</a>'; print '<a class="butAction" href="'.$_SEVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('ModifyInfoGen').'</a>';
@ -1619,7 +1611,7 @@ if ($action != 'create' && $action != 'edit')
// 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="'.$_SEVER["PHP_SELF"].'?action=save_from_refuse&id='.$id.'">'.$langs->trans('Validate').'</a>'; print '<a class="butAction" href="'.$_SEVER["PHP_SELF"].'?action=save_from_refuse&id='.$id.'">'.$langs->trans('ValidateAndSubmit').'</a>';
if ($user->rights->expensereport->supprimer) if ($user->rights->expensereport->supprimer)
{ {
@ -1631,10 +1623,10 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==5) if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==5)
{ {
if ($object->fk_user_author == $user->id || $object->fk_user_valid == $user->id) 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('BROUILLONNER').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('SetToDraft').'</a>';
} }
} }
@ -1648,7 +1640,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('BROUILLONNER').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('SetToDraft').'</a>';
} }
} }
@ -1659,12 +1651,12 @@ if ($action != 'create' && $action != 'edit')
// Valider // Valider
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='.$id.'">'.$langs->trans('Approve').'</a>';
// Refuser // Refuser
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Refuse').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=refuse&id='.$id.'">'.$langs->trans('Deny').'</a>';
//} //}
if ($object->fk_user_author==$user->id) if ($user->id == $object->fk_user_author || $user->id == $object->fk_user_valid)
{ {
// Annuler // 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='.$id.'">'.$langs->trans('Cancel').'</a>';
} }
@ -1679,14 +1671,17 @@ if ($action != 'create' && $action != 'edit')
* ET user à droit de "to_paid" * ET user à droit de "to_paid"
* Afficher : "Annuler" / "Payer" / "Supprimer" * Afficher : "Annuler" / "Payer" / "Supprimer"
*/ */
if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts==5) if ($user->rights->expensereport->to_paid && $object->fk_c_expensereport_statuts == 5)
{ {
// Payer // Payer
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='.$id.'">'.$langs->trans('TO_PAID').'</a>';
// Annuler // Cancel
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('CANCEL').'</a>'; 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>';
}
if($user->rights->expensereport->supprimer) if($user->rights->expensereport->supprimer)
{ {
// Supprimer // Supprimer
@ -1717,10 +1712,10 @@ if ($action != 'create' && $action != 'edit')
if ($user->rights->expensereport->supprimer && $object->fk_c_expensereport_statuts==4) if ($user->rights->expensereport->supprimer && $object->fk_c_expensereport_statuts==4)
{ {
if ($object->fk_user_validator==$user->id) 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('BROUILLONNER').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=brouillonner&id='.$id.'">'.$langs->trans('ReOpen').'</a>';
} }
// Supprimer // Supprimer
@ -1732,7 +1727,7 @@ if ($action != 'create' && $action != 'edit')
print '</div>'; print '</div>';
$conf->global->DOL_URL_ROOT_DOCUMENT_PHP=dol_buildpath('/expensereport/documentwrapper.php',1); //$conf->global->DOL_URL_ROOT_DOCUMENT_PHP=dol_buildpath('/expensereport/documentwrapper.php',1);
print '<div style="width:50%">'; print '<div style="width:50%">';

View File

@ -39,40 +39,40 @@ class ExpenseReport extends CommonObject
ACTIONS ACTIONS
*/ */
// Enregistrement // Enregistrement
var $date_create; var $date_create;
var $fk_user_author; var $fk_user_author;
// Refus // Refus
var $date_refuse; var $date_refuse;
var $detail_refuse; var $detail_refuse;
var $fk_user_refuse; var $fk_user_refuse;
// Annulation // Annulation
var $date_cancel; var $date_cancel;
var $detail_cancel; var $detail_cancel;
var $fk_user_cancel; var $fk_user_cancel;
// Validation // Validation
var $date_valide; var $date_valide;
var $fk_user_valid; var $fk_user_valid;
var $user_valid_infos; var $user_valid_infos;
// Paiement // Paiement
var $date_paiement; var $date_paiement;
var $fk_user_paid; var $fk_user_paid;
var $user_paid_infos; var $user_paid_infos;
/* /*
END ACTIONS END ACTIONS
*/ */
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Handler acces base de donnees * @param DoliDB $db Handler acces base de donnees
*/ */
function __construct($db) function __construct($db)
{ {
$this->db = $db; $this->db = $db;
@ -242,13 +242,13 @@ class ExpenseReport extends CommonObject
} }
} }
/** /**
* Load an object from database * Load an object from database
* *
* @param int $id Id * @param int $id Id
* @param string $ref Ref * @param string $ref Ref
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function fetch($id, $ref='') function fetch($id, $ref='')
{ {
global $conf,$db; global $conf,$db;
@ -467,94 +467,94 @@ class ExpenseReport extends CommonObject
if($user->rights->expensereport->lire) { if($user->rights->expensereport->lire) {
$sql = "SELECT de.fk_expensereport, de.date, de.comments, de.total_ht, de.total_ttc"; $sql = "SELECT de.fk_expensereport, de.date, de.comments, de.total_ht, de.total_ttc";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport_det as de"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport_det as de";
$sql.= " WHERE de.fk_projet = ".$projectid; $sql.= " WHERE de.fk_projet = ".$projectid;
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$result = $db->query($sql) ; $result = $db->query($sql) ;
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$total_HT = 0; $total_HT = 0;
$total_TTC = 0; $total_TTC = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_c_expensereport_statuts"; $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_c_expensereport_statuts";
$sql2.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; $sql2.= " FROM ".MAIN_DB_PREFIX."expensereport as d";
$sql2.= " WHERE d.rowid = '".$objp->fk_expensereport."'"; $sql2.= " WHERE d.rowid = '".$objp->fk_expensereport."'";
$result2 = $db->query($sql2); $result2 = $db->query($sql2);
$obj = $db->fetch_object($result2); $obj = $db->fetch_object($result2);
$objp->fk_user_author = $obj->fk_user_author; $objp->fk_user_author = $obj->fk_user_author;
$objp->ref = $obj->ref; $objp->ref = $obj->ref;
$objp->fk_c_expensereport_status = $obj->fk_c_expensereport_statuts; $objp->fk_c_expensereport_status = $obj->fk_c_expensereport_statuts;
$objp->rowid = $obj->rowid; $objp->rowid = $obj->rowid;
$total_HT = $total_HT + $objp->total_ht; $total_HT = $total_HT + $objp->total_ht;
$total_TTC = $total_TTC + $objp->total_ttc; $total_TTC = $total_TTC + $objp->total_ttc;
$author = new User($db); $author = new User($db);
$author->fetch($objp->fk_user_author); $author->fetch($objp->fk_user_author);
print '<tr>'; print '<tr>';
print '<td><a href="'.DOL_URL_ROOT.'/expensereport/card.php?id='.$objp->rowid.'">'.$objp->ref_num.'</a></td>'; print '<td><a href="'.DOL_URL_ROOT.'/expensereport/card.php?id='.$objp->rowid.'">'.$objp->ref_num.'</a></td>';
print '<td align="center">'.dol_print_date($objp->date,'day').'</td>'; print '<td align="center">'.dol_print_date($objp->date,'day').'</td>';
print '<td>'.$author->getNomUrl().'</td>'; print '<td>'.$author->getNomUrl().'</td>';
print '<td>'.$objp->comments.'</td>'; print '<td>'.$objp->comments.'</td>';
print '<td align="right">'.price($objp->total_ht).'</td>'; print '<td align="right">'.price($objp->total_ht).'</td>';
print '<td align="right">'.price($objp->total_ttc).'</td>'; print '<td align="right">'.price($objp->total_ttc).'</td>';
print '<td align="right">'; print '<td align="right">';
switch($objp->fk_c_expensereport_status) { switch($objp->fk_c_expensereport_status) {
case 4: case 4:
print img_picto($langs->trans('StatusOrderCanceled'),'statut5'); print img_picto($langs->trans('StatusOrderCanceled'),'statut5');
break; break;
case 1: case 1:
print $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); print $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0');
break; break;
case 2: case 2:
print $langs->trans('TripForValid').' '.img_picto($langs->trans('TripForValid'),'statut3');; print $langs->trans('TripForValid').' '.img_picto($langs->trans('TripForValid'),'statut3');;
break; break;
case 5: case 5:
print $langs->trans('TripForPaid').' '.img_picto($langs->trans('TripForPaid'),'statut3'); print $langs->trans('TripForPaid').' '.img_picto($langs->trans('TripForPaid'),'statut3');
break; break;
case 6: case 6:
print $langs->trans('TripPaid').' '.img_picto($langs->trans('TripPaid'),'statut4'); print $langs->trans('TripPaid').' '.img_picto($langs->trans('TripPaid'),'statut4');
break; break;
} }
/* /*
if ($status==4) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); if ($status==4) return img_picto($langs->trans('StatusOrderCanceled'),'statut5');
if ($status==1) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); if ($status==1) return img_picto($langs->trans('StatusOrderDraft'),'statut0');
if ($status==2) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); if ($status==2) return img_picto($langs->trans('StatusOrderValidated'),'statut1');
if ($status==2) return img_picto($langs->trans('StatusOrderOnProcess'),'statut3'); if ($status==2) return img_picto($langs->trans('StatusOrderOnProcess'),'statut3');
if ($status==5) return img_picto($langs->trans('StatusOrderToBill'),'statut4'); if ($status==5) return img_picto($langs->trans('StatusOrderToBill'),'statut4');
if ($status==6) return img_picto($langs->trans('StatusOrderOnProcess'),'statut6'); if ($status==6) return img_picto($langs->trans('StatusOrderOnProcess'),'statut6');
*/ */
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Number").': '.$i.'</td>'; print '<tr class="liste_total"><td colspan="4">'.$langs->trans("Number").': '.$i.'</td>';
print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_HT).'</td>'; print '<td align="right" width="100">'.$langs->trans("TotalHT").' : '.price($total_HT).'</td>';
print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_TTC).'</td>'; print '<td align="right" width="100">'.$langs->trans("TotalTTC").' : '.price($total_TTC).'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '</tr>'; print '</tr>';
} }
else else
{ {
$this->error=$db->error(); $this->error=$db->error();
return -1; return -1;
} }
} }
} }
@ -580,10 +580,10 @@ class ExpenseReport extends CommonObject
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num): while ($i < $num):
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$total_ht+=$objp->total_ht; $total_ht+=$objp->total_ht;
$total_tva+=$objp->total_tva; $total_tva+=$objp->total_tva;
$i++; $i++;
endwhile; endwhile;
$total_ttc = $total_ht + $total_tva; $total_ttc = $total_ht + $total_tva;
@ -594,19 +594,19 @@ class ExpenseReport extends CommonObject
$sql.= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if($result): if($result):
$this->db->free($result); $this->db->free($result);
return 1; return 1;
else: else:
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR); dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR);
return -3; return -3;
endif; endif;
} }
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR); dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR);
return -3; return -3;
} }
} }
@ -718,12 +718,12 @@ class ExpenseReport extends CommonObject
} }
/** /**
* set_save * Set to status validate
* *
* @param User $user User * @param User $user User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_save($user) function setValidate($user)
{ {
global $conf,$langs; global $conf,$langs;
@ -752,8 +752,8 @@ class ExpenseReport extends CommonObject
if ($this->fk_c_expensereport_statuts != 2) if ($this->fk_c_expensereport_statuts != 2)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 2"; $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 2, fk_user_valid = ".$user->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;
dol_syslog(get_class($this)."::set_save sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::set_save sql=".$sql, LOG_DEBUG);
@ -822,30 +822,30 @@ class ExpenseReport extends CommonObject
} }
/** /**
* set_valide * Set status to approved
* *
* @param User $user User * @param User $user User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_valide($user) function setApproved($user)
{ {
// date de validation // date de validation
$this->date_valide = $this->db->idate(gmmktime()); $this->date_valide = $this->db->idate(gmmktime());
if ($this->fk_c_expensereport_statuts != 5) if ($this->fk_c_expensereport_statuts != 5)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 5, fk_user_valid = ".$user->id; $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 5, fk_user_approve = ".$user->id.",";
$sql.= ', date_valide='.$this->date_valide; $sql.= " date_valide='".$this->date_valide."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
dol_syslog(get_class($this)."::set_valide sql=".$sql, LOG_DEBUG); {
if ($this->db->query($sql)):
return 1; return 1;
else: }
$this->error=$this->db->error(); else
{
$this->error=$this->db->lasterror();
return -1; return -1;
endif; }
} }
else else
{ {
@ -861,24 +861,29 @@ class ExpenseReport extends CommonObject
*/ */
function set_refuse($user,$details) function set_refuse($user,$details)
{ {
$now = dol_now();
// date de refus // date de refus
$this->date_refuse = $this->db->idate(gmmktime());
if ($this->fk_c_expensereport_statuts != 99) if ($this->fk_c_expensereport_statuts != 99)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 99, fk_user_refuse = ".$user->id; $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 99, fk_user_refuse = ".$user->id.",";
$sql.= ', date_refuse='.$this->date_refuse; $sql.= " date_refuse='".$this->db->idate($now)."',";
$sql.= ", detail_refuse='".addslashes($details)."'"; $sql.= " detail_refuse='".$this->db->escape($details)."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql))
dol_syslog(get_class($this)."::set_refuse sql=".$sql, LOG_DEBUG); {
$this->fk_c_expensereport_statuts = 99;
if ($this->db->query($sql)): $this->fk_user_refuse = $user->id;
$this->detail_refuse = $details;
$this->date_refuse = $now;
return 1; return 1;
else: }
$this->error=$this->db->error(); else
{
$this->error=$this->db->lasterror();
return -1; return -1;
endif; }
} }
else else
{ {
@ -887,22 +892,22 @@ class ExpenseReport extends CommonObject
} }
/** /**
* set_paid * setPaid
* *
* @param User $user User * @param User $user User
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
function set_paid($user) function setPaid($user)
{ {
$this->date_paiement = $this->db->idate(gmmktime()); $this->date_paiement = $this->db->idate(gmmktime());
if ($this->fk_c_expensereport_statuts != 6) if ($this->fk_c_expensereport_statuts != 6)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_expensereport_statuts = 6, fk_user_paid = ".$user->id; $sql.= " SET fk_c_expensereport_statuts = 6, fk_user_paid = ".$user->id.",";
$sql.= ', date_paiement='.$this->date_paiement; $sql.= " date_paiement='".$this->date_paiement."'";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_paid sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::setPaid sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
@ -931,52 +936,21 @@ class ExpenseReport extends CommonObject
if ($this->fk_c_deplacement_statuts != 5) if ($this->fk_c_deplacement_statuts != 5)
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_deplacement_statuts = 5"; $sql.= " SET fk_c_expensereport_statuts = 5";
$sql.= ' WHERE rowid = '.$this->id; $sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)): if ($this->db->query($sql)):
return 1; return 1;
else: else:
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
endif; endif;
} }
else else
{ {
dol_syslog(get_class($this)."::set_unpaid deplacement already with unpaid status", LOG_WARNING); dol_syslog(get_class($this)."::set_unpaid expensereport already with unpaid status", LOG_WARNING);
}
}
/**
* set_draft
*
* @param User $user User
* @return int <0 if KO, >0 if OK
*/
function set_draft($user)
{
if ($this->fk_c_deplacement_statuts != 1)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_deplacement_statuts = 1,";
//$sql.= " , ref = '(PROV".$this->id.")', ref_number_int = 0";
$sql.= " ref_number_int = 0";
$sql.= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::set_draft sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) return 1;
else
{
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog(get_class($this)."::set_draft deplacement already with draft status", LOG_WARNING);
} }
} }
@ -1026,7 +1000,7 @@ class ExpenseReport extends CommonObject
{ {
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql.= " SET fk_c_expensereport_statuts = 4, fk_user_cancel = ".$user->id; $sql.= " SET fk_c_expensereport_statuts = 4, fk_user_cancel = ".$user->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;
@ -1062,24 +1036,24 @@ class ExpenseReport extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if($this->db->num_rows($result) > 0): if($this->db->num_rows($result) > 0):
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$this->ref = $objp->ref_number_int; $this->ref = $objp->ref_number_int;
$this->ref++; $this->ref++;
while(strlen($this->ref) < $num_car): while(strlen($this->ref) < $num_car):
$this->ref = "0".$this->ref; $this->ref = "0".$this->ref;
endwhile; endwhile;
else: else:
$this->ref = 1; $this->ref = 1;
while(strlen($this->ref) < $num_car): while(strlen($this->ref) < $num_car):
$this->ref = "0".$this->ref; $this->ref = "0".$this->ref;
endwhile; endwhile;
endif; endif;
if ($result): if ($result):
return 1; return 1;
else: else:
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
endif; endif;
} }
@ -1123,10 +1097,10 @@ class ExpenseReport extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result): if ($result):
return 1; return 1;
else: else:
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
endif; endif;
} }
@ -1143,10 +1117,10 @@ class ExpenseReport extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result): if ($result):
return 1; return 1;
else: else:
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;
endif; endif;
} }
@ -1214,12 +1188,12 @@ class ExpenseReport extends CommonObject
$result = $ligne->update(); $result = $ligne->update();
if ($result > 0): if ($result > 0):
$this->db->commit(); $this->db->commit();
return 1; return 1;
else: else:
$this->error=$ligne->error; $this->error=$ligne->error;
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
endif; endif;
} }
@ -1467,7 +1441,7 @@ class ExpenseReportLine
$sql.= " VALUES (".$this->fk_expensereport.","; $sql.= " VALUES (".$this->fk_expensereport.",";
$sql.= " ".$this->fk_c_type_fees.","; $sql.= " ".$this->fk_c_type_fees.",";
$sql.= " ".($this->fk_projet>0?$this->fk_projet:'null').","; $sql.= " ".($this->fk_projet>0?$this->fk_projet:'null').",";
$sql.= " ".$this->fk_c_tva.","; $sql.= " ".$this->vatrate.",";
$sql.= " '".$this->db->escape($this->comments)."',"; $sql.= " '".$this->db->escape($this->comments)."',";
$sql.= " ".$this->qty.","; $sql.= " ".$this->qty.",";
$sql.= " ".$this->value_unit.","; $sql.= " ".$this->value_unit.",";
@ -1531,8 +1505,11 @@ class ExpenseReportLine
$sql.= " comments='".$this->db->escape($this->comments)."'"; $sql.= " comments='".$this->db->escape($this->comments)."'";
$sql.= ",value_unit=".$this->value_unit.""; $sql.= ",value_unit=".$this->value_unit."";
$sql.= ",qty=".$this->qty.""; $sql.= ",qty=".$this->qty."";
if ($this->date) { $sql.= ",date='".$this->date."'"; } if ($this->date) {
else { $sql.=',date=null'; } $sql.= ",date='".$this->date."'";
}
else { $sql.=',date=null';
}
$sql.= ",total_ht=".$this->total_ht.""; $sql.= ",total_ht=".$this->total_ht."";
$sql.= ",total_tva=".$this->total_tva.""; $sql.= ",total_tva=".$this->total_tva."";
$sql.= ",total_ttc=".$this->total_ttc.""; $sql.= ",total_ttc=".$this->total_ttc."";
@ -1587,9 +1564,9 @@ class ExpenseReportLine
*/ */
function select_expensereport_statut($selected='',$htmlname='fk_c_expensereport_statuts',$useempty=1) function select_expensereport_statut($selected='',$htmlname='fk_c_expensereport_statuts',$useempty=1)
{ {
global $db; global $db;
$tmpep=new ExpenseReport($db); $tmpep=new ExpenseReport($db);
print '<select class="flat" name="'.$htmlname.'">'; print '<select class="flat" name="'.$htmlname.'">';
if ($useempty) print '<option value="-1">&nbsp;</option>'; if ($useempty) print '<option value="-1">&nbsp;</option>';
@ -1609,65 +1586,6 @@ function select_expensereport_statut($selected='',$htmlname='fk_c_expensereport_
print '</select>'; print '</select>';
} }
/**
* select_projet
* TODO Utiliser le select project officiel
*
* @param int $selected Id selected
* @param string $filter Filter
* @param string $htmlname Select name
* @return int <0 if KO, >0 if OK
*/
function select_projet($selected='',$filter='', $htmlname='fk_projet')
{
global $conf,$user,$langs,$db;
$out='';
$sql = "SELECT p.rowid, p.ref, p.title";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " WHERE p.entity = ".$conf->entity;
if (is_numeric($selected)) $sql.= " AND p.rowid = ".$selected;
dol_syslog("Form::select_projet sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
if ($conf->use_javascript_ajax && ! $forcecombo)
{
$minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT)?$conf->global->COMPANY_USE_SEARCH_TO_SELECT:2);
$projetid = 0;
if ($selected)
{
$obj = $db->fetch_object($resql);
$projetid = $obj->rowid?$obj->rowid:'';
}
$out.= "\n".'<!-- Input text for third party with Ajax.Autocompleter (select_techno_ajax) -->'."\n";
$out.= '<table class="nobordernopadding"><tr class="nocellnopadd">';
$out.= '<td class="nobordernopadding">';
if ($projetid == 0) {
$out.= '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="" />';
} else {
$out.= '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$obj->ref.' - '.$obj->title.'" />';
}
$out.= ajax_autocompleter(($projetid?$projetid:-1),$htmlname,dol_buildpath('/expensereport/ajax/ajaxprojet.php',1).'?filter='.urlencode($filter), '', $minLength);
$out.= '</td>';
$out.= '</tr>';
$out.= '</table>';
}
}
else
{
dol_print_error($db);
}
return $out;
}
/** /**
* Return list of types of notes with select value = id * Return list of types of notes with select value = id
* *

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
@ -25,10 +25,12 @@
/** /**
* \file htdocs/expensereport/document.php * \file htdocs/expensereport/document.php
* \ingroup expensereport * \ingroup expensereport
* \brief Page of linked files onto trip and expenses * \brief Page of linked files onto trip and expens reports
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php';
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
@ -102,7 +104,7 @@ if ($object->id)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/expensereport/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';

View File

@ -41,6 +41,7 @@ CREATE TABLE llx_expensereport (
note text, note text,
note_private text, note_private text,
fk_user_valid integer DEFAULT NULL, fk_user_valid integer DEFAULT NULL,
fk_user_approve integer DEFAULT NULL,
fk_user_paid integer DEFAULT NULL, fk_user_paid integer DEFAULT NULL,
detail_refuse varchar(255) DEFAULT NULL, detail_refuse varchar(255) DEFAULT NULL,
date_cancel datetime, date_cancel datetime,

View File

@ -21,7 +21,7 @@ CREATE TABLE llx_expensereport_det
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
fk_expensereport integer NOT NULL, fk_expensereport integer NOT NULL,
fk_c_type_fees integer NOT NULL, fk_c_type_fees integer NOT NULL,
fk_projet integer NOT NULL, fk_projet integer,
fk_c_tva integer NOT NULL, fk_c_tva integer NOT NULL,
comments text NOT NULL, comments text NOT NULL,
product_type integer DEFAULT -1, product_type integer DEFAULT -1,

View File

@ -30,7 +30,7 @@ ExportDataset_fournisseur_2=Supplier invoices and payments
ExportDataset_fournisseur_3=Supplier orders and order lines ExportDataset_fournisseur_3=Supplier orders and order lines
ApproveThisOrder=Approve this order ApproveThisOrder=Approve this order
ConfirmApproveThisOrder=Are you sure you want to approve order <b>%s</b> ? ConfirmApproveThisOrder=Are you sure you want to approve order <b>%s</b> ?
DenyingThisOrder=Denying this order DenyingThisOrder=Deny this order
ConfirmDenyingThisOrder=Are you sure you want to deny this order <b>%s</b> ? ConfirmDenyingThisOrder=Are you sure you want to deny this order <b>%s</b> ?
ConfirmCancelThisOrder=Are you sure you want to cancel this order <b>%s</b> ? ConfirmCancelThisOrder=Are you sure you want to cancel this order <b>%s</b> ?
AddCustomerOrder=Create customer order AddCustomerOrder=Create customer order

View File

@ -37,71 +37,63 @@ TF_ESSENCE=Fuel
TF_HOTEL=Hostel TF_HOTEL=Hostel
TF_TAXI=Taxi TF_TAXI=Taxi
ErrorDoubleDeclaration=ERREUR : Vous avez déclaré au moins une note de frais dans le même intervalle. ErrorDoubleDeclaration=You have declared another expense report into a similar date range.
ListTripsAndExpenses=Liste des notes de frais ListTripsAndExpenses=List of expense reports
AucuneNDF=Il n'y a aucune note de frais déclarée correspondante à votre recherche! AucuneNDF=No expense reports found for this criteria
AucuneLigne=Il n'y a aucune ligne de déclarée dans cette note de frais! AucuneLigne=There is no expense report declared yet
AddLine=Ajouter une ligne AddLine=Add a line
AddLineMini=Ajouter AddLineMini=Add
TotalHT=Montant HT
TotalTTC=Montant TTC
TotalTVA=Total TVA
Date_DEBUT=Date de début période Date_DEBUT=Period date start
Date_FIN=Date de fin période Date_FIN=Period date end
ModePaiement=Mode de paiement ModePaiement=Payment mode
Note=Note Note=Note
Project=Projet Project=Project
VALIDATOR=Utilisateur informé pour validation VALIDATOR=User to inform for approbation
VALIDOR=Validée par VALIDOR=Approved by
AUTHOR=Enregistrée par AUTHOR=Recorded by
AUTHORPAIEMENT=Payée par AUTHORPAIEMENT=Paied by
REFUSEUR=Refusée par REFUSEUR=Denied by
CANCEL_USER=Annulée par CANCEL_USER=Canceled by
MOTIF_REFUS=Motif de refus MOTIF_REFUS=Reason
MOTIF_CANCEL=Motif d'annulation MOTIF_CANCEL=Reason
DATE_REFUS=Date du refus DATE_REFUS=Deny date
DATE_CANCEL=Date annulation DATE_CANCEL=Cancelation date
DATE_VALIDE=Date de validation DATE_VALIDE=Validation date
DATE_PAIEMENT=Date de paiement DATE_PAIEMENT=Payment date
DATE_SAVE=Date d'enregistrement DATE_SAVE=Recording date
REFUSE=Refuse Deny=Deny
TO_PAID=Pay TO_PAID=Pay
BROUILLONNER=Reopen BROUILLONNER=Reopen
SendToValid=Sent to approve SendToValid=Sent to approve
ModifyInfoGen=Edit ModifyInfoGen=Edit
ValidateAndSubmit=Validate and submit for approval
NOT_VALIDATOR=Vous n'êtes pas la personne habilitée à valider cette note de frais! NOT_VALIDATOR=You are not allowed to approve this expense report
NOT_AUTHOR=Vous n'êtes pas l'auteur de cette note de frais, impossible de réaliser l'opération voulue! NOT_AUTHOR=You are not the author of this expense report. Operation cancelled.
NOT_VALIDOR=Vous n'êtes pas le valideur de cette note de frais, vous ne pouvez donc pas réaliser cette opération!
NotUserRightToView=Vous n'avez pas le droit d'afficher cette note de frais.
RefuseTrip=Refuser une note de frais RefuseTrip=Deny an expense report
ConfirmRefuseTrip=Êtes vous sûr de vouloir refuser cette note de frais ? ConfirmRefuseTrip=Are you sure you want to deny this expense report ?
ValideTrip=Valider une note de frais ValideTrip=Approve expense report
ConfirmValideTrip=Êtes vous sûr de vouloir valider cette note de frais ? ConfirmValideTrip=Are you sure you want to approve this expense report ?
PaidTrip=Payer une note de frais PaidTrip=Pay an expense report
ConfirmPaidTrip=Êtes vous sûr de vouloir payer cette note de frais ? ConfirmPaidTrip=Are you sure you want to change status of this expense report to "Paid" ?
CancelTrip=Annuler une note de frais CancelTrip=Cancel an expense report
ConfirmCancelTrip=Êtes vous sûr de vouloir annuler cette note de frais ? ConfirmCancelTrip=Are you sure you want to cancel this expense report ?
BrouillonnerTrip=Remettre une note de frais en brouillon BrouillonnerTrip=Move back expense report to status "Draft"n
ConfirmBrouillonnerTrip=Êtes vous sûr de vouloir remettre cette note de frais en brouillon ? ConfirmBrouillonnerTrip=Are you sure you want to move this expense report to status "Draft" ?
SaveTrip=Enregistrement de votre note de frais SaveTrip=Validate expense report
ConfirmSaveTrip=Êtes vous sûr de vouloir enregistrer cette note de frais? (elle sera transmise par mail pour validation) ConfirmSaveTrip=Are you sure you want to validate this expense report ?
INFOS_DATES=Infos Workflow
INFOS_NDF=Infos générales note de frais
StatsTrip=Statistiques
Synchro_Compta=NDF <-> Compte Synchro_Compta=NDF <-> Compte
TripSynch=Synchronisation : Notes de frais <-> Compte courant TripSynch=Synchronisation : Notes de frais <-> Compte courant

View File

@ -1,137 +0,0 @@
# Dolibarr language file - fr_FR - trips
CHARSET=UTF-8
Trip=Note de frais
Trips=Notes de frais
TripsAndExpenses=Notes de frais
TripId=Id note de frais
TripCard=Fiche note de frais
AddTrip=Ajouter note de frais
ListOfTrips=Liste des notes de frais
ListOfFees=Liste des notes de frais
NewTrip=Nouvelle note de frais
CancelAddTrip=Annuler
ExportTripCSV=Exporter en CSV
AnyOtherInThisListCanValidate=Toute personne dans la liste pourra valider. Le choix détermine qui sera informé.
TripSociete=Informations société
TripSalarie=Informations salarié
TripNDF=Informations note de frais
DeleteTrip=Supprimer note de frais
ConfirmDeleteTrip=Êtes vous sûr de vouloir supprimer cette note de frais ?
DeleteLine=Supprimer une ligne de la note de frais
ConfirmDeleteLine=Êtes vous sûr de vouloir supprimer cette ligne ?
TF_OTHER=Autre
TF_LUNCH=Repas
TF_METRO=Métro
TF_TRAIN=Train
TF_RATP=Ratp
TF_BUS=Bus
TF_PEAGE=Péage
TF_ESSENCE=Essence
TF_SNCF=SNCF (Autre)
TF_HOTEL=Hôtel
TF_TRANSPORT=SNCF (Train)
TF_TAXI=Taxi
ErrorDoubleDeclaration=ERREUR : Vous avez déclaré au moins une note de frais dans le même intervalle.
ListTripsAndExpenses=Liste des notes de frais
AucuneNDF=Il n'y a aucune note de frais déclarée correspondante à votre recherche!
AucuneLigne=Il n'y a aucune ligne de déclarée dans cette note de frais!
AddLine=Ajouter une ligne
AddLineMini=Ajouter
TotalHT=Montant HT
TotalTTC=Montant TTC
TotalTVA=Total TVA
Date_DEBUT=Date de début période
Date_FIN=Date de fin période
ModePaiement=Mode de paiement
Note=Note
Project=Projet
VALIDATOR=Utilisateur informé pour validation
VALIDOR=Validée par
AUTHOR=Enregistrée par
AUTHORPAIEMENT=Payée par
REFUSEUR=Refusée par
CANCEL_USER=Annulée par
MOTIF_REFUS=Motif de refus
MOTIF_CANCEL=Motif d'annulation
DATE_REFUS=Date du refus
DATE_CANCEL=Date annulation
DATE_VALIDE=Date de validation
DATE_PAIEMENT=Date de paiement
DATE_SAVE=Date d'enregistrement
VALIDATE=Valider
REFUSE=Refuser
CANCEL=Annuler
TO_PAID=Payer
BROUILLONNER=Remettre en brouillon
SendToValid=Envoyer en validation
ModifyInfoGen=Modifier les infos générales
Module20130304Name=Notes de frais
Module20130304Desc=Gestion des notes de frais et déplacement (par ')
NOT_VALIDATOR=Vous n'êtes pas la personne habilitée à valider cette note de frais!
NOT_AUTHOR=Vous n'êtes pas l'auteur de cette note de frais, impossible de réaliser l'opération voulue!
NOT_VALIDOR=Vous n'êtes pas le valideur de cette note de frais, vous ne pouvez donc pas réaliser cette opération!
NotUserRightToView=Vous n'avez pas le droit d'afficher cette note de frais.
RefuseTrip=Refuser une note de frais
ConfirmRefuseTrip=Êtes vous sûr de vouloir refuser cette note de frais ?
ValideTrip=Valider une note de frais
ConfirmValideTrip=Êtes vous sûr de vouloir valider cette note de frais ?
PaidTrip=Payer une note de frais
ConfirmPaidTrip=Êtes vous sûr de vouloir payer cette note de frais ?
CancelTrip=Annuler une note de frais
ConfirmCancelTrip=Êtes vous sûr de vouloir annuler cette note de frais ?
BrouillonnerTrip=Remettre une note de frais en brouillon
ConfirmBrouillonnerTrip=Êtes vous sûr de vouloir remettre cette note de frais en brouillon ?
SaveTrip=Enregistrement de votre note de frais
ConfirmSaveTrip=Êtes vous sûr de vouloir enregistrer cette note de frais? (elle sera transmise par mail pour validation)
INFOS_DATES=Infos Workflow
INFOS_NDF=Infos générales note de frais
EURO=€
PriceUNITAIRE=Prix U. (TTC)
StatsTrip=Statistiques
Synchro_Compta=NDF <-> Compte
TripSynch=Synchronisation : Notes de frais <-> Compte courant
TripToSynch=Notes de frais à intégrer dans la compta
AucuneTripToSynch=Aucune note de frais n'est en statut "Payée".
ViewAccountSynch=Voir le compte
ConfirmNdfToAccount=Êtes-vous sûr de vouloir intégrer cette note de frais dans le compte courant?
ndfToAccount=Note de frais - Intégration
ConfirmAccountToNdf=Êtes-vous sûr de vouloir retirer cette note de frais du compte courant?
AccountToNdf=Note de frais - Retrait
USER_AUTHOR=Auteur
PU=P.U.
Q=Q
LINE_NOT_ADDED=Ligne non ajoutée :
NO_PROJECT=Aucun projet sélectionné.
NO_DATE=Aucune date sélectionnée.
NO_PRICE=Aucun prix indiqué.
TripForValid=à Valider
TripForPaid=à Payer
TripPaid=Payée
NoTripsToExportCSV=Il n'y a pas de notes de frais à exporter pour cette période.

View File

@ -466,7 +466,7 @@ if ($action == 'create' && $user->rights->projet->creer)
// Budget // Budget
print '<tr><td>'.$langs->trans("Budget").'</td>'; print '<tr><td>'.$langs->trans("Budget").'</td>';
print '<td><input size="4" type="text" name="budget_amount" value="'.(isset($_POST['budget_amount'])?price(GETPOST('budget_amount')):'').'"></td></tr>'; print '<td><input size="4" type="text" name="budget_amount" value="'.(GETPOST('budget_amount')!=''?price(GETPOST('budget_amount')):'').'"></td></tr>';
print '</td></tr>'; print '</td></tr>';
// Description // Description

View File

@ -126,7 +126,7 @@ class Project extends CommonObject
$sql.= ", '".$this->db->idate($now)."'"; $sql.= ", '".$this->db->idate($now)."'";
$sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); $sql.= ", " . ($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql.= ", " . $this->budget_amount; $sql.= ", " . ($this->budget_amount != ''?price2num($this->budget_amount):'null');
$sql.= ", ".$conf->entity; $sql.= ", ".$conf->entity;
$sql.= ")"; $sql.= ")";
@ -152,7 +152,7 @@ class Project extends CommonObject
$error++; $error++;
} }
//Update extrafield // Update extrafield
if (!$error) { if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{ {
@ -495,6 +495,23 @@ class Project extends CommonObject
} }
} }
// Set fk_projet into elements to null
$listoftables=array(
'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet','facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet',
'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet'
);
foreach($listoftables as $key => $value)
{
$sql = "UPDATE " . MAIN_DB_PREFIX . $key . " SET ".$value." = NULL where ".$value." = ". $this->id;
$resql = $this->db->query($sql);
if (!$resql)
{
$this->errors[] = $this->db->lasterror();
$error++;
break;
}
}
// Delete tasks // Delete tasks
if (! $error) if (! $error)
{ {

View File

@ -393,6 +393,9 @@ th .button {
.centpercent { .centpercent {
width: 100%; width: 100%;
} }
textarea.centpercent {
width: 96%;
}
.center { .center {
text-align: center; text-align: center;
} }
@ -444,11 +447,17 @@ th .button {
.hideobject { display: none; } .hideobject { display: none; }
.minwidth100 { min-width: 100px; } .minwidth100 { min-width: 100px; }
.minwidth200 { min-width: 200px; } .minwidth200 { min-width: 200px; }
.minwidth300 { min-width: 300px; }
.maxwidth100 { max-width: 100px; }
.maxwidth200 { max-width: 200px; }
.maxwidth300 { max-width: 300px; }
<?php if (! empty($dol_optimize_smallscreen)) { ?> <?php if (! empty($dol_optimize_smallscreen)) { ?>
.hideonsmartphone { display: none; } .hideonsmartphone { display: none; }
.noenlargeonsmartphone { width : 50px !important; display: inline !important; } .noenlargeonsmartphone { width : 50px !important; display: inline !important; }
.maxwidthonsmartphone { max-width: 100px; } .maxwidthonsmartphone { max-width: 100px; }
.maxwidth100onsmartphone { max-width: 100px; }
.maxwidth200onsmartphone { max-width: 200px; } .maxwidth200onsmartphone { max-width: 200px; }
.maxwidth300onsmartphone { max-width: 300px; }
<?php } ?> <?php } ?>
.linkobject { cursor: pointer; } .linkobject { cursor: pointer; }
<?php if (GETPOST("optioncss") == 'print') { ?> <?php if (GETPOST("optioncss") == 'print') { ?>