From 03fbd72d66edc1324e772c412204d70285c9d300 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 21 Jun 2020 19:52:15 +0200 Subject: [PATCH 01/12] FIX For better compatibility with Samba4 AD --- htdocs/core/class/ldap.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index b22473ec483..4434bd7be89 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -55,6 +55,10 @@ class Ldap /** * Version du protocole ldap */ + public $ldapProtocolVersion; + /** + * Server DN + */ public $domain; /** * User administrateur Ldap @@ -466,8 +470,6 @@ class Ldap */ public function modify($dn, $info, $user) { - global $conf; - dol_syslog(get_class($this)."::modify dn=".$dn." info=".join(',', $info)); // Check parameters @@ -492,6 +494,10 @@ class Ldap $this->dump($dn, $info); //print_r($info); + // For better compatibility with Samba4 AD + if ($this->serverType == "activedirectory") { + unset($info['cn']); // For avoid error : Operation not allowed on RDN (Code 67) + } $result=@ldap_modify($this->connection, $dn, $info); if ($result) @@ -520,8 +526,6 @@ class Ldap */ public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) { - global $conf; - dol_syslog(get_class($this)."::modify dn=".$dn." newrdn=".$newrdn." newparent=".$newparent." deleteoldrdn=".($deleteoldrdn?1:0)); // Check parameters @@ -571,8 +575,6 @@ class Ldap */ public function update($dn, $info, $user, $olddn, $newrdn = false, $newparent = false) { - global $conf; - dol_syslog(get_class($this)."::update dn=".$dn." olddn=".$olddn); // Check parameters @@ -589,7 +591,7 @@ class Ldap if (! $olddn || $olddn != $dn) { - if (! empty($olddn) && ! empty($newrdn) && ! empty($newparent) && $conf->global->LDAP_SERVER_PROTOCOLVERSION === '3') + if (! empty($olddn) && ! empty($newrdn) && ! empty($newparent) && $this->ldapProtocolVersion === '3') { // This function currently only works with LDAPv3 $result = $this->rename($olddn, $newrdn, $newparent, $user, true); @@ -631,8 +633,6 @@ class Ldap */ public function delete($dn) { - global $conf; - dol_syslog(get_class($this)."::delete Delete LDAP entry dn=".$dn); // Check parameters From 9a4f5e3d9a2b319027e86630ecc90028da38ae6e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 21 Jun 2020 21:10:51 +0200 Subject: [PATCH 02/12] FIX We force "modify" for avoid some field not modify --- htdocs/core/class/ldap.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 4434bd7be89..dfcb4690a7f 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -595,6 +595,7 @@ class Ldap { // This function currently only works with LDAPv3 $result = $this->rename($olddn, $newrdn, $newparent, $user, true); + $result = $this->modify($dn, $info, $user); // We force "modify" for avoid some fields not modify } else { From 32844a8d0c587e6c429c6200631b6b97dfae2c89 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 22 Jun 2020 09:26:42 +0200 Subject: [PATCH 03/12] FIX clean code --- htdocs/core/class/ldap.class.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index dfcb4690a7f..213f644029e 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -164,7 +164,7 @@ class Ldap public function connect_bind() { // phpcs:enable - global $langs, $conf; + global $conf; $connected=0; $this->bind=0; @@ -187,7 +187,7 @@ class Ldap if (empty($this->error)) { // Loop on each ldap server - foreach ($this->server as $key => $host) + foreach ($this->server as $host) { if ($connected) break; if (empty($host)) continue; @@ -416,8 +416,6 @@ class Ldap */ public function add($dn, $info, $user) { - global $conf; - dol_syslog(get_class($this)."::add dn=".$dn." info=".join(',', $info)); // Check parameters @@ -692,7 +690,7 @@ class Ldap } else { - foreach($value as $valuekey => $valuevalue) + foreach($value as $valuevalue) { $content.="$key: $valuevalue\n"; } @@ -774,8 +772,6 @@ class Ldap */ public function addAttribute($dn, $info, $user) { - global $conf; - dol_syslog(get_class($this)."::addAttribute dn=".$dn." info=".join(',', $info)); // Check parameters @@ -826,8 +822,6 @@ class Ldap */ public function updateAttribute($dn, $info, $user) { - global $conf; - dol_syslog(get_class($this)."::updateAttribute dn=".$dn." info=".join(',', $info)); // Check parameters @@ -878,8 +872,6 @@ class Ldap */ public function deleteAttribute($dn, $info, $user) { - global $conf; - dol_syslog(get_class($this)."::deleteAttribute dn=".$dn." info=".join(',', $info)); // Check parameters From 69b320f347f3492613e64123f0dd53bf9adcec96 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 24 Jun 2020 10:17:46 +0200 Subject: [PATCH 04/12] New : filter on progress column in task list --- htdocs/projet/tasks/list.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 8930220f6ec..08fe2390cfa 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -61,6 +61,7 @@ $search_task_description = GETPOST('search_task_description'); $search_task_ref_parent = GETPOST('search_task_ref_parent'); $search_project_user = GETPOST('search_project_user'); $search_task_user = GETPOST('search_task_user'); +$search_task_progress = GETPOST('search_task_progress'); $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; if ($mine) { $search_task_user = $user->id; $mine = 0; } @@ -175,6 +176,7 @@ if (empty($reshook)) $search_task_label = ""; $search_task_description = ""; $search_task_ref_parent = ""; + $search_task_progress = ""; $search_task_user = -1; $search_project_user = -1; $search_sday = ''; @@ -309,6 +311,7 @@ if ($search_task_ref) $sql .= natural_search('t.ref', $search_task_ref); if ($search_task_label) $sql .= natural_search('t.label', $search_task_label); if ($search_task_description) $sql .= natural_search('t.description', $search_task_description); if ($search_task_ref_parent) $sql .= ' AND t.fk_task_parent IN (SELECT ipt.rowid FROM '.MAIN_DB_PREFIX.'projet_task as ipt WHERE '.natural_search('ipt.ref', $search_task_ref_parent, 0, 1).')'; +if ($search_task_progress) $sql .= natural_search('t.progress', $search_task_progress, 1); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); $sql .= dolSqlDateFilter('t.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('t.datee', $search_eday, $search_emonth, $search_eyear); @@ -396,6 +399,7 @@ if ($search_task_ref != '') $param .= '&search_task_ref='.urlencode($search_r if ($search_task_label != '') $param .= '&search_task_label='.urlencode($search_label); if ($search_task_description != '') $param .= '&search_task_description='.urlencode($search_description); if ($search_task_ref_parent != '') $param .= '&search_task_ref_parent='.urlencode($search_task_ref_parent); +if ($search_task_progress != '') $param .= '&search_task_progress='.urlencode($search_task_progress); if ($search_societe != '') $param .= '&search_societe='.urlencode($search_societe); if ($search_projectstatus != '') $param .= '&search_projectstatus='.urlencode($search_projectstatus); if ((is_numeric($search_opp_status) && $search_opp_status >= 0) || in_array($search_opp_status, array('all', 'none'))) $param .= '&search_opp_status='.urlencode($search_opp_status); @@ -571,7 +575,13 @@ if (!empty($arrayfields['p.fk_statut']['checked'])) if (!empty($arrayfields['t.planned_workload']['checked'])) print ''; if (!empty($arrayfields['t.duration_effective']['checked'])) print ''; if (!empty($arrayfields['t.progress_calculated']['checked'])) print ''; -if (!empty($arrayfields['t.progress']['checked'])) print ''; +if (!empty($arrayfields['t.progress']['checked'])) +{ + print ''; + print ''; + print ''; +} + if (!empty($arrayfields['t.progress_summary']['checked'])) print ''; if (!empty($arrayfields['t.tobill']['checked'])) print ''; if (!empty($arrayfields['t.billed']['checked'])) print ''; From 22f708b95afdbaffa559e8577eaa6a9e3083b85e Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Thu, 25 Jun 2020 14:36:42 +0200 Subject: [PATCH 05/12] Add search, sort, select for leave log view --- htdocs/holiday/view_log.php | 121 +++++++++++++++++++++--------------- 1 file changed, 71 insertions(+), 50 deletions(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 0d987844924..adbdd83de65 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -1,6 +1,7 @@ * Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -28,18 +29,20 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... -$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) -$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? -$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation -$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search -$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page -$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') -$search_id = GETPOST('search_id', 'alpha'); -$year = GETPOST('year'); +$search_id = GETPOST('search_id', 'alpha'); +$search_prev_solde = GETPOST('search_prev_solde', 'alpha'); +$search_new_solde = GETPOST('search_new_solde', 'alpha'); +$year=GETPOST('year'); if (empty($year)) { $tmpdate = dol_getdate(dol_now()); @@ -47,7 +50,7 @@ if (empty($year)) } // Load variable for pagination -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -55,8 +58,8 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -//if (! $sortfield) $sortfield="p.date_fin"; -//if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="cpl.rowid"; +if (! $sortorder) $sortorder="DESC"; // Protection if external user @@ -118,6 +121,18 @@ if (empty($reshook)) } +// Definition of fields for lists +$arrayfields = array( + 'cpl.rowid'=>array('label'=>$langs->trans("ID"), 'checked'=>1), + 'cpl.date_action'=>array('label'=>$langs->trans("Date"), 'checked'=>1), + 'cpl.fk_user_action'=>array('label'=>$langs->trans("ActionByCP"), 'checked'=>1), + 'cpl.fk_user_update'=>array('label'=>$langs->trans("UserUpdateCP"), 'checked'=>1), + 'cpl.type_action'=>array('label'=>$langs->trans("Description"), 'checked'=>1), + 'cpl.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), + 'cpl.prev_solde'=>array('label'=>$langs->trans("PrevSoldeCP"), 'checked'=>1), + 'variation'=>array('label'=>$langs->trans("Variation"), 'checked'=>1), + 'cpl.new_solde'=>array('label'=>$langs->trans("NewSoldeCP"), 'checked'=>1), +); /* * View @@ -132,10 +147,12 @@ llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year. $sqlwhere = ''; -$sqlwhere .= " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'"; -if ($search_id != '') $sqlwhere .= natural_search('rowid', $search_id, 1); +$sqlwhere.= " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'"; +if ($search_id != '') $sqlwhere.= natural_search('rowid', $search_id, 1); +if ($search_prev_solde != '') $sqlwhere.= natural_search('prev_solde', $search_prev_solde, 1); +if ($search_new_solde != '') $sqlwhere.= natural_search('new_solde', $search_new_solde, 1); -$sqlorder = 'ORDER BY cpl.rowid DESC'; +$sqlorder = $db->order($sortfield, $sortorder); // Recent changes are more important than old changes $log_holiday = $object->fetchLog($sqlorder, $sqlwhere); // Load $object->logs @@ -172,9 +189,9 @@ print "
\n"; $moreforfilter = ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); $selectedfields = ''; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''."\n"; @@ -182,15 +199,15 @@ print '
'; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +if (!empty($arrayfields['cpl.rowid']['checked'])) print ''; +if (!empty($arrayfields['cpl.date_action']['checked'])) print ''; +if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print ''; +if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print ''; +if (!empty($arrayfields['cpl.type_action']['checked'])) print ''; +if (!empty($arrayfields['cpl.fk_type']['checked'])) print ''; +if (!empty($arrayfields['cpl.prev_solde']['checked'])) print ''; +if (!empty($arrayfields['variation']['checked'])) print ''; +if (!empty($arrayfields['cpl.new_solde']['checked'])) print ''; // Action column print ''; print ''; print ''; -print_liste_field_titre('ID'); -print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'center '); -print_liste_field_titre('ActionByCP'); -print_liste_field_titre('UserUpdateCP'); -print_liste_field_titre('Description'); -print_liste_field_titre('Type'); -print_liste_field_titre('PrevSoldeCP', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right '); -print_liste_field_titre('Variation', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right '); -print_liste_field_titre('NewSoldeCP', $_SERVER["PHP_SELF"], '', '', '', '', '', '', 'right '); +if (!empty($arrayfields['cpl.rowid']['checked'])) print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.date_action']['checked'])) print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_action']['label'], $_SERVER["PHP_SELF"], 'fk_user_action', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_user_update']['label'], $_SERVER["PHP_SELF"], 'fk_user_update', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.type_action']['checked'])) print_liste_field_titre($arrayfields['cpl.type_action']['label'], $_SERVER["PHP_SELF"], 'type_action', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.fk_type']['checked'])) print_liste_field_titre($arrayfields['cpl.fk_type']['label'], $_SERVER["PHP_SELF"], 'fk_type', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cpl.prev_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.prev_solde']['label'], $_SERVER["PHP_SELF"], 'prev_solde', '', '', '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['variation']['checked'])) print_liste_field_titre($arrayfields['variation']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['cpl.new_solde']['checked'])) print_liste_field_titre($arrayfields['cpl.new_solde']['label'], $_SERVER["PHP_SELF"], 'new_solde', '', '', '', $sortfield, $sortorder, 'right '); print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''; @@ -221,21 +238,25 @@ foreach ($object->logs as $logs_CP) $user_update->fetch($logs_CP['fk_user_update']); $delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); - $detasign = ($delta > 0 ? '+' : '-'); + $detasign = ($delta > 0 ? '+' : ''); print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if (!empty($arrayfields['cpl.rowid']['checked'])) print ''; + if (!empty($arrayfields['cpl.date_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print ''; + if (!empty($arrayfields['cpl.type_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_type']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['cpl.prev_solde']['checked'])) print ''; + if (!empty($arrayfields['variation']['checked'])) print ''; + if (!empty($arrayfields['cpl.new_solde']['checked'])) print ''; print ''; print ''."\n"; } From 289886cd2939b09dbda83ffb5d01263f02cbdbd7 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Thu, 25 Jun 2020 14:37:09 +0200 Subject: [PATCH 06/12] missing update --- htdocs/holiday/view_log.php | 74 ++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index adbdd83de65..6ec1e01b71f 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -42,7 +42,7 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the $search_id = GETPOST('search_id', 'alpha'); $search_prev_solde = GETPOST('search_prev_solde', 'alpha'); $search_new_solde = GETPOST('search_new_solde', 'alpha'); -$year=GETPOST('year'); +$year = GETPOST('year'); if (empty($year)) { $tmpdate = dol_getdate(dol_now()); @@ -104,8 +104,13 @@ if (empty($reshook)) $toselect = ''; $search_array_options = array(); } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + + if (GETPOST('button_removefilter_x', 'alpha') + || GETPOST('button_removefilter.x', 'alpha') + || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') + || GETPOST('button_search.x', 'alpha') + || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -144,10 +149,11 @@ $alltypeleaves = $object->getTypes(1, -1); // To have labels llxHeader('', $langs->trans('CPTitreMenu').' ('.$langs->trans("Year").' '.$year.')'); +$sqlwhere = " AND date_action BETWEEN ". +$sqlwhere.= "'".$db->idate(dol_get_first_day($year, 1, 1))."'"; +$sqlwhere.= " AND "; +$sqlwhere.= "'".$db->idate(dol_get_last_day($year, 12, 1))."'"; - -$sqlwhere = ''; -$sqlwhere.= " AND date_action BETWEEN '".$db->idate(dol_get_first_day($year, 1, 1))."' AND '".$db->idate(dol_get_last_day($year, 12, 1))."'"; if ($search_id != '') $sqlwhere.= natural_search('rowid', $search_id, 1); if ($search_prev_solde != '') $sqlwhere.= natural_search('prev_solde', $search_prev_solde, 1); if ($search_new_solde != '') $sqlwhere.= natural_search('new_solde', $search_new_solde, 1); @@ -172,10 +178,32 @@ print ''; print ''; print ''; -$pagination = ''; +$pagination = ''; + print load_fiche_titre($langs->trans('LogCP'), $pagination, 'title_hrm.png'); print '
'.$langs->trans('LastUpdateCP').': '."\n"; + $lastUpdate = $object->getConfCP('lastUpdate'); if ($lastUpdate) { @@ -183,7 +211,11 @@ if ($lastUpdate) $yearLastUpdate = $lastUpdate[0].$lastUpdate[1].$lastUpdate[2].$lastUpdate[3]; print ''.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; print '
'.$langs->trans("MonthOfLastMonthlyUpdate").': '.$yearLastUpdate.'-'.$monthLastUpdate.''."\n"; -} else print $langs->trans('None'); +} +else +{ + print $langs->trans('None'); +} print "

\n"; $moreforfilter = ''; @@ -231,20 +263,20 @@ print ''; foreach ($object->logs as $logs_CP) { - $user_action = new User($db); - $user_action->fetch($logs_CP['fk_user_action']); + $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']); + $user_update = new User($db); + $user_update->fetch($logs_CP['fk_user_update']); - $delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); - $detasign = ($delta > 0 ? '+' : ''); + $delta = price2num($logs_CP['new_solde'] - $logs_CP['prev_solde'], 5); + $detasign = ($delta > 0 ? '+' : ''); - print '
'; - if (!empty($arrayfields['cpl.rowid']['checked'])) print ''; - if (!empty($arrayfields['cpl.date_action']['checked'])) print ''; - if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print ''; - if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print ''; + print ''; + if (!empty($arrayfields['cpl.rowid']['checked'])) print ''; + if (!empty($arrayfields['cpl.date_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_user_action']['checked'])) print ''; + if (!empty($arrayfields['cpl.fk_user_update']['checked'])) print ''; if (!empty($arrayfields['cpl.type_action']['checked'])) print ''; if (!empty($arrayfields['cpl.fk_type']['checked'])) { @@ -257,8 +289,8 @@ foreach ($object->logs as $logs_CP) if (!empty($arrayfields['cpl.prev_solde']['checked'])) print ''; if (!empty($arrayfields['variation']['checked'])) print ''; if (!empty($arrayfields['cpl.new_solde']['checked'])) print ''; - print ''; - print ''."\n"; + print ''; + print ''."\n"; } if ($log_holiday == '2') From adb3cc72f9577a023a5b5456f79286403f039a9c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 25 Jun 2020 12:44:57 +0000 Subject: [PATCH 07/12] Fixing style errors. --- htdocs/holiday/view_log.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 6ec1e01b71f..44d57e9860a 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -212,8 +212,7 @@ if ($lastUpdate) print ''.dol_print_date($db->jdate($object->getConfCP('lastUpdate')), 'dayhour', 'tzuser').''; print '
'.$langs->trans("MonthOfLastMonthlyUpdate").': '.$yearLastUpdate.'-'.$monthLastUpdate.''."\n"; } -else -{ +else { print $langs->trans('None'); } print "
\n"; From c689b91539faf7a4dd50368d0e69d96265cb6c3e Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 25 Jun 2020 16:59:48 +0200 Subject: [PATCH 08/12] FIX upload file in import module --- htdocs/core/lib/security.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 3c1d143ae55..216c859171d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -306,7 +306,10 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } elseif ($feature == 'cheque') { if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; } - } elseif (!empty($feature2)) // This is for permissions on one level + } elseif ($feature == 'import') { + if (!$user->rights->import->run) { $createok = 0; $nbko++; } + } + elseif (!empty($feature2)) // This is for permissions on one level { foreach ($feature2 as $subfeature) { From 3eb695ffa8e2e4ef9666e3819e20a713326792e5 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 26 Jun 2020 09:14:06 +0200 Subject: [PATCH 09/12] NEW add region in export companies and contacts --- htdocs/core/modules/modSociete.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index a9be157d126..4b422348bee 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -263,7 +263,7 @@ class modSociete extends DolibarrModules $this->export_fields_array[$r] = array( 's.rowid'=>"Id", 's.nom'=>"Name", 's.name_alias'=>"AliasNameShort", 's.status'=>"Status", 's.client'=>"Customer", 's.fournisseur'=>"Supplier", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", - 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", + 's.address'=>"Address", 's.zip'=>"Zip", 's.town'=>"Town", 'd.nom'=>'State', 'r.nom' => 'Region', 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email", 's.default_lang'=>"DefaultLang", 's.siren'=>"ProfId1", 's.siret'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.idprof5'=>"ProfId5", 's.idprof6'=>"ProfId6", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital", 's.note_private'=>"NotePrivate", 's.note_public'=>"NotePublic", 't.libelle'=>"ThirdPartyType", 'ce.code'=>"Staff", "cfj.libelle"=>"JuridicalStatus", 's.fk_prospectlevel'=>'ProspectLevel', @@ -295,7 +295,7 @@ class modSociete extends DolibarrModules 's.default_lang'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text", 's.idprof5'=>"Text", 's.idprof6'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_private'=>"Text", 's.note_public'=>"Text", 't.libelle'=>"Text", 'ce.code'=>"List:c_effectif:libelle:code", "cfj.libelle"=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code', - 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text', + 'st.code'=>'List:c_stcomm:libelle:code', 'd.nom'=>'Text', 'r.nom' => 'Text', 'u.login'=>'Text', 'u.firstname'=>'Text', 'u.lastname'=>'Text', 'payterm.libelle'=>'Text', 'paymode.libelle'=>'Text', 's.entity'=>'Numeric', 's.price_level'=>'Numeric' ); @@ -310,6 +310,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = s.fk_pays'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_stcomm as st ON s.fk_stcomm = st.id'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON sc.fk_user = u.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_payment_term as payterm ON s.cond_reglement = payterm.rowid'; @@ -333,7 +334,7 @@ class modSociete extends DolibarrModules $this->export_fields_array[$r] = array( 'c.rowid'=>"IdContact", 'c.civility'=>"CivilityCode", 'c.lastname'=>'Lastname', 'c.firstname'=>'Firstname', 'c.poste'=>'PostOrFunction', 'c.datec'=>"DateCreation", 'c.tms'=>"DateLastModification", 'c.priv'=>"ContactPrivate", 'c.address'=>"Address", 'c.zip'=>"Zip", 'c.town'=>"Town", - 'd.nom'=>'State', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", + 'd.nom'=>'State', 'r.nom' => 'Region', 'co.label'=>"Country", 'co.code'=>"CountryCode", 'c.phone'=>"Phone", 'c.fax'=>"Fax", 'c.phone_mobile'=>"Mobile", 'c.email'=>"EMail", 'c.statut'=>"Status", 's.rowid'=>"IdCompany", 's.nom'=>"CompanyName", 's.status'=>"Status", 's.code_client'=>"CustomerCode", 's.code_fournisseur'=>"SupplierCode", 's.code_compta'=>"AccountancyCode", 's.code_compta_fournisseur'=>"SupplierAccountancyCode", @@ -344,7 +345,7 @@ class modSociete extends DolibarrModules $this->export_examplevalues_array[$r] = array('s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)', 's.fournisseur'=>'0 (not a supplier) or 1 (supplier)'); $this->export_TypeFields_array[$r] = array( 'c.civility'=>"List:c_civility:label:code", 'c.lastname'=>'Text', 'c.firstname'=>'Text', 'c.poste'=>'Text', 'c.datec'=>"Date", 'c.priv'=>"Boolean", - 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", + 'c.address'=>"Text", 'c.zip'=>"Text", 'c.town'=>"Text", 'd.nom'=>'Text', 'r.nom' => 'Text', 'co.label'=>"List:c_country:label:rowid", 'co.code'=>"Text", 'c.phone'=>"Text", 'c.fax'=>"Text", 'c.email'=>"Text", 'c.statut'=>"Status", 's.rowid'=>"List:societe:nom::thirdparty", 's.nom'=>"Text", 's.status'=>"Status", 's.code_client'=>"Text", 's.code_fournisseur'=>"Text", @@ -375,6 +376,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extrasoc ON s.rowid = extrasoc.fk_object'; if (is_object($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_regions as r ON r.code_region = d.fk_region AND r.fk_pays = c.fk_pays'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id'; From 2bb8efa86f3d9dd277a5e3e3a4ed5582a256f540 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Fri, 26 Jun 2020 10:54:27 +0200 Subject: [PATCH 10/12] Common behavior for monthly leave list view --- htdocs/holiday/month_report.php | 238 ++++++++++++++++++++++++-------- 1 file changed, 179 insertions(+), 59 deletions(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 0c4ffe76335..6259b64062e 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2010 Laurent Destailleur * Copyright (C) 2011 François Legastelois * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -42,13 +43,79 @@ if ($user->socid > 0) // Protection if external user } $result = restrictedArea($user, 'holiday', $id, ''); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; +$massaction = GETPOST('massaction', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ'); +$optioncss = GETPOST('optioncss', 'aZ'); + +$search_ref = GETPOST('search_ref', 'alpha'); + +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); + +if (! $sortfield) $sortfield = "cp.rowid"; +if (! $sortorder) $sortorder = "ASC"; + +$hookmanager->initHooks(array('leavemovementlist')); + +$arrayfields = array(); +$arrayofmassactions = array(); + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +if (empty($reshook)) +{ + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_ref = ''; + $toselect = ''; + $search_array_options = array(); + } + + if (GETPOST('button_removefilter_x', 'alpha') + || GETPOST('button_removefilter.x', 'alpha') + || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') + || GETPOST('button_search.x', 'alpha') + || GETPOST('button_search', 'alpha')) + { + $massaction = ''; + } +} + +$arrayfields = array( + 'cp.ref'=>array('label'=>$langs->trans('Ref'), 'checked'=>1), + 'cp.fk_user'=>array('label'=>$langs->trans('Employee'), 'checked'=>1), + 'ct.label'=>array('label'=>$langs->trans('Type'), 'checked'=>1), + 'cp.date_debut'=>array('label'=>$langs->trans('DateDebCP'), 'checked'=>1), + 'cp.date_fin'=>array('label'=>$langs->trans('DateFinCP'), 'checked'=>1), + 'used_days'=>array('label'=>$langs->trans('NbUseDaysCPShort'), 'checked'=>1), + 'date_start_month'=>array('label'=>$langs->trans('DateStartInMonth'), 'checked'=>1), + 'date_end_month'=>array('label'=>$langs->trans('DateEndInMonth'), 'checked'=>1), + 'used_days_month'=>array('label'=>$langs->trans('NbUseDaysCPShortInMonth'), 'checked'=>1), + 'cp.description'=>array('label'=>$langs->trans('DescCP'), 'checked'=>1), +); /* * View */ -$html = new Form($db); +$form = new Form($db); $formother = new FormOther($db); $holidaystatic = new Holiday($db); @@ -56,36 +123,21 @@ $listhalfday = array('morning'=>$langs->trans("Morning"), "afternoon"=>$langs->t llxHeader('', $langs->trans('CPTitreMenu')); -print load_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm'); - - -// Selection filter -print '
'; - -print '
'."\n"; - $search_month = GETPOST("remonth", 'int') ?GETPOST("remonth", 'int') : date("m", time()); $search_year = GETPOST("reyear", 'int') ?GETPOST("reyear", 'int') : date("Y", time()); - $year_month = sprintf("%04d", $search_year).'-'.sprintf("%02d", $search_month); -print $formother->select_month($search_month, 'remonth'); +$sql = "SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, ct.label, cp.description, cp.halfday"; +$sql.= " FROM ".MAIN_DB_PREFIX."holiday cp"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; +$sql.= " WHERE cp.rowid > 0"; +$sql.= " AND cp.statut = 3"; // 3 = Approved +$sql.= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; -print $formother->select_year($search_year, 'reyear'); +if ($search_ref != '') $sql.= natural_search('cp.ref', $search_ref, 0); -print ''; - -print ''; - - -$sql = "SELECT cp.rowid, cp.fk_user, cp.date_debut, cp.date_fin, ct.label, cp.description, cp.halfday"; -$sql .= " FROM ".MAIN_DB_PREFIX."holiday cp"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; -$sql .= " WHERE cp.rowid > 0"; -$sql .= " AND cp.statut = 3"; // Approved -$sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; -$sql .= " ORDER BY u.lastname, cp.date_debut"; +$sql.= $db->order($sortfield, $sortorder); $resql = $db->query($sql); if (empty($resql)) @@ -96,31 +148,79 @@ if (empty($resql)) $num = $db->num_rows($resql); +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.= '&limit='.urlencode($limit); +if ($search_ref) $param = '&search_ref='.urlencode($search_ref); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print load_fiche_titre($langs->trans('MenuReportMonth'), '', 'title_hrm'); + +// Selection filter +print '
'; +print $formother->select_month($search_month, 'remonth'); +print $formother->select_year($search_year, 'reyear'); +print ''; print '
'; - - print '
'; +$moreforfilter = ''; + +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = ''; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + print '
'; print '
'; $searchpicto = $form->showFilterButtons(); @@ -199,15 +216,15 @@ print '
'.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getNomUrl(-1).''.$user_update->getNomUrl(-1).''.$logs_CP['type_action'].''; - $label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) != $alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']); - print $label ? $label : $logs_CP['fk_type']; - print ''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').''.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getNomUrl(-1).''.$user_update->getNomUrl(-1).''.$logs_CP['type_action'].''; + $label = (($alltypeleaves[$logs_CP['fk_type']]['code'] && $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) != $alltypeleaves[$logs_CP['fk_type']]['code']) ? $langs->trans($alltypeleaves[$logs_CP['fk_type']]['code']) : $alltypeleaves[$logs_CP['fk_type']]['label']); + print $label ? $label : $logs_CP['fk_type']; + print ''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'
'.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getNomUrl(-1).''.$user_update->getNomUrl(-1).'
'.$logs_CP['rowid'].''.$logs_CP['date_action'].''.$user_action->getNomUrl(-1).''.$user_update->getNomUrl(-1).''.$logs_CP['type_action'].''.price2num($logs_CP['prev_solde'], 5).' '.$langs->trans('days').''.$detasign.$delta.''.price2num($logs_CP['new_solde'], 5).' '.$langs->trans('days').'
'; print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; +if (!empty($arrayfields['cp.ref']['checked'])) print ''; +if (!empty($arrayfields['cp.fk_user']['checked'])) print ''; +if (!empty($arrayfields['ct.label']['checked'])) print ''; +if (!empty($arrayfields['cp.date_debut']['checked'])) print ''; +if (!empty($arrayfields['cp.date_fin']['checked'])) print ''; +if (!empty($arrayfields['used_days']['checked'])) print ''; +if (!empty($arrayfields['date_start_month']['checked'])) print ''; +if (!empty($arrayfields['date_end_month']['checked'])) print ''; +if (!empty($arrayfields['used_days_month']['checked'])) print ''; +if (!empty($arrayfields['cp.description']['checked'])) print ''; +// Action column +print ''; +print ''; + +print ''; +if (!empty($arrayfields['cp.ref']['checked'])) print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cp.fk_user']['checked'])) print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['ct.label']['checked'])) print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cp.date_debut']['checked'])) print_liste_field_titre($arrayfields['cp.date_debut']['label'], $_SERVER["PHP_SELF"], 'cp.date_debut', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cp.date_fin']['checked'])) print_liste_field_titre($arrayfields['cp.date_fin']['label'], $_SERVER["PHP_SELF"], 'cp.date_fin', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['used_days']['checked'])) print_liste_field_titre($arrayfields['used_days']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['date_start_month']['checked'])) print_liste_field_titre($arrayfields['date_start_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['date_end_month']['checked'])) print_liste_field_titre($arrayfields['date_end_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['used_days_month']['checked'])) print_liste_field_titre($arrayfields['used_days_month']['label'], $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder); +if (!empty($arrayfields['cp.description']['checked'])) print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder); +print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''; if ($num == 0) { print ''; -} else { +} +else +{ while ($obj = $db->fetch_object($resql)) { $user = new User($db); @@ -161,34 +261,54 @@ if ($num == 0) // Leave request $holidaystatic->id = $obj->rowid; - $holidaystatic->ref = $obj->rowid; + $holidaystatic->ref = $obj->ref; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + + if (!empty($arrayfields['cp.ref']['checked'])) print ''; + if (!empty($arrayfields['cp.fk_user']['checked'])) print ''; + if (!empty($arrayfields['ct.label']['checked'])) print ''; + + if (!empty($arrayfields['cp.date_debut']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['cp.date_fin']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['used_days']['checked'])) print ''; + + if (!empty($arrayfields['date_start_month']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['date_end_month']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['used_days_month']['checked'])) print ''; + if (!empty($arrayfields['cp.description']['checked'])) print ''; + + print ''; print ''; } } print '
'.$langs->trans('Ref').''.$langs->trans('Employee').''.$langs->trans('Type').''.$langs->trans('DateDebCP').''.$langs->trans('DateFinCP').''.$langs->trans('NbUseDaysCPShort').''.$langs->trans('DateStartInMonth').''.$langs->trans('DateEndInMonth').''.$langs->trans('NbUseDaysCPShortInMonth').''.$langs->trans('DescCP').''; +$searchpicto = $form->showFilterButtons(); +print $searchpicto; +print '
'.$langs->trans('None').'
'; - print $holidaystatic->getNomUrl(1, 1); - print ''.$user->getFullName($langs).''.$obj->label.''.dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print ''.dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print ''.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).''.dol_print_date($date_start_inmonth, 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; - print ''.dol_print_date($date_end_inmonth, 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; - print ''.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).''.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).''.$holidaystatic->getNomUrl(1, 1).''.$user->getFullName($langs).''.$obj->label.''.dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ''.dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ''.num_open_day($date_start, $date_end, 0, 1, $obj->halfday).''.dol_print_date($date_start_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfdayinmonth]).')'; + print ''.dol_print_date($date_end_inmonth, 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfdayinmonth]).')'; + print ''.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).''.dol_escape_htmltag(dolGetFirstLineOfText($obj->description)).'
'; print '
'; +print ''; // End of page llxFooter(); From a8ad21c011741bbbed63c05c6cf672ca37c46e7e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 26 Jun 2020 08:59:50 +0000 Subject: [PATCH 11/12] Fixing style errors. --- htdocs/holiday/month_report.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 6259b64062e..b6da0427464 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -44,9 +44,9 @@ if ($user->socid > 0) // Protection if external user $result = restrictedArea($user, 'holiday', $id, ''); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; -$massaction = GETPOST('massaction', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ'); -$optioncss = GETPOST('optioncss', 'aZ'); +$optioncss = GETPOST('optioncss', 'aZ'); $search_ref = GETPOST('search_ref', 'alpha'); @@ -219,8 +219,7 @@ if ($num == 0) { print ''.$langs->trans('None').''; } -else -{ +else { while ($obj = $db->fetch_object($resql)) { $user = new User($db); From ad36447295eddfb216f77b71516f5e90cb3be8b9 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Fri, 26 Jun 2020 12:20:53 +0200 Subject: [PATCH 12/12] NEW can edit and set sales representatives directly on thirdparty card --- htdocs/comm/card.php | 7 ++ htdocs/societe/card.php | 7 ++ .../tpl/linesalesrepresentative.tpl.php | 66 ++++++++++++------- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 7d9059fc9c1..d65a744398f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -190,6 +190,13 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } + // Set sales representatives + if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) + { + $object->fetch($id); + $result = $object->setSalesRep(GETPOST('commercial', 'array')); + } + if ($action == 'update_extras') { $object->fetch($id); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index c22aab4cfd1..354b29eabed 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -839,6 +839,13 @@ if (empty($reshook)) $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } + // Set sales representatives + if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) + { + $object->fetch($socid); + $result = $object->setSalesRep(GETPOST('commercial', 'array')); + } + $id = $socid; $object->fetch($socid); diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 8ee338fba44..5b9078e6b76 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -23,30 +23,48 @@ if (empty($conf) || !is_object($conf)) } // Sale representative -print ''; +print ''; +print ''; -print ''; +} +print '
'; print $langs->trans('SalesRepresentatives'); print ''; +if ($action != 'editsalesrepresentatives' && $user->rights->societe->creer) { + print ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + print '
'; +print ''; -$listsalesrepresentatives = $object->getSalesRepresentatives($user); -$nbofsalesrepresentative = count($listsalesrepresentatives); -if ($nbofsalesrepresentative > 0) -{ - $userstatic = new User($db); - foreach ($listsalesrepresentatives as $val) - { - $userstatic->id = $val['id']; - $userstatic->login = $val['login']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->statut = $val['statut']; - $userstatic->photo = $val['photo']; - $userstatic->email = $val['email']; - $userstatic->phone = $val['phone']; - $userstatic->job = $val['job']; - $userstatic->entity = $val['entity']; - print $userstatic->getNomUrl(-1); - print ' '; - } -} else print ''.$langs->trans("NoSalesRepresentativeAffected").''; -print ''; +if ($action == 'editsalesrepresentatives') { + print '
'; + print ''; + print ''; + print ''; + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); + $arrayselected = GETPOST('commercial', 'array'); + if (empty($arrayselected)) $arrayselected = $object->getSalesRepresentatives($user, 1); + print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); + print ''; + print '
'; +} else { + $listsalesrepresentatives = $object->getSalesRepresentatives($user); + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->login = $val['login']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->statut = $val['statut']; + $userstatic->photo = $val['photo']; + $userstatic->email = $val['email']; + $userstatic->phone = $val['phone']; + $userstatic->job = $val['job']; + $userstatic->entity = $val['entity']; + print $userstatic->getNomUrl(-1); + print ' '; + } + } else print '' . $langs->trans("NoSalesRepresentativeAffected") . ''; + print ''; +}