diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index fe0cbb9e27b..a1a73ad1c2f 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1705,14 +1705,11 @@ else print ''; } - // Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { - print ''; $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid); - print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); - print ''; + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } } // Ligne en mode update @@ -1767,7 +1764,8 @@ else print ''; print '
'; print ''; - + print ''; + $colspan=6; if (! empty($conf->margin->enabled) && ! empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) $colspan++; if($conf->global->PRODUCT_USE_UNITS) $colspan++; @@ -1780,16 +1778,13 @@ else print '   '.$langs->trans("DateEndPlanned").' '; $form->select_date($db->jdate($objp->date_fin),"date_end_update",$usehm,$usehm,($db->jdate($objp->date_fin)>0?0:1),"update"); print ''; + print ''; if (is_array($extralabelslines) && count($extralabelslines)>0) { - print ''; $line = new ContratLigne($db); $line->fetch_optionals($objp->rowid); - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); - print ''; + print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } - - print ''; } $db->free($result); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 64e1d05657b..8ec7fa36b73 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5908,15 +5908,15 @@ abstract class CommonObject /** * Function to show lines of extrafields with output datas * - * @param Extrafields $extrafields Extrafield Object - * @param string $mode Show output (view) or input (edit) for extrafield - * @param array $params Optional parameters - * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) - * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) - * - * @return string + * @param Extrafields $extrafields Extrafield Object + * @param string $mode Show output (view) or input (edit) for extrafield + * @param array $params Optional parameters + * @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names) + * @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names) + * @param string $onetrtd All fields in same tr td + * @return string */ - function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='') + function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='', $onetrtd=0) { global $_POST, $conf, $langs, $action; @@ -5980,15 +5980,13 @@ abstract class CommonObject $csstyle=$params['style']; } } - if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) + + $out .= ''; + if (empty($onetrtd)) { - $out .= ''; - $colspan='0'; - } - else - { - $out .= ''; + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; } } + // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { @@ -6006,10 +6004,17 @@ abstract class CommonObject { $labeltoshow = ''.$labeltoshow.''; } - $out .= ''.$labeltoshow.''; + + if (empty($onetrtd)) $out .= ''; + else $out .= ''; + + $out .= $labeltoshow; + + if (empty($onetrtd)) $out .= ''; + else $out.=' '; $html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : ''; - $out .=''; + $out .=''; switch($mode) { case "view": @@ -6021,9 +6026,8 @@ abstract class CommonObject } $out .= ''; + $out .= ''; - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; - else $out .= ''; $e++; } } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index ac866d1213c..6937af8c3f7 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -425,7 +425,7 @@ class Conf if (empty($this->global->MAIN_MONNAIE)) $this->global->MAIN_MONNAIE='EUR'; $this->currency=$this->global->MAIN_MONNAIE; - if (empty($conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $conf->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure + if (empty($this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY)) $this->global->MAIN_BROWSER_NOTIFICATION_FREQUENCY = 30; // Less than 1 minutes to be sure // conf->global->ACCOUNTING_MODE = Option des modules Comptabilites (simple ou expert). Defini le mode de calcul des etats comptables (CA,...) if (empty($this->global->ACCOUNTING_MODE)) $this->global->ACCOUNTING_MODE='RECETTES-DEPENSES'; // By default. Can be 'RECETTES-DEPENSES' ou 'CREANCES-DETTES' @@ -584,15 +584,15 @@ class Conf if (! isset($this->global->THEME_HIDE_BORDER_ON_INPUT)) $this->global->THEME_HIDE_BORDER_ON_INPUT=0; // Save inconsistent option - if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && (! isset($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $conf->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) + if (empty($this->global->AGENDA_USE_EVENT_TYPE) && (! isset($this->global->AGENDA_DEFAULT_FILTER_TYPE) || $this->global->AGENDA_DEFAULT_FILTER_TYPE == 'AC_NON_AUTO')) { - $conf->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. + $this->global->AGENDA_DEFAULT_FILTER_TYPE='0'; // 'AC_NON_AUTO' does not exists when AGENDA_DEFAULT_FILTER_TYPE is not on. } if (! isset($this->global->MAIN_EXTRAFIELDS_IN_ONE_TD)) $this->global->MAIN_EXTRAFIELDS_IN_ONE_TD = 1; - $conf->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; - $conf->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; + $this->global->MAIN_MODULE_DOLISTORE_API_SRV='https://www.dolistore.com'; + $this->global->MAIN_MODULE_DOLISTORE_API_KEY='dolistorecatalogpublickey1234567'; // For backward compatibility if (isset($this->product)) $this->produit=$this->product; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 23758a1de5e..4cd3a9f0a72 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1447,7 +1447,7 @@ class Form /** * Return select list of users * - * @param string $selected User id or user object of user preselected. If -1, we use id of current user. + * @param string $selected User id or user object of user preselected. If 0 or < -2, we use id of current user. If -1, keep unselected (if empty is allowed) * @param string $htmlname Field name in form * @param int $show_empty 0=list with no empty value, 1=add also an empty value into list * @param array $exclude Array list of users id to exclude diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 75f002d9a57..204af818d20 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -352,7 +352,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5000__+MAX_llx_menu__, 'hrm', 'hrm', 15__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'CPTitreMenu', 0, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5001__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/card.php?&action=request', 'MenuAddCP', 1, 'holiday', '$user->rights->holiday->write', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5002__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/list.php?&leftmenu=hrm', 'List', 1, 'holiday', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?select_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5003__+MAX_llx_menu__, 'hrm', '', 5002__+MAX_llx_menu__, '/holiday/list.php?search_statut=2&leftmenu=hrm', 'ListToApprove', 2, 'trips', '$user->rights->holiday->read', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5004__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?&action=request', 'MenuConfCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->holiday->enabled', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?&action=request', 'MenuLogCP', 1, 'holiday', '$user->rights->holiday->define_holiday', '', 0, 3, __ENTITY__); -- HRM - Trips and expenses (old module) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 039150409a9..0fe22806568 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1371,11 +1371,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm'); $newmenu->add("/holiday/card.php?action=request", $langs->trans("New"), 1,$user->rights->holiday->write); $newmenu->add("/holiday/list.php?leftmenu=hrm", $langs->trans("List"), 1,$user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?select_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=1&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=2&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=3&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=4&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); + if ($usemenuhider || empty($leftmenu) || $leftmenu=="hrm") $newmenu->add("/holiday/list.php?search_statut=5&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); $newmenu->add("/holiday/define_holiday.php?action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); $newmenu->add("/holiday/month_report.php", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->read_all); $newmenu->add("/holiday/view_log.php?action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index e2dfed0f68b..fdef8a03ed8 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -58,6 +58,37 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; $colspan = 3; // Col total ht + col edit + col delete if (in_array($object->element,array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button //print $object->element; + +// Lines for extrafield +$objectline = null; +if (!empty($extrafieldsline)) +{ + if ($this->table_element_line=='commandedet') { + $objectline = new OrderLine($this->db); + } + elseif ($this->table_element_line=='propaldet') { + $objectline = new PropaleLigne($this->db); + } + elseif ($this->table_element_line=='supplier_proposaldet') { + $objectline = new SupplierProposalLine($this->db); + } + elseif ($this->table_element_line=='facturedet') { + $objectline = new FactureLigne($this->db); + } + elseif ($this->table_element_line=='contratdet') { + $objectline = new ContratLigne($this->db); + } + elseif ($this->table_element_line=='commande_fournisseurdet') { + $objectline = new CommandeFournisseurLigne($this->db); + } + elseif ($this->table_element_line=='facture_fourn_det') { + $objectline = new SupplierInvoiceLine($this->db); + } + elseif ($this->table_element_line=='facturedet_rec') { + $objectline = new FactureLigneRec($this->db); + } +} + ?> @@ -384,41 +415,14 @@ else { - table_element_line=='commandedet') { - $newline = new OrderLine($this->db); - } - elseif ($this->table_element_line=='propaldet') { - $newline = new PropaleLigne($this->db); - } - elseif ($this->table_element_line=='supplier_proposaldet') { - $newline = new SupplierProposalLine($this->db); - } - elseif ($this->table_element_line=='facturedet') { - $newline = new FactureLigne($this->db); - } - elseif ($this->table_element_line=='contratdet') { - $newline = new ContratLigne($this->db); - } - elseif ($this->table_element_line=='commande_fournisseurdet') { - $newline = new CommandeFournisseurLigne($this->db); - } - elseif ($this->table_element_line=='facture_fourn_det') { - $newline = new SupplierInvoiceLine($this->db); - } - elseif ($this->table_element_line=='facturedet_rec') { - $newline = new FactureLigneRec($this->db); - } - if (is_object($newline)) { - print $newline->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8)); - } - } - ?> +showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay+8), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); +} +?> + service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 30b4f01cfb8..63321d16506 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -240,16 +240,16 @@ $coldisplay=-1; // We remove first td ">
"> - - showOptionals($extrafieldsline,'edit',array('style'=>$bc[$var],'colspan'=>$coldisplay)); - } - ?> +showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); +} +?> + service->enabled) && $line->product_type == 1 && $dateSelector) { ?> > global->MAIN_VIEW_LINE_NUMBER)) { ?> diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index d24a094b9f0..4f0b1cb8a99 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -304,14 +304,14 @@ if (empty($outputalsopricetotalwithtax)) $outputalsopricetotalwithtax=0; + + showOptionals($extrafieldsline,'view',array('style'=>$bcdd[$var],'colspan'=>$coldisplay)); + print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcdd[$var],'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> - - diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 2c05350fd43..23744912c9b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -50,6 +50,18 @@ $now=dol_now(); $langs->load("holiday"); +$childids = $user->getAllChildIds(1); + +$cancreate = 0; +if (! empty($user->rights->holiday->write_all)) $cancreate=1; +if (! empty($user->rights->holiday->write) && in_array($fuserid, $childids)) $cancreate=1; + +$candelete = 0; +if (! empty($user->rights->holiday->delete)) $candelete=1; + +$morefilter = 'AND employee = 1'; +if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; + /* * Actions @@ -61,8 +73,7 @@ if ($action == 'create') $object = new Holiday($db); // If no right to create a request - $fuserid = GETPOST('fuserid','int'); - if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all))) + if (! $cancreate) { $error++; setEventMessages($langs->trans('CantCreateCP'), null, 'errors'); @@ -201,13 +212,11 @@ if ($action == 'update') $object = new Holiday($db); $object->fetch($id); - $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); - // If under validation if ($object->statut == 1) { // If this is the requestor or has read/write rights - if ($canedit) + if ($cancreate) { $valideur = $_POST['valideur']; $description = trim($_POST['description']); @@ -280,13 +289,11 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- $object = new Holiday($db); $object->fetch($id); - $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); - // If this is a rough draft, approved, canceled or refused if ($object->statut == 1 || $object->statut == 4 || $object->statut == 5) { // Si l'utilisateur à le droit de lire cette demande, il peut la supprimer - if ($canedit) + if ($candelete) { $result=$object->delete($user); } @@ -314,10 +321,8 @@ if ($action == 'confirm_send') $object = new Holiday($db); $object->fetch($id); - $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); - // Si brouillon et créateur - if($object->statut == 1 && $canedit) + if($object->statut == 1 && $cancreate) { $object->statut = 2; @@ -615,7 +620,7 @@ if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') $object->fetch($id); // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres - if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all))) + if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all))) { $db->begin(); @@ -849,10 +854,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; if (empty($user->rights->holiday->write_all)) { - print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); - print ''; + print $form->select_dolusers(($fuserid?$fuserid:$user->id), 'fuserid', 0, '', 0, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth300'); + //print ''; } - else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, 'AND employee = 1'); + else print $form->select_dolusers(GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id, 'fuserid', 0, '', 0, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth300'); print ''; print ''; @@ -957,8 +962,6 @@ else { $object->fetch($id); - $canedit=(($user->id == $object->fk_user && $user->rights->holiday->write) || ($user->id != $object->fk_user && $user->rights->holiday->write_all)); - $valideur = new User($db); $valideur->fetch($object->fk_validator); @@ -1005,7 +1008,7 @@ else } // On vérifie si l'utilisateur à le droit de lire cette demande - if ($canedit) + if ($cancreate) { if ($action == 'delete') { @@ -1244,7 +1247,7 @@ else if ($action == 'edit' && $object->statut == 1) { print '
'; - if ($canedit && $object->statut == 1) + if ($cancreate && $object->statut == 1) { print ''; } @@ -1259,11 +1262,11 @@ else print '
'; // Boutons d'actions - if ($canedit && $object->statut == 1) + if ($cancreate && $object->statut == 1) { print ''.$langs->trans("EditCP").''; } - if ($canedit && $object->statut == 1) + if ($cancreate && $object->statut == 1) // If draft { print ''.$langs->trans("Validate").''; } @@ -1272,7 +1275,7 @@ else print ''.$langs->trans("DeleteCP").''; } - if ($object->statut == 2) + if ($object->statut == 2) // If validated { if ($user->id == $object->fk_validator) { @@ -1286,13 +1289,13 @@ else } } - if (($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved + if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved { if (($object->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; else print ''.$langs->trans("ActionCancelCP").''; } - if ($canedit && $object->statut == 4) + if ($cancreate && $object->statut == 4) { print ''.$langs->trans("SetToDraft").''; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c3c894d5088..67ef15c74ef 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -958,7 +958,7 @@ class Holiday extends CommonObject * Affiche un select HTML des statuts de congés payés * * @param int $selected Id of preselected status - * @param string $select_statut Name of HTML select field + * @param string $htmlname Name of HTML select field * @return string Show select of status */ function selectStatutCP($selected='', $htmlname='select_statut') { diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index bf5a7906f7a..d417fd7d5a5 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -107,6 +107,7 @@ $fieldstosearchall = array( 'uu.firstname'=>'EmployeeFirstname' ); +$childids = $user->getAllChildIds(1); /* @@ -171,9 +172,6 @@ $holiday = new Holiday($db); $holidaystatic=new Holiday($db); $fuser = new User($db); -$childids = $user->getAllChildIds(); -$childids[]=$user->id; - // Update sold $result = $holiday->updateBalance(); @@ -313,7 +311,7 @@ if ($search_year_create) $param.='&search_year_create='.urlencode($searc if ($search_search_day_start) $param.='&search_day_start='.urlencode($search_day_start); if ($search_month_start) $param.='&search_month_start='.urlencode($search_month_start); if ($search_year_start) $param.='&search_year_start='.urlencode($search_year_start); -if ($day_end) $param.='&day_end='.urlencode($day_end); +if ($search_day_end) $param.='&search_day_end='.urlencode($search_day_end); if ($search_month_end) $param.='&search_month_end='.urlencode($search_month_end); if ($search_year_end) $param.='&search_year_end='.urlencode($search_year_end); if ($search_employee > 0) $param.='&search_employee='.urlencode($search_employee); @@ -412,6 +410,10 @@ print ''; - print $form->select_dolusers($search_employee,"search_employee",1,"",$disabled,'','',0,0,0,'',0,'','maxwidth200'); + if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int'); + print ''; + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, '', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } else { - //print ' '; + if (GETPOSTISSET('search_employee')) $search_employee=GETPOST('search_employee','int'); print ''; - print $form->select_dolusers($search_employee,"search_employee",1,"",$disabled,'hierarchyme','',0,0,0,'',0,'','maxwidth200'); + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, 'hierarchyme', '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } @@ -444,7 +447,7 @@ if ($user->rights->holiday->read_all) $valideurobjects = $validator->listUsersForGroup($excludefilter); $valideurarray = array(); foreach($valideurobjects as $val) $valideurarray[$val->id]=$val->id; - print $form->select_dolusers($search_valideur,"search_valideur",1,"",0,$valideurarray,'', 0, 0, 0, '', 0, '', 'maxwidth200'); + print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth200'); print ''; } else @@ -510,9 +513,10 @@ $listhalfday=array('morning'=>$langs->trans("Morning"),"afternoon"=>$langs->tran // If we ask a dedicated card and not allow to see it, we forc on user. -if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childis)) +if ($id && empty($user->rights->holiday->read_all) && ! in_array($id, $childids)) { - print ''.$langs->trans("NotEnoughPermission").''; + $langs->load("errors"); + print ''.$langs->trans("NotEnoughPermissions").''; $result = 0; } // Lines diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index da58499482a..3a7e8a7d14a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -837,11 +837,11 @@ Permission1251=Run mass imports of external data into database (data load) Permission1321=Export customer invoices, attributes and payments Permission1322=Reopen a paid bill Permission1421=Export customer orders and attributes -Permission20001=Read leave requests (yours and your subordinates) -Permission20002=Create/modify your leave requests +Permission20001=Read leave requests (your leaves and the one of your subordinates) +Permission20002=Create/modify your leave requests (yours leaves and the one of your subordinates) Permission20003=Delete leave requests -Permission20004=Read all leave requests (even user not subordinates) -Permission20005=Create/modify leave requests for everybody +Permission20004=Read all leave requests (even of user not subordinates) +Permission20005=Create/modify leave requests for everybody (even of user not subordinates) Permission20006=Admin leave requests (setup and update balance) Permission23001=Read Scheduled job Permission23002=Create/update Scheduled job diff --git a/htdocs/langs/en_US/holiday.lang b/htdocs/langs/en_US/holiday.lang index 55ba6a1d91d..eca2bbdfe46 100644 --- a/htdocs/langs/en_US/holiday.lang +++ b/htdocs/langs/en_US/holiday.lang @@ -71,6 +71,7 @@ DateRefusCP=Date of refusal DateCancelCP=Date of cancellation DefineEventUserCP=Assign an exceptional leave for a user addEventToUserCP=Assign leave +NotTheAssignedApprover=You are not the assigned approver MotifCP=Reason UserCP=User ErrorAddEventToUserCP=An error occurred while adding the exceptional leave.