From 070accd1e0f9001f6fec4f5aa77b53ab95cc8b6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 21 Feb 2015 12:57:17 +0100 Subject: [PATCH] Work on new module expense report --- htdocs/core/class/commonobject.class.php | 7 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formfile.class.php | 5 +- htdocs/core/class/html.formprojet.class.php | 5 +- ...lacement.php => modules_expensereport.php} | 0 .../tpl/document_actions_post_headers.tpl.php | 3 +- htdocs/expensereport/card.php | 309 ++++++----- .../class/expensereport.class.php | 500 ++++++++---------- htdocs/expensereport/document.php | 8 +- .../mysql/tables/llx_expensereport.sql | 1 + .../mysql/tables/llx_expensereport_det.sql | 2 +- htdocs/langs/en_US/suppliers.lang | 2 +- htdocs/langs/en_US/trips.lang | 88 ++- htdocs/langs/fr_FR/expensereport.lang | 137 ----- htdocs/projet/card.php | 2 +- htdocs/projet/class/project.class.php | 21 +- htdocs/theme/eldy/style.css.php | 9 + 17 files changed, 452 insertions(+), 649 deletions(-) rename htdocs/core/modules/expensereport/{modules_deplacement.php => modules_expensereport.php} (100%) delete mode 100755 htdocs/langs/fr_FR/expensereport.lang diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aed2aa3b224..20f7859469d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2121,7 +2121,7 @@ abstract class CommonObject * * @param int $status Status to set * @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 */ function setStatut($status,$elementId='',$elementType='') @@ -2135,9 +2135,12 @@ abstract class CommonObject $fieldstatus="fk_statut"; if ($elementTable == 'user') $fieldstatus="statut"; - + if ($elementTable == 'expensereport') $fieldstatus="fk_c_expensereport_statuts"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable; $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; dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 53d04b8ab6a..6e6f39837d5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3042,7 +3042,7 @@ class Form if (! empty($more)) { $formconfirm.= '<div>'.$more.'</div>'; } - $formconfirm.= img_help('','').' '.$question; + $formconfirm.= ($question ? img_help('','').' '.$question : ''); $formconfirm.= '</div>'."\n"; $formconfirm.= "\n<!-- begin ajax form_confirm page=".$page." -->\n"; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 274fa19a417..241c44cf5f8 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -273,7 +273,7 @@ class FormFile } $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; } @@ -440,7 +440,6 @@ class FormFile } else if ($modulepart != 'agenda') { - // For normalized standard modules $file=dol_buildpath('/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); if (file_exists($file)) @@ -449,7 +448,7 @@ class FormFile } // For normalized external modules else - { + { $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); $res=include_once $file; } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index e1487818438..86d46f3b9b5 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -86,6 +86,8 @@ class FormProjets $resql=$this->db->query($sql); if ($resql) { + $minmax=''; + // Use select2 selector $nodatarole=''; if (! empty($conf->use_javascript_ajax)) @@ -94,10 +96,11 @@ class FormProjets $comboenhancement = ajax_combobox($htmlname, '', 0, $forcefocus); $out.=$comboenhancement; $nodatarole=($comboenhancement?' data-role="none"':''); + $minmax='minwidth100 maxwidth300'; } 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)) { $out.= '<option value="0"> </option>'; diff --git a/htdocs/core/modules/expensereport/modules_deplacement.php b/htdocs/core/modules/expensereport/modules_expensereport.php similarity index 100% rename from htdocs/core/modules/expensereport/modules_deplacement.php rename to htdocs/core/modules/expensereport/modules_expensereport.php diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index d1a1cedca61..abd42296cde 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -20,6 +20,7 @@ $langs->load("link"); if (empty($relativepathwithnofile)) $relativepathwithnofile=''; + /* * Confirm form to delete */ @@ -46,7 +47,7 @@ $savingdocmask=''; if (empty($conf->global->MAIN_DISABLE_SUGGEST_REF_AS_PREFIX)) { //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__'; } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index b555746c05b..871cbe22990 100755 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -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.'/compta/bank/class/account.class.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/class/expensereport.class.php"); @@ -99,9 +100,9 @@ if ($action == 'add' && $user->rights->expensereport->creer) $object->date_debut = $date_start; $object->date_fin = $date_end; - $object->fk_user_validator = GETPOST('fk_user_validator','int'); $object->fk_c_expensereport_statuts = 1; $object->fk_c_paiement = GETPOST('fk_c_paiement','int'); + $object->fk_user_validator = GETPOST('fk_user_validator','int'); $object->note = GETPOST('note'); 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->fetch($id); - $result = $object->set_save($user); + $result = $object->setValidate($user); if ($result > 0) { // 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->fetch($id); @@ -315,7 +316,7 @@ if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $ $object = new ExpenseReport($db); $object->fetch($id); - $result = $object->set_valide($user); + $result = $object->setApproved($user); if ($result > 0) { 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->fetch($id); - - $result = $object->set_refuse($user,$_POST['detail_refuse']); + + $result = $object->set_refuse($user,GETPOST('detail_refuse')); if ($result > 0) { 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->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']); - + if ($result > 0) { if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) { - // Send mail - + // TO $destinataire = new User($db); $destinataire->fetch($object->fk_user_author); $emailTo = $destinataire->email; - + // FROM $expediteur = new User($db); $expediteur->fetch($object->fk_user_cancel); $emailFrom = $expediteur->email; - + // SUBJECT $subject = "' ERP - Note de frais annulée"; - + // CONTENT $message = "Bonjour {$destinataire->firstname},\n\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.= "- Lien : {$dolibarr_main_url_root}/expensereport/card.php?id={$object->id}\n\n"; $message.= "Bien cordialement,\n' SI"; - + // PREPARE SEND $mailfile = new CMailFile($subject,$emailTo,$emailFrom,$message); - + if(!$mailfile->error) { // SEND @@ -520,10 +521,6 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && !empty($_POST['d 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) @@ -531,7 +528,7 @@ if ($action == "confirm_paid" && $_GET['confirm']=="yes" && $id > 0 && $user->ri $object = new ExpenseReport($db); $object->fetch($id,$user); - $result = $object->set_paid($user); + $result = $object->setPaid($user); if ($result > 0) { 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->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) { header("Location: ".$_SEVER["PHP_SELF"]."?id=".$id); @@ -654,19 +651,21 @@ if ($action == "addline") $object_ligne = new ExpenseReportLine($db); $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')); - $object_ligne->value_unit = price2num($object_ligne->value_unit,'MU'); + $up=price2num(GETPOST('value_unit'),'MU'); + $object_ligne->value_unit = $up; $object_ligne->date = $date; $object_ligne->fk_c_type_fees = GETPOST('fk_c_type_fees'); - $tva=GETPOST('vatrate'); - - $object_ligne->fk_c_tva = $tva; - + $vatrate=GETPOST('vatrate'); + $object_ligne->fk_c_tva = $vatrate; + $object_ligne->vatrate = $vatrate; + $object_ligne->fk_projet = $fk_projet; if (! GETPOST('fk_c_type_fees') > 0) @@ -682,7 +681,7 @@ if ($action == "addline") $action=''; } - // Si aucun projet n'est défini + /* Projects are never required. To force them, check module forceproject if ($conf->projet->enabled) { if (empty($object_ligne->fk_projet) || $object_ligne->fk_projet==-1) @@ -690,7 +689,7 @@ if ($action == "addline") $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Project")), 'errors'); } - } + }*/ // Si aucune date n'est rentrée if (empty($object_ligne->date) || $object_ligne->date=="--") @@ -698,7 +697,6 @@ if ($action == "addline") $error++; setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); } - // Si aucun prix n'est rentré if($object_ligne->value_unit==0) { @@ -711,25 +709,19 @@ if ($action == "addline") { $object_ligne->fk_expensereport = $_POST['fk_expensereport']; - // Calculs des totos - $object_ligne->total_ttc = $object_ligne->value_unit * $object_ligne->qty; - $object_ligne->total_ttc = price2num($object_ligne->total_ttc,'MT'); + $type = 0; // TODO What if service + $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type); + $object_ligne->total_ttc = $tmp[2]; $object_ligne->tva_taux = GETPOST('vatrate'); - - $tx_tva = $object_ligne->tva_taux / 100; - $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; + $object_ligne->total_ht = $tmp[0]; + $object_ligne->total_tva = $tmp[1]; $result = $object_ligne->insert(); if ($result > 0) { $db->commit(); - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$_GET['id']); + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } else @@ -910,10 +902,7 @@ if (! empty($conf->global->DEPLACEMENT_TO_CLEAN)) } -/* - * Create - */ - +// Create if ($action == 'create') { print print_fiche_titre($langs->trans("NewTrip")); @@ -1002,11 +991,6 @@ else } $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)) { @@ -1062,10 +1046,10 @@ else if($object->fk_c_expensereport_statuts<3) { print '<tr>'; - print '<td>'.$langs->trans("VALIDATOR").'</td>'; + print '<td>'.$langs->trans("VALIDATOR").'</td>'; // Approbator print '<td>'; $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 '</td>'; print '</tr>'; @@ -1146,7 +1130,7 @@ else endif; 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); if ($ret == 'html') print '<br>'; endif; @@ -1157,14 +1141,14 @@ else endif; if ($action == 'refuse'): - $array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif de refus :",'name'=>"detail_refuse",'size'=>"50",'value'=>"")); - $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("ConfirmRefuseTrip"),"","confirm_refuse",$array_input,"yes",0); + $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("Deny"),'',"confirm_refuse",$array_input,"yes",1); if ($ret == 'html') print '<br>'; endif; if ($action == 'delete_line') { - $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$_GET['id']."&rowid=".$_GET['rowid'],$langs->trans("DeleteLine"),$langs->trans("ConfirmDeleteLine"),"confirm_delete_line"); + $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id."&rowid=".$_GET['rowid'],$langs->trans("DeleteLine"),$langs->trans("ConfirmDeleteLine"),"confirm_delete_line",'','yes',1); if ($ret == 'html') print '<br>'; } @@ -1190,9 +1174,10 @@ else print '<td>'.$object->libelle_paiement.'</td>'; print '</tr>'; } + // Status print '<tr>'; 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 '<td>'.$langs->trans("Note").'</td>'; @@ -1211,6 +1196,38 @@ else print '<td>'.price($object->total_ttc).'</td>'; print '</tr>'; + // Author + print '<tr>'; + print '<td>'.$langs->trans("AUTHOR").'</td>'; + print '<td>'; + if ($object->fk_user_author > 0) + { + $userauthor=new User($db); + $result=$userauthor->fetch($object->fk_user_author); + if ($result < 0) dol_print_error('',$userauthor->error); + print $userauthor->getNomUrl(1); + } + print '</td></tr>'; + + print '<tr>'; + print '<td>'.$langs->trans("DATE_SAVE").'</td>'; + print '<td>'.$object->date_create.'</td></tr>'; + print '</tr>'; + if($object->fk_c_expensereport_statuts==6) + { + print '<tr>'; + print '<td>'.$langs->trans("AUTHORPAIEMENT").'</td>'; + print '<td>'; + $userfee=new User($db); + $userfee->fetch($object->fk_user_paid); + print $userfee->getNomUrl(1); + print '</td></tr>'; + print '<tr>'; + print '<td>'.$langs->trans("DATE_PAIEMENT").'</td>'; + print '<td>'.$object->date_paiement.'</td></tr>'; + print '</tr>'; + } + if($object->fk_c_expensereport_statuts<3) { print '<tr>'; @@ -1227,22 +1244,22 @@ else 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;">'; + 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 '</span></td></tr>'; + print '</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 '<td>'.$langs->trans("MOTIF_CANCEL").'</td>'; + print '<td>'.$object->detail_cancel.'</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 '<td>'.$langs->trans("DATE_CANCEL").'</td>'; + print '<td>'.$object->date_cancel.'</td></tr>'; print '</tr>'; } else @@ -1263,61 +1280,29 @@ else print '</tr>'; } - print '<tr>'; - print '<td>'.$langs->trans("AUTHOR").'</td>'; - print '<td>'; - if ($object->fk_user_author > 0) - { - $userauthor=new User($db); - $result=$userauthor->fetch($object->fk_user_author); - if ($result < 0) dol_print_error('',$userauthor->error); - print $userauthor->getNomUrl(1); - } - print '</td></tr>'; - - print '<tr>'; - print '<td>'.$langs->trans("DATE_SAVE").'</td>'; - print '<td>'.$object->date_create.'</td></tr>'; - print '</tr>'; - if($object->fk_c_expensereport_statuts==6) - { - print '<tr>'; - print '<td>'.$langs->trans("AUTHORPAIEMENT").'</td>'; - print '<td>'; - $userfee=new User($db); - $userfee->fetch($object->fk_user_paid); - print $userfee->getNomUrl(1); - print '</td></tr>'; - print '<tr>'; - print '<td>'.$langs->trans("DATE_PAIEMENT").'</td>'; - print '<td>'.$object->date_paiement.'</td></tr>'; - print '</tr>'; - } if($object->fk_c_expensereport_statuts==99 || !empty($object->detail_refuse)) { print '<tr>'; - print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("REFUSEUR").'</span></td>'; - print '<td><span style="font-weight:bold;color:red;">'; + print '<td>'.$langs->trans("REFUSEUR").'</td>'; + print '<td>'; $userfee=new User($db); $userfee->fetch($object->fk_user_refuse); print $userfee->getNomUrl(1); - print '</span></td></tr>'; - print '<tr>'; - print '<td><span style="font-weight:bold;color:red;">'.$langs->trans("MOTIF_REFUS").'</span></td>'; - print '<td><span style="font-weight:bold;color:red;">'.$object->detail_refuse.'</span></td></tr>'; - print '</tr>'; + print '</td></tr>'; print '<tr>'; - 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 '<td>'.$langs->trans("DATE_REFUS").'</td>'; + print '<td>'.$object->date_refuse; + if ($object->detail_refuse) print ' - '.$object->detail_refuse; + print '</td>'; print '</tr>'; } print '</table>'; 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.= ' 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.= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql.= ' FROM '.MAIN_DB_PREFIX.'expensereport_det fde'; @@ -1357,7 +1342,7 @@ else print '<td style="text-align:right;">'.$langs->trans('AmountTTC').'</td>'; } // 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>'; } @@ -1370,25 +1355,34 @@ else $piece_comptable = $i + 1; $objp = $db->fetch_object($resql); $var=!$var; - if ($action != 'editline') + if ($action != 'editline' || $objp->rowid != GETPOST('rowid')) { print '<tr '.$bc[$var].'>'; - print '<td style="text-align:center;width:9%;">'; - print img_picto($langs->trans("Document"), "object_generic"); - print ' <span style="color:red;font-weight:bold;font-size:14px;">'.$piece_comptable.'</span></td>'; + if ($action != 'editline') + { + 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;">'; - $projecttmp->id=$objp->projet_id; - $projecttmp->ref=$objp->projet_ref; - print $projecttmp->getNomUrl(1); + if ($objp->projet_id > 0) + { + $projecttmp->id=$objp->projet_id; + $projecttmp->ref=$objp->projet_ref; + print $projecttmp->getNomUrl(1); + } print '</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: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;">'.$objp->qty.'</td>'; - print '<td style="text-align:right;">'.price($objp->total_ht).'</td>'; - print '<td style="text-align:right;">'.price($objp->total_ttc).'</td>'; + if ($action != 'editline') + { + 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 if($object->fk_c_expensereport_statuts<2 OR $object->fk_c_expensereport_statuts==99) @@ -1404,45 +1398,44 @@ else } print '</tr>'; } - else + + if ($action == 'editline' && $objp->rowid == GETPOST('rowid')) { - if($objp->rowid==$_GET['rowid']) - { //modif ligne!!!!! print '<tr '.$bc[$var].'>'; // Sélection date - print '<td style="text-align:center;width:10%;">'; + print '<td style="text-align:center;">'; $form->select_date($objp->date,'date'); print '</td>'; - // Sélection projet - print '<td style="text-align:center;width:10%;">'; - print select_projet($objp->fk_projet,'','fk_projet'); + // Select project + print '<td>'; + $formproject->select_projects(-1, $objp->fk_projet,'fk_projet', 0, 0, 0, 1); print '</td>'; - // Sélection type - print '<td style="text-align:center;width:10%;">'; + // Sélect type + print '<td style="text-align:center;">'; select_type_fees_id($objp->type_fees_code,'fk_c_type_fees'); print '</td>'; // 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 '</td>'; // 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 '</td>'; // Prix unitaire - print '<td style="text-align:right;width:10%;">'; - print '<input type="text" size="10" name="value_unit" value="'.$objp->value_unit.'" />'; + print '<td style="text-align:right;">'; + print '<input type="text" size="6" name="value_unit" value="'.$objp->value_unit.'" />'; print '</td>'; // Quantité - print '<td style="text-align:right;width:10%;">'; - print '<input type="text" size="10" name="qty" value="'.$objp->qty.'" />'; + print '<td style="text-align:right;">'; + print '<input type="text" size="4" name="qty" value="'.$objp->qty.'" />'; print '</td>'; print '<td style="text-align:center;">'; @@ -1450,7 +1443,6 @@ else 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 '</td>'; - } } $i++; @@ -1503,7 +1495,7 @@ else // Sélection projet 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>'; // Sélection type @@ -1528,7 +1520,7 @@ else // Prix unitaire 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>'; // Quantité @@ -1593,7 +1585,7 @@ if ($action != 'create' && $action != 'edit') // Validate 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) @@ -1611,7 +1603,7 @@ if ($action != 'create' && $action != 'edit') */ 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 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) //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="'.$_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) { @@ -1631,10 +1623,10 @@ if ($action != 'create' && $action != 'edit') 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 - 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) { // 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 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Approve').'</a>'; // 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>'; } @@ -1679,14 +1671,17 @@ if ($action != 'create' && $action != 'edit') * ET user à droit de "to_paid" * 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 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=paid&id='.$id.'">'.$langs->trans('TO_PAID').'</a>'; - // Annuler - print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=cancel&id='.$id.'">'.$langs->trans('CANCEL').'</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>'; + } + if($user->rights->expensereport->supprimer) { // Supprimer @@ -1717,10 +1712,10 @@ if ($action != 'create' && $action != 'edit') 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 - 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 @@ -1732,7 +1727,7 @@ if ($action != 'create' && $action != 'edit') 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%">'; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 84db5bd9ece..76534e94c2a 100755 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -39,40 +39,40 @@ class ExpenseReport extends CommonObject ACTIONS */ - // Enregistrement - var $date_create; - var $fk_user_author; - - // Refus - var $date_refuse; - var $detail_refuse; - var $fk_user_refuse; - - // Annulation - var $date_cancel; - var $detail_cancel; - var $fk_user_cancel; - - // Validation - var $date_valide; - var $fk_user_valid; - var $user_valid_infos; - - // Paiement - var $date_paiement; - var $fk_user_paid; - var $user_paid_infos; + // Enregistrement + var $date_create; + var $fk_user_author; + + // Refus + var $date_refuse; + var $detail_refuse; + var $fk_user_refuse; + + // Annulation + var $date_cancel; + var $detail_cancel; + var $fk_user_cancel; + + // Validation + var $date_valide; + var $fk_user_valid; + var $user_valid_infos; + + // Paiement + var $date_paiement; + var $fk_user_paid; + var $user_paid_infos; /* END ACTIONS */ - /** - * Constructor - * - * @param DoliDB $db Handler acces base de donnees - */ + /** + * Constructor + * + * @param DoliDB $db Handler acces base de donnees + */ function __construct($db) { $this->db = $db; @@ -242,13 +242,13 @@ class ExpenseReport extends CommonObject } } - /** - * Load an object from database - * - * @param int $id Id - * @param string $ref Ref - * @return int <0 if KO, >0 if OK - */ + /** + * Load an object from database + * + * @param int $id Id + * @param string $ref Ref + * @return int <0 if KO, >0 if OK + */ function fetch($id, $ref='') { global $conf,$db; @@ -467,94 +467,94 @@ class ExpenseReport extends CommonObject if($user->rights->expensereport->lire) { - $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.= " WHERE de.fk_projet = ".$projectid; - - dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); - $result = $db->query($sql) ; - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - $total_HT = 0; - $total_TTC = 0; - - while ($i < $num) - { - - $objp = $db->fetch_object($result); - - $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_c_expensereport_statuts"; - $sql2.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; - $sql2.= " WHERE d.rowid = '".$objp->fk_expensereport."'"; - - $result2 = $db->query($sql2); - $obj = $db->fetch_object($result2); - - $objp->fk_user_author = $obj->fk_user_author; - $objp->ref = $obj->ref; - $objp->fk_c_expensereport_status = $obj->fk_c_expensereport_statuts; - $objp->rowid = $obj->rowid; - - $total_HT = $total_HT + $objp->total_ht; - $total_TTC = $total_TTC + $objp->total_ttc; - $author = new User($db); - $author->fetch($objp->fk_user_author); - - print '<tr>'; - 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>'.$author->getNomUrl().'</td>'; - print '<td>'.$objp->comments.'</td>'; - print '<td align="right">'.price($objp->total_ht).'</td>'; - print '<td align="right">'.price($objp->total_ttc).'</td>'; - print '<td align="right">'; - - switch($objp->fk_c_expensereport_status) { - case 4: - print img_picto($langs->trans('StatusOrderCanceled'),'statut5'); - break; - case 1: - print $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); - break; - case 2: - print $langs->trans('TripForValid').' '.img_picto($langs->trans('TripForValid'),'statut3');; - break; - case 5: - print $langs->trans('TripForPaid').' '.img_picto($langs->trans('TripForPaid'),'statut3'); - break; - case 6: - print $langs->trans('TripPaid').' '.img_picto($langs->trans('TripPaid'),'statut4'); - break; - } - /* - if ($status==4) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); - 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('StatusOrderOnProcess'),'statut3'); - if ($status==5) return img_picto($langs->trans('StatusOrderToBill'),'statut4'); - if ($status==6) return img_picto($langs->trans('StatusOrderOnProcess'),'statut6'); - */ - print '</td>'; - print '</tr>'; - - $i++; - } - - 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("TotalTTC").' : '.price($total_TTC).'</td>'; - print '<td> </td>'; - print '</tr>'; - - } - else - { - $this->error=$db->error(); - return -1; - } - } + $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.= " WHERE de.fk_projet = ".$projectid; + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $result = $db->query($sql) ; + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total_HT = 0; + $total_TTC = 0; + + while ($i < $num) + { + + $objp = $db->fetch_object($result); + + $sql2 = "SELECT d.rowid, d.fk_user_author, d.ref, d.fk_c_expensereport_statuts"; + $sql2.= " FROM ".MAIN_DB_PREFIX."expensereport as d"; + $sql2.= " WHERE d.rowid = '".$objp->fk_expensereport."'"; + + $result2 = $db->query($sql2); + $obj = $db->fetch_object($result2); + + $objp->fk_user_author = $obj->fk_user_author; + $objp->ref = $obj->ref; + $objp->fk_c_expensereport_status = $obj->fk_c_expensereport_statuts; + $objp->rowid = $obj->rowid; + + $total_HT = $total_HT + $objp->total_ht; + $total_TTC = $total_TTC + $objp->total_ttc; + $author = new User($db); + $author->fetch($objp->fk_user_author); + + print '<tr>'; + 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>'.$author->getNomUrl().'</td>'; + print '<td>'.$objp->comments.'</td>'; + print '<td align="right">'.price($objp->total_ht).'</td>'; + print '<td align="right">'.price($objp->total_ttc).'</td>'; + print '<td align="right">'; + + switch($objp->fk_c_expensereport_status) { + case 4: + print img_picto($langs->trans('StatusOrderCanceled'),'statut5'); + break; + case 1: + print $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut0'); + break; + case 2: + print $langs->trans('TripForValid').' '.img_picto($langs->trans('TripForValid'),'statut3');; + break; + case 5: + print $langs->trans('TripForPaid').' '.img_picto($langs->trans('TripForPaid'),'statut3'); + break; + case 6: + print $langs->trans('TripPaid').' '.img_picto($langs->trans('TripPaid'),'statut4'); + break; + } + /* + if ($status==4) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); + 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('StatusOrderOnProcess'),'statut3'); + if ($status==5) return img_picto($langs->trans('StatusOrderToBill'),'statut4'); + if ($status==6) return img_picto($langs->trans('StatusOrderOnProcess'),'statut6'); + */ + print '</td>'; + print '</tr>'; + + $i++; + } + + 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("TotalTTC").' : '.price($total_TTC).'</td>'; + print '<td> </td>'; + print '</tr>'; + + } + else + { + $this->error=$db->error(); + return -1; + } + } } @@ -580,10 +580,10 @@ class ExpenseReport extends CommonObject $num = $this->db->num_rows($result); $i = 0; while ($i < $num): - $objp = $this->db->fetch_object($result); - $total_ht+=$objp->total_ht; - $total_tva+=$objp->total_tva; - $i++; + $objp = $this->db->fetch_object($result); + $total_ht+=$objp->total_ht; + $total_tva+=$objp->total_tva; + $i++; endwhile; $total_ttc = $total_ht + $total_tva; @@ -594,19 +594,19 @@ class ExpenseReport extends CommonObject $sql.= " WHERE rowid = ".$id; $result = $this->db->query($sql); if($result): - $this->db->free($result); - return 1; + $this->db->free($result); + return 1; else: - $this->error=$this->db->error(); - dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR); - return -3; + $this->error=$this->db->error(); + dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR); + return -3; endif; } else { - $this->error=$this->db->error(); - dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR); - return -3; + $this->error=$this->db->error(); + dol_syslog('ExpenseReport::recalculer: Error '.$this->error,LOG_ERR); + return -3; } } @@ -718,12 +718,12 @@ class ExpenseReport extends CommonObject } /** - * set_save + * Set to status validate * * @param User $user User * @return int <0 if KO, >0 if OK */ - function set_save($user) + function setValidate($user) { global $conf,$langs; @@ -752,8 +752,8 @@ class ExpenseReport extends CommonObject if ($this->fk_c_expensereport_statuts != 2) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 2"; - $sql.= " ,ref_number_int = $ref_number_int"; + $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 2, fk_user_valid = ".$user->id.","; + $sql.= " ref_number_int = ".$ref_number_int; $sql.= ' WHERE rowid = '.$this->id; 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 * @return int <0 if KO, >0 if OK */ - function set_valide($user) + function setApproved($user) { // date de validation $this->date_valide = $this->db->idate(gmmktime()); if ($this->fk_c_expensereport_statuts != 5) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 5, fk_user_valid = ".$user->id; - $sql.= ', date_valide='.$this->date_valide; + $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 5, fk_user_approve = ".$user->id.","; + $sql.= " date_valide='".$this->date_valide."'"; $sql.= ' WHERE rowid = '.$this->id; - - dol_syslog(get_class($this)."::set_valide sql=".$sql, LOG_DEBUG); - - if ($this->db->query($sql)): + if ($this->db->query($sql)) + { return 1; - else: - $this->error=$this->db->error(); + } + else + { + $this->error=$this->db->lasterror(); return -1; - endif; + } } else { @@ -861,24 +861,29 @@ class ExpenseReport extends CommonObject */ function set_refuse($user,$details) { + $now = dol_now(); + // date de refus - $this->date_refuse = $this->db->idate(gmmktime()); if ($this->fk_c_expensereport_statuts != 99) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 99, fk_user_refuse = ".$user->id; - $sql.= ', date_refuse='.$this->date_refuse; - $sql.= ", detail_refuse='".addslashes($details)."'"; + $sql.= " SET ref = '".$this->ref."', fk_c_expensereport_statuts = 99, fk_user_refuse = ".$user->id.","; + $sql.= " date_refuse='".$this->db->idate($now)."',"; + $sql.= " detail_refuse='".$this->db->escape($details)."'"; $sql.= ' WHERE rowid = '.$this->id; - - dol_syslog(get_class($this)."::set_refuse sql=".$sql, LOG_DEBUG); - - if ($this->db->query($sql)): + if ($this->db->query($sql)) + { + $this->fk_c_expensereport_statuts = 99; + $this->fk_user_refuse = $user->id; + $this->detail_refuse = $details; + $this->date_refuse = $now; return 1; - else: - $this->error=$this->db->error(); + } + else + { + $this->error=$this->db->lasterror(); return -1; - endif; + } } else { @@ -887,22 +892,22 @@ class ExpenseReport extends CommonObject } /** - * set_paid + * setPaid * * @param User $user User * @return int <0 if KO, >0 if OK */ - function set_paid($user) + function setPaid($user) { $this->date_paiement = $this->db->idate(gmmktime()); if ($this->fk_c_expensereport_statuts != 6) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; - $sql.= " SET fk_c_expensereport_statuts = 6, fk_user_paid = ".$user->id; - $sql.= ', date_paiement='.$this->date_paiement; + $sql.= " SET fk_c_expensereport_statuts = 6, fk_user_paid = ".$user->id.","; + $sql.= " date_paiement='".$this->date_paiement."'"; $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)) { @@ -931,52 +936,21 @@ class ExpenseReport extends CommonObject if ($this->fk_c_deplacement_statuts != 5) { $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; dol_syslog(get_class($this)."::set_unpaid sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } else { - dol_syslog(get_class($this)."::set_unpaid deplacement 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); + dol_syslog(get_class($this)."::set_unpaid expensereport already with unpaid status", LOG_WARNING); } } @@ -1026,7 +1000,7 @@ class ExpenseReport extends CommonObject { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $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.= ' WHERE rowid = '.$this->id; @@ -1062,24 +1036,24 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if($this->db->num_rows($result) > 0): - $objp = $this->db->fetch_object($result); - $this->ref = $objp->ref_number_int; - $this->ref++; - while(strlen($this->ref) < $num_car): - $this->ref = "0".$this->ref; - endwhile; + $objp = $this->db->fetch_object($result); + $this->ref = $objp->ref_number_int; + $this->ref++; + while(strlen($this->ref) < $num_car): + $this->ref = "0".$this->ref; + endwhile; else: - $this->ref = 1; - while(strlen($this->ref) < $num_car): - $this->ref = "0".$this->ref; - endwhile; + $this->ref = 1; + while(strlen($this->ref) < $num_car): + $this->ref = "0".$this->ref; + endwhile; endif; if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -1123,10 +1097,10 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -1143,10 +1117,10 @@ class ExpenseReport extends CommonObject $result = $this->db->query($sql); if ($result): - return 1; + return 1; else: - $this->error=$this->db->error(); - return -1; + $this->error=$this->db->error(); + return -1; endif; } @@ -1214,12 +1188,12 @@ class ExpenseReport extends CommonObject $result = $ligne->update(); if ($result > 0): - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; else: - $this->error=$ligne->error; - $this->db->rollback(); - return -2; + $this->error=$ligne->error; + $this->db->rollback(); + return -2; endif; } @@ -1467,7 +1441,7 @@ class ExpenseReportLine $sql.= " VALUES (".$this->fk_expensereport.","; $sql.= " ".$this->fk_c_type_fees.","; $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->qty.","; $sql.= " ".$this->value_unit.","; @@ -1531,8 +1505,11 @@ class ExpenseReportLine $sql.= " comments='".$this->db->escape($this->comments)."'"; $sql.= ",value_unit=".$this->value_unit.""; $sql.= ",qty=".$this->qty.""; - if ($this->date) { $sql.= ",date='".$this->date."'"; } - else { $sql.=',date=null'; } + if ($this->date) { + $sql.= ",date='".$this->date."'"; + } + else { $sql.=',date=null'; + } $sql.= ",total_ht=".$this->total_ht.""; $sql.= ",total_tva=".$this->total_tva.""; $sql.= ",total_ttc=".$this->total_ttc.""; @@ -1587,9 +1564,9 @@ class ExpenseReportLine */ 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.'">'; if ($useempty) print '<option value="-1"> </option>'; @@ -1609,65 +1586,6 @@ function select_expensereport_statut($selected='',$htmlname='fk_c_expensereport_ 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 * diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index b8f3d02c8a6..86ff064db7d 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -1,6 +1,6 @@ <?php /* 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-2009 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> @@ -25,10 +25,12 @@ /** * \file htdocs/expensereport/document.php * \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_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.'/expensereport/class/expensereport.class.php'; @@ -102,7 +104,7 @@ if ($object->id) 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 print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql index e998343e6db..5fd3d2a3998 100755 --- a/htdocs/install/mysql/tables/llx_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_expensereport.sql @@ -41,6 +41,7 @@ CREATE TABLE llx_expensereport ( note text, note_private text, fk_user_valid integer DEFAULT NULL, + fk_user_approve integer DEFAULT NULL, fk_user_paid integer DEFAULT NULL, detail_refuse varchar(255) DEFAULT NULL, date_cancel datetime, diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 98e7c33265e..418f1ce6cc5 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -21,7 +21,7 @@ CREATE TABLE llx_expensereport_det rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_expensereport integer NOT NULL, fk_c_type_fees integer NOT NULL, - fk_projet integer NOT NULL, + fk_projet integer, fk_c_tva integer NOT NULL, comments text NOT NULL, product_type integer DEFAULT -1, diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 5919ffea61e..fb7dbd26032 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -30,7 +30,7 @@ ExportDataset_fournisseur_2=Supplier invoices and payments ExportDataset_fournisseur_3=Supplier orders and order lines ApproveThisOrder=Approve this order 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> ? ConfirmCancelThisOrder=Are you sure you want to cancel this order <b>%s</b> ? AddCustomerOrder=Create customer order diff --git a/htdocs/langs/en_US/trips.lang b/htdocs/langs/en_US/trips.lang index e34f58715d8..b5e950b6a0c 100644 --- a/htdocs/langs/en_US/trips.lang +++ b/htdocs/langs/en_US/trips.lang @@ -37,71 +37,63 @@ TF_ESSENCE=Fuel TF_HOTEL=Hostel 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 +ErrorDoubleDeclaration=You have declared another expense report into a similar date range. +ListTripsAndExpenses=List of expense reports +AucuneNDF=No expense reports found for this criteria +AucuneLigne=There is no expense report declared yet +AddLine=Add a line +AddLineMini=Add + +Date_DEBUT=Period date start +Date_FIN=Period date end +ModePaiement=Payment mode Note=Note -Project=Projet +Project=Project -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 +VALIDATOR=User to inform for approbation +VALIDOR=Approved by +AUTHOR=Recorded by +AUTHORPAIEMENT=Paied by +REFUSEUR=Denied by +CANCEL_USER=Canceled by -MOTIF_REFUS=Motif de refus -MOTIF_CANCEL=Motif d'annulation +MOTIF_REFUS=Reason +MOTIF_CANCEL=Reason -DATE_REFUS=Date du refus -DATE_CANCEL=Date annulation -DATE_VALIDE=Date de validation -DATE_PAIEMENT=Date de paiement -DATE_SAVE=Date d'enregistrement +DATE_REFUS=Deny date +DATE_CANCEL=Cancelation date +DATE_VALIDE=Validation date +DATE_PAIEMENT=Payment date +DATE_SAVE=Recording date -REFUSE=Refuse +Deny=Deny TO_PAID=Pay BROUILLONNER=Reopen SendToValid=Sent to approve ModifyInfoGen=Edit +ValidateAndSubmit=Validate and submit for approval -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 ? +NOT_VALIDATOR=You are not allowed to approve this expense report +NOT_AUTHOR=You are not the author of this expense report. Operation cancelled. -ValideTrip=Valider une note de frais -ConfirmValideTrip=Êtes vous sûr de vouloir valider cette note de frais ? +RefuseTrip=Deny an expense report +ConfirmRefuseTrip=Are you sure you want to deny this expense report ? -PaidTrip=Payer une note de frais -ConfirmPaidTrip=Êtes vous sûr de vouloir payer cette note de frais ? +ValideTrip=Approve expense report +ConfirmValideTrip=Are you sure you want to approve this expense report ? -CancelTrip=Annuler une note de frais -ConfirmCancelTrip=Êtes vous sûr de vouloir annuler cette note de frais ? +PaidTrip=Pay an expense report +ConfirmPaidTrip=Are you sure you want to change status of this expense report to "Paid" ? -BrouillonnerTrip=Remettre une note de frais en brouillon -ConfirmBrouillonnerTrip=Êtes vous sûr de vouloir remettre cette note de frais en brouillon ? +CancelTrip=Cancel an expense report +ConfirmCancelTrip=Are you sure you want to cancel this expense report ? -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) +BrouillonnerTrip=Move back expense report to status "Draft"n +ConfirmBrouillonnerTrip=Are you sure you want to move this expense report to status "Draft" ? -INFOS_DATES=Infos Workflow -INFOS_NDF=Infos générales note de frais +SaveTrip=Validate expense report +ConfirmSaveTrip=Are you sure you want to validate this expense report ? -StatsTrip=Statistiques Synchro_Compta=NDF <-> Compte TripSynch=Synchronisation : Notes de frais <-> Compte courant diff --git a/htdocs/langs/fr_FR/expensereport.lang b/htdocs/langs/fr_FR/expensereport.lang deleted file mode 100755 index 6af74164f2d..00000000000 --- a/htdocs/langs/fr_FR/expensereport.lang +++ /dev/null @@ -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. \ No newline at end of file diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 1103396658f..0f6a74f1a48 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -466,7 +466,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Budget 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>'; // Description diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e1aa84f1f4c..0b80c7b9cd7 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -126,7 +126,7 @@ class Project extends CommonObject $sql.= ", '".$this->db->idate($now)."'"; $sql.= ", " . ($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : '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.= ")"; @@ -152,7 +152,7 @@ class Project extends CommonObject $error++; } - //Update extrafield + // Update extrafield if (!$error) { 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 if (! $error) { diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e83964949b6..ccf54a6f9b5 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -393,6 +393,9 @@ th .button { .centpercent { width: 100%; } +textarea.centpercent { + width: 96%; +} .center { text-align: center; } @@ -444,11 +447,17 @@ th .button { .hideobject { display: none; } .minwidth100 { min-width: 100px; } .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)) { ?> .hideonsmartphone { display: none; } .noenlargeonsmartphone { width : 50px !important; display: inline !important; } .maxwidthonsmartphone { max-width: 100px; } +.maxwidth100onsmartphone { max-width: 100px; } .maxwidth200onsmartphone { max-width: 200px; } +.maxwidth300onsmartphone { max-width: 300px; } <?php } ?> .linkobject { cursor: pointer; } <?php if (GETPOST("optioncss") == 'print') { ?> -- GitLab