diff --git a/ChangeLog b/ChangeLog index c723a0e626d..9ba0fb88d98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,8 +41,11 @@ For users: - New: Add unit foot2, inch2, foot3 and inch3 for surface and volumes. - New: Can select thirdparties into emailing targets, even if module category is not enabled. - New: [ task #498 ] Improvement of the block to add products/services lines. -- New: Add margin and commissions management module. - New: ECM autodir works also for files joined to products and services. +New experimental modules: +- New: Add margin and commissions management module. +- New: Add holiday module. + - Fix: [ bug #499 ]: Supplier order input method not translated - Fix: No images into product description lines as PDF generation does not work with this. diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php new file mode 100644 index 00000000000..ef2dff6bac4 --- /dev/null +++ b/htdocs/core/modules/modHoliday.class.php @@ -0,0 +1,292 @@ + + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2011 Dimitri Mouillard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \defgroup holiday Payes Module holiday Payes + * \brief Module de gestion des congés payés + */ + +/** + * \file htdocs/includes/modules/modLeave.class.php + * \ingroup holiday + * \brief Description and activation file for module holiday + */ + +include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php"); + + +/** + * Description and activation class for module holiday + */ +class modHoliday extends DolibarrModules +{ + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 20000; + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'holiday'; + + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page + $this->family = "hr"; + // 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"; + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + $this->version = 'experimental'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) + $this->special = 0; + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='holiday'; + + // Defined if the directory /mymodule/inc/triggers/ contains triggers or not + $this->triggers = 0; + + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mymodule/temp"); + $this->dirs = array(); + $r=0; + + // Relative path to module style sheet if exists. Example: '/mymodule/css/mycss.css'. + //$this->style_sheet = '/mymodule/mymodule.css.php'; + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. + $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); + + // Dependencies + $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->phpmin = array(4,3); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(3,0); // Minimum version of Dolibarr required by module + $this->langfiles = array("holiday"); + + // Constants + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); + // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) + $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') + + // Array to add new pages in new tabs + // Example: $this->tabs = array('objecttype:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__', // To add a new tab identified by code tabname1 + // 'objecttype:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2 + // 'objecttype:-tabname'); // To remove an existing tab identified by code tabname + // where objecttype can be + // 'thirdparty' to add a tab in third party view + // 'intervention' to add a tab in intervention view + // 'order_supplier' to add a tab in supplier order view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'invoice' to add a tab in customer invoice view + // 'order' to add a tab in customer order view + // 'product' to add a tab in product view + // 'stock' to add a tab in stock view + // 'propal' to add a tab in propal view + // 'member' to add a tab in fundation member view + // 'contract' to add a tab in contract view + // 'user' to add a tab in user view + // 'group' to add a tab in group view + // 'contact' to add a tab in contact view + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + $this->tabs = array('user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->write:/holiday/index.php?mainmenu=holiday&id=__ID__'); + + // Boxes + $this->boxes = array(); // List of boxes + $r=0; + + // Add here list of php file(s) stored in includes/boxes that contains class to show a box. + // Example: + //$this->boxes[$r][1] = "myboxa.php"; + //$r++; + //$this->boxes[$r][1] = "myboxb.php"; + //$r++; + + + // Permissions + $this->rights = array(); // Permission array used by this module + $r=0; + + $this->rights[$r][0] = 20001; // Permission id (must not be already used) + $this->rights[$r][1] = 'Créer / Modifier / Lire ses demandes de congés payés'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = 20002; // Permission id (must not be already used) + $this->rights[$r][1] = 'Lire / Modifier toutes les demandes de congés payés'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'lire_tous'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = 20003; // Permission id (must not be already used) + $this->rights[$r][1] = 'Supprimer des demandes de congés payés'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = 20004; // Permission id (must not be already used) + $this->rights[$r][1] = 'Définir les congés payés des utilisateurs'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = 20005; // Permission id (must not be already used) + $this->rights[$r][1] = 'Voir les logs de modification des congés payés'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'view_log'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + $this->rights[$r][0] = 20006; // Permission id (must not be already used) + $this->rights[$r][1] = 'Accéder au rapport mensuel des congés payés'; // Permission label + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'month_report'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $r++; + + // Main menu entries + $this->menus = array(); // List of menus to add + $r=0; + + // Add here entries to declare new menus + $this->menu[$r]=array( 'fk_menu'=>0, // Put 0 if this is a top menu + 'type'=>'top', // This is a Top menu entry + 'titre'=>'CPTitreMenu', + 'mainmenu'=>'holiday', + 'url'=>'/holiday/index.php?leftmenu=holiday', + 'langs'=>'holiday', // 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'=>'$user->rights->holiday->write', // 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++; + // + // Example to declare a Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=0', // 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'=>'MyModule left menu 1', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel1.php', + // 'langs'=>'mylangfile', // 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 + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + // + // Example to declare another Left Menu entry: + // $this->menu[$r]=array( 'fk_menu'=>'r=1', // 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'=>'MyModule left menu 2', + // 'mainmenu'=>'mymodule', + // 'url'=>'/mymodule/pagelevel2.php', + // 'langs'=>'mylangfile', // 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 + // 'target'=>'', + // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + // $r++; + + + // Exports + $r=1; + + + // Agenda + $this->Agenda = 1; + $this->agendas = array('holiday:holidayAgenda'); + + // Example: + // $this->export_code[$r]=$this->rights_class.'_'.$r; + // $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + // $this->export_permission[$r]=array(array("facture","facture","export")); + // $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.cp'=>'Zip','s.ville'=>'Town','s.fk_pays'=>'Country','s.tel'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'); + // $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.cp'=>'company','s.ville'=>'company','s.fk_pays'=>'company','s.tel'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'); + // $this->export_alias_array[$r]=array('s.rowid'=>"socid",'s.nom'=>'soc_name','s.address'=>'soc_adres','s.cp'=>'soc_zip','s.ville'=>'soc_ville','s.fk_pays'=>'soc_pays','s.tel'=>'soc_tel','s.siren'=>'soc_siren','s.siret'=>'soc_siret','s.ape'=>'soc_ape','s.idprof4'=>'soc_idprof4','s.code_compta'=>'soc_customer_accountancy','s.code_compta_fournisseur'=>'soc_supplier_accountancy','f.rowid'=>"invoiceid",'f.facnumber'=>"ref",'f.datec'=>"datecreation",'f.datef'=>"dateinvoice",'f.total'=>"totalht",'f.total_ttc'=>"totalttc",'f.tva'=>"totalvat",'f.paye'=>"paid",'f.fk_statut'=>'status','f.note'=>"note",'fd.rowid'=>'lineid','fd.description'=>"linedescription",'fd.price'=>"lineprice",'fd.total_ht'=>"linetotalht",'fd.total_tva'=>"linetotaltva",'fd.total_ttc'=>"linetotalttc",'fd.tva_tx'=>"linevatrate",'fd.qty'=>"lineqty",'fd.date_start'=>"linedatestart",'fd.date_end'=>"linedateend",'fd.fk_product'=>'productid','p.ref'=>'productref'); + // $this->export_sql_start[$r]='SELECT DISTINCT '; + // $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)'; + // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; + // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; + // $r++; + } + + /** + * \brief Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * \return int 1 if OK, 0 if KO + */ + function init() + { + $sql = array(); + + $result=$this->load_tables(); + + return $this->_init($sql); + } + + /** + * \brief Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted. + * \return int 1 if OK, 0 if KO + */ + function remove() + { + $sql = array(); + + return $this->_remove($sql); + } + + + /** + * \brief Create tables, keys and data required by module + * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys + * and create data commands must be stored in directory /mymodule/sql/ + * This function is called by this->init. + * \return int <=0 if KO, >0 if OK + */ + function load_tables() + { + return $this->_load_tables(''); + } +} + +?> diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php new file mode 100644 index 00000000000..3a1b1ac2ea7 --- /dev/null +++ b/htdocs/holiday/admin/holiday.php @@ -0,0 +1,422 @@ + + * Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * Page module configuration paid holiday. + * + * \file holiday.php + * \ingroup holiday + * \brief Page module configuration paid holiday. + */ + +$res=0; +if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); // For root directory +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // For "custom" directory +if (! $res) die("Include of main fails"); + +dol_include_once("/holiday/class/holiday.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/core/class/html.form.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/user/class/user.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/user/class/usergroup.class.php"); + +$action=GETPOST('action'); + +$langs->load("holiday"); + +// Si pas administrateur +if (! $user->admin) accessforbidden(); + + +/* + * View + */ + +// Vérification si module activé +if (! $conf->holiday->enabled) print $langs->trans('NotActiveModCP'); + +llxheader('',$langs->trans('TitleAdminCP')); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans('ConfCP'), $linkback); + +$cp = new Holiday($db); + +// Contrôle du formulaire +if ($action == "add") +{ + $message = ''; + $error = false; + + // Option du groupe de validation + if (!$cp->updateConfCP('userGroup',$_POST['userGroup'])) + { + $error = true; + } + + // Option du délai pour faire une demande de congés payés + if (!$cp->updateConfCP('delayForRequest',$_POST['delayForRequest'])) + { + $error = true; + } + + // Option du nombre de jours à ajouter chaque mois + $nbHolidayEveryMonth = price2num($_POST['nbHolidayEveryMonth'],2); + + if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth)) + { + $error = true; + } + + // Option du nombre de jours pour un mariage + $OptMariageCP = price2num($_POST['OptMariage'],2); + + if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) { + $error = true; + } + + // Option du nombre de jours pour un décés d'un proche + $OptDecesProcheCP = price2num($_POST['OptDecesProche'],2); + + if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) { + $error = true; + } + + // Option du nombre de jours pour un mariage d'un enfant + $OptMariageProcheCP = price2num($_POST['OptMariageProche'],2); + + if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) { + $error = true; + } + + // Option du nombre de jours pour un décés d'un parent + $OptDecesParentsCP = price2num($_POST['OptDecesParents'],2); + + if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) { + $error = true; + } + + // Option pour avertir le valideur si délai de demande incorrect + if(isset($_POST['AlertValidatorDelay'])) { + if(!$cp->updateConfCP('AlertValidatorDelay','1')) { + $error = true; + } + } else { + if(!$cp->updateConfCP('AlertValidatorDelay','0')) { + $error = true; + } + } + + // Option pour avertir le valideur si solde des congés de l'utilisateur inccorect + if(isset($_POST['AlertValidatorSolde'])) { + if(!$cp->updateConfCP('AlertValidatorSolde','1')) { + $error = true; + } + } else { + if(!$cp->updateConfCP('AlertValidatorSolde','0')) { + $error = true; + } + } + + // Option du nombre de jours à déduire pour 1 jour de congés + $nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2); + + if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) { + $error = true; + } + + if ($error) { + $message = '
'.$langs->trans('ErrorUpdateConfCP').'
'; + } else { + $message = '
'.$langs->trans('UpdateConfCPOK').'
'; + } + + // Si première mise à jour, prévenir l'utilisateur de mettre à jour le solde des congés payés + $sql = "SELECT *"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; + + $result = $db->query($sql); + $num = $db->num_rows($sql); + + if($num < 1) { + $cp->createCPusers(); + $message.= '
'.$langs->trans('AddCPforUsers').'
'; + } + + + dol_htmloutput_mesg($message); + + + // Si il s'agit de créer un event +} +elseif ($action == 'create_event') +{ + $error = false; + + if (!empty($_POST['optName'])) + { + $optName = trim($_POST['optName']); + } else { + $error = true; + } + + if (!empty($_POST['optValue'])) + { + $optValue = price2num($_POST['optValue'],2); + } else { + $error = true; + } + + $cp->optName = $optName; + $cp->optValue = $optValue; + + if($error) + { + $message = 'ErrorCreateEventCP'; + } + else + { + $result = $cp->createEventCP($user); + + if($result > 0) + { + $message = 'OkCreateEventCP'; + } + else + { + $message = 'ErrorCreateEventCP'; + } + } + + dol_htmloutput_mesg($message); + +} +elseif($action == 'event' && isset($_POST['update_event'])) +{ + $error = false; + + $eventId = array_keys($_POST['update_event']); + $eventId = $eventId[0]; + + $eventName = $_POST['optName']; + $eventName = $eventName[$eventId]; + + $eventValue = $_POST['optValue']; + $eventValue = $eventValue[$eventId]; + + if(!empty($eventName)) { + $eventName = trim($eventName); + } else { + $error = true; + } + + if(!empty($eventValue)) { + $eventValue = price2num($eventValue,2); + } else { + $error = true; + } + + if(!$error) + { + // Mise à jour des congés de l'utilisateur + $update = $cp->updateEventCP($eventId,$eventName,$eventValue); + if(!$update) { + $message='ErrorUpdateEventCP'; + } else { + $message='UpdateEventOkCP'; + } + } else { + $message='ErrorUpdateEventCP'; + } + + dol_htmloutput_mesg($message); + +} +elseif($action && isset($_POST['delete_event'])) +{ + $eventId = array_keys($_POST['delete_event']); + $eventId = $eventId[0]; + + $result = $cp->deleteEventCP($eventId); + + if($result) { + print '
'; + print $langs->trans('DeleteEventOkCP'); + print '
'; + } else { + print '
'; + print $langs->trans('ErrorDeleteEventCP'); + print '
'; + } + +} + + +// Affichage de la page de configuation +print '
'; + +print '

'.$langs->trans('TitleOptionMainCP').'

'; + +print '
'."\n"; +print ''."\n"; + +print ''; +print ''; +print ''; +print ''; + +$var=true; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +$var=!$var; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +print ''."\n"; +print '
'.$langs->trans('DescOptionCP').''; +print ''.$langs->trans('ValueOptionCP').''; +print '
'.$langs->trans('GroupToValidateCP').''.$cp->selectUserGroup('userGroup').'
'.$langs->trans('DelayForSubmitCP').' '.$langs->trans('Jours').'
'.$langs->trans('AlertValidatorDelayCP').'getCheckOption('AlertValidatorDelay').'/>
'.$langs->trans('AlertValidorSoldeCP').'getCheckOption('AlertValidatorSolde').'/>
'.$langs->trans('nbHolidayEveryMonthCP').' '.$langs->trans('Jours').'
'.$langs->trans('nbHolidayDeductedCP').' '.$langs->trans('Jours').'
'.$langs->trans('nbUserCP').'
'.$langs->trans('LastUpdateCP').'
'."\n"; + +print '
'."\n"; +print '
'."\n\n"; + +print '

'.$langs->trans('TitleOptionEventCP').'

'."\n\n"; + +$cp_events = $cp->fetchEventsCP(); + +if($cp_events == 1) { + + $var = false; + $i = 0; + + print '
'."\n"; + print ''."\n"; + + print '
'.$langs->trans('TitleUpdateEventCP').'
'."\n"; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + print ''."\n"; + + foreach($cp->events as $infos_event) { + + $var=!$var; + + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + + $i++; + } + + print ''."\n"; + print '
'.$langs->trans('NameEventCP').''.$langs->trans('ValueOptionCP').''.$langs->trans('UpdateEventOptionCP').''.$langs->trans('DeleteEventOptionCP').'
'.$langs->trans('Jours').'
'."\n"; + print '
'."\n"; + print '
'."\n\n"; + +} + +print '
'."\n"; + +print '
'.$langs->trans('TitleCreateEventCP').'
'; + +print ''; +print ''; + +print ''; + +print ''; +print ''; +print ''; + +print ''; + +print ''."\n"; + +print ''; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +print ''; +print '
'.$langs->trans('NameEventCP').''.$langs->trans('ValueOptionCP').''.$langs->trans('CreateEventCP').'
'.$langs->trans('Jours').'
'; + +print '
'; + +print '
'; + + +// Fin de page +llxFooter(); + +if (is_object($db)) $db->close(); \ No newline at end of file diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php new file mode 100644 index 00000000000..69e5d9b0cfc --- /dev/null +++ b/htdocs/holiday/class/holiday.class.php @@ -0,0 +1,1592 @@ + + * Copyright (C) 2011 Dimitri Mouillard +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * \file holiday.class.php + * \ingroup holiday + * \brief Class file of the module paid holiday. + * \version $Id: holiday.class.php,v 1.00 2011/09/15 11:00:00 dmouillard Exp $ + * \author dmouillard@teclib.com + * \remarks Class file of the module paid holiday. + */ + + +/** + * \class Holiday + * \brief Class pour les Congés Payés + * \remarks Développé par Teclib ( http://www.teclib.com/ ) + */ +class Holiday // extends CommonObject +{ + var $db; + var $error; + var $errors=array(); + + var $rowid; + + var $fk_user; + var $date_create=''; + var $description; + var $date_debut=''; + var $date_fin=''; + var $statut=''; + var $fk_validator; + var $date_valid=''; + var $fk_user_valid; + var $date_refuse=''; + var $fk_user_refuse; + var $date_cancel=''; + var $fk_user_cancel; + var $detail_refuse=''; + + var $holiday = array(); + var $events = array(); + var $logs = array(); + + var $optName = ''; + var $optValue = ''; + var $optRowid = ''; + + /** + * Constructor + * + * @param DB Database handler + */ + function __construct($db) + { + $this->db = $db; + + // Mets à jour les congés payés en début de mois + $this->updateSoldeCP(); + + // Vérifie le nombre d'utilisateur et mets à jour si besoin + $this->verifNbUsers($this->countActiveUsers(),$this->getConfCP('nbUser')); + return 1; + } + + + /** + * \brief Créer un congés payés dans la base de données + * \param user User that create + * \param notrigger 0=launch triggers after, 1=disable triggers + * \return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; + + $sql.= "fk_user,"; + $sql.= "date_create,"; + $sql.= "description,"; + $sql.= "date_debut,"; + $sql.= "date_fin,"; + $sql.= "statut,"; + $sql.= "fk_validator"; + + $sql.= ") VALUES ("; + + // User + if(!empty($this->fk_user)) { + $sql.= "'".$this->fk_user."',"; + } else { + $error++; + } + $sql.= " NOW(),"; + $sql.= " '".addslashes($this->description)."',"; + $sql.= " '".$this->date_debut."',"; + $sql.= " '".$this->date_fin."',"; + $sql.= " '1',"; + if(is_numeric($this->fk_validator)) { + $sql.= " '".$this->fk_validator."'"; + } + else { + $error++; + } + + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + + if (! $error) + { + $this->rowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); + + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->rowid; + } + } + + + /** + * \brief Load object in memory from database + * \param id id object + * \return int <0 if KO, >0 if OK + */ + function fetch($id) + { + global $langs; + + $sql = "SELECT"; + $sql.= " cp.rowid,"; + + $sql.= " cp.fk_user,"; + $sql.= " cp.date_create,"; + $sql.= " cp.description,"; + $sql.= " cp.date_debut,"; + $sql.= " cp.date_fin,"; + $sql.= " cp.statut,"; + $sql.= " cp.fk_validator,"; + $sql.= " cp.date_valid,"; + $sql.= " cp.fk_user_valid,"; + $sql.= " cp.date_refuse,"; + $sql.= " cp.fk_user_refuse,"; + $sql.= " cp.date_cancel,"; + $sql.= " cp.fk_user_cancel,"; + $sql.= " cp.detail_refuse"; + + + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql.= " WHERE cp.rowid = ".$id; + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->rowid = $obj->rowid; + $this->fk_user = $obj->fk_user; + $this->date_create = $obj->date_create; + $this->description = $obj->description; + $this->date_debut = $obj->date_debut; + $this->date_fin = $obj->date_fin; + $this->statut = $obj->statut; + $this->fk_validator = $obj->fk_validator; + $this->date_valid = $obj->date_valid; + $this->fk_user_valid = $obj->fk_user_valid; + $this->date_refuse = $obj->date_refuse; + $this->fk_user_refuse = $obj->fk_user_refuse; + $this->date_cancel = $obj->date_cancel; + $this->fk_user_cancel = $obj->fk_user_cancel; + $this->detail_refuse = $obj->detail_refuse; + + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * \brief Liste les congés payés pour un utilisateur + * \param user id ID de l'utilisateur à lister + * \param order Filtrage par ordre + * \param filter Filtre de séléction + * \return int -1 si erreur, 1 si OK et 2 si pas de résultat + */ + function fetchByUser($user_id,$order='',$filter='') + { + global $langs, $conf; + + $sql = "SELECT"; + $sql.= " cp.rowid,"; + + $sql.= " cp.fk_user,"; + $sql.= " cp.date_create,"; + $sql.= " cp.description,"; + $sql.= " cp.date_debut,"; + $sql.= " cp.date_fin,"; + $sql.= " cp.statut,"; + $sql.= " cp.fk_validator,"; + $sql.= " cp.date_valid,"; + $sql.= " cp.fk_user_valid,"; + $sql.= " cp.date_refuse,"; + $sql.= " cp.fk_user_refuse,"; + $sql.= " cp.date_cancel,"; + $sql.= " cp.fk_user_cancel,"; + $sql.= " cp.detail_refuse"; + + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql.= " WHERE cp.fk_user = '".$user_id."'"; + + // Filtre de séléction + if(!empty($filter)) { + $sql.= $filter; + } + + // Ordre d'affichage du résultat + if(!empty($order)) { + $sql.= $order; + } + + dol_syslog(get_class($this)."::fetchByUser sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $tab_result = $this->holiday; + $num = $this->db->num_rows($resql); + + // Si pas d'enregistrement + if(!$num) { + return 2; + } + + // Liste les enregistrements et les ajoutent au tableau + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + $tab_result[$i]['rowid'] = $obj->rowid; + $tab_result[$i]['fk_user'] = $obj->fk_user; + $tab_result[$i]['date_create'] = $obj->date_create; + $tab_result[$i]['description'] = $obj->description; + $tab_result[$i]['date_debut'] = $obj->date_debut; + $tab_result[$i]['date_fin'] = $obj->date_fin; + $tab_result[$i]['statut'] = $obj->statut; + $tab_result[$i]['fk_validator'] = $obj->fk_validator; + $tab_result[$i]['date_valid'] = $obj->date_valid; + $tab_result[$i]['fk_user_valid'] = $obj->fk_user_valid; + $tab_result[$i]['date_refuse'] = $obj->date_refuse; + $tab_result[$i]['fk_user_refuse'] = $obj->fk_user_refuse; + $tab_result[$i]['date_cancel'] = $obj->date_cancel; + $tab_result[$i]['fk_user_cancel'] = $obj->fk_user_cancel; + $tab_result[$i]['detail_refuse'] = $obj->detail_refuse; + + $i++; + } + + // Retourne 1 avec le tableau rempli + $this->holiday = $tab_result; + return 1; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchByUser ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * \brief Liste les congés payés de tout les utilisateurs + * \param order Filtrage par ordre + * \param filter Filtre de séléction + * \return int -1 si erreur, 1 si OK et 2 si pas de résultat + */ + function fetchAll($order,$filter) + { + global $langs; + + $sql = "SELECT"; + $sql.= " cp.rowid,"; + + $sql.= " cp.fk_user,"; + $sql.= " cp.date_create,"; + $sql.= " cp.description,"; + $sql.= " cp.date_debut,"; + $sql.= " cp.date_fin,"; + $sql.= " cp.statut,"; + $sql.= " cp.fk_validator,"; + $sql.= " cp.date_valid,"; + $sql.= " cp.fk_user_valid,"; + $sql.= " cp.date_refuse,"; + $sql.= " cp.fk_user_refuse,"; + $sql.= " cp.date_cancel,"; + $sql.= " cp.fk_user_cancel,"; + $sql.= " cp.detail_refuse"; + + $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; + $sql.= " WHERE cp.rowid > '0'"; // Hack pour la recherche sur le tableau + + // Filtrage de séléction + if(!empty($filter)) { + $sql.= $filter; + } + + // Ordre d'affichage + if(!empty($order)) { + $sql.= $order; + } + + dol_syslog(get_class($this)."::fetchAll sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $tab_result = $this->holiday; + $num = $this->db->num_rows($resql); + + // Si pas d'enregistrement + if(!$num) { + return 2; + } + + // On liste les résultats et on les ajoutent dans le tableau + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + $tab_result[$i]['rowid'] = $obj->rowid; + $tab_result[$i]['fk_user'] = $obj->fk_user; + $tab_result[$i]['date_create'] = $obj->date_create; + $tab_result[$i]['description'] = $obj->description; + $tab_result[$i]['date_debut'] = $obj->date_debut; + $tab_result[$i]['date_fin'] = $obj->date_fin; + $tab_result[$i]['statut'] = $obj->statut; + $tab_result[$i]['fk_validator'] = $obj->fk_validator; + $tab_result[$i]['date_valid'] = $obj->date_valid; + $tab_result[$i]['fk_user_valid'] = $obj->fk_user_valid; + $tab_result[$i]['date_refuse'] = $obj->date_refuse; + $tab_result[$i]['fk_user_refuse'] = $obj->fk_user_refuse; + $tab_result[$i]['date_cancel'] = $obj->date_cancel; + $tab_result[$i]['fk_user_cancel'] = $obj->fk_user_cancel; + $tab_result[$i]['detail_refuse'] = $obj->detail_refuse; + + $i++; + } + // Retourne 1 et ajoute le tableau à la variable + $this->holiday = $tab_result; + return 1; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * \brief Update database + * \param user User that modify + * \param notrigger 0=launch triggers after, 1=disable triggers + * \return int <0 if KO, >0 if OK + */ + function update($user=0, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET"; + + $sql.= " description= '".addslashes($this->description)."',"; + + if(!empty($this->date_debut)) { + $sql.= " date_debut = '".$this->date_debut."',"; + } else { + $error++; + } + if(!empty($this->date_fin)) { + $sql.= " date_fin = '".$this->date_fin."',"; + } else { + $error++; + } + if(!empty($this->statut) && is_numeric($this->statut)) { + $sql.= " statut = '".$this->statut."',"; + } else { + $error++; + } + if(!empty($this->fk_validator)) { + $sql.= " fk_validator = '".$this->fk_validator."',"; + } else { + $error++; + } + if(!empty($this->date_valid)) { + $sql.= " date_valid = '".$this->date_valid."',"; + } else { + $sql.= " date_valid = NULL,"; + } + if(!empty($this->fk_user_valid)) { + $sql.= " fk_user_valid = '".$this->fk_user_valid."',"; + } else { + $sql.= " fk_user_valid = NULL,"; + } + if(!empty($this->date_refuse)) { + $sql.= " date_refuse = '".$this->date_refuse."',"; + } else { + $sql.= " date_refuse = NULL,"; + } + if(!empty($this->fk_user_refuse)) { + $sql.= " fk_user_refuse = '".$this->fk_user_refuse."',"; + } else { + $sql.= " fk_user_refuse = NULL,"; + } + if(!empty($this->date_cancel)) { + $sql.= " date_cancel = '".$this->date_cancel."',"; + } else { + $sql.= " date_cancel = NULL,"; + } + if(!empty($this->fk_user_cancel)) { + $sql.= " fk_user_cancel = '".$this->fk_user_cancel."',"; + } else { + $sql.= " fk_user_cancel = NULL,"; + } + if(!empty($this->detail_refuse)) { + $sql.= " detail_refuse = '".addslashes($this->detail_refuse)."'"; + } else { + $sql.= " detail_refuse = NULL"; + } + + $sql.= " WHERE rowid= '".$this->rowid."'"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + + if (! $error) + { + + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param user User that delete + * @param notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE rowid=".$this->rowid; + + $this->db->begin(); + + dol_syslog(get_class($this)."::delete sql=".$sql); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + + if (! $error) + { + + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + /** + * + * @param unknown_type $fk_user + * @param unknown_type $dateDebut + * @param unknown_type $dateFin + * @return boolean + */ + function verifDateHolidayCP($fk_user,$dateDebut,$dateFin) + { + $this->fetchByUser($fk_user,'',''); + + foreach($this->holiday as $infos_CP) { + + if($dateDebut >= $infos_CP['date_debut'] && $dateDebut <= $infos_CP['date_fin'] || $dateFin <= $infos_CP['date_fin'] && $dateFin >= $infos_CP['date_debut']) { + return false; + } + + } + + return true; + + } + + /** + * \brief Retourne la traduction du statut d'un congé payé + * \param statut int du statut du congé + * \return string retourne la traduction du statut + */ + function getStatutCP($statut) { + + global $langs; + + if(is_numeric($statut)) { + + switch($statut) { + case 1: // Brouillon + $statut = $langs->trans('DraftCP'); + break; + case 2: // En attente de validation + $statut = $langs->trans('ToValidateCP'); + break; + case 3: // Validée + $statut = $langs->trans('ValidateCP'); + break; + case 4: // Annulée + $statut = $langs->trans('CancelCP'); + break; + case 5: // Refusée + $statut = $langs->trans('RefuseCP'); + } + + return $statut; + } + } + + /** + * \brief Affiche un select HTML des statuts de congés payés + * \param selected int du statut séléctionné par défaut + * \return select affiche le select des statuts + */ + function selectStatutCP($selected='') { + + global $langs; + + // Liste des statuts + $name = array('DraftCP','ToValidateCP','ValidateCP','CancelCP','RefuseCP'); + $nb = count($name)+1; + + // Select HTML + $statut = ''."\n"; + print $statut; + + } + + /** + * \brief Retourne un select HTML des groupes d'utilisateurs + * \param prefix nom du champ dans le formulaire + * \return select retourne le select des groupes + */ + function selectUserGroup($prefix) + { + // On récupère le groupe déjà configuré + $group.= "SELECT value"; + $group.= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $group.= " WHERE name = 'userGroup'"; + + $resultat = $this->db->query($group); + $objet = $this->db->fetch_object($resultat); + $groupe = $objet->value; + + // On liste les groupes de Dolibarr + $sql = "SELECT u.rowid, u.nom"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup as u"; + $sql.= " ORDER BY u.rowid"; + + dol_syslog(get_class($this)."::selectUserGroup sql=".$sql,LOG_DEBUG); + $result = $this->db->query($sql); + + // Si pas d'erreur SQL + if ($result) + { + // On créer le select HTML + $selectGroup = ''."\n"; + $this->db->free($result); + } + else + { + // Erreur SQL + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::selectUserGroup ".$this->error, LOG_ERR); + return -1; + } + + // Retourne le select HTML + return $selectGroup; + } + + /** + * Met à jour une option du module Holiday Payés + * + * @param name nom du paramètre de configuration + * @return value vrai si mise à jour OK sinon faux + */ + function updateConfCP($name,$value) { + + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; + $sql.= " value = '".$value."'"; + $sql.= " WHERE name = '".$name."'"; + + dol_syslog(get_class($this).'::updateConfCP name='.$name.' sql='.$sql); + $result = $this->db->query($sql); + if($result) { + return true; + } + + return false; + } + + /** + * Retourne la valeur d'un paramètre de configuration + * + * @param name nom du paramètre de configuration + * @return string retourne la valeur du paramètre + */ + function getConfCP($name) + { + $sql = "SELECT value"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql.= " WHERE name = '".$name."'"; + + dol_syslog(get_class($this).'::getConfCP name='.$name.' sql='.$sql); + $result = $this->db->query($sql); + + // Si pas d'erreur + if($result) { + + $objet = $this->db->fetch_object($result); + // Retourne la valeur + return $objet->value; + + } else { + + // Erreur SQL + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::getConfCP ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * Met à jour le timestamp de la dernière mise à jour du solde des CP + * + * @return nothing ne retourne rien + */ + function updateSoldeCP($userID='',$nbHoliday='') + { + global $user; + + if (empty($userID) && empty($nbHoliday)) + { + // Si mise à jour pour tous le monde en début de mois + + // Mois actuel + $month = date('m',time()); + $lastUpdate = $this->getConfCP('lastUpdate'); + $monthLastUpdate = date('m', $lastUpdate); + + // Si la date du mois n'est pas la même que celle sauvegardé, on met à jour le timestamp + if ($month != $monthLastUpdate) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; + $sql.= " value = '".dol_now()."'"; + $sql.= " WHERE name = 'lastUpdate'"; + + $result = $this->db->query($sql); + + // On ajoute x jours à chaque utilisateurs + $nb_holiday = $this->getConfCP('nbHolidayEveryMonth'); + if (empty($nb_holiday)) $nb_holiday=0; + + $users = $this->fetchUsers(false,false); + $nbUser = count($users); + + $i = 0; + + while($i < $nbUser) + { + $now_holiday = $this->getCPforUser($users[$i]['rowid']); + $new_solde = $now_holiday + $this->getConfCP('nbHolidayEveryMonth'); + + // On ajoute la modification dans le LOG + $this->addLogCP($user->id,$users[$i]['rowid'],'Event : Mise à jour mensuelle',$new_solde); + + $i++; + } + + $sql2 = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; + $sql2.= " nb_holiday = nb_holiday + ".$nb_holiday; + + dol_syslog(get_class($this).'::updateSoldeCP sql='.$sql2); + $this->db->query($sql2); + } + } else { + // Mise à jour pour un utilisateur + $nbHoliday = number_format($nbHoliday,2,'.',''); + + // Mise à jour pour un utilisateur + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_users SET"; + $sql.= " nb_holiday = ".$nbHoliday; + $sql.= " WHERE fk_user = '".$userID."'"; + + dol_syslog(get_class($this).'::updateSoldeCP sql='.$sql); + $this->db->query($sql); + } + + } + + /** + * \brief Retourne un checked si vrai + * \param name nom du paramètre de configuration + * \return string retourne checked si > 0 + */ + function getCheckOption($name) { + + $sql = "SELECT *"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; + $sql.= " WHERE name = '".$name."'"; + + $result = $this->db->query($sql); + + if($result) { + $obj = $this->db->fetch_object($result); + + // Si la valeur est 1 on retourne checked + if($obj->value) { + return 'checked="checked"'; + } + } + } + + + /** + * Créer les entrées pour chaque utilisateur au moment de la configuration + * + * @return nothing ne retourne rien + */ + function createCPusers($single=false,$userid='') + { + // Si c'est l'ensemble des utilisateurs à ajoutés + if(!$single) + { + dol_syslog(get_class($this).'::createCPusers'); + foreach($this->fetchUsers(false,true) as $users) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; + $sql.= " (fk_user, nb_holiday)"; + $sql.= " VALUES ('".$users['rowid']."','0')"; + + $this->db->query($sql); + } + } else { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_users"; + $sql.= " (fk_user, nb_holiday)"; + $sql.= " VALUES ('".$userid."','0')"; + + $this->db->query($sql); + } + + } + + /** + * \brief Supprime un utilisateur du module Congés Payés + * \param int ID de l'utilisateur à supprimer + * \return boolean Vrai si pas d'erreur, faut si Erreur + */ + function deleteCPuser($user_id) { + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; + $sql.= " WHERE fk_user = '".$user_id."'"; + + $this->db->query($sql); + + } + + + /** + * \brief Retourne le solde de congés payés pour un utilisateur + * \param user_id ID de l'utilisateur + * \return float Retourne le solde de congés payés de l'utilisateur + */ + function getCPforUser($user_id) { + + $sql = "SELECT *"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; + $sql.= " WHERE fk_user = '".$user_id."'"; + + $result = $this->db->query($sql); + + if($result) { + $obj = $this->db->fetch_array($result); + return number_format($obj['nb_holiday'],2); + } else { + return '0'; + } + + } + + /** + * Liste la liste des utilisateurs du module congés + * uniquement pour vérifier si il existe de nouveau utilisateur + * + * @param boolean si vrai retourne une liste, si faux retourne un array + * @param boolean si vrai retourne pour Dolibarr si faux retourne pour CP + * @return string retourne un tableau de tout les utilisateurs actifs + */ + function fetchUsers($liste=true,$type=true) + { + // Si vrai donc pour user Dolibarr + if($liste) { + + if($type) { + // Si utilisateur de Dolibarr + + $sql = "SELECT u.rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE statut > '0'"; + + dol_syslog(get_class($this)."::fetchUsers sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $num = $this->db->num_rows($resql); + $liste = ''; + + // Boucles du listage des utilisateurs + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + if($i == 0) { + $liste.= $obj->rowid; + } else { + $liste.= ', '.$obj->rowid; + } + + $i++; + } + // Retoune le tableau des utilisateurs + return $liste; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchUsers ".$this->error, LOG_ERR); + return -1; + } + + } else { // Si utilisateur du module Congés Payés + $sql = "SELECT u.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as u"; + + dol_syslog(get_class($this)."::fetchUsers sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $num = $this->db->num_rows($resql); + $liste = ''; + + // Boucles du listage des utilisateurs + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + if($i == 0) { + $liste.= $obj->fk_user; + } else { + $liste.= ', '.$obj->fk_user; + } + + $i++; + } + // Retoune le tableau des utilisateurs + return $liste; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchUsers ".$this->error, LOG_ERR); + return -1; + } + } + + } else { // Si faux donc user Congés Payés + + // Si c'est pour les utilisateurs de Dolibarr + if($type) { + + $sql = "SELECT u.rowid, u.name, u.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE statut > '0'"; + + dol_syslog(get_class($this)."::fetchUsers sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $tab_result = $this->holiday; + $num = $this->db->num_rows($resql); + + // Boucles du listage des utilisateurs + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + $tab_result[$i]['rowid'] = $obj->rowid; + $tab_result[$i]['name'] = $obj->name; + $tab_result[$i]['firstname'] = $obj->firstname; + + $i++; + } + // Retoune le tableau des utilisateurs + return $tab_result; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchUsers ".$this->error, LOG_ERR); + return -1; + } + + // Si c'est pour les utilisateurs du module Congés Payés + } else { + + $sql = "SELECT cpu.fk_user, u.name, u.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as cpu,"; + $sql.= " ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE cpu.fk_user = u.rowid"; + + dol_syslog(get_class($this)."::fetchUsers sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $tab_result = $this->holiday; + $num = $this->db->num_rows($resql); + + // Boucles du listage des utilisateurs + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + $tab_result[$i]['rowid'] = $obj->fk_user; + $tab_result[$i]['name'] = $obj->name; + $tab_result[$i]['firstname'] = $obj->firstname; + + $i++; + } + // Retoune le tableau des utilisateurs + return $tab_result; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchUsers ".$this->error, LOG_ERR); + return -1; + } + } + } + } + + /** + * \brief Compte le nombre d'utilisateur actifs dans Dolibarr + * \return int retourne le nombre d'utilisateur + */ + function countActiveUsers() { + + $sql = "SELECT count(u.rowid) as compteur"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE statut > '0'"; + + $result = $this->db->query($sql); + $objet = $this->db->fetch_object($result); + return $objet->compteur; + + } + + /** + * \brief Compare le nombre d'utilisateur actif de Dolibarr à celui des utilisateurs des congés payés + * \param nbUsersDolibarr nombre d'utilisateur actifs dans Dolibarr + * \param nbUsersHoliday nombre d'utilisateur actifs dans le module congés payés + * \return nothing ne retourne rien + */ + function verifNbUsers($userDolibarr,$userCP) { + + if (empty($userCP)) $userCP=0; + dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarr.' userCP='.$userCP); + + // Si il y a plus d'utilisateur Dolibarr que dans le module CP + if ($userDolibarr > $userCP) + { + $this->updateConfCP('nbUser',$userDolibarr); + + $listUsersCP = $this->fetchUsers(true,false); + + // On séléctionne les utilisateurs qui ne sont pas déjà dans le module + $sql = "SELECT u.rowid, u.name, u.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE u.rowid NOT IN(".$listUsersCP.")"; + + $result = $this->db->query($sql); + + // Si pas d'erreur SQL + if($result) { + + $i = 0; + $num = $this->db->num_rows($resql); + + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + // On ajoute l'utilisateur + $this->createCPusers(true,$obj->rowid); + + $i++; + } + + + } else { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR); + return -1; + } + + } else { + // Si il y a moins d'utilisateur Dolibarr que dans le module CP + + $this->updateConfCP('nbUser',$userDolibarr); + + $listUsersDolibarr = $this->fetchUsers(true,true); + + // On séléctionne les utilisateurs qui ne sont pas déjà dans le module + $sql = "SELECT u.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users as u"; + $sql.= " WHERE u.fk_user NOT IN(".$listUsersDolibarr.")"; + + $result = $this->db->query($sql); + + // Si pas d'erreur SQL + if($result) { + + $i = 0; + $num = $this->db->num_rows($resql); + + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + // On ajoute l'utilisateur + $this->deleteCPuser($obj->fk_user); + + $i++; + } + + + } else { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::verifNbUsers ".$this->error, LOG_ERR); + return -1; + } + } + + } + + + /** + * \brief Retourne le nombre de jours ouvrés entre deux dates + * \param Date de début et date de fin au format TimeStamp + * \remarks Prise en compte des jours fériés en France + */ + + function getOpenDays($date_start, $date_stop) { + + // Tableau des jours feriés + $arr_bank_holidays = array(); + + // On boucle dans le cas où l'année de départ serait différente de l'année d'arrivée + $diff_year = date('Y', $date_stop) - date('Y', $date_start); + + for ($i = 0; $i <= $diff_year; $i++) { + $year = (int)date('Y', $date_start) + $i; + // Liste des jours feriés + $arr_bank_holidays[] = '1_1_'.$year; // Jour de l'an + $arr_bank_holidays[] = '1_5_'.$year; // Fete du travail + $arr_bank_holidays[] = '8_5_'.$year; // Victoire 1945 + $arr_bank_holidays[] = '14_7_'.$year; // Fete nationale + $arr_bank_holidays[] = '15_8_'.$year; // Assomption + $arr_bank_holidays[] = '1_11_'.$year; // Toussaint + $arr_bank_holidays[] = '11_11_'.$year; // Armistice 1918 + $arr_bank_holidays[] = '25_12_'.$year; // Noel + // Récupération de paques. Permet ensuite d'obtenir le jour de l'ascension et celui de la pentecote + $easter = easter_date($year); + $arr_bank_holidays[] = date('j_n_'.$year, $easter + 86400); // Paques + $arr_bank_holidays[] = date('j_n_'.$year, $easter + (86400*39)); // Ascension + $arr_bank_holidays[] = date('j_n_'.$year, $easter + (86400*50)); // Pentecote + } + + $nb_days_open = 0; + + while ($date_start <= $date_stop) { + // Si le jour suivant n'est ni un dimanche (0) ou un samedi (6), ni un jour férié, on incrémente les jours ouvrés + if (!in_array(date('w', $date_start), array(0, 6)) && !in_array(date('j_n_'.date('Y', $date_start), $date_start), $arr_bank_holidays)) { + $nb_days_open++; + } + + $date_start = mktime(date('H', $date_start), date('i', $date_start), date('s', $date_start), date('m', $date_start), date('d', $date_start) + 1, date('Y', $date_start)); + } + + // On retourne le nombre de jours ouvrés + return $nb_days_open; + } + + /** + * \brief Liste les évènements de congés payés enregistré + * \return int -1 si erreur, 1 si OK et 2 si pas de résultat + */ + function fetchEventsCP() + { + global $langs; + + $sql = "SELECT"; + $sql.= " cpe.rowid,"; + $sql.= " cpe.name,"; + $sql.= " cpe.value"; + + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events as cpe"; + + dol_syslog(get_class($this)."::fetchEventsCP sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $tab_result = $this->events; + $num = $this->db->num_rows($resql); + + // Si pas d'enregistrement + if(!$num) { + return 2; + } + + // On liste les résultats et on les ajoutent dans le tableau + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + $tab_result[$i]['rowid'] = $obj->rowid; + $tab_result[$i]['name'] = $obj->name; + $tab_result[$i]['value'] = $obj->value; + + $i++; + } + // Retourne 1 et ajoute le tableau à la variable + $this->events = $tab_result; + return 1; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchEventsCP ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * \brief Créer un évènement de congés payés + * \return int -1 si erreur, id si OK + */ + function createEventCP($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_events ("; + + $sql.= "name,"; + $sql.= "value"; + + $sql.= ") VALUES ("; + + $sql.= " '".addslashes($this->optName)."',"; + $sql.= " '".$this->optValue."'"; + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::createEventCP sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + + if (! $error) + { + $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_events"); + + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::createEventCP ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->optRowid; + } + } + + /** + * \brief Met à jour les évènements de congés payés + * \return int -1 si erreur, id si OK + */ + function updateEventCP($rowid, $name, $value) { + + $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_events SET"; + $sql.= " name = '".addslashes($name)."', value = '".$value."'"; + $sql.= " WHERE rowid = '".$rowid."'"; + + $result = $this->db->query($sql); + + if($result) { + return true; + } + + return false; + } + + function selectEventCP() { + + $sql = "SELECT *"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; + + $result = $this->db->query($sql); + + if($result) { + + $num = $this->db->num_rows($result); + $i = 0; + $out = ''; + + return $out; + + } else { + + return false; + + } + + } + + function deleteEventCP($rowid) { + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_events"; + $sql.= " WHERE rowid = '".$rowid."'"; + + $result = $this->db->query($sql); + + if($result) { + return true; + } else { + return false; + } + } + + function getValueEventCp($rowid) { + + $sql = "SELECT value"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; + $sql.= " WHERE rowid = '".$rowid."'"; + + $result = $this->db->query($sql); + + if($result) { + $obj = $this->db->fetch_array($result); + return number_format($obj['value'],2); + } else { + return false; + } + } + + function getNameEventCp($rowid) { + + $sql = "SELECT name"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_events"; + $sql.= " WHERE rowid = '".$rowid."'"; + + $result = $this->db->query($sql); + + if($result) { + $obj = $this->db->fetch_array($result); + return $obj['name']; + } else { + return false; + } + } + + function addLogCP($fk_user_action,$fk_user_update,$type,$new_solde) { + + global $conf, $langs, $db; + + $error=0; + + $prev_solde = $this->getCPforUser($fk_user_update); + $new_solde = number_format($new_solde,2,'.',''); + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday_logs ("; + + $sql.= "date_action,"; + $sql.= "fk_user_action,"; + $sql.= "fk_user_update,"; + $sql.= "type_action,"; + $sql.= "prev_solde,"; + $sql.= "new_solde"; + + $sql.= ") VALUES ("; + + $sql.= " NOW(), "; + $sql.= " '".$fk_user_action."',"; + $sql.= " '".$fk_user_update."',"; + $sql.= " '".addslashes($type)."',"; + $sql.= " '".$prev_solde."',"; + $sql.= " '".$new_solde."'"; + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::addLogCP sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + + if (! $error) + { + $this->optRowid = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday_logs"); + + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::addLogCP ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->optRowid; + } + } + + /** + * \brief Liste le log des congés payés + * \param order Filtrage par ordre + * \param filter Filtre de séléction + * \return int -1 si erreur, 1 si OK et 2 si pas de résultat + */ + function fetchLog($order,$filter) + { + global $langs; + + $sql = "SELECT"; + $sql.= " cpl.rowid,"; + $sql.= " cpl.date_action,"; + $sql.= " cpl.fk_user_action,"; + $sql.= " cpl.fk_user_update,"; + $sql.= " cpl.type_action,"; + $sql.= " cpl.prev_solde,"; + $sql.= " cpl.new_solde"; + + $sql.= " FROM ".MAIN_DB_PREFIX."holiday_logs as cpl"; + $sql.= " WHERE cpl.rowid > '0'"; // Hack pour la recherche sur le tableau + + // Filtrage de séléction + if(!empty($filter)) { + $sql.= $filter; + } + + // Ordre d'affichage + if(!empty($order)) { + $sql.= $order; + } + + dol_syslog(get_class($this)."::fetchLog sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + + // Si pas d'erreur SQL + if ($resql) { + + $i = 0; + $tab_result = $this->logs; + $num = $this->db->num_rows($resql); + + // Si pas d'enregistrement + if(!$num) { + return 2; + } + + // On liste les résultats et on les ajoutent dans le tableau + while($i < $num) { + + $obj = $this->db->fetch_object($resql); + + $tab_result[$i]['rowid'] = $obj->rowid; + $tab_result[$i]['date_action'] = $obj->date_action; + $tab_result[$i]['fk_user_action'] = $obj->fk_user_action; + $tab_result[$i]['fk_user_update'] = $obj->fk_user_update; + $tab_result[$i]['type_action'] = $obj->type_action; + $tab_result[$i]['prev_solde'] = $obj->prev_solde; + $tab_result[$i]['new_solde'] = $obj->new_solde; + + $i++; + } + // Retourne 1 et ajoute le tableau à la variable + $this->logs = $tab_result; + return 1; + } + else + { + // Erreur SQL + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetchLog ".$this->error, LOG_ERR); + return -1; + } + } + +} +?> diff --git a/htdocs/holiday/class/holidayagenda.class.php b/htdocs/holiday/class/holidayagenda.class.php new file mode 100644 index 00000000000..5abe1eeaaa4 --- /dev/null +++ b/htdocs/holiday/class/holidayagenda.class.php @@ -0,0 +1,279 @@ + + * Copyright (C) 2005-2010 Regis Houssin +* Copyright (C) 2010 Juanjo Menent +* Copyright (C) 2011 Anthony Hebert +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * \file holidayagenda.class.php + * \ingroup holiday + * \brief Fichier d'agenda pour le module Congés Payés + * \version $Id: holidayagenda.class.php,v 1.00 2011/09/15 11:00:00 ahebert Exp $ + */ + + +/** + * \class CommonAgenda + * \brief Classe mere pour heritage des classes Agenda + */ + +require_once(DOL_DOCUMENT_ROOT."/core/class/commonagenda.class.php"); +require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php"); + + +class HolidayAgenda extends CommonAgenda +{ + var $db; + + // Nombre de seconde à ajouter ou soustraire pour être GMT? + var $offset = 3600; + + // Pays ou calendrier assujetti à l'heure d'été? + var $summerTime = 0; + + + + + /** + * Constructeur de la classe + * @param DB Handler acces base de donnees + */ + function construct($DB) + { + $this->db = $DB; + } + + /** + * Fonction permettant d'altérer les paramètres javascript + * du calendrier + * @what string clé de paramètre recherché + */ + function getParams($what = ''){ + + $params = array( 'timeslotsPerHour' => 2, + 'businessHours' => '{start: 0, end: 24, limitDisplay: true }'); + + if(empty($what)){ + return $params; + }elseif(array_key_exists($what,$params)){ + return $params[$what]; + }else{ + return false; + } + } + + /** + * Accesseur des évènements à mettre dans l'agenda + * @param $start Timestamp de début + * @param $end Timestamp de fin + * @param $options Array stockage de paramètre à utiliser au besoin. + * @return $events Events encodés en Json + */ + function getEvents($start,$end,$options) + { + global $langs,$conf,$user,$db; + + $langs->load('holiday'); + $data = array(); + + if(!isset($options['user']) or empty($options['user'])): + $users_id = $user->id; + else: + $users_id = $options['user']; + endif; + + $sql = "SELECT lcp.rowid as id, + UNIX_TIMESTAMP(date_debut) as start, + UNIX_TIMESTAMP(CONCAT(date_fin, ' 23:59:59')) as end, + lu.firstname as prenom, + lu.name as nom, + lcp.description as title, + lcp.statut as statut + FROM llx_holiday lcp + INNER JOIN llx_user lu + ON lu.rowid = lcp.fk_user + WHERE lcp.fk_user = {$users_id} + AND lcp.statut in (1,3) + AND (UNIX_TIMESTAMP(date_debut) BETWEEN LEFT('$start',10) AND LEFT('$end',10) + OR UNIX_TIMESTAMP(CONCAT(date_fin, ' 23:59:59')) BETWEEN LEFT('$start',10) AND LEFT('$end',10)) + "; + + $qry = $db->query($sql); + $nbr = $db->num_rows($qry); + + if($nbr) + { + $i = 0; + while($res = $db->fetch_object($qry)) + { + $data[$i]['eventid'] = $res->id; + $data[$i]['readonly'] = 0; + $data[$i]['draggable'] = 0; + $data[$i]['resizable'] = 0; + $data[$i]['eventstart'] = (string)$res->start; + $data[$i]['eventend'] = (string)$res->end; + $data[$i]['eventmessage'] = $res->message; + $data[$i]['extraInfo'] = $res->message; + $data[$i]['color'] = "#7AAC22"; + $data[$i]['type'] = $langs->trans('CPTitreMenu'); + $data[$i]['icon'] = ""; + + + $data[$i]['eventtitle'] = "{$res->prenom} {$res->nom}
{$res->title}
"; + $data[$i]['eventtitle'] .= ($res->statut == 1) ? "
{$langs->trans('ToValidateCP')}" : "
{$langs->trans('ValidateCP')}"; + $i++; + } + } + + + + + return $data; + } + + + function getFormItems() + { + global $conf; + + $fields = array( + 'selectedTab' => 'input', + 'user' => 'select' + + ); + + return $fields; + + } + + + /** + * Accesseur d'un formulaire à mettre en en-tête de l'agenda + * @return $form code html + */ + function getForm($get,$post) + { + global $user,$langs,$conf,$db; + + $post = $get + $post; + + if($user->admin){ + $sql = "SELECT * from llx_user where statut = 1"; + $options = ""; + $qry = $db->query($sql); + while($res = $db->fetch_object($qry)){ + $options .= ((isset($_POST['user']) && $res->rowid == $_POST['user']) or ($res->rowid == $user->id and !isset($_POST['user']))) + ? "" + : ""; + } + + + + } + else{ + $options = ""; + } + + $HTML = << + + + + + +
+ {$langs->trans('Collab')} + + + + +
+ +HTML; + $form = $HTML; + return $form; + } + + /** + * Exporteur au format iCal + * @see http://tools.ietf.org/html/rfc5545 + * @todo Export en iCal + * @return $iCal calendrier au format iCal + */ + static function exportIniCal() + { + } + + /** + * Générateur du lien public d'accès au calendrier iCal + * @see http://tools.ietf.org/html/rfc5545 + * @todo Générer le lien + * @return $iCal calendrier au format iCal + */ + function getiCalLink() + { + global $conf,$user,$langs; + } + + + + /** + * Accesseur du label à afficher par print_fiche_titre() + * @return $label Label de l'agenda + */ + function getLabel() + { + global $user,$langs,$conf; + $langs->load('holiday'); + ob_start(); + print_fiche_titre($langs->trans('ListeCP')); + $label = ob_get_contents(); + ob_end_clean(); + + return $label; + } + + + + + function getTitle() + { + global $langs; + $langs->load('holiday'); + return $langs->trans('CPTitreMenu'); + + } + + + function getLink($action = "") + { + global $conf,$user; + + $action = ($action == 'create') ? 'request' : ''; + $url = DOL_URL_ROOT."/holiday/fiche.php"; + + return (empty($action)) ? $url : $url."?action={$action}"; + } + + + +} + +?> diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php new file mode 100644 index 00000000000..4df02005b20 --- /dev/null +++ b/htdocs/holiday/define_holiday.php @@ -0,0 +1,173 @@ + + * Copyright (C) 2011 Dimitri Mouillard +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * File that defines the balance of paid holiday of users. + * + * \file define_holiday.php + * \ingroup holiday + * \brief File that defines the balance of paid holiday of users. + * \author dmouillard@teclib.com + */ + +require('pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT. "/user/class/user.class.php"); + +// Protection if external user +if ($user->societe_id > 0) accessforbidden(); + +// Si l'utilisateur n'a pas le droit de lire cette page +if(!$user->rights->holiday->define_holiday) accessforbidden(); + + +/* + * View +*/ + +llxHeader($langs->trans('CPTitreMenu')); + +print_fiche_titre($langs->trans('MenuConfCP')); + +$holiday = new Holiday($db); +$listUsers = $holiday->fetchUsers(false,false); +$userstatic=new User($db); + +// Si il y a une action de mise à jour +if(isset($_POST['action']) && $_POST['action'] == 'update' && isset($_POST['update_cp'])) { + + $userID = array_keys($_POST['update_cp']); + $userID = $userID[0]; + + $userValue = $_POST['nb_holiday']; + $userValue = $userValue[$userID]; + + if(!empty($userValue)) { + $userValue = price2num($userValue,2); + } else { + $userValue = 0; + } + + // On ajoute la modification dans le LOG + $holiday->addLogCP($user->id,$userID,'Event : Manual update',$userValue); + + // Mise à jour des congés de l'utilisateur + $holiday->updateSoldeCP($userID,$userValue); + + + print '
'; + print $langs->trans('UpdateConfCPOK'); + print '
'; + + +} elseif(isset($_POST['action']) && $_POST['action'] == 'add_event') { + + $error = false; + + if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) { + $event = $_POST['list_event']; + } else { $error = true; + } + + if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) { + $userCP = $_POST['userCP']; + } else { $error = true; + } + + if($error) { + $message = '
'.$langs->trans('ErrorAddEventToUserCP').'
'; + } else { + $nb_holiday = $holiday->getCPforUser($userCP); + $add_holiday = $holiday->getValueEventCp($event); + $new_holiday = $nb_holiday + $add_holiday; + + // On ajoute la modification dans le LOG + $holiday->addLogCP($user->id,$userCP,'Event : '.$holiday->getNameEventCp($event),$new_holiday); + + $holiday->updateSoldeCP($userCP,$new_holiday); + + $message = $langs->trans('AddEventToUserOkCP'); + } + + dol_htmloutput_mesg($message); +} + +$var=true; +$i = 0; + +print '
'; + +print '
'."\n"; +print ''; +print ''; +print ""; +print ''; +print ''; +print ''; +print ''; +print ''; + +foreach($listUsers as $users) +{ + + $var=!$var; + + print ''; + print ''; + print ''; + print ''."\n"; + print ''."\n"; + print ''; + + $i++; +} + +print '
User ID'.$langs->trans('UserName').''.$langs->trans('Available').''.$langs->trans('UpdateButtonCP').'
'.$users['rowid'].''; + $userstatic->id=$users['rowid']; + $userstatic->nom=$users['name']; + $userstatic->prenom=$users['firstname']; + print $userstatic->getNomUrl(1); + print ''; + print ''; + print ' jours
'; +print '
'; + +$cp_events = $holiday->fetchEventsCP(); + +if($cp_events == 1) { + + $html = new Form($db); + + print '
'."\n"; + print ''; + + print '

'.$langs->trans('DefineEventUserCP').'

'; + print $langs->trans('MotifCP').' : '; + print $holiday->selectEventCP(); + print ' '.$langs->trans('UserCP').' : '; + print $html->select_users('',"userCP",1,"",0,''); + print ' '; + + + print '
'; +} +print '
'; +// Fin de page +$db->close(); +llxFooter(); +?> diff --git a/htdocs/holiday/fiche.php b/htdocs/holiday/fiche.php new file mode 100644 index 00000000000..59ed1816d25 --- /dev/null +++ b/htdocs/holiday/fiche.php @@ -0,0 +1,1051 @@ + + * Copyright (C) 2011 Dimitri Mouillard +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * \file fiche.php + * \ingroup holiday + * \brief Form and file creation of paid holiday. + * \version $Id: fiche.php,v 1.16 2011/09/15 11:00:00 dmouillard Exp $ + * \author dmouillard@teclib.com + * \remarks Form and file creation of paid holiday. + */ + +require('pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT. "/core/class/html.form.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/user/class/usergroup.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/core/class/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/core/class/CMailFile.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/core/class/html.formmail.class.php"); + +// Get parameters +$myparam = GETPOST("myparam"); +$action=GETPOST('action'); + +// Protection if external user +if ($user->societe_id > 0) accessforbidden(); + +$user_id = $user->id; + + + +/******************************************************************* + * Actions +********************************************************************/ + +// Si création de la demande +if ($action == 'add') +{ + + // Si pas le droit de créer une demande + if(!$user->rights->holiday->create_edit_read) + { + header('Location: fiche.php?action=request&error=CantCreate'); + exit; + } + + $date_debut = dol_mktime(0, 0, 0, $_POST['date_debut_month'], $_POST['date_debut_day'], $_POST['date_debut_year']); + $date_fin = dol_mktime(0, 0, 0, $_POST['date_fin_month'], $_POST['date_fin_day'], $_POST['date_fin_year']); + + $valideur = $_POST['valideur']; + $description = trim($_POST['description']); + $userID = $_POST['userID']; + + // Si pas de date de début + if (empty($date_debut)) + { + header('Location: fiche.php?action=request&error=nodatedebut'); + exit; + } + + // Si pas de date de fin + if (empty($date_fin)) + { + header('Location: fiche.php?action=request&error=nodatefin'); + exit; + } + + $testDateDebut = $date_debut; + $testDateFin = $date_fin; + + // Si date de début après la date de fin + if($testDateDebut > $testDateFin) + { + header('Location: fiche.php?action=request&error=datefin'); + exit; + } + + $cp = new Holiday($db); + + $verifCP = $cp->verifDateHolidayCP($userID,$date_debut,$date_fin); + + // On vérifie si il n'y a pas déjà des congés payés sur cette période + if(!$verifCP) + { + header('Location: fiche.php?action=request&error=alreadyCP'); + exit; + } + + // Si aucun jours ouvrés dans la demande + if($cp->getOpenDays($testDateDebut,$testDateFin) < 1) + { + header('Location: fiche.php?action=request&error=DureeHoliday'); + exit; + } + + // Si pas de validateur choisi + if($valideur < 1) + { + header('Location: fiche.php?action=request&error=Valideur'); + exit; + } + + $cp->fk_user = $user_id; + $cp->description = $description; + $cp->date_debut = $date_debut; + $cp->date_fin = $date_fin; + $cp->fk_validator = $valideur; + + $verif = $cp->create($user_id); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if ($verif > 0) + { + header('Location: fiche.php?id='.$verif); + exit; + } + else + { + // Sinon on affiche le formulaire de demande avec le message d'erreur SQL + header('Location: fiche.php?action=request&error=SQL_Create&msg='.$cp->error); + exit; + } + +} + +if($action == 'update') +{ + + // Si pas le droit de modifier une demande + if(!$user->rights->holiday->create_edit_read) + { + header('Location: fiche.php?action=request&error=CantUpdate'); + exit; + } + + $cp = new Holiday($db); + $cp->fetch($_POST['holiday_id']); + + // Si en attente de validation + if ($cp->statut == 1) + { + + // Si c'est le créateur ou qu'il a le droit de tout lire / modifier + if ($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) + { + $date_debut = $_POST['date_debut_year'].'-'.str_pad($_POST['date_debut_month'],2,"0",STR_PAD_LEFT).'-'.str_pad($_POST['date_debut_day'],2,"0",STR_PAD_LEFT); + $date_fin = $_POST['date_fin_year'].'-'.str_pad($_POST['date_fin_month'],2,"0",STR_PAD_LEFT).'-'.str_pad($_POST['date_fin_day'],2,"0",STR_PAD_LEFT); + $valideur = $_POST['valideur']; + $description = trim($_POST['description']); + + // Si pas de date de début + if(empty($_POST['date_debut_'])) { + header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=nodatedebut'); + exit; + } + + // Si pas de date de fin + if(empty($_POST['date_fin_'])) { + header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=nodatefin'); + exit; + } + + $testDateDebut = strtotime($date_debut); + $testDateFin = strtotime($date_fin); + + // Si date de début après la date de fin + if($testDateDebut > $testDateFin) { + header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=datefin'); + exit; + } + + // Si pas de valideur choisi + if($valideur < 1) { + header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=Valideur'); + exit; + } + + // Si pas de jours ouvrés dans la demande + if($cp->getOpenDays($testDateDebut,$testDateFin) < 1) { + header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=DureeHoliday'); + exit; + } + + $cp->description = $description; + $cp->date_debut = $date_debut; + $cp->date_fin = $date_fin; + $cp->fk_validator = $valideur; + + $verif = $cp->update($user->id); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if($verif > 0) { + header('Location: fiche.php?id='.$_POST['holiday_id']); + exit; + } else { + // Sinon on affiche le formulaire de demande avec le message d'erreur SQL + header('Location: fiche.php?id='.$_POST['holiday_id'].'&action=edit&error=SQL_Create&msg='.$cp->error); + exit; + } + } + } else { + header('Location: fiche.php?id='.$_POST['holiday_id']); + exit; + } +} + +// Si suppression de la demande +if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes') +{ + if($user->rights->holiday->delete) + { + + $cp = new Holiday($db); + $cp->fetch($_GET['id']); + + // Si c'est bien un brouillon + if($cp->statut == 1) { + // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer + if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) { + $cp->delete($_GET['id']); + header('Location: index.php'); + exit; + } + else { + $error = $langs->trans('ErrorCantDeleteCP'); + } + } + } +} + +// Si envoi de la demande +if ($_GET['action'] == 'confirm_send') +{ + $cp = new Holiday($db); + $cp->fetch($_GET['id']); + + $userID = $user->id; + + // Si brouillon et créateur + if($cp->statut == 1 && $userID == $cp->fk_user) + { + $cp->statut = 2; + + $verif = $cp->update($user->id); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if($verif > 0) { + + // A + $destinataire = new User($db); + $destinataire->fetch($cp->fk_validator); + $emailTo = $destinataire->email; + + // De + $expediteur = new User($db); + $expediteur->fetch($cp->fk_user); + $emailFrom = $expediteur->email; + + // Sujet + if($conf->global->MAIN_APPLICATION_TITLE != NULL) { + $societeName = addslashes($conf->global->MAIN_APPLICATION_TITLE); + } else { + $societeName = addslashes($conf->global->MAIN_INFO_SOCIETE_NOM); + } + + $subject = stripslashes($societeName)." - Demande de congés payés à valider"; + + // Contenu + $message = "Bonjour {$destinataire->prenom},\n\n"; + $message.= "Veuillez trouver ci-dessous une demande de congés payés à valider.\n"; + + $delayForRequest = $cp->getConfCP('delayForRequest'); + $delayForRequest = $delayForRequest * (60*60*24); + + $nextMonth = date('Y-m-d', time()+$delayForRequest); + + // Si l'option pour avertir le valideur en cas de délai trop court + if($cp->getConfCP('AlertValidatorDelay')) { + if($cp->date_debut < $nextMonth) { + $message.= "\n"; + $message.= "Cette demande de congés payés à été effectué dans un"; + $message.= " délai de moins de ".$cp->getConfCP('delayForRequest')." jours avant ceux-ci.\n"; + } + } + + // Si l'option pour avertir le valideur en cas de solde inférieur à la demande + if($cp->getConfCP('AlertValidatorSolde')) { + if($cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)) > $cp->getCPforUser($cp->fk_user)) { + $message.= "\n"; + $message.= "L'utilisateur ayant fait cette demande de congés payés n'a pas le solde requis.\n"; + } + } + + $message.= "\n"; + $message.= "- Demandeur : {$expediteur->prenom} {$expediteur->nom}\n"; + $message.= "- Période : du ".date('d/m/Y',strtotime($cp->date_debut))." au ".date('d/m/Y',strtotime($cp->date_fin))."\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/holiday/fiche.php?id={$cp->rowid}\n\n"; + $message.= "Bien cordialement,\n".$societeName; + + $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); + + // Envoi du mail + $result=$mail->sendfile(); + + if(!$result) { + header('Location: fiche.php?id='.$_GET['id'].'&error=mail&error_content='.$mail->error); + exit; + } + + header('Location: fiche.php?id='.$_GET['id']); + exit; + } else { + // Sinon on affiche le formulaire de demande avec le message d'erreur SQL + header('Location: fiche.php?id='.$_GET['id'].'&error=SQL_Create&msg='.$cp->error); + exit; + } + } +} + +// Si Validation de la demande +if($_GET['action'] == 'confirm_valid') +{ + + $cp = new Holiday($db); + $cp->fetch($_GET['id']); + + $userID = $user->id; + + // Si statut en attente de validation et valideur = utilisateur + if($cp->statut == 2 && $userID == $cp->fk_validator) + { + + $cp->date_valid = date('Y-m-d H:i:s', time()); + $cp->fk_user_valid = $user->id; + $cp->statut = 3; + + $verif = $cp->update($user->id); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if($verif > 0) { + + // Retrait du nombre de jours prit + $nbJour = $cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)); + + $soldeActuel = $cp->getCpforUser($cp->fk_user); + $newSolde = $soldeActuel - ($nbJour*$cp->getConfCP('nbHolidayDeducted')); + + // On ajoute la modification dans le LOG + $cp->addLogCP($userID,$cp->fk_user,'Event : Prise de congés payés',$newSolde); + + // Mise à jour du solde + $cp->updateSoldeCP($cp->fk_user,$newSolde); + + // A + $destinataire = new User($db); + $destinataire->fetch($cp->fk_user); + $emailTo = $destinataire->email; + + // De + $expediteur = new User($db); + $expediteur->fetch($cp->fk_validator); + $emailFrom = $expediteur->email; + + // Sujet + if($conf->global->MAIN_APPLICATION_TITLE != NULL) { + $societeName = addslashes($conf->global->MAIN_APPLICATION_TITLE); + } else { + $societeName = addslashes($conf->global->MAIN_INFO_SOCIETE_NOM); + } + + $subject = stripslashes($societeName)." - Demande de congés payés validée"; + + // Contenu + $message = "Bonjour {$destinataire->prenom},\n\n"; + $message.= "Votre demande de congés payés du ".$cp->date_debut." au ".$cp->date_fin." vient d'être validée!\n"; + $message.= "- Valideur : {$expediteur->prenom} {$expediteur->nom}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/holiday/fiche.php?id={$cp->rowid}\n\n"; + $message.= "Bien cordialement,\n".$societeName; + + + $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); + + // Envoi du mail + $result=$mail->sendfile(); + + if(!$result) { + header('Location: fiche.php?id='.$_GET['id'].'&error=mail&error_content='.$mail->error); + exit; + } + + header('Location: fiche.php?id='.$_GET['id']); + exit; + } else { + // Sinon on affiche le formulaire de demande avec le message d'erreur SQL + header('Location: fiche.php?id='.$_GET['id'].'&error=SQL_Create&msg='.$cp->error); + exit; + } + + } + +} + +if ($_GET['action'] == 'confirm_refuse') +{ + if($_POST['action'] == 'confirm_refuse' && !empty($_POST['detail_refuse'])) + { + $cp = new Holiday($db); + $cp->fetch($_GET['id']); + + $userID = $user->id; + + // Si statut en attente de validation et valideur = utilisateur + if($cp->statut == 2 && $userID == $cp->fk_validator) { + + $cp->date_refuse = date('Y-m-d H:i:s', time()); + $cp->fk_user_refuse = $user->id; + $cp->statut = 5; + $cp->detail_refuse = $_POST['detail_refuse']; + + $verif = $cp->update($user->id); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if($verif > 0) { + + // A + $destinataire = new User($db); + $destinataire->fetch($cp->fk_user); + $emailTo = $destinataire->email; + + // De + $expediteur = new User($db); + $expediteur->fetch($cp->fk_validator); + $emailFrom = $expediteur->email; + + // Sujet + if($conf->global->MAIN_APPLICATION_TITLE != NULL) { + $societeName = addslashes($conf->global->MAIN_APPLICATION_TITLE); + } else { + $societeName = addslashes($conf->global->MAIN_INFO_SOCIETE_NOM); + } + + $subject = stripslashes($societeName)." - Demande de congés payés refusée"; + + // Contenu + $message = "Bonjour {$destinataire->prenom},\n\n"; + $message.= "Votre demande de congés payés ".$cp->date_debut." au ".$cp->date_fin." vient d'être refusée pour le motif suivant :\n"; + $message.= $_POST['detail_refuse']."\n\n"; + $message.= "- Valideur : {$expediteur->prenom} {$expediteur->nom}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/holiday/fiche.php?id={$cp->rowid}\n\n"; + $message.= "Bien cordialement,\n".$societeName; + + + $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); + + // Envoi du mail + $result=$mail->sendfile(); + + if(!$result) { + header('Location: fiche.php?id='.$_GET['id'].'&error=mail&error_content='.$mail->error); + exit; + } + + header('Location: fiche.php?id='.$_GET['id']); + exit; + } else { + // Sinon on affiche le formulaire de demande avec le message d'erreur SQL + header('Location: fiche.php?id='.$_GET['id'].'&error=SQL_Create&msg='.$cp->error); + exit; + } + + } + + } else { + header('Location: fiche.php?id='.$_GET['id'].'&error=NoMotifRefuse'); + exit; + } +} + +// Si Validation de la demande +if ($_GET['action'] == 'confirm_cancel' && $_GET['confirm'] == 'yes') +{ + $cp = new Holiday($db); + $cp->fetch($_GET['id']); + + $userID = $user->id; + + // Si statut en attente de validation et valideur = utilisateur + if($cp->statut == 2 && $userID == $cp->fk_validator) + { + $cp->date_cancel = date('Y-m-d H:i:s', time()); + $cp->fk_user_cancel = $user->id; + $cp->statut = 4; + + $verif = $cp->update($user->id); + + // Si pas d'erreur SQL on redirige vers la fiche de la demande + if($verif > 0) + { + // A + $destinataire = new User($db); + $destinataire->fetch($cp->fk_user); + $emailTo = $destinataire->email; + + // De + $expediteur = new User($db); + $expediteur->fetch($cp->fk_validator); + $emailFrom = $expediteur->email; + + // Sujet + if($conf->global->MAIN_APPLICATION_TITLE != NULL) { + $societeName = addslashes($conf->global->MAIN_APPLICATION_TITLE); + } else { + $societeName = addslashes($conf->global->MAIN_INFO_SOCIETE_NOM); + } + + $subject = stripslashes($societeName)."- Demande de congés payés annulée"; + + // Contenu + $message = "Bonjour {$destinataire->prenom},\n\n"; + $message.= "Votre demande de congés payés ".$cp->date_debut." au ".$cp->date_fin." vient d'être annulée !\n"; + $message.= "- Valideur : {$expediteur->prenom} {$expediteur->nom}\n"; + $message.= "- Lien : {$dolibarr_main_url_root}/holiday/fiche.php?id={$cp->rowid}\n\n"; + $message.= "Bien cordialement,\n".$societeName; + + + $mail = new CMailFile($subject,$emailTo,$emailFrom,$message); + + // Envoi du mail + $result=$mail->sendfile(); + + if(!$result) + { + header('Location: fiche.php?id='.$_GET['id'].'&error=mail&error_content='.$mail->error); + exit; + } + + header('Location: fiche.php?id='.$_GET['id']); + exit; + } + else + { + // Sinon on affiche le formulaire de demande avec le message d'erreur SQL + header('Location: fiche.php?id='.$_GET['id'].'&error=SQL_Create&msg='.$cp->error); + exit; + } + + } + +} + + + +/*************************************************** + * View +****************************************************/ + +llxHeader($langs->trans('CPTitreMenu')); + +if ($_GET['action'] == 'request') +{ + + // Si l'utilisateur n'a pas le droit de faire une demande + if(!$user->rights->holiday->create_edit_read) + { + print '
'; + print $langs->trans('CantCreateCP'); + print '
'."\n"; + } + else + { + // Formulaire de demande de congés payés + print_fiche_titre($langs->trans('MenuAddCP')); + + // Si il y a une erreur + if(isset($_GET['error'])) { + + switch($_GET['error']) { + case 'datefin' : + $msg = $langs->trans('ErrorEndDateCP'); + break; + case 'SQL_Create' : + $msg = $langs->trans('ErrorSQLCreateCP').' '.htmlentities($_GET['msg']).''; + break; + case 'CantCreate' : + $msg = $langs->trans('CantCreateCP'); + break; + case 'Valideur' : + $msg = $langs->trans('InvalidValidatorCP'); + break; + case 'nodatedebut' : + $msg = $langs->trans('NoDateDebut'); + break; + case 'nodatedebut' : + $msg = $langs->trans('NoDateFin'); + break; + case 'DureeHoliday' : + $msg = $langs->trans('ErrorDureeCP'); + break; + case 'alreadyCP' : + $msg = $langs->trans('alreadyCPexist'); + break; + } + + print '
'; + print $msg; + print '
'."\n"; + + } + + $html = new Form($db); + $cp = new Holiday($db); + + $delayForRequest = $cp->getConfCP('delayForRequest'); + $delayForRequest = $delayForRequest * (60*60*24); + + $nextMonth = date('Y-m-d', time()+$delayForRequest); + + print ''."\n"; + + // Formulaire de demande + print '
'."\n"; + print ''."\n"; + print ''."\n"; + print '
'; + print ''.$langs->trans('DelayToRequestCP',$cp->getConfCP('delayForRequest')).'

'; + + $nb_holiday = $cp->getCPforUser($user->id) / $cp->getConfCP('nbHolidayDeducted'); + + print ''.$langs->trans('SoldeCPUser', round($nb_holiday,0)).'

'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + // Liste des utiliseurs du groupes choisi dans la config + $idGroupValid = $cp->getConfCP('userGroup'); + + $validator = new UserGroup($db,$idGroupValid); + $valideur = $validator->listUsersForGroup(); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("DateDebCP").''; + // Si la demande ne vient pas de l'agenda + if(!isset($_GET['datep'])) { + $html->select_date($nextMonth,'date_debut_'); + } else { + $date = substr($_GET['datep'],0,4)."-".substr($_GET['datep'],4,2)."-".substr($_GET['datep'],6,2); + $html->select_date($date,'date_debut_'); + } + print '
'.$langs->trans("DateFinCP").''; + // Si la demande ne vient pas de l'agenda + if(!isset($_GET['datep'])) { + $html->select_date($nextMonth,'date_fin_'); + } else { + $date = substr($_GET['datef'],0,4)."-".substr($_GET['datef'],4,2)."-".substr($_GET['datef'],6,2); + $html->select_date($date,'date_fin_'); + } + print '
'.$langs->trans("ValidateByCP").''; + $html->select_users('',"valideur",1,"",0,$valideur,''); + print '
'.$langs->trans("DescCP").''; + print ''; + print '
'; + print '
'; + print '
'; + print ''."\n"; + + print '
'; + print ''; + print '    '; + print ''; + print '
'; + } + +} +elseif(isset($_GET['id'])) +{ + if ($error) + { + print '
'; + print $error; + print '

'; + print '
'; + } + else + { + // Affichage de la fiche d'une demande de congés payés + if ($_GET['id'] > 0) + { + $cp = new Holiday($db); + $cp->fetch($_GET['id']); + + $valideur = new User($db); + $valideur->fetch($cp->fk_validator); + + $userRequest = new User($db); + $userRequest->fetch($cp->fk_user); + + // Utilisateur connecté + $userID = $user->id; + + print_fiche_titre($langs->trans('TitreRequestCP')); + + // Si il y a une erreur + if(isset($_GET['error'])) { + + switch($_GET['error']) { + case 'datefin' : + $msg = $langs->trans('ErrorEndDateCP'); + break; + case 'SQL_Create' : + $msg = $langs->trans('ErrorSQLCreateCP').' '.htmlentities($_GET['msg']).''; + break; + case 'CantCreate' : + $msg = $langs->trans('CantCreateCP'); + break; + case 'Valideur' : + $msg = $langs->trans('InvalidValidatorCP'); + break; + case 'nodatedebut' : + $msg = $langs->trans('NoDateDebut'); + break; + case 'nodatedebut' : + $msg = $langs->trans('NoDateFin'); + break; + case 'DureeHoliday' : + $msg = $langs->trans('ErrorDureeCP'); + break; + case 'NoMotifRefuse' : + $msg = $langs->trans('NoMotifRefuseCP'); + break; + case 'mail' : + $msg = $langs->trans('ErrorMailNotSend').'
'.$_GET['error_content'].''; + break; + } + + print '
'; + print $msg; + print '
'; + + } + + // On vérifie si l'utilisateur à le droit de lire cette demande + if($user->id == $cp->fk_user || $user->rights->holiday->lire_tous) { + + if($_GET['action'] == 'delete' && $cp->statut == 1) { + if($user->rights->holiday->delete) { + $html = new Form($db); + + $ret=$html->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleDeleteCP"),$langs->trans("ConfirmDeleteCP"),"confirm_delete", '', 0, 1); + if ($ret == 'html') print '
'; + } + } + + // Si envoi en validation + if($_GET['action'] == 'sendToValidate' && $cp->statut == 1 && $userID == $cp->fk_user) { + $html = new Form($db); + + $ret=$html->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleToValidCP"),$langs->trans("ConfirmToValidCP"),"confirm_send", '', 0, 1); + if ($ret == 'html') print '
'; + } + + // Si validation de la demande + if($_GET['action'] == 'valid' && $cp->statut == 2 && $userID == $cp->fk_validator) { + $html = new Form($db); + + $ret=$html->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleValidCP"),$langs->trans("ConfirmValidCP"),"confirm_valid", '', 0, 1); + if ($ret == 'html') print '
'; + } + + // Si refus de la demande + if($_GET['action'] == 'refuse' && $cp->statut == 2 && $userID == $cp->fk_validator) { + $html = new Form($db); + + $array_input = array(array('type'=>"text",'label'=>"Entrez ci-dessous un motif de refus :",'name'=>"detail_refuse",'size'=>"50",'value'=>"")); + $ret=$html->form_confirm("fiche.php?id=".$_GET['id']."&action=confirm_refuse",$langs->trans("TitleRefuseCP"),"","confirm_refuse",$array_input,"",0); + if ($ret == 'html') print '
'; + } + + // Si annulation de la demande + if($_GET['action'] == 'cancel' && $cp->statut == 2 && $userID == $cp->fk_validator) { + $html = new Form($db); + + $ret=$html->form_confirm("fiche.php?id=".$_GET['id'],$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 0, 1); + if ($ret == 'html') print '
'; + } + + + print '
'; + + + if($_GET['action'] == 'edit' && $user->id == $cp->fk_user && $cp->statut == 1) + { + $edit = true; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + $html = new Form($db); + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + if(!$edit) { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + } + + if(!$edit) { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + } + print ''; + print ''; + print ''; + print ''; + if(!$edit) { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + print ''; + print ''; + } + print ''; + print '
'.$langs->trans("InfosCP").'
ID'.$cp->rowid.'
'.$langs->trans('DateDebCP').''.date('d-m-Y', strtotime($cp->date_debut)).'
'.$langs->trans('DateDebCP').''; + $html->select_date($cp->date_debut,'date_debut_'); + print '
'.$langs->trans('DateFinCP').''.date('d-m-Y', strtotime($cp->date_fin)).'
'.$langs->trans('DateFinCP').''; + $html->select_date($cp->date_fin,'date_fin_'); + print '
'.$langs->trans('NbUseDaysCP').''.$cp->getOpenDays(strtotime($cp->date_debut),strtotime($cp->date_fin)).'
'.$langs->trans('DescCP').''.nl2br($cp->description).'
'.$langs->trans('DescCP').'
'."\n"; + + print '
 
'; + + print '
'."\n"; + + print ''."\n"; + print ''; + print ''; + print ''; + print ''; + + if(!$edit) { + print ''; + print ''; + print ''; + print ''; + } else { + print ''; + print ''; + // Liste des utiliseurs du groupes choisi dans la config + $idGroupValid = $cp->getConfCP('userGroup'); + + $validator = new UserGroup($db,$idGroupValid); + $valideur = $validator->listUsersForGroup(); + + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if($cp->statut == 3) { + print ''; + print ''; + print ''; + print ''; + } + if($cp->statut == 4) { + print ''; + print ''; + print ''; + print ''; + } + if($cp->statut == 5) { + print ''; + print ''; + print ''; + print ''; + } + print ''; + print ''; + print ''; + print ''; + if($cp->statut == 5) { + print ''; + print ''; + print ''; + print ''; + } + print ''; + print '
'.$langs->trans("InfosWorkflowCP").'
'.$langs->trans('ValidateByCP').''.$valideur->getNomUrl(1).'
'.$langs->trans('ValidateByCP').''; + $html->select_users($cp->fk_validator,"valideur",1,"",0,$valideur,''); + print '
'.$langs->trans('RequestByCP').''.$userRequest->getNomUrl(1).'
'.$langs->trans('DateCreateCP').''.$cp->date_create.'
'.$langs->trans('DateValidCP').''.$cp->date_valid.'
'.$langs->trans('DateCancelCP').''.$cp->date_cancel.'
'.$langs->trans('DateRefusCP').''.$cp->date_refuse.'
'.$langs->trans('StatutCP').''.$cp->getStatutCP($cp->statut).'
'.$langs->trans('DetailRefusCP').''.$cp->detail_refuse.'
'; + + print '
'."\n"; + + print '
'; + print '
'."\n"; + print '
'; + + if ($edit) + { + print '
'; + if($user->rights->holiday->create_edit_read && $_GET['action'] == 'edit' && $cp->statut == 1) + { + print ''; + } + print '
'; + + print '
'; + } + + if (! $edit) + { + print '
'; + print '
'."\n"; + + // Boutons d'actions + + if($user->rights->holiday->create_edit_read && $_GET['action'] != 'edit' && $cp->statut == 1) { + print ''.$langs->trans("EditCP").''; + } + if($user->rights->holiday->delete && $cp->statut == 1) { + print ''.$langs->trans("DeleteCP").''; + } + if($user->id == $cp->fk_user && $cp->statut == 1) { + print ''.$langs->trans("SendToValidationCP").''; + } + + // Si le statut est en attente de validation et que le valideur est connecté + if($userID == $cp->fk_validator && $cp->statut == 2) { + print ''.$langs->trans("ActionValidCP").''; + print ''.$langs->trans("ActionRefuseCP").''; + print ''.$langs->trans("ActionCancelCP").''; + } + + print '
'; + } + + } else { + print '
'; + print $langs->trans('ErrorUserViewCP'); + print '

'; + print '
'; + } + + } else { + print '
'; + print $langs->trans('ErrorIDFicheCP'); + print '

'; + print '
'; + } + + } + +} + +// End of page +llxFooter(); + +if (is_object($db)) $db->close(); +?> diff --git a/htdocs/holiday/img/conges.png b/htdocs/holiday/img/conges.png new file mode 100644 index 00000000000..69ccdb279a5 Binary files /dev/null and b/htdocs/holiday/img/conges.png differ diff --git a/htdocs/holiday/index.php b/htdocs/holiday/index.php new file mode 100644 index 00000000000..7e05bbaeb5b --- /dev/null +++ b/htdocs/holiday/index.php @@ -0,0 +1,330 @@ + + * Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file index.php + * \ingroup holiday + * \brief List of holiday. + */ + +require('pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT. "/core/class/html.form.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/core/class/html.formother.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/user/class/user.class.php"); +require_once(DOL_DOCUMENT_ROOT. "/user/class/usergroup.class.php"); + +// Protection if external user +if ($user->societe_id > 0) accessforbidden(); + + +/* + * Actions + */ + +// None + + + +/* + * View + */ + +llxHeader($langs->trans('CPTitreMenu')); + +/***************************************** + * Tri du tableau +*****************************************/ + +$sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"]; +$sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"]; +$page = isset($_GET["page"])? $_GET["page"]:$_POST["page"]; +$page = is_numeric($page) ? $page : 0; +$page = $page == -1 ? 0 : $page; + +if (! $sortfield) $sortfield="cp.rowid"; +if (! $sortorder) $sortorder="DESC"; +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +$order = " ORDER BY $sortfield $sortorder " . $db->plimit( $conf->liste_limit + 1 ,$offset); + + +/************************************* + * Filtres de recherche +*************************************/ + +$max_year = 5; +$min_year = 5; + +$search_ref = $_GET['search_ref']; +$month_create = $_GET['month_create']; +$year_create = $_GET['year_create']; +$month_start = $_GET['month_start']; +$year_start = $_GET['year_start']; +$month_end = $_GET['month_end']; +$year_end = $_GET['year_end']; +$search_employe = $_GET['search_employe']; +$search_valideur = $_GET['search_valideur']; +$search_statut = $_GET['select_statut']; + +// WHERE +if(!empty($search_ref)){ + $filter.= " AND cp.rowid LIKE '%$search_ref%'\n"; +} + +// DATE START +if($year_start > 0) { + if($month_start > 0) { + $filter.= " AND date_format(cp.date_debut, '%Y-%m') = '$year_start-$month_start'"; + } else { + $filter.= " AND date_format(cp.date_debut, '%Y') = '$year_start'"; + } +} else { + if($month_start > 0) { + $filter.= " AND date_format(cp.date_debut, '%m') = '$month_start'"; + } +} + +// DATE FIN +if($year_end > 0) { + if($month_end > 0) { + $filter.= " AND date_format(cp.date_fin, '%Y-%m') = '$year_end-$month_end'"; + } else { + $filter.= " AND date_format(cp.date_fin, '%Y') = '$year_end'"; + } +} else { + if($month_end > 0) { + $filter.= " AND date_format(cp.date_fin, '%m') = '$month_end'"; + } +} + +// DATE CREATE +if($year_create > 0) { + if($month_create > 0) { + $filter.= " AND date_format(cp.date_create, '%Y-%m') = '$year_create-$month_create'"; + } else { + $filter.= " AND date_format(cp.date_create, '%Y') = '$year_create'"; + } +} else { + if($month_create > 0) { + $filter.= " AND date_format(cp.date_create, '%m') = '$month_create'"; + } +} + +// EMPLOYE +if(!empty($search_employe) && $search_employe != -1) { + $filter.= " AND cp.fk_user = '$search_employe'\n"; +} + +// VALIDEUR +if(!empty($search_valideur) && $search_valideur != -1) { + $filter.= " AND cp.fk_validator = '$search_valideur'\n"; +} + +// STATUT +if(!empty($search_statut) && $search_statut != -1) { + $filter.= " AND cp.statut = '$search_statut'\n"; +} + +/************************************* + * Fin des filtres de recherche +*************************************/ + +// Récupération de l'ID de l'utilisateur +$user_id = $user->id; + +// Récupération des congés payés de l'utilisateur ou de tous les users +if(!$user->rights->holiday->lire_tous) +{ + $holiday = new Holiday($db); + $holiday_payes = $holiday->fetchByUser($user_id,$order,$filter); +} +else +{ + $holiday = new Holiday($db); + $holiday_payes = $holiday->fetchAll($order,$filter); +} + +// Si pas de congés payés +if($holiday_payes == 0) +{ + print_fiche_titre($langs->trans('CPTitreMenu')); + + print '
'; + print ''.$langs->trans('NoCPforUser').'

'; + print ''.$langs->trans('AddCP').'
'; + print '
'; + exit(); +} + +// Si erreur SQL +if($holiday_payes == '-1') +{ + print_fiche_titre($langs->trans('CPTitreMenu')); + + print '
'; + print ''.$langs->trans('CPErrorSQL'); + print ' '.$holiday->error.''; + print '
'; + exit(); +} + +/************************************* + * Affichage du tableau des congés payés +*************************************/ + +$var=true; $num = count($holiday->holiday); +$html = new Form($db); +$htmlother = new FormOther($db); +print_barre_liste($langs->trans("ListeCP"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num,$nbtotalofrecords); + +print '
'; + +$nbaquis=$holiday->getCPforUser($user->id); +$nbdeduced=$holiday->getConfCP('nbHolidayDeducted'); +$nb_holiday = $nbaquis / $nbdeduced; +print $langs->trans('SoldeCPUser',round($nb_holiday,2)).($nbdeduced != 1 ? ' ('.$nbaquis.' / '.$nbdeduced.')' : ''); +print '
'; + +print '
'."\n"; +print ''; +print ""; +print_liste_field_titre($langs->trans("ID"),"index.php","cp.rowid","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("DateCreateCP"),"index.php","cp.date_create","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Employe"),"index.php","cp.fk_user","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("ValidatorCP"),"index.php","cp.fk_validator","",'','',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("DateDebCP"),"index.php","cp.date_debut","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("DateFinCP"),"index.php","cp.date_fin","",'','align="center"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans("Duration")); +print_liste_field_titre($langs->trans("Statut"),"index.php","cp.statut","",'','align="center"',$sortfield,$sortorder); +print "\n"; + +// FILTRES +print ''; +print ''; + +// UTILISATEUR +if($user->rights->holiday->lire_tous) { + print ''; +} else { + print ''; +} + +// VALIDEUR +if($user->rights->holiday->lire_tous){ + print ''; +} else { + print ''; +} + +// DATE DEBUT +print ''; + +// DATE FIN +print ''; + +// DUREE +print ''; + +// STATUT +print '\n"; + +if (! empty($holiday->holiday)) +{ + foreach($holiday->holiday as $infos_CP) + { + $var=!$var; + + // Utilisateur + $user = new User($db); + $user->fetch($infos_CP['fk_user']); + + // Valideur + $validator = new User($db); + $validator->fetch($infos_CP['fk_validator']); + + $date = date_create($infos_CP['date_create']); + $date = date_format($date,'Y-m-d'); + + $statut = $holiday->getStatutCP($infos_CP['statut']); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + + } +} + +// Si il n'y a pas d'enregistrement suite à une recherche +if($holiday_payes == '2') +{ + print ''; + print ''; + print ''; +} + +print '
'; +print ''; + +// DATE CREATE +print ''; +print ''; +$htmlother->select_year($year_create,'year_create',1, $min_year, $max_year); +print ''; + $html->select_users($search_employe,"search_employe",1,"",0,''); + print ' '; + + // Liste des utiliseurs du groupes Comptabilité + + $idGroupValid = $holiday->getConfCP('userGroup'); + + $validator = new UserGroup($db,$idGroupValid); + $valideur = $validator->listUsersForGroup(); + + $html->select_users($search_valideur,"search_valideur",1,"",0,$valideur,''); + print ' '; +print ''; +$htmlother->select_year($year_start,'year_start',1, $min_year, $max_year); +print ''; +print ''; +$htmlother->select_year($year_end,'year_end',1, $min_year, $max_year); +print ' '; +$holiday->selectStatutCP($search_statut); +print ''; +print "
CP '.$infos_CP['rowid'].''.$date.''.$user->getNomUrl('1').''.$validator->getNomUrl('1').''.$infos_CP['date_debut'].''.$infos_CP['date_fin'].''.$holiday->getOpenDays(strtotime($infos_CP['date_debut']),strtotime($infos_CP['date_fin'])).' '.$langs->trans('Jours').''.$statut.'
'.$langs->trans('None').'
'; +print '
'; + +print '
'; +print '
'; +print ''.$langs->trans('AddCP').''; +print '
'; + +// Fin de page +$db->close(); +llxFooter(); +?> diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php new file mode 100644 index 00000000000..86666f9f53d --- /dev/null +++ b/htdocs/holiday/month_report.php @@ -0,0 +1,138 @@ + + * Copyright (C) 2011 François Legastelois + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file month_report.php + * \ingroup holiday + * \brief Monthly report of paid holiday. + * \version $Id: month_report.php,v 1.00 2011/09/15 11:00:00 flegastelois Exp $ + * \author flegastelois@teclib.com + * \remarks Monthly report of paid holiday. + */ +require('pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT.'/user/class/user.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'); + +// Protection if external user +if ($user->societe_id > 0) accessforbidden(); + + +// Si l'utilisateur n'a pas le droit de lire cette page +if(!$user->rights->holiday->month_report) accessforbidden(); + + + +/* + * View + */ + +$html = new Form($db); +$htmlother = new FormOther($db); + + +llxHeader($langs->trans('CPTitreMenu')); + +$cp = new Holiday($db); + +$month = GETPOST('month_start'); +$year = GETPOST('year_start'); + +if(empty($month)) { + $month = date('m'); +} +if(empty($year)) { + $year = date('Y'); +} + +$sql = "SELECT cp.fk_user, cp.date_debut, cp.date_fin"; +$sql.= " FROM llx_holiday cp"; +$sql.= " LEFT JOIN llx_user u ON cp.fk_user = u.rowid"; +$sql.= " WHERE cp.rowid > '0'"; +$sql.= " AND cp.statut = 3"; +$sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '$year-$month' + OR date_format(cp.date_fin, '%Y-%m') = '$year-$month')"; +$sql.= " ORDER BY u.name,cp.date_debut"; + +$result = $db->query($sql); +$num = $db->num_rows($result); + +print_fiche_titre($langs->trans('MenuReportMonth')); + +print '
'; + +print '
'."\n"; + +print 'Choix mois :  '; +$htmlother->select_year($year,'year_start',1,10,3); + +print ''; + +print '
'; + +print '
'; + +$var=true; +print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if($num == '0') { + + print ''; + print ''; + print ''; + + } else { + + while($holiday = $db->fetch_array($result)){ + $user = new User($db); + $user->fetch($holiday['fk_user']); + $var=!$var; + + if(substr($holiday['date_debut'],5,2)==$month-1){ + $holiday['date_debut'] = date('Y-'.$month.'-01'); + } + + if(substr($holiday['date_fin'],5,2)==$month+1){ + $holiday['date_fin'] = date('Y-'.$month.'-t'); + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + } + + } +print '
'.$langs->trans('Employee').''.$langs->trans('DateDebCP').''.$langs->trans('DateFinCP').''.$langs->trans('nbJours').'
'.$langs->trans('NoCPforMonth').'
'.$user->nom.' '.$user->prenom.''.$holiday['date_debut'].''.$holiday['date_fin'].''.$cp->getOpenDays(strtotime($holiday['date_debut']),strtotime($holiday['date_fin'])).'
'; +print '
'; + +// Fin de page +$db->close(); +llxFooter(); +?> diff --git a/htdocs/holiday/pre.inc.php b/htdocs/holiday/pre.inc.php new file mode 100644 index 00000000000..6600c4d51b1 --- /dev/null +++ b/htdocs/holiday/pre.inc.php @@ -0,0 +1,113 @@ + + * Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2012 Regis Houssin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file pre.inc.php + * \ingroup holiday + * \brief Load files and menus. + */ + +$res=0; +if (! $res && file_exists("../main.inc.php")) $res=@include("../main.inc.php"); // For root directory +if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php"); // For "custom" directory +if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php"); +if (! $res) die("Include of main fails"); + +dol_include_once("/holiday/class/holiday.class.php"); + +$langs->load("user"); +$langs->load("other"); +$langs->load("holiday"); + + +if (empty($conf->holiday->enabled)) +{ + llxHeader('',$langs->trans('CPTitreMenu')); + print '
'; + print ''.$langs->trans('NotActiveModCP').''; + print '
'; + llxFooter(); + exit(); +} + + +$verifConf.= "SELECT value"; +$verifConf.= " FROM ".MAIN_DB_PREFIX."holiday_config"; +$verifConf.= " WHERE name = 'userGroup'"; + +$result = $db->query($verifConf); +$obj = $db->fetch_object($result); + +if($obj->value == NULL) +{ + llxHeader('',$langs->trans('CPTitreMenu')); + print '
'; + print ''.$langs->trans('NotConfigModCP').''; + print '
'; + llxFooter(); + exit(); +} + + + +function llxHeader($title) +{ + global $user, $conf, $langs; + + top_htmlhead('',$title); + top_menu($head); + + $menu = new Menu(); + + $menu->add("/holiday/index.php?mainmenu=holiday",$langs->trans("CPTitreMenu")); + if($user->rights->holiday->create_edit_read) { + $menu->add("/holiday/fiche.php?mainmenu=holiday&action=request",$langs->trans("MenuAddCP"),2); + } + if($user->rights->holiday->define_holiday) { + $menu->add("/holiday/define_holiday.php?leftmenu=setup&mainmenu=holiday",$langs->trans("MenuConfCP"),2); + } + if($user->rights->holiday->view_log) { + $menu->add("/holiday/view_log.php?mainmenu=holiday",$langs->trans("MenuLogCP"),2); + } + if($user->rights->holiday->view_log) { + $menu->add("/holiday/month_report.php?mainmenu=holiday",$langs->trans("MenuReportMonth"),2); + } + + if(in_array('employees', $conf->modules) && $user->rights->employees->module_access) + { + $menu->add("/employees/index.php",$langs->trans("Menu_Title_EMPLOYEE")); + $menu->add("/employees/index.php",$langs->trans("Menu_List_EMPLOYEE"),2); + $menu->add("/employees/fiche.php?action=create",$langs->trans("Menu_Add_EMPLOYEE"),2); + $menu->add("/employees/hire.php?action=create",$langs->trans("Menu_Add_HIRE"),2); + $menu->add("/employees/salary.php?action=create",$langs->trans("Menu_Add_SALARY"),2); + $menu->add("/employees/job.php?action=create",$langs->trans("Menu_Add_JOB"),2); + $menu->add("/employees/disease.php?action=create",$langs->trans("Menu_Add_DISEASE"),2); + $menu->add("/employees/month_report_disease.php",$langs->trans("Menu_Report_Disease"),2); + $menu->add("/employees/set_hire_type.php",$langs->trans("Menu_Set_Hire_type"),2); + + if(!isset($_SESSION['employees_passphrase'])){ + $menu->add("/employees/store_secure.php",$langs->trans("Menu_Store_Secure"),2); + } + } + + left_menu($menu->liste); +} + +?> diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php new file mode 100644 index 00000000000..e3460839f66 --- /dev/null +++ b/htdocs/holiday/view_log.php @@ -0,0 +1,101 @@ + + * Copyright (C) 2011 Dimitri Mouillard +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * Displays the log of actions performed in the module. + * + * \file view_log.php + * \ingroup holiday + */ + +require('pre.inc.php'); +require_once(DOL_DOCUMENT_ROOT. "/user/class/user.class.php"); + +// Protection if external user +if ($user->societe_id > 0) accessforbidden(); + +// Si l'utilisateur n'a pas le droit de lire cette page +if(!$user->rights->holiday->view_log) accessforbidden(); + + + +/* + * View +*/ + +llxHeader($langs->trans('CPTitreMenu')); + + +$cp = new Holiday($db); +$log_holiday = $cp->fetchLog('',''); + +print_fiche_titre($langs->trans('LogCP')); + +print ''; +print ''; +print ''; + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print ''; +$var=true; + +foreach($cp->logs as $logs_CP) +{ + $var=!$var; + + $user_action = new User($db); + $user_action->fetch($logs_CP['fk_user_action']); + + $user_update = new User($db); + $user_update->fetch($logs_CP['fk_user_update']); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''."\n"; + +} + +if($log_holiday == '2') +{ + print ''; + print ''; + print ''; +} + +print ''."\n"; +print '
'.$langs->trans('ID').''.$langs->trans('Date').''.$langs->trans('ActionByCP').''.$langs->trans('UserUpdateCP').''.$langs->trans('ActionTypeCP').''.$langs->trans('PrevSoldeCP').''.$langs->trans('NewSoldeCP').'
'.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getFullName($langs).''.$user_update->getFullName($langs).''.$logs_CP['type_action'].''.$logs_CP['prev_solde'].' jours'.$logs_CP['new_solde'].' jours
'.$langs->trans('NoResult').'
'."\n"; + + +// Fin de page +$db->close(); +llxFooter(); +?> diff --git a/htdocs/install/mysql/data/llx_holiday_config.sql b/htdocs/install/mysql/data/llx_holiday_config.sql new file mode 100644 index 00000000000..c92812cbd92 --- /dev/null +++ b/htdocs/install/mysql/data/llx_holiday_config.sql @@ -0,0 +1,8 @@ +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'userGroup', NULL); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'lastUpdate', NULL); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'nbUser', NULL); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'delayForRequest', '31'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'AlertValidatorDelay', '0'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'AlertValidatorSolde', '0'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'nbHolidayDeducted', '1'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'nbHolidayEveryMonth', '2.5'); diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql index f9ad48af159..3b93d301c8c 100755 --- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql +++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql @@ -123,3 +123,70 @@ create table llx_element_tag ALTER TABLE llx_element_tag ADD UNIQUE INDEX uk_element_tag (entity, lang, tag, fk_element, element); -- END TASK #107 + + +CREATE TABLE llx_holiday_config +( +rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, +name VARCHAR( 255 ) NOT NULL UNIQUE, +value TEXT NULL +) +ENGINE=innodb; + +CREATE TABLE llx_holiday_events +( +rowid INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT , +name VARCHAR( 255 ) NOT NULL , +value TEXT NOT NULL +) +ENGINE=innodb; + +CREATE TABLE llx_holiday_logs +( +rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +date_action DATETIME NOT NULL , +fk_user_action INT( 11 ) NOT NULL , +fk_user_update INT( 11 ) NOT NULL , +type_action VARCHAR( 255 ) NOT NULL , +prev_solde VARCHAR( 255 ) NOT NULL , +new_solde VARCHAR( 255 ) NOT NULL +) +ENGINE=innodb; + +CREATE TABLE llx_holiday_users +( +fk_user INT( 11 ) NOT NULL PRIMARY KEY, +nb_holiday FLOAT( 5 ) NOT NULL DEFAULT '0' +) +ENGINE=innodb; + +CREATE TABLE llx_holiday +( +rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, +fk_user INT( 11 ) NOT NULL , +date_create DATETIME NOT NULL , +description VARCHAR( 255 ) NOT NULL , +date_debut DATE NOT NULL , +date_fin DATE NOT NULL , +statut INT( 11 ) NOT NULL DEFAULT '1', +fk_validator INT( 11 ) NOT NULL , +date_valid DATETIME NULL DEFAULT NULL , +fk_user_valid INT( 11 ) NULL DEFAULT NULL , +date_refuse DATETIME NULL DEFAULT NULL , +fk_user_refuse INT( 11 ) NULL DEFAULT NULL , +date_cancel DATETIME NULL DEFAULT NULL , +fk_user_cancel INT( 11 ) NULL DEFAULT NULL, +detail_refuse varchar( 250 ) NULL DEFAULT NULL +) +ENGINE=innodb; + + +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'userGroup', NULL); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'lastUpdate', NULL); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'nbUser', NULL); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'delayForRequest', '31'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'AlertValidatorDelay', '0'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'AlertValidatorSolde', '0'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'nbHolidayDeducted', '1'); +INSERT INTO llx_holiday_config (rowid ,name ,value) VALUES (NULL , 'nbHolidayEveryMonth', '2.5'); + diff --git a/htdocs/install/mysql/tables/llx_holiday.sql b/htdocs/install/mysql/tables/llx_holiday.sql new file mode 100644 index 00000000000..637d0903ad6 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday.sql @@ -0,0 +1,19 @@ +CREATE TABLE llx_holiday +( +rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, +fk_user INT( 11 ) NOT NULL , +date_create DATETIME NOT NULL , +description VARCHAR( 255 ) NOT NULL , +date_debut DATE NOT NULL , +date_fin DATE NOT NULL , +statut INT( 11 ) NOT NULL DEFAULT '1', +fk_validator INT( 11 ) NOT NULL , +date_valid DATETIME NULL DEFAULT NULL , +fk_user_valid INT( 11 ) NULL DEFAULT NULL , +date_refuse DATETIME NULL DEFAULT NULL , +fk_user_refuse INT( 11 ) NULL DEFAULT NULL , +date_cancel DATETIME NULL DEFAULT NULL , +fk_user_cancel INT( 11 ) NULL DEFAULT NULL, +detail_refuse varchar( 250 ) NULL DEFAULT NULL +) +ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_holiday_config.sql b/htdocs/install/mysql/tables/llx_holiday_config.sql new file mode 100644 index 00000000000..ea4a1cf767b --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_config.sql @@ -0,0 +1,7 @@ +CREATE TABLE llx_holiday_config +( +rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, +name VARCHAR( 255 ) NOT NULL UNIQUE, +value TEXT NULL +) +ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_holiday_events.sql b/htdocs/install/mysql/tables/llx_holiday_events.sql new file mode 100644 index 00000000000..0445bd7c6e4 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_events.sql @@ -0,0 +1,7 @@ +CREATE TABLE llx_holiday_events +( +rowid INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT , +name VARCHAR( 255 ) NOT NULL , +value TEXT NOT NULL +) +ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_holiday_logs.sql b/htdocs/install/mysql/tables/llx_holiday_logs.sql new file mode 100644 index 00000000000..de70b4e370d --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_logs.sql @@ -0,0 +1,11 @@ +CREATE TABLE llx_holiday_logs +( +rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , +date_action DATETIME NOT NULL , +fk_user_action INT( 11 ) NOT NULL , +fk_user_update INT( 11 ) NOT NULL , +type_action VARCHAR( 255 ) NOT NULL , +prev_solde VARCHAR( 255 ) NOT NULL , +new_solde VARCHAR( 255 ) NOT NULL +) +ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/install/mysql/tables/llx_holiday_users.sql b/htdocs/install/mysql/tables/llx_holiday_users.sql new file mode 100644 index 00000000000..cf41254e911 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_holiday_users.sql @@ -0,0 +1,6 @@ +CREATE TABLE llx_holiday_users +( +fk_user INT( 11 ) NOT NULL PRIMARY KEY, +nb_holiday FLOAT( 5 ) NOT NULL DEFAULT '0' +) +ENGINE=innodb; \ No newline at end of file diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang new file mode 100755 index 00000000000..46c9e7d941e --- /dev/null +++ b/htdocs/langs/en_US/holiday.lang @@ -0,0 +1,130 @@ +# Dolibarr language file - en_US - holiday +CHARSET= UTF-8 + +CPTitreMenu=Holidays +MenuReportMonth=Monthly statement +MenuAddCP=Demand for holidays +NotActiveModCP=You must enable the module holidays to view this page. +NotConfigModCP=You must configure the module holidays to view this page. To do this, click here . +NoCPforUser=You don't have a demand for holidays. +AddCP=Apply for holidays +CPErrorSQL=An SQL error occurred: +Employe=Employee +DateDebCP=Start date +DateFinCP=End date +DateCreateCP=Creation date +DraftCP=Draft +ToValidateCP=Awaiting approval +ValidateCP=Validated +CancelCP=Canceled +RefuseCP=Refused +ValidatorCP=Validator +ListeCP=List of holidays +ValidateByCP=Will be validated by +DescCP=Description +SendRequestCP=Creating demand for holidays +DelayToRequestCP=Applications for holidays must be made at least % s day before them. +MenuConfCP=Define the holidays +UpdateAllCP=Update the holidays +SoldeCPUser=Your balance of holidays is %s days. +ErrorEndDateCP=You must select an end date greater than the start date. +ErrorSQLCreateCP=An SQL error occurred during the creation: +ErrorIDFicheCP=An error has occurred, the request for holidays does not exist. +ReturnCP=Return to previous page +ErrorUserViewCP=You are not authorized to read this request for holidays. +InfosCP=Information of the demand of holidays +InfosWorkflowCP=Information Workflow +DateCreateCP=Creation date +RequestByCP=Requested by +TitreRequestCP=Sheet of holidays +NbUseDaysCP=Number of days of holidays consumed +EditCP=Edit +DeleteCP=Delete +ActionValidCP=Validate +ActionRefuseCP=Refuse +ActionCancelCP=Cancel +StatutCP=Status +SendToValidationCP=Send to validation +TitleDeleteCP=Delete the request of holidays +ConfirmDeleteCP=Confirm the deletion of this request for holidays? +ErrorCantDeleteCP=Error you don't have the right to delete this request of holidays. +CantCreateCP=You don't have the right to apply for holidays. +InvalidValidatorCP=You must choose a validator to your request of holidays. +UpdateButtonCP=Update +CantUpdate=You cannot update this request of holidays. +NoDateDebut=You must select a start date. +NoDateFin=You must select an end date. +ErrorDureeCP=Your request for holidays does not contain working day. +TitleValidCP=Validate the request holidays +ConfirmValidCP=Are you sure you want to validate the request of holidays? +DateValidCP=Date validation +TitleToValidCP=Send request holidays +ConfirmToValidCP=Are you sure you want to send the request of holidays? +TitleRefuseCP=Refuse the request holidays +ConfirmRefuseCP=Are you sure you want to refuse the request of holidays? +NoMotifRefuseCP=You must choose a reason for refusing the request. +TitleCancelCP=Cancel the request holidays +ConfirmCancelCP=Are you sure you want to cancel the request of holidays? +DetailRefusCP=Reason for refusal +DateRefusCP=Date of refusal +DateCancelCP=Date of cancellation +DefineEventUserCP=Assign an exceptional leave for a user +addEventToUserCP=Assign leave +MotifCP=Reason +UserCP=User +ErrorAddEventToUserCP=An error occurred while adding the exceptional leave. +AddEventToUserOkCP=The addition of the exceptional leave has been completed. +MenuLogCP=View logs of holidays +LogCP=Log of updates of holidays +ActionByCP=Performed by +UserUpdateCP=For the user +ActionTypeCP=Type +PrevSoldeCP=Previous Balance +NewSoldeCP=New Balance +alreadyCPexist=A request for holidays has already been done on this period. +UserName=Name +Employee=Employee + + +## Configuration du Module ## +ConfCP=Configuration of holidays module +DescOptionCP=Description of the option +ValueOptionCP=Value +GroupToValidateCP=Group with the ability to validate holidays +ConfirmConfigCP=Validate the configuration +LastUpdateCP=Last updated automatically of holidays +UpdateConfCPOK=Updated successfully. +ErrorUpdateConfCP=An error occurred during the update, please try again. +AddCPforUsers=Please add the balance of holidays of users by clicking here. +DelayForSubmitCP=Deadline to apply for holidays +AlertValidatorDelayCP=Prevent the validator if the request for leave to meet the deadline +AlertValidorSoldeCP=Prevent the validator if the user requests holidays exceeding the balance +nbUserCP=Number of users supported in the module holidays +nbHolidayDeductedCP=Number of holidays to be deducted per day of holiday taken +nbHolidayEveryMonthCP=Number of holidays added every month +Module27130Name= Management of holidays +Module27130Desc= Management of holidays +TitleOptionMainCP=Main settings of holidays +TitleOptionEventCP=Settings of holidays related to events +ValidEventCP=Validate +UpdateEventCP=Update events +CreateEventCP=Create +NameEventCP=Event name +OkCreateEventCP=The addition of the event went well. +ErrorCreateEventCP=Error creating the event. +UpdateEventOkCP=The update of the event went well. +ErrorUpdateEventCP=Error while updating the event. +DeleteEventCP=Delete Event +DeleteEventOkCP=The event has been deleted. +ErrorDeleteEventCP=Error while deleting the event. +TitleDeleteEventCP=Delete a exceptional leave +TitleCreateEventCP=Create a exceptional leave +TitleUpdateEventCP=Edit or delete a exceptional leave +DeleteEventOptionCP=Delete +UpdateEventOptionCP=Update +ErrorMailNotSend=An error occurred while sending email: +NoCPforMonth=No leave this month. +Jours=days +nbJours=Number days +TitleAdminCP=Configuration of Holidays +Permission20001=Read / Modify all requests of holidays diff --git a/htdocs/langs/fr_FR/holiday.lang b/htdocs/langs/fr_FR/holiday.lang new file mode 100644 index 00000000000..d6960b2c8dd --- /dev/null +++ b/htdocs/langs/fr_FR/holiday.lang @@ -0,0 +1,129 @@ +# Dolibarr language file - fr_FR - holiday +CHARSET= UTF-8 + +CPTitreMenu=Congés +MenuReportMonth=Etat mensuel +MenuAddCP=Nouvelle demande +NotActiveModCP=Vous devez activer le module Congés pour afficher cette page. +NotConfigModCP=Vous devez configurer le module Congés pour afficher cette page. Pour effectuer cette opération, cliquer ici. +NoCPforUser=Vous n'avez pas encore de demande de congés. +AddCP=Créer demande de congés +CPErrorSQL=Une erreur SQL est survenue : +Employe=Employé +DateDebCP=Date Début +DateFinCP=Date Fin +DateCreateCP=Date de création +DraftCP=Brouillon +ToValidateCP=En attente de validation +ValidateCP=Validée +CancelCP=Annulée +RefuseCP=Refusée +ValidatorCP=Valideur +ListeCP=Liste des congés +ValidateByCP=Sera validée par +DescCP=Description +SendRequestCP=Envoyer la demande de congés +DelayToRequestCP=Les demandes de congés doivent être faites au moins %s jours avant la date de ceux-ci. +MenuConfCP=Définir les congés +UpdateAllCP=Mettre à jour les congés +SoldeCPUser=Votre solde de congés est de %s jours. +ErrorEndDateCP=Vous devez choisir une date de fin supérieur à la date de début. +ErrorSQLCreateCP=Une erreur SQL est survenue durant la création : +ErrorIDFicheCP=Une erreur est survenue, cette demande de congés n'existe pas. +ReturnCP=Retour à la page précédente +ErrorUserViewCP=Vous n'êtes pas autorisé à lire cette demande de congés. +InfosCP=Informations de la demande de congés +InfosWorkflowCP=Informations du workflow +DateCreateCP=Date de création +RequestByCP=Demandée par +TitreRequestCP=Fiche Congés +NbUseDaysCP=Nombre de jours de congés consommés +EditCP=Modifier +DeleteCP=Supprimer +ActionValidCP=Valider +ActionRefuseCP=Refuser +ActionCancelCP=Annuler +StatutCP=Statut +SendToValidationCP=Envoyer en validation +TitleDeleteCP=Supprimer la demande de Congés +ConfirmDeleteCP=Confirmer la suppression de cette demande de congés ? +ErrorCantDeleteCP=Erreur, vous n'avez pas le droit de supprimer cette demande de congés. +CantCreateCP=Vous n'avez pas le droit de faire des demandes de congés. +InvalidValidatorCP=Vous devez choisir un valideur pour votre demande de congés. +UpdateButtonCP=Mettre à jour +CantUpdate=Vous ne pouvez pas mettre à jour cette demande de congés. +NoDateDebut=Vous devez choisir une date de début. +NoDateFin=Vous devez choisir une date de fin. +ErrorDureeCP=Votre demande de congés payés ne contient aucun jour ouvré. +TitleValidCP=Valider la demande de Congés Payés +ConfirmValidCP=Êtes-vous sûr de vouloir valider la demande de congés ? +DateValidCP=Date de validation +TitleToValidCP=Envoyer la demande de Congés Payés +ConfirmToValidCP=Êtes-vous sûr de vouloir envoyer la demande de congés ? +TitleRefuseCP=Refuser la demande de Congés Payés +ConfirmRefuseCP=Êtes-vous sûr de vouloir refuser la demande de congés ? +NoMotifRefuseCP=Vous devez choisir un motif pour refuser cette demande. +TitleCancelCP=Annuler la demande de Congés Payés +ConfirmCancelCP=Êtes-vous sûr de vouloir annuler la demande de congés ? +DetailRefusCP=Motif du refus +DateRefusCP=Date du refus +DateCancelCP=Date de l'annulation +DefineEventUserCP=Attribuer un congé exceptionnel à un utilisateur +addEventToUserCP=Attribuer ce congé +MotifCP=Motif +UserCP=Utilisateur +ErrorAddEventToUserCP=Une erreur est survenue durant l'ajout du congé exceptionnel. +AddEventToUserOkCP=L'ajout du congé exceptionnel à bien été effectué. +MenuLogCP=Voir les logs des congés +LogCP=Logs des mises à jours des congés +ActionByCP=Réalisée par +UserUpdateCP=Pour l'utilisateur +ActionTypeCP=Type +PrevSoldeCP=Précédent Solde +NewSoldeCP=Nouveau Solde +alreadyCPexist=Une demande de congés à déjà été effectuée sur cette période. +UserName=Nom Prénom +Employee=Salarié + + +## Configuration du Module ## +ConfCP=Configuration du module Congés +DescOptionCP=Description de l'option +ValueOptionCP=Valeur +GroupToValidateCP=Groupe ayant la possibilité de valider les congés +ConfirmConfigCP=Valider la configuration +LastUpdateCP=Dernière mise à jour automatique des congés +UpdateConfCPOK=Mise à jour effectuée avec succès. +ErrorUpdateConfCP=Une erreur à eu lieu durant la mise à jour, merci de réessayer. +AddCPforUsers=Veuillez ajouter le solde des congés des utilisateurs en cliquant ici. +DelayForSubmitCP=Délai pour faire une demande de congés avant ceux-ci +AlertValidatorDelayCP=Prévenir le valideur si la demande de congés ne respecte le délai prévu +AlertValidorSoldeCP=Prévenir le valideur si l'utilisateur demande des congés dépassant son solde +nbUserCP=Nombre d'utilisateur pris en charge dans le module congés +nbHolidayDeductedCP=Nombre de congés payés à déduire par jour de congé pris +nbHolidayEveryMonthCP=Nombre de congés payés ajoutés chaque mois +Module27130Name= Gestion des congés +TitleOptionMainCP=Réglages principaux des congés +TitleOptionEventCP=Réglages des congés liés à des évènements +ValidEventCP=Valider +UpdateEventCP=Mettre à jour les évènements +CreateEventCP=Créer +NameEventCP=Nom de l'évènement +OkCreateEventCP=L'ajout de l'évènement s'est bien déroulé. +ErrorCreateEventCP=Erreur lors de la création de l'évènement. +UpdateEventOkCP=La mise à jour de l'évènement s'est bien déroulé. +ErrorUpdateEventCP=Erreur lors de la mise à jour de l'évènement. +DeleteEventCP=Supprimer l'évènement +DeleteEventOkCP=L'évènement à bien été supprimé. +ErrorDeleteEventCP=Erreur lors de la suppression de l'évènement. +TitleDeleteEventCP=Supprimer un congé exceptionnel +TitleCreateEventCP=Créer un congé exceptionnel +TitleUpdateEventCP=Modifier ou supprimer un congé exceptionnel +DeleteEventOptionCP=Supprimer +UpdateEventOptionCP=Mettre à jour +ErrorMailNotSend=Une erreur est survenue lors de l'envoi du mail : +NoCPforMonth=Aucun congé ce mois-ci. +Jours=jours +nbJours=Nombre jours +TitleAdminCP=Configuration des Congés +Permission20001=Lire / Créer / modifier ses congès \ No newline at end of file diff --git a/htdocs/theme/amarok/img/object_holiday.png b/htdocs/theme/amarok/img/object_holiday.png new file mode 100644 index 00000000000..69ccdb279a5 Binary files /dev/null and b/htdocs/theme/amarok/img/object_holiday.png differ diff --git a/htdocs/theme/auguria/img/object_holiday.png b/htdocs/theme/auguria/img/object_holiday.png new file mode 100644 index 00000000000..69ccdb279a5 Binary files /dev/null and b/htdocs/theme/auguria/img/object_holiday.png differ diff --git a/htdocs/theme/bureau2crea/img/object_holiday.png b/htdocs/theme/bureau2crea/img/object_holiday.png new file mode 100644 index 00000000000..69ccdb279a5 Binary files /dev/null and b/htdocs/theme/bureau2crea/img/object_holiday.png differ diff --git a/htdocs/theme/cameleo/img/object_holiday.png b/htdocs/theme/cameleo/img/object_holiday.png new file mode 100644 index 00000000000..69ccdb279a5 Binary files /dev/null and b/htdocs/theme/cameleo/img/object_holiday.png differ diff --git a/htdocs/theme/eldy/img/object_holiday.png b/htdocs/theme/eldy/img/object_holiday.png new file mode 100644 index 00000000000..69ccdb279a5 Binary files /dev/null and b/htdocs/theme/eldy/img/object_holiday.png differ