From b25a0ca672ad05ce4cef1f66b7f1f4545a652130 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Sep 2018 23:25:17 +0200 Subject: [PATCH 01/10] Fix no need of thumb when upload image for email --- htdocs/core/actions_sendmails.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 8c81c0efc6a..6afd6b1e354 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -42,7 +42,7 @@ if (GETPOST('addfile','alpha')) $vardir=$conf->user->dir_output."/".$user->id; $upload_dir_tmp = $vardir.'/temp'; // TODO Add $keytoavoidconflict in upload_dir path - dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid); + dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', '', null, $trackid, 0); $action='presend'; } From da4e9026453367196c30d9ea160ba6d089f4f28f Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 6 Sep 2018 11:35:19 +0200 Subject: [PATCH 02/10] Fix error when delete stripe customer --- htdocs/societe/paymentmodes.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 89aad30e2f5..aabc9ae7bed 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -550,13 +550,17 @@ if (empty($reshook)) $db->begin(); + if (empty($newcu)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; + } else { $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - + } + $resql = $db->query($sql); $num = $db->num_rows($resql); - if (empty($num)) + if (empty($num) && !empty($newcu)) { $societeaccount = new SocieteAccount($db); $societeaccount->fk_soc = $object->id; From a5f4a74ecce4e0e8bcc6478289018ded2c4c7d4e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 6 Sep 2018 14:49:48 +0200 Subject: [PATCH 03/10] FIX : Homepage links were using wrong topmenus --- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/index.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7f26f3cdb53..1ebd9fedfd6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3742,7 +3742,7 @@ class Facture extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->client->warning_delay/60/60/24; $response->label=$langs->trans("CustomerBillsUnpaid"); - $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=customers_bills'; + $response->url=DOL_URL_ROOT.'/compta/facture/list.php?search_status=1&mainmenu=billing&leftmenu=customers_bills'; $response->img=img_object('',"bill"); $generic_facture = new Facture($this->db); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 040bbb49bfa..7f5496094f7 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2080,7 +2080,7 @@ class FactureFournisseur extends CommonInvoice $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $response->label=$langs->trans("SupplierBillsToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=billing&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"),"bill"); $facturestatic = new FactureFournisseur($this->db); diff --git a/htdocs/index.php b/htdocs/index.php index 2843289c557..9ca5585d0ca 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -270,11 +270,11 @@ if (empty($user->societe_id)) DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products', DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial&leftmenu=propals', DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial&leftmenu=orders', - DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=accountancy&leftmenu=customers_bills', + DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills', DOL_URL_ROOT.'/contrat/list.php?mainmenu=commercial&leftmenu=contracts', DOL_URL_ROOT.'/fichinter/list.php?mainmenu=commercial&leftmenu=ficheinter', DOL_URL_ROOT.'/fourn/commande/list.php?mainmenu=commercial&leftmenu=orders_suppliers', - DOL_URL_ROOT.'/fourn/facture/list.php?mainmenu=accountancy&leftmenu=suppliers_bills', + DOL_URL_ROOT.'/fourn/facture/list.php?mainmenu=billing&leftmenu=suppliers_bills', DOL_URL_ROOT.'/supplier_proposal/list.php?mainmenu=commercial&leftmenu=', DOL_URL_ROOT.'/projet/list.php?mainmenu=project', DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport', From ff05997f0aee0f13092f41e006399ac26a2c1198 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 6 Sep 2018 17:37:02 +0200 Subject: [PATCH 04/10] FIX Several fixes on the management of minimal amount for orders --- htdocs/comm/card.php | 24 ++++++++++++------- htdocs/commande/card.php | 2 +- htdocs/fourn/card.php | 22 +++++++++-------- htdocs/fourn/commande/card.php | 2 +- htdocs/societe/list.php | 5 ++-- .../tpl/linesalesrepresentative.tpl.php | 4 ++-- 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 83db0e0f1d2..bc7ea0cd67d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -181,7 +181,7 @@ if (empty($reshook)) if ($action == 'setorder_min_amount') { $object->fetch($id); - $object->order_min_amount=GETPOST('order_min_amount'); + $object->order_min_amount=price2num(GETPOST('order_min_amount','alpha')); $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -423,15 +423,21 @@ if ($object->id > 0) print ''; print ''; + } - print ''; - print ''; - print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer); - print ''; - print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : '')); - - print ''; - print ''; + if ($object->client) + { + if (! empty($conf->commande->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) + { + print ''."\n"; + print ''; + print ''; + print $form->editfieldkey("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer); + print ''; + print $form->editfieldval("OrderMinAmount",'order_min_amount',$object->order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->order_min_amount != '' ? price($object->order_min_amount) : '')); + print ''; + print ''; + } } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c10591b4e45..fff45f59bf5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2387,7 +2387,7 @@ if ($action == 'create' && $user->rights->commande->creer) // Total HT $alert = ''; - if($object->total_ht < $object->thirdparty->order_min_amount) { + if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->order_min_amount) { $alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); } print '' . $langs->trans('AmountHT') . ''; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 906dbda4f6e..b295355bdc9 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -109,7 +109,7 @@ if (empty($reshook)) if ($action == 'setsupplier_order_min_amount') { $object->fetch($id); - $object->supplier_order_min_amount=GETPOST('supplier_order_min_amount'); + $object->supplier_order_min_amount=price2num(GETPOST('supplier_order_min_amount','alpha')); $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -298,15 +298,17 @@ if ($object->id > 0) print ''; print ''; - print ''; - print ''; - print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer); - print ''; - $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; - print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); - - print ''; - print ''; + if (! empty($conf->fournisseur->enabled) && ! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT)) + { + print ''; + print ''; + print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer); + print ''; + $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; + print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); + print ''; + print ''; + } // Categories if (! empty($conf->categorie->enabled)) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index e1670e0c4d0..09310deb2fc 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2116,7 +2116,7 @@ elseif (! empty($object->id)) // Total $alert = ''; - if($object->total_ht < $object->thirdparty->supplier_order_min_amount) { + if (! empty($conf->global->ORDER_MANAGE_MIN_AMOUNT) && $object->total_ht < $object->thirdparty->supplier_order_min_amount) { $alert = ' ' . img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->supplier_order_min_amount)); } print ''.$langs->trans("AmountHT").''; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 72071919a9b..8ea73b73884 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -424,11 +424,10 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as region on (region. code_region // We'll need this table joined to the select in order to filter by categ if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ if (! empty($search_categ_sup)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs ON s.rowid = cs.fk_soc"; // We'll need this table joined to the select in order to filter by categ -$sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st"; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; // We'll need this table joined to the select in order to filter by sale if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND s.entity IN (".getEntity('societe').")"; +$sql.= " WHERE s.entity IN (".getEntity('societe').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 2f325f3001f..c2ea3d987a5 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -23,10 +23,10 @@ if (empty($conf) || ! is_object($conf)) } // Sale representative -print ''; +print ''; print $langs->trans('SalesRepresentatives'); print ''; -print ''; +print ''; $listsalesrepresentatives=$object->getSalesRepresentatives($user); $nbofsalesrepresentative=count($listsalesrepresentatives); From 0ef17fe5818e44af3ad31fbbd6357644dc7a182c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Sep 2018 13:32:56 +0200 Subject: [PATCH 05/10] FIX Problems with permissions of module to record payment of salaries --- htdocs/compta/charges/index.php | 2 +- htdocs/compta/salaries/card.php | 2 +- htdocs/compta/salaries/document.php | 3 +- htdocs/compta/salaries/index.php | 2 +- htdocs/compta/salaries/stats/index.php | 17 ----------- htdocs/compta/sociales/payments.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 10 +++--- htdocs/core/menus/standard/eldy.lib.php | 12 ++++---- htdocs/core/modules/modSalaries.class.php | 37 +++++------------------ htdocs/langs/en_US/admin.lang | 8 ++--- htdocs/user/bank.php | 9 +++--- 11 files changed, 31 insertions(+), 73 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 6d369b696b9..4b3caf4f790 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -455,7 +455,7 @@ while($j<$numlt) // Payment Salary -if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) +if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) { if (! $mode || $mode != 'sconly') { diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index 45fee127642..c4a2406e6d0 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -39,7 +39,7 @@ $action=GETPOST('action','aZ09'); // Security check $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'salaries', '', '', 'payment'); +$result = restrictedArea($user, 'salaries', '', '', ''); $object = new PaymentSalary($db); diff --git a/htdocs/compta/salaries/document.php b/htdocs/compta/salaries/document.php index 99c34f60815..49d283522ee 100644 --- a/htdocs/compta/salaries/document.php +++ b/htdocs/compta/salaries/document.php @@ -44,8 +44,9 @@ $action = GETPOST('action','alpha'); $confirm = GETPOST('confirm','alpha'); // Security check +$socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'salaries', $id, ''); +$result = restrictedArea($user, 'salaries', '', '', ''); // Get parameters diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 0b70275654f..73f50b57564 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -148,7 +148,7 @@ if ($result) if ($optioncss != '') $param.='&optioncss='.$optioncss; $newcardbutton=''; - if ($user->rights->salaries->payment->write) + if (! empty($user->rights->salaries->write)) { $newcardbutton=''.$langs->trans('NewSalaryPayment').''; $newcardbutton.= ''; diff --git a/htdocs/compta/salaries/stats/index.php b/htdocs/compta/salaries/stats/index.php index 3e6fd56a266..090629ba97d 100644 --- a/htdocs/compta/salaries/stats/index.php +++ b/htdocs/compta/salaries/stats/index.php @@ -41,18 +41,6 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'salaries', '', '', ''); -// Other security check -$childids = $user->getAllChildIds(); -$childids[]=$user->id; -if ($userid > 0) -{ - if (empty($user->rights->salaries->payment->readall) && ! in_array($userid, $childids)) - { - accessforbidden(); - exit; - } -} - $nowyear=strftime("%Y", dol_now()); $year = GETPOST('year')>0?GETPOST('year'):$nowyear; //$startyear=$year-2; @@ -77,11 +65,6 @@ print load_fiche_titre($title, $mesg); dol_mkdir($dir); $useridtofilter=$userid; // Filter from parameters -if (empty($useridtofilter)) -{ - $useridtofilter=$childids; - if (! empty($user->rights->salaries->payment->readall)) $useridtofilter=0; -} $stats = new SalariesStats($db, $socid, $useridtofilter); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 3b7f68f8c83..b31ea8e4d2f 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -397,7 +397,7 @@ while($j<$numlt) // Payment Salary -if (! empty($conf->salaries->enabled) && $user->rights->salaries->read) +if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) { if (! $mode || $mode != 'sconly') { diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 76973a1571c..86942478969 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -198,11 +198,11 @@ 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->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2002__+MAX_llx_menu__, 'billing', '', 2000__+MAX_llx_menu__, '/don/list.php?leftmenu=donations&mainmenu=billing', 'List', 1, 'donations', '$user->rights->don->lire', '', 2, 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->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'billing', '', 2000__+MAX_llx_menu__, '/don/stats/index.php?leftmenu=donations&mainmenu=billing', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__); -- Special expenses -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->tax->enabled || $conf->salaries->enabled || $conf->loan->enabled || $conf->banque->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'billing', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=billing', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read) || (! empty($conf->loan->enabled) && $user->rights->loan->read) || (! empty($conf->banque->enabled) && $user->rights->banque->lire)', '', 0, 6, __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->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=billing', 'Salaries', 1, 'salaries', '$user->rights->salaries->payment->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->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->payment->write', '', 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->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->payment->read', '', 0, 3, __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->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2213__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/stats/index.php?leftmenu=tax_salary', 'Statistics', 2, 'companies', '$user->rights->salaries->payment->read', '', 0, 4, __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->tax->enabled || $conf->salaries->enabled || $conf->loan->enabled || $conf->banque->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'billing', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=billing', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->loan->enabled) && $user->rights->loan->read) || (! empty($conf->banque->enabled) && $user->rights->banque->lire)', '', 0, 6, __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->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'billing', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=billing', 'Salaries', 1, 'salaries', '$user->rights->salaries->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->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2211__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/card.php?leftmenu=tax_salary&action=create', 'NewPayment', 2, 'companies', '$user->rights->salaries->write', '', 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->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2212__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary', 'Payments', 2, 'companies', '$user->rights->salaries->read', '', 0, 3, __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->salaries->enabled && $leftmenu=="tax_salary"', __HANDLER__, 'left', 2213__+MAX_llx_menu__, 'billing', '', 2210__+MAX_llx_menu__, '/compta/salaries/stats/index.php?leftmenu=tax_salary', 'Statistics', 2, 'companies', '$user->rights->salaries->read', '', 0, 4, __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->loan->enabled', __HANDLER__, 'left', 2220__+MAX_llx_menu__, 'billing', 'tax_loan', 2200__+MAX_llx_menu__, '/loan/index.php?leftmenu=tax_loan&mainmenu=billing', 'Loans', 1, 'loan', '$user->rights->loan->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->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2221__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/card.php?leftmenu=tax_loan&action=create', 'NewLoan', 2, 'loan', '$user->rights->loan->write', '', 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->loan->enabled && $leftmenu=="tax_loan"', __HANDLER__, 'left', 2222__+MAX_llx_menu__, 'billing', '', 2220__+MAX_llx_menu__, '/loan/payment/list.php?leftmenu=tax_loan', 'Payments', 2, 'companies', '$user->rights->loan->read', '', 0, 3, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 695e7c4ca7f..143b2d7173a 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -152,7 +152,7 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! empty($conf->loan->enabled)) $menuqualified++; $tmpentry=array( 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), 'module'=>'facture|supplier_invoice|don|tax|salaries|loan'); $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -883,7 +883,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu { global $mysoc; - $permtoshowmenu=((! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read) || (! empty($conf->loan->enabled) && $user->rights->loan->read) || (! empty($conf->banque->enabled) && $user->rights->banque->lire)); + $permtoshowmenu=((! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) || (! empty($conf->loan->enabled) && $user->rights->loan->read) || (! empty($conf->banque->enabled) && $user->rights->banque->lire)); $newmenu->add("/compta/charges/index.php?leftmenu=tax&mainmenu=billing",$langs->trans("MenuSpecialExpenses"), 0, $permtoshowmenu, '', $mainmenu, 'tax'); // Social contributions @@ -931,10 +931,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->salaries->enabled)) { $langs->load("salaries"); - $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=billing",$langs->trans("Salaries"),1,$user->rights->salaries->payment->read, '', $mainmenu, 'tax_salary'); - if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->payment->write); - if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->payment->read); - if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"),2,$user->rights->salaries->payment->read); + $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=billing",$langs->trans("Salaries"),1,$user->rights->salaries->read, '', $mainmenu, 'tax_salary'); + if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/card.php?leftmenu=tax_salary&action=create",$langs->trans("NewPayment"),2,$user->rights->salaries->write); + if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/index.php?leftmenu=tax_salary",$langs->trans("Payments"),2,$user->rights->salaries->read); + if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_salary/i',$leftmenu)) $newmenu->add("/compta/salaries/stats/index.php?leftmenu=tax_salary", $langs->trans("Statistics"),2,$user->rights->salaries->read); } // Loan diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index e3d418d182e..2c93c45f9f6 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -50,7 +50,7 @@ class modSalaries extends DolibarrModules $this->db = $db; $this->numero = 510; // Perms from 501..519 - $this->family = "hr"; + $this->family = "compta"; // 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) @@ -97,55 +97,32 @@ class modSalaries extends DolibarrModules $r=0; $r++; - $this->rights[$r][0] = 501; - $this->rights[$r][1] = 'Read employee contracts/salaries'; + $this->rights[$r][0] = 511; + $this->rights[$r][1] = 'Read payments of employee salaries'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'read'; $this->rights[$r][5] = ''; $r++; - $this->rights[$r][0] = 502; - $this->rights[$r][1] = 'Create/modify employee contracts/salaries'; + $this->rights[$r][0] = 512; + $this->rights[$r][1] = 'Create/modify payments of empoyee salaries'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; $this->rights[$r][5] = ''; - $r++; - $this->rights[$r][0] = 511; - $this->rights[$r][1] = 'Read payment of salaries'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'payment'; - $this->rights[$r][5] = 'read'; - - $r++; - $this->rights[$r][0] = 512; - $this->rights[$r][1] = 'Create/modify payment of salaries'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'payment'; - $this->rights[$r][5] = 'write'; - $r++; $this->rights[$r][0] = 514; - $this->rights[$r][1] = 'Delete contracts/salaries'; + $this->rights[$r][1] = 'Delete payments of employee salary'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'delete'; $this->rights[$r][5] = ''; - $this->rights[$r][0] = 515; - $this->rights[$r][1] = 'Read all salaries'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'payment'; - $this->rights[$r][5] = 'readall'; - $r++; $this->rights[$r][0] = 517; - $this->rights[$r][1] = 'Export employee contracts and salaries payments'; + $this->rights[$r][1] = 'Export payments of employee salaries'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2ca70eda8ac..137b28ee523 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -789,11 +789,9 @@ Permission401=Read discounts Permission402=Create/modify discounts Permission403=Validate discounts Permission404=Delete discounts -Permission501=Read employee contracts/salaries -Permission502=Create/modify employee contracts/salaries -Permission511=Read payment of salaries -Permission512=Create/modify payment of salaries -Permission514=Delete salaries +Permission511=Read payments of salaries +Permission512=Create/modify payments of salaries +Permission514=Delete payments of salaries Permission517=Export salaries Permission520=Read Loans Permission522=Create/modify loans diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 7f11911a46b..7f4084ab4fe 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -48,13 +48,12 @@ $cancel = GETPOST('cancel','alpha'); $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); -// Ok if user->rights->salaries->read or user->rights->salaries->payment->write or user->rights->hrm->read +// Ok if user->rights->salaries->read or user->rights->hrm->read //$result = restrictedArea($user, 'salaries|hrm', $id, 'user&user', $feature2); $ok=false; if ($user->id == $id) $ok=true; // A user can always read its own card -if ($user->rights->salaries->read) $ok=true; -if ($user->rights->salaries->payment->write) $ok=true; -if ($user->rights->hrm->read) $ok=true; +if (! empty($user->rights->salaries->read)) $ok=true; +if (! empty($user->rights->hrm->read)) $ok=true; if (! $ok) { accessforbidden(); @@ -293,7 +292,7 @@ if ($action != 'edit' && $action != 'create') // If not bank account yet, $acco * Last salaries */ if (! empty($conf->salaries->enabled) && - ($user->rights->salaries->read || ($user->rights->salaries->read && $object->id == $user->id)) + ($user->rights->salaries->read && $object->id == $user->id) ) { $salary = new PaymentSalary($db); From 7c5ceff56955237663807c2ba1c0647db9ca23f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 7 Sep 2018 15:01:34 +0200 Subject: [PATCH 06/10] Fix search on project --- htdocs/projet/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 779091d069f..aa0c4b0d8fe 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -70,7 +70,7 @@ $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -$search_all=GETPOST('search_all', 'alphanohtml'); +$search_all=GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search_categ=GETPOST("search_categ",'alpha'); $search_ref=GETPOST("search_ref"); $search_label=GETPOST("search_label"); From 15aa99fc8e7599ea4460e231fc1e3274c81b69d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Sep 2018 01:22:01 +0200 Subject: [PATCH 07/10] Fix css --- htdocs/societe/consumption.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 848b0b74327..4138bf0891c 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -361,7 +361,7 @@ if ($sql_select) { $resql=$db->query($sql); if (!$resql) dol_print_error($db); - + $num = $db->num_rows($resql); $param="&socid=".$socid."&type_element=".$type_element; @@ -384,7 +384,7 @@ if ($sql_select) print ''; print ''; print ''; // date - print $formother->select_month($month?$month:-1,'month',1); + print $formother->select_month($month?$month:-1, 'month', 1, 0, 'valignmiddle'); $formother->select_year($year?$year:-1,'year',1, 20, 1); print ''; print ''; From d01120462465258d879f7ad0b6cfb3870c6e2c84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Sep 2018 17:36:46 +0200 Subject: [PATCH 08/10] Fix switch of extrafields between all and only one entity --- htdocs/core/class/extrafields.class.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index df837abdf4b..200c869f5e8 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -657,11 +657,22 @@ class ExtraFields $params=''; } - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; - $sql_del.= " WHERE name = '".$attrname."'"; - $sql_del.= " AND entity = ".($entity===''?$conf->entity:$entity); - $sql_del.= " AND elementtype = '".$elementtype."'"; - + if ($entity === '' || $entity != '0') + { + // We dont want on all entities, we delete all and current + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; + $sql_del.= " WHERE name = '".$attrname."'"; + $sql_del.= " AND entity IN (0, ".($entity===''?$conf->entity:$entity).")"; + $sql_del.= " AND elementtype = '".$elementtype."'"; + } + else + { + // We want on all entities ($entities = '0'), we delete on all only (we keep setup specific to each entity) + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."extrafields"; + $sql_del.= " WHERE name = '".$attrname."'"; + $sql_del.= " AND entity = 0"; + $sql_del.= " AND elementtype = '".$elementtype."'"; + } $resql1=$this->db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."extrafields("; From 7bea9f5ffb3ebc89086918926ffd8bc775e481c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Sep 2018 10:57:09 +0200 Subject: [PATCH 09/10] FIX Lose filter on payment type or category after a sort on invoice list --- htdocs/compta/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index d45939bb29c..f5c3d469dda 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -575,14 +575,14 @@ if ($resql) if ($search_zip) $param.='&search_zip='.urlencode($search_zip); if ($search_sale > 0) $param.='&search_sale=' .urlencode($search_sale); if ($search_user > 0) $param.='&search_user=' .urlencode($search_user); - if ($search_product_category > 0) $param.='$search_product_category=' .urlencode($search_product_category); + if ($search_product_category > 0) $param.='&search_product_category=' .urlencode($search_product_category); if ($search_montant_ht != '') $param.='&search_montant_ht='.urlencode($search_montant_ht); if ($search_montant_vat != '') $param.='&search_montant_vat='.urlencode($search_montant_vat); if ($search_montant_localtax1 != '') $param.='&search_montant_localtax1='.urlencode($search_montant_localtax1); if ($search_montant_localtax2 != '') $param.='&search_montant_localtax2='.urlencode($search_montant_localtax2); if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_status != '') $param.='&search_status='.urlencode($search_status); - if ($search_paymentmode > 0) $param.='search_paymentmode='.urlencode($search_paymentmode); + if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); if ($show_files) $param.='&show_files='.urlencode($show_files); if ($option) $param.="&search_option=".urlencode($option); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); From 53da80a79f37dc39d7fdb62af8f18ad5990ef026 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 Sep 2018 12:55:10 +0200 Subject: [PATCH 10/10] FIX Missing translation in predefined email to membership renewal --- htdocs/core/class/html.formmail.class.php | 1 + htdocs/core/lib/functions.lib.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index fe3ef54552e..8ec31ec77bf 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -939,6 +939,7 @@ class FormMail extends Form if (count($validpaymentmethod) > 0 && $paymenturl) { + $langs->load('other'); $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=str_replace('\n',"\n",$langs->transnoentities("PredefinedMailContentLink", $paymenturl)); $this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 77d64406d3b..c67596fde09 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6064,7 +6064,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { // Set the online payment url link into __ONLINE_PAYMENT_URL__ key require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - $outputlangs->load('paypal'); + $outputlangs->loadLangs(array('paypal','other')); $typeforonlinepayment='free'; if (is_object($object) && $object->element == 'commande') $typeforonlinepayment='order'; if (is_object($object) && $object->element == 'facture') $typeforonlinepayment='invoice';