From eb8664e649f41c381540f03e44f42a748310ca70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 9 Feb 2018 16:08:28 +0100 Subject: [PATCH] NEW Can export leave requests --- htdocs/core/menus/standard/eldy.lib.php | 4 +++- htdocs/core/modules/modHoliday.class.php | 22 ++++++++++++++++++++-- htdocs/exports/export.php | 6 ++++-- htdocs/langs/en_US/holiday.lang | 10 ++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fed1cecdc23..5a44a3677fd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -70,7 +70,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode else $classname = 'class="tmenu"'; $idsel='home'; - $menu->add('/index.php?mainmenu=home&leftmenu=home', $langs->trans("Home"), 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname); + $titlehome = $langs->trans("Home"); + if (! empty($conf->global->THEME_TOPMENU_DISABLE_IMAGE)) $titlehome = '   '; + $menu->add('/index.php?mainmenu=home&leftmenu=home', $titlehome, 0, $showmode, $atarget, "home", '', 10, $id, $idsel, $classname); // Third parties $tmpentry=array('enabled'=>(( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur'); diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 75bb6a04a07..aef9eb9a7bb 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -57,7 +57,7 @@ class modHoliday extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Leave management"; + $this->description = "Leave requests"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) @@ -158,7 +158,25 @@ class modHoliday extends DolibarrModules // Exports - $r=1; + $r=0; + + $r++; + $this->export_code[$r]='leaverequest_'.$r; + $this->export_label[$r]='ListeCP'; + $this->export_icon[$r]='holiday'; + $this->export_permission[$r]=array(array("holiday","read_all")); + $this->export_fields_array[$r]=array('d.rowid'=>"LeaveId",'d.fk_type'=>'TypeOfLeaveId','t.code'=>'TypeOfLeaveCode','t.label'=>'TypeOfLeaveLabel','d.fk_user'=>'UserID','u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>"Login",'d.date_debut'=>'DateStart','d.date_fin'=>'DateEnd','d.halfday'=>'HalfDay','d.date_valid'=>'DateApprove','d.fk_validator'=>"UserForApprovalID",'ua.lastname'=>"UserForApprovalLastname",'ua.firstname'=>"UserForApprovalFirstname",'ua.login'=>"UserForApprovalLogin",'d.description'=>'Description','d.statut'=>'Status'); + $this->export_entities_array[$r]=array('u.lastname'=>'user','u.firstname'=>'user','u.login'=>'user','ua.lastname'=>'user','ua.firstname'=>'user','ua.login'=>'user'); + $this->export_alias_array[$r]=array('d.rowid'=>"idholiday"); + $this->export_dependencies_array[$r]=array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them + + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'holiday as d'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_holiday_types as t ON t.rowid = d.fk_type'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as ua ON ua.rowid = d.fk_validator,'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'user as u'; + $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; + $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('holiday').')'; // Example: // $this->export_code[$r]=$this->rights_class.'_'.$r; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 92a63afcd0e..e76d8e113cf 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -69,8 +69,9 @@ $entitytoicon = array( 'category' => 'category', 'shipment' => 'sending', 'shipment_line'=> 'sending', - 'expensereport'=> 'trip', + 'expensereport'=> 'trip', 'expensereport_line'=> 'trip', + 'holiday' => 'holiday', 'contract_line' => 'contract', 'translation' => 'generic' ); @@ -115,7 +116,8 @@ $entitytolang = array( 'action' => 'Event', 'expensereport'=> 'ExpenseReport', 'expensereport_line'=> 'ExpenseReportLine', - 'contract' => 'Contract', + 'holiday' => 'TitreRequestCP', + 'contract' => 'Contract', 'contract_line'=> 'ContractLine', 'translation' => 'Translation' ); diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 0ed06cceb40..f73bbdeee52 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -16,7 +16,12 @@ CancelCP=Canceled RefuseCP=Refused ValidatorCP=Approbator ListeCP=List of leaves +LeaveId=Leave ID ReviewedByCP=Will be approved by +UserForApprovalID=User for approval ID +UserForApprovalFirstname=Firstname of approval user +UserForApprovalLastname=Lastname of approval user +UserForApprovalLogin=Login of approval user DescCP=Description SendRequestCP=Create leave request DelayToRequestCP=Leave requests must be made at least %s day(s) before them. @@ -30,6 +35,9 @@ ErrorUserViewCP=You are not authorized to read this leave request. InfosWorkflowCP=Information Workflow RequestByCP=Requested by TitreRequestCP=Leave request +TypeOfLeaveId=Type of leave ID +TypeOfLeaveCode=Type of leave code +TypeOfLeaveLabel=Type of leave label NbUseDaysCP=Number of days of vacation consumed EditCP=Edit DeleteCP=Delete @@ -81,6 +89,8 @@ EmployeeFirstname=Employee first name TypeWasDisabledOrRemoved=Leave type (id %s) was disabled or removed LastHolidays=Latest %s leave requests AllHolidays=All leave requests +HalfDay=Half day +NotTheAssignedApprover=You are not the assigned approver ## Configuration du Module ## LastUpdateCP=Latest automatic update of leaves allocation