diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php
index bdde060f448..bd4a4555fb7 100644
--- a/htdocs/compta/deplacement/card.php
+++ b/htdocs/compta/deplacement/card.php
@@ -128,7 +128,7 @@ else if ($action == 'add' && $user->rights->deplacement->creer)
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
$error++;
}
- if ($object->type == '-1') // Otherwise it is TF_LUNCH,...
+ if ($object->type == '-1')
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors');
$error++;
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 86d46f3b9b5..85c9ffbb241 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -87,7 +87,7 @@ class FormProjets
if ($resql)
{
$minmax='';
-
+
// Use select2 selector
$nodatarole='';
if (! empty($conf->use_javascript_ajax))
@@ -219,6 +219,11 @@ class FormProjets
$sql = "SELECT id as rowid, label as ref";
$projectkey="fk_project";
break;
+ case "expensereport_det":
+ return '';
+ /*$sql = "SELECT rowid, '' as ref"; // table is llx_expensereport_det
+ $projectkey="fk_projet";
+ break;*/
default:
$sql = "SELECT rowid, ref";
break;
@@ -226,10 +231,8 @@ class FormProjets
$sql.= " FROM ".MAIN_DB_PREFIX.$table_element;
$sql.= " WHERE ".$projectkey." is null";
- if (!empty($socid)) {
- $sql.= " AND fk_soc=".$socid;
- }
- $sql.= ' AND entity='.getEntity('project');
+ if (!empty($socid)) $sql.= " AND fk_soc=".$socid;
+ if (! in_array($table_element, array('expensereport_det'))) $sql.= ' AND entity='.getEntity('project');
$sql.= " ORDER BY ref DESC";
dol_syslog(get_class($this).'::select_element', LOG_DEBUG);
@@ -260,9 +263,12 @@ class FormProjets
}*/
$this->db->free($resql);
- return $sellist ;
- }else {
+ return $sellist;
+ }
+ else
+ {
$this->error=$this->db->lasterror();
+ $this->errors[]=$this->db->lasterror();
dol_syslog(get_class($this) . "::select_element " . $this->error, LOG_ERR);
return -1;
}
diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php
index edee0952b00..b5b45ea23f8 100755
--- a/htdocs/core/modules/modExpenseReport.class.php
+++ b/htdocs/core/modules/modExpenseReport.class.php
@@ -224,8 +224,8 @@ class modExpenseReport extends DolibarrModules
'url'=>'/expensereport/index.php',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
- 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->expensereport->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
@@ -234,12 +234,12 @@ class modExpenseReport extends DolibarrModules
'type'=>'left', // This is a Left menu entry
'titre'=>'New',
'mainmenu'=>'accountancy',
- 'leftmenu'=>'expensereport_detail',
+ 'leftmenu'=>'expensereport_detailnew',
'url'=>'/expensereport/card.php?action=create',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
- 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->expensereport->creer', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
@@ -248,12 +248,26 @@ class modExpenseReport extends DolibarrModules
'type'=>'left', // This is a Left menu entry
'titre'=>'List',
'mainmenu'=>'accountancy',
- 'leftmenu'=>'expensereport_detail',
+ 'leftmenu'=>'expensereport_detaillist',
'url'=>'/expensereport/list.php',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
- 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->expensereport->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'target'=>'',
+ 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
+ $r++;
+
+ $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport_detaillist', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
+ 'type'=>'left', // This is a Left menu entry
+ 'titre'=>'ListToApprove',
+ 'mainmenu'=>'accountancy',
+ 'leftmenu'=>'expensereport_detaillist_approve',
+ 'url'=>'/expensereport/list.php?search_state=2',
+ 'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+ 'position'=>100,
+ 'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->expensereport->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
@@ -266,13 +280,14 @@ class modExpenseReport extends DolibarrModules
'url'=>'/expensereport/stats/index.php',
'langs'=>'trips', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
- 'enabled'=>'1', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'enabled'=>'$conf->expensereport->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
+ 'perms'=>'$user->rights->expensereport->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
+ // Disabled, not yet stable
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=accountancy,fk_leftmenu=expensereport', // Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)
'type'=>'left', // This is a Left menu entry
'titre'=>'ExportTripCSV',
@@ -282,7 +297,7 @@ class modExpenseReport extends DolibarrModules
'langs'=>'expensereport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->global->DEPLACEMENT_TO_CLEAN', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'perms'=>'$user->rights->expensereport->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
@@ -296,7 +311,7 @@ class modExpenseReport extends DolibarrModules
'langs'=>'expensereport', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->global->DEPLACEMENT_TO_CLEAN', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled.
- 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
+ 'perms'=>'$user->rights->expensereport->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 871cbe22990..cfe3c86058b 100755
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -105,7 +105,7 @@ if ($action == 'add' && $user->rights->expensereport->creer)
$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')))
+ if ($object->periode_existe($user,$object->date_debut,$object->date_fin))
{
$error++;
setEventMessage($langs->trans("ErrorDoubleDeclaration"),'errors');
@@ -398,8 +398,8 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user
{
$object = new ExpenseReport($db);
$object->fetch($id);
-
- $result = $object->set_refuse($user,GETPOST('detail_refuse'));
+
+ $result = $object->setDeny($user,GETPOST('detail_refuse'));
if ($result > 0)
{
if (! empty($conf->global->DEPLACEMENT_TO_CLEAN))
@@ -456,34 +456,34 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user
}
//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)
+if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && GETPOST('detail_cancel') && $id > 0 && $user->rights->expensereport->creer)
{
$object = new ExpenseReport($db);
$object->fetch($id);
-
+
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,GETPOST('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";
@@ -491,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
@@ -523,10 +523,10 @@ if ($action == "confirm_cancel" && GETPOST('confirm')=="yes" && !empty($_POST['d
}
}
-if ($action == "confirm_paid" && $_GET['confirm']=="yes" && $id > 0 && $user->rights->expensereport->to_paid)
+if ($action == "confirm_paid" && GETPOST('confirm')=="yes" && $id > 0 && $user->rights->expensereport->to_paid)
{
$object = new ExpenseReport($db);
- $object->fetch($id,$user);
+ $object->fetch($id);
$result = $object->setPaid($user);
if ($result > 0)
@@ -665,7 +665,7 @@ if ($action == "addline")
$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)
@@ -1129,22 +1129,24 @@ else
if ($ret == 'html') print ' ';
endif;
- if ($action == 'cancel'):
- $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 ' ';
- endif;
+ if ($action == 'cancel')
+ {
+ $array_input = array('text'=>$langs->trans("ConfirmCancelTrip"), array('type'=>"text",'label'=>$langs->trans("Comment"),'name'=>"detail_cancel",'size'=>"50",'value'=>""));
+ $ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("Cancel"),"","confirm_cancel",$array_input,"",1);
+ if ($ret == 'html') print ' ';
+ }
if ($action == 'brouillonner'):
$ret=$form->form_confirm($_SEVER["PHP_SELF"]."?id=".$id,$langs->trans("BrouillonnerTrip"),$langs->trans("ConfirmBrouillonnerTrip"),"confirm_brouillonner","","",1);
if ($ret == 'html') print ' ';
endif;
- if ($action == 'refuse'):
- $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 ' ';
- endif;
+ if ($action == 'refuse') // Deny
+ {
+ $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 ' ';
+ }
if ($action == 'delete_line')
{
@@ -1211,7 +1213,7 @@ else
print '