@@ -51,14 +51,14 @@ |
||
51 | 51 | header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); |
52 | 52 | |
53 | 53 | switch ($_SERVER['REQUEST_METHOD']) { |
54 | - case 'OPTIONS': |
|
55 | - break; |
|
54 | + case 'OPTIONS': |
|
55 | + break; |
|
56 | 56 | case 'HEAD': |
57 | 57 | case 'GET': |
58 | 58 | $upload_handler->get(); |
59 | 59 | break; |
60 | 60 | case 'POST': |
61 | - if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { |
|
61 | + if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { |
|
62 | 62 | $upload_handler->delete(); |
63 | 63 | } else { |
64 | 64 | $upload_handler->post(); |
@@ -21,10 +21,20 @@ |
||
21 | 21 | * \brief File to return Ajax response on file upload |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
24 | +if (! defined('NOCSRFCHECK')) { |
|
25 | + define('NOCSRFCHECK','1'); |
|
26 | +} |
|
27 | +if (! defined('NOTOKENRENEWAL')) { |
|
28 | + define('NOTOKENRENEWAL','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREMENU')) { |
|
31 | + define('NOREQUIREMENU','1'); |
|
32 | +} |
|
33 | +// If there is no menu to show |
|
34 | +if (! defined('NOREQUIREHTML')) { |
|
35 | + define('NOREQUIREHTML','1'); |
|
36 | +} |
|
37 | +// If we don't need to load the html.form.class.php |
|
28 | 38 | |
29 | 39 | |
30 | 40 |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * \brief File to return Ajax response on file upload |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
24 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
25 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
26 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
27 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/fileupload.class.php'; |
35 | 35 | |
36 | 36 | error_reporting(E_ALL | E_STRICT); |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | //print_r($_GET); |
40 | 40 | //print 'upload_dir='.GETPOST('upload_dir'); |
41 | 41 | |
42 | -$fk_element = GETPOST('fk_element','int'); |
|
43 | -$element = GETPOST('element','alpha'); |
|
42 | +$fk_element = GETPOST('fk_element', 'int'); |
|
43 | +$element = GETPOST('element', 'alpha'); |
|
44 | 44 | |
45 | 45 | |
46 | -$upload_handler = new FileUpload(null,$fk_element,$element); |
|
46 | +$upload_handler = new FileUpload(null, $fk_element, $element); |
|
47 | 47 | |
48 | 48 | header('Pragma: no-cache'); |
49 | 49 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | |
50 | 50 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvnext') |
51 | 51 | { |
52 | - // Increase date |
|
53 | - $al = new AccountLine($db); |
|
52 | + // Increase date |
|
53 | + $al = new AccountLine($db); |
|
54 | 54 | $al->datev_next(GETPOST('rowid','int')); |
55 | 55 | $al->fetch(GETPOST('rowid','int')); |
56 | 56 | |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | |
62 | 62 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') |
63 | 63 | { |
64 | - // Decrease date |
|
65 | - $al =new AccountLine($db); |
|
64 | + // Decrease date |
|
65 | + $al =new AccountLine($db); |
|
66 | 66 | $al->datev_previous(GETPOST('rowid','int')); |
67 | 67 | $al->fetch(GETPOST('rowid','int')); |
68 | 68 | |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | |
74 | 74 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') |
75 | 75 | { |
76 | - // Increase date |
|
77 | - $al = new AccountLine($db); |
|
76 | + // Increase date |
|
77 | + $al = new AccountLine($db); |
|
78 | 78 | $al->dateo_next(GETPOST('rowid','int')); |
79 | 79 | $al->fetch(GETPOST('rowid','int')); |
80 | 80 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | |
86 | 86 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') |
87 | 87 | { |
88 | - // Decrease date |
|
89 | - $al =new AccountLine($db); |
|
88 | + // Decrease date |
|
89 | + $al =new AccountLine($db); |
|
90 | 90 | $al->dateo_previous(GETPOST('rowid','int')); |
91 | 91 | $al->fetch(GETPOST('rowid','int')); |
92 | 92 |
@@ -20,11 +20,22 @@ |
||
20 | 20 | * \brief File to set data for bank concilation |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREHTML')) { |
|
31 | + define('NOREQUIREHTML','1'); |
|
32 | +} |
|
33 | +if (! defined('NOREQUIREAJAX')) { |
|
34 | + define('NOREQUIREAJAX','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIRESOC')) { |
|
37 | + define('NOREQUIRESOC','1'); |
|
38 | +} |
|
28 | 39 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date |
29 | 40 | |
30 | 41 |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | * \brief File to set data for bank concilation |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | 28 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Required to know date format for dol_print_date |
29 | 29 | |
30 | 30 | |
31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
35 | 35 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
36 | 36 | |
37 | -$action=GETPOST('action','aZ09'); |
|
37 | +$action = GETPOST('action', 'aZ09'); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | /* |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | { |
55 | 55 | // Increase date |
56 | 56 | $al = new AccountLine($db); |
57 | - $al->datev_next(GETPOST('rowid','int')); |
|
58 | - $al->fetch(GETPOST('rowid','int')); |
|
57 | + $al->datev_next(GETPOST('rowid', 'int')); |
|
58 | + $al->fetch(GETPOST('rowid', 'int')); |
|
59 | 59 | |
60 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
60 | + print '<span>'.dol_print_date($db->jdate($al->datev), "day").'</span>'; |
|
61 | 61 | |
62 | 62 | exit; |
63 | 63 | } |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') |
66 | 66 | { |
67 | 67 | // Decrease date |
68 | - $al =new AccountLine($db); |
|
69 | - $al->datev_previous(GETPOST('rowid','int')); |
|
70 | - $al->fetch(GETPOST('rowid','int')); |
|
68 | + $al = new AccountLine($db); |
|
69 | + $al->datev_previous(GETPOST('rowid', 'int')); |
|
70 | + $al->fetch(GETPOST('rowid', 'int')); |
|
71 | 71 | |
72 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
72 | + print '<span>'.dol_print_date($db->jdate($al->datev), "day").'</span>'; |
|
73 | 73 | |
74 | 74 | exit; |
75 | 75 | } |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | { |
79 | 79 | // Increase date |
80 | 80 | $al = new AccountLine($db); |
81 | - $al->dateo_next(GETPOST('rowid','int')); |
|
82 | - $al->fetch(GETPOST('rowid','int')); |
|
81 | + $al->dateo_next(GETPOST('rowid', 'int')); |
|
82 | + $al->fetch(GETPOST('rowid', 'int')); |
|
83 | 83 | |
84 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
84 | + print '<span>'.dol_print_date($db->jdate($al->dateo), "day").'</span>'; |
|
85 | 85 | |
86 | 86 | exit; |
87 | 87 | } |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') |
90 | 90 | { |
91 | 91 | // Decrease date |
92 | - $al =new AccountLine($db); |
|
93 | - $al->dateo_previous(GETPOST('rowid','int')); |
|
94 | - $al->fetch(GETPOST('rowid','int')); |
|
92 | + $al = new AccountLine($db); |
|
93 | + $al->dateo_previous(GETPOST('rowid', 'int')); |
|
94 | + $al->fetch(GETPOST('rowid', 'int')); |
|
95 | 95 | |
96 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
96 | + print '<span>'.dol_print_date($db->jdate($al->dateo), "day").'</span>'; |
|
97 | 97 | |
98 | 98 | exit; |
99 | 99 | } |
@@ -42,25 +42,25 @@ |
||
42 | 42 | // Load original field value |
43 | 43 | if (! empty($output) && isset($amount) && isset($tva_tx)) |
44 | 44 | { |
45 | - $return=array(); |
|
46 | - $price=''; |
|
45 | + $return=array(); |
|
46 | + $price=''; |
|
47 | 47 | |
48 | - if (is_numeric($amount) && $amount != '') |
|
49 | - { |
|
50 | - if ($output == 'price_ttc') { |
|
48 | + if (is_numeric($amount) && $amount != '') |
|
49 | + { |
|
50 | + if ($output == 'price_ttc') { |
|
51 | 51 | |
52 | - $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); |
|
53 | - $return['price_ht'] = $amount; |
|
54 | - $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); |
|
55 | - } |
|
56 | - else if ($output == 'price_ht') { |
|
52 | + $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); |
|
53 | + $return['price_ht'] = $amount; |
|
54 | + $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); |
|
55 | + } |
|
56 | + else if ($output == 'price_ht') { |
|
57 | 57 | |
58 | - $price = price2num($amount / (1 + ($tva_tx/100)), 'MU'); |
|
59 | - $return['price_ht'] = (isset($price) && $price != '' ? price($price) : ''); |
|
60 | - $return['price_ttc'] = ($tva_tx == 0 ? $price : $amount); |
|
61 | - } |
|
62 | - } |
|
58 | + $price = price2num($amount / (1 + ($tva_tx/100)), 'MU'); |
|
59 | + $return['price_ht'] = (isset($price) && $price != '' ? price($price) : ''); |
|
60 | + $return['price_ttc'] = ($tva_tx == 0 ? $price : $amount); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - echo json_encode($return); |
|
64 | + echo json_encode($return); |
|
65 | 65 | } |
66 | 66 |
@@ -20,10 +20,19 @@ discard block |
||
20 | 20 | * \brief File to get ht and ttc |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX','1'); |
|
32 | +} |
|
33 | +if (! defined('NOREQUIRESOC')) { |
|
34 | + define('NOREQUIRESOC','1'); |
|
35 | +} |
|
27 | 36 | |
28 | 37 | |
29 | 38 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -55,8 +64,7 @@ discard block |
||
55 | 64 | $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); |
56 | 65 | $return['price_ht'] = $amount; |
57 | 66 | $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); |
58 | - } |
|
59 | - else if ($output == 'price_ht') { |
|
67 | + } else if ($output == 'price_ht') { |
|
60 | 68 | |
61 | 69 | $price = price2num($amount / (1 + ($tva_tx/100)), 'MU'); |
62 | 70 | $return['price_ht'] = (isset($price) && $price != '' ? price($price) : ''); |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * \brief File to get ht and ttc |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
31 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
31 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
32 | 32 | |
33 | -$output = GETPOST('output','alpha'); |
|
34 | -$amount = price2num(GETPOST('amount','alpha')); |
|
35 | -$tva_tx = str_replace('*','',GETPOST('tva_tx','alpha')); |
|
33 | +$output = GETPOST('output', 'alpha'); |
|
34 | +$amount = price2num(GETPOST('amount', 'alpha')); |
|
35 | +$tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha')); |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * View |
@@ -43,22 +43,22 @@ discard block |
||
43 | 43 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
44 | 44 | |
45 | 45 | // Load original field value |
46 | -if (! empty($output) && isset($amount) && isset($tva_tx)) |
|
46 | +if (!empty($output) && isset($amount) && isset($tva_tx)) |
|
47 | 47 | { |
48 | - $return=array(); |
|
49 | - $price=''; |
|
48 | + $return = array(); |
|
49 | + $price = ''; |
|
50 | 50 | |
51 | 51 | if (is_numeric($amount) && $amount != '') |
52 | 52 | { |
53 | 53 | if ($output == 'price_ttc') { |
54 | 54 | |
55 | - $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); |
|
55 | + $price = price2num($amount * (1 + ($tva_tx / 100)), 'MU'); |
|
56 | 56 | $return['price_ht'] = $amount; |
57 | 57 | $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); |
58 | 58 | } |
59 | 59 | else if ($output == 'price_ht') { |
60 | 60 | |
61 | - $price = price2num($amount / (1 + ($tva_tx/100)), 'MU'); |
|
61 | + $price = price2num($amount / (1 + ($tva_tx / 100)), 'MU'); |
|
62 | 62 | $return['price_ht'] = (isset($price) && $price != '' ? price($price) : ''); |
63 | 63 | $return['price_ttc'] = ($tva_tx == 0 ? $price : $amount); |
64 | 64 | } |
@@ -43,28 +43,28 @@ |
||
43 | 43 | // Load original field value |
44 | 44 | if (! empty($id) && ! empty($action) && ! empty($htmlname)) |
45 | 45 | { |
46 | - $form = new Form($db); |
|
47 | - $soc = new Societe($db); |
|
46 | + $form = new Form($db); |
|
47 | + $soc = new Societe($db); |
|
48 | 48 | |
49 | - $soc->fetch($id); |
|
49 | + $soc->fetch($id); |
|
50 | 50 | |
51 | - if ($action == 'getSellerVATRates') |
|
52 | - { |
|
53 | - $seller = $mysoc; |
|
54 | - $buyer = $soc; |
|
55 | - } |
|
56 | - else |
|
57 | - { |
|
58 | - $buyer = $mysoc; |
|
59 | - $seller = $soc; |
|
60 | - } |
|
51 | + if ($action == 'getSellerVATRates') |
|
52 | + { |
|
53 | + $seller = $mysoc; |
|
54 | + $buyer = $soc; |
|
55 | + } |
|
56 | + else |
|
57 | + { |
|
58 | + $buyer = $mysoc; |
|
59 | + $seller = $soc; |
|
60 | + } |
|
61 | 61 | |
62 | - $return=array(); |
|
62 | + $return=array(); |
|
63 | 63 | |
64 | - $return['value'] = $form->load_tva('tva_tx',$selected,$seller,$buyer,$productid,0,'',true); |
|
65 | - $return['num'] = $form->num; |
|
66 | - $return['error'] = $form->error; |
|
64 | + $return['value'] = $form->load_tva('tva_tx',$selected,$seller,$buyer,$productid,0,'',true); |
|
65 | + $return['num'] = $form->num; |
|
66 | + $return['error'] = $form->error; |
|
67 | 67 | |
68 | - echo json_encode($return); |
|
68 | + echo json_encode($return); |
|
69 | 69 | } |
70 | 70 |
@@ -20,9 +20,16 @@ discard block |
||
20 | 20 | * \brief File to load vat rates combobox |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX','1'); |
|
32 | +} |
|
26 | 33 | |
27 | 34 | |
28 | 35 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -55,8 +62,7 @@ discard block |
||
55 | 62 | { |
56 | 63 | $seller = $mysoc; |
57 | 64 | $buyer = $soc; |
58 | - } |
|
59 | - else |
|
65 | + } else |
|
60 | 66 | { |
61 | 67 | $buyer = $mysoc; |
62 | 68 | $seller = $soc; |
@@ -20,20 +20,20 @@ discard block |
||
20 | 20 | * \brief File to load vat rates combobox |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
29 | 29 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
30 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
30 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
31 | 31 | |
32 | -$id = GETPOST('id','int'); |
|
33 | -$action = GETPOST('action','alpha'); |
|
34 | -$htmlname = GETPOST('htmlname','alpha'); |
|
35 | -$selected = (GETPOST('selected')?GETPOST('selected'):'-1'); |
|
36 | -$productid = (GETPOST('productid','int')?GETPOST('productid','int'):0); |
|
32 | +$id = GETPOST('id', 'int'); |
|
33 | +$action = GETPOST('action', 'alpha'); |
|
34 | +$htmlname = GETPOST('htmlname', 'alpha'); |
|
35 | +$selected = (GETPOST('selected') ?GETPOST('selected') : '-1'); |
|
36 | +$productid = (GETPOST('productid', 'int') ?GETPOST('productid', 'int') : 0); |
|
37 | 37 | |
38 | 38 | /* |
39 | 39 | * View |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
45 | 45 | |
46 | 46 | // Load original field value |
47 | -if (! empty($id) && ! empty($action) && ! empty($htmlname)) |
|
47 | +if (!empty($id) && !empty($action) && !empty($htmlname)) |
|
48 | 48 | { |
49 | 49 | $form = new Form($db); |
50 | 50 | $soc = new Societe($db); |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | $seller = $soc; |
63 | 63 | } |
64 | 64 | |
65 | - $return=array(); |
|
65 | + $return = array(); |
|
66 | 66 | |
67 | - $return['value'] = $form->load_tva('tva_tx',$selected,$seller,$buyer,$productid,0,'',true); |
|
68 | - $return['num'] = $form->num; |
|
67 | + $return['value'] = $form->load_tva('tva_tx', $selected, $seller, $buyer, $productid, 0, '', true); |
|
68 | + $return['num'] = $form->num; |
|
69 | 69 | $return['error'] = $form->error; |
70 | 70 | |
71 | 71 | echo json_encode($return); |
@@ -43,15 +43,15 @@ |
||
43 | 43 | // Load original field value |
44 | 44 | if (! empty($id) && ! empty($action) && ! empty($htmlname)) |
45 | 45 | { |
46 | - $form = new Form($db); |
|
46 | + $form = new Form($db); |
|
47 | 47 | |
48 | - $return=array(); |
|
49 | - if (empty($showempty)) $showempty=0; |
|
48 | + $return=array(); |
|
49 | + if (empty($showempty)) $showempty=0; |
|
50 | 50 | |
51 | - $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); |
|
52 | - $return['num'] = $form->num; |
|
53 | - $return['error'] = $form->error; |
|
51 | + $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); |
|
52 | + $return['num'] = $form->num; |
|
53 | + $return['error'] = $form->error; |
|
54 | 54 | |
55 | - echo json_encode($return); |
|
55 | + echo json_encode($return); |
|
56 | 56 | } |
57 | 57 |
@@ -21,9 +21,16 @@ discard block |
||
21 | 21 | * \brief File to load contacts combobox |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
24 | +if (! defined('NOTOKENRENEWAL')) { |
|
25 | + define('NOTOKENRENEWAL','1'); |
|
26 | +} |
|
27 | +// Disables token renewal |
|
28 | +if (! defined('NOREQUIREMENU')) { |
|
29 | + define('NOREQUIREMENU','1'); |
|
30 | +} |
|
31 | +if (! defined('NOREQUIREAJAX')) { |
|
32 | + define('NOREQUIREAJAX','1'); |
|
33 | +} |
|
27 | 34 | |
28 | 35 | |
29 | 36 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -49,7 +56,9 @@ discard block |
||
49 | 56 | $form = new Form($db); |
50 | 57 | |
51 | 58 | $return=array(); |
52 | - if (empty($showempty)) $showempty=0; |
|
59 | + if (empty($showempty)) { |
|
60 | + $showempty=0; |
|
61 | + } |
|
53 | 62 | |
54 | 63 | $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); |
55 | 64 | $return['num'] = $form->num; |
@@ -21,19 +21,19 @@ discard block |
||
21 | 21 | * \brief File to load contacts combobox |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
24 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
25 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
31 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
31 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
32 | 32 | |
33 | -$id = GETPOST('id','int'); |
|
34 | -$action = GETPOST('action','alpha'); |
|
35 | -$htmlname = GETPOST('htmlname','alpha'); |
|
36 | -$showempty = GETPOST('showempty','int'); |
|
33 | +$id = GETPOST('id', 'int'); |
|
34 | +$action = GETPOST('action', 'alpha'); |
|
35 | +$htmlname = GETPOST('htmlname', 'alpha'); |
|
36 | +$showempty = GETPOST('showempty', 'int'); |
|
37 | 37 | |
38 | 38 | /* |
39 | 39 | * View |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
45 | 45 | |
46 | 46 | // Load original field value |
47 | -if (! empty($id) && ! empty($action) && ! empty($htmlname)) |
|
47 | +if (!empty($id) && !empty($action) && !empty($htmlname)) |
|
48 | 48 | { |
49 | 49 | $form = new Form($db); |
50 | 50 | |
51 | - $return=array(); |
|
52 | - if (empty($showempty)) $showempty=0; |
|
51 | + $return = array(); |
|
52 | + if (empty($showempty)) $showempty = 0; |
|
53 | 53 | |
54 | - $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); |
|
55 | - $return['num'] = $form->num; |
|
54 | + $return['value'] = $form->selectcontacts($id, '', $htmlname, $showempty, '', '', 0, '', true); |
|
55 | + $return['num'] = $form->num; |
|
56 | 56 | $return['error'] = $form->error; |
57 | 57 | |
58 | 58 | echo json_encode($return); |
@@ -58,175 +58,175 @@ |
||
58 | 58 | // Load original field value |
59 | 59 | if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) |
60 | 60 | { |
61 | - $ext_element = GETPOST('ext_element','alpha',2); |
|
62 | - $field = substr($field, 8); // remove prefix val_ |
|
63 | - $type = GETPOST('type','alpha',2); |
|
64 | - $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); |
|
65 | - $loadmethod = GETPOST('loadmethod','alpha',2); |
|
66 | - $savemethod = GETPOST('savemethod','alpha',2); |
|
67 | - $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); |
|
68 | - $newelement = $element; |
|
69 | - |
|
70 | - $view=''; |
|
71 | - $format='text'; |
|
72 | - $return=array(); |
|
73 | - $error=0; |
|
74 | - |
|
75 | - if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) |
|
76 | - { |
|
77 | - $element = $regs[1]; |
|
78 | - $subelement = $regs[2]; |
|
79 | - } |
|
80 | - |
|
81 | - if ($element == 'propal') $newelement = 'propale'; |
|
82 | - else if ($element == 'fichinter') $newelement = 'ficheinter'; |
|
83 | - else if ($element == 'product') $newelement = 'produit'; |
|
84 | - else if ($element == 'member') $newelement = 'adherent'; |
|
85 | - else if ($element == 'order_supplier') { |
|
86 | - $newelement = 'fournisseur'; |
|
87 | - $subelement = 'commande'; |
|
88 | - } |
|
89 | - else if ($element == 'invoice_supplier') { |
|
90 | - $newelement = 'fournisseur'; |
|
91 | - $subelement = 'facture'; |
|
92 | - } |
|
93 | - else $newelement = $element; |
|
94 | - |
|
95 | - $_POST['action']='update'; // Hack so restrictarea will test permissions on write too |
|
96 | - $feature = $newelement; |
|
97 | - $feature2 = $subelement; |
|
98 | - $object_id = $fk_element; |
|
99 | - if ($feature == 'expedition' || $feature == 'shipping') |
|
100 | - { |
|
101 | - $feature = 'commande'; |
|
102 | - $object_id = 0; |
|
103 | - } |
|
104 | - if ($feature == 'shipping') $feature = 'commande'; |
|
105 | - if ($feature == 'payment') { $feature = 'facture'; } |
|
106 | - if ($feature == 'payment_supplier') { $feature = 'fournisseur'; $feature2 = 'facture'; } |
|
107 | - //var_dump(GETPOST('action','aZ09')); |
|
108 | - //var_dump($newelement.'-'.$subelement."-".$feature."-".$object_id); |
|
109 | - $check_access = restrictedArea($user, $feature, $object_id, '', $feature2); |
|
110 | - //var_dump($user->rights); |
|
111 | - /* |
|
61 | + $ext_element = GETPOST('ext_element','alpha',2); |
|
62 | + $field = substr($field, 8); // remove prefix val_ |
|
63 | + $type = GETPOST('type','alpha',2); |
|
64 | + $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); |
|
65 | + $loadmethod = GETPOST('loadmethod','alpha',2); |
|
66 | + $savemethod = GETPOST('savemethod','alpha',2); |
|
67 | + $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); |
|
68 | + $newelement = $element; |
|
69 | + |
|
70 | + $view=''; |
|
71 | + $format='text'; |
|
72 | + $return=array(); |
|
73 | + $error=0; |
|
74 | + |
|
75 | + if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) |
|
76 | + { |
|
77 | + $element = $regs[1]; |
|
78 | + $subelement = $regs[2]; |
|
79 | + } |
|
80 | + |
|
81 | + if ($element == 'propal') $newelement = 'propale'; |
|
82 | + else if ($element == 'fichinter') $newelement = 'ficheinter'; |
|
83 | + else if ($element == 'product') $newelement = 'produit'; |
|
84 | + else if ($element == 'member') $newelement = 'adherent'; |
|
85 | + else if ($element == 'order_supplier') { |
|
86 | + $newelement = 'fournisseur'; |
|
87 | + $subelement = 'commande'; |
|
88 | + } |
|
89 | + else if ($element == 'invoice_supplier') { |
|
90 | + $newelement = 'fournisseur'; |
|
91 | + $subelement = 'facture'; |
|
92 | + } |
|
93 | + else $newelement = $element; |
|
94 | + |
|
95 | + $_POST['action']='update'; // Hack so restrictarea will test permissions on write too |
|
96 | + $feature = $newelement; |
|
97 | + $feature2 = $subelement; |
|
98 | + $object_id = $fk_element; |
|
99 | + if ($feature == 'expedition' || $feature == 'shipping') |
|
100 | + { |
|
101 | + $feature = 'commande'; |
|
102 | + $object_id = 0; |
|
103 | + } |
|
104 | + if ($feature == 'shipping') $feature = 'commande'; |
|
105 | + if ($feature == 'payment') { $feature = 'facture'; } |
|
106 | + if ($feature == 'payment_supplier') { $feature = 'fournisseur'; $feature2 = 'facture'; } |
|
107 | + //var_dump(GETPOST('action','aZ09')); |
|
108 | + //var_dump($newelement.'-'.$subelement."-".$feature."-".$object_id); |
|
109 | + $check_access = restrictedArea($user, $feature, $object_id, '', $feature2); |
|
110 | + //var_dump($user->rights); |
|
111 | + /* |
|
112 | 112 | if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->create) || ! empty($user->rights->$newelement->write) |
113 | 113 | || (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write))) |
114 | 114 | || ($element == 'payment' && $user->rights->facture->paiement) |
115 | 115 | || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer)) |
116 | 116 | */ |
117 | 117 | |
118 | - if ($check_access) |
|
119 | - { |
|
120 | - // Clean parameters |
|
121 | - $newvalue = trim($value); |
|
122 | - |
|
123 | - if ($type == 'numeric') |
|
124 | - { |
|
125 | - $newvalue = price2num($newvalue); |
|
126 | - |
|
127 | - // Check parameters |
|
128 | - if (! is_numeric($newvalue)) |
|
129 | - { |
|
130 | - $error++; |
|
131 | - $return['error'] = $langs->trans('ErrorBadValue'); |
|
132 | - } |
|
133 | - } |
|
134 | - else if ($type == 'datepicker') |
|
135 | - { |
|
136 | - $timestamp = GETPOST('timestamp','int',2); |
|
137 | - $format = 'date'; |
|
138 | - $newvalue = ($timestamp / 1000); |
|
139 | - } |
|
140 | - else if ($type == 'select') |
|
141 | - { |
|
142 | - $loadmethodname = 'load_cache_'.$loadmethod; |
|
143 | - $loadcachename = 'cache_'.$loadmethod; |
|
144 | - $loadviewname = 'view_'.$loadmethod; |
|
145 | - |
|
146 | - $form = new Form($db); |
|
147 | - if (method_exists($form, $loadmethodname)) |
|
148 | - { |
|
149 | - $ret = $form->$loadmethodname(); |
|
150 | - if ($ret > 0) |
|
151 | - { |
|
152 | - $loadcache = $form->$loadcachename; |
|
153 | - $value = $loadcache[$newvalue]; |
|
154 | - |
|
155 | - if (! empty($form->$loadviewname)) |
|
156 | - { |
|
157 | - $loadview = $form->$loadviewname; |
|
158 | - $view = $loadview[$newvalue]; |
|
159 | - } |
|
160 | - } |
|
161 | - else |
|
162 | - { |
|
163 | - $error++; |
|
164 | - $return['error'] = $form->error; |
|
165 | - } |
|
166 | - } |
|
167 | - else |
|
168 | - { |
|
169 | - $module = $subelement = $ext_element; |
|
170 | - if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
|
171 | - { |
|
172 | - $module = $regs[1]; |
|
173 | - $subelement = $regs[2]; |
|
174 | - } |
|
175 | - |
|
176 | - dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); |
|
177 | - $classname = 'Actions'.ucfirst($subelement); |
|
178 | - $object = new $classname($db); |
|
179 | - $ret = $object->$loadmethodname(); |
|
180 | - if ($ret > 0) |
|
181 | - { |
|
182 | - $loadcache = $object->$loadcachename; |
|
183 | - $value = $loadcache[$newvalue]; |
|
184 | - |
|
185 | - if (! empty($object->$loadviewname)) |
|
186 | - { |
|
187 | - $loadview = $object->$loadviewname; |
|
188 | - $view = $loadview[$newvalue]; |
|
189 | - } |
|
190 | - } |
|
191 | - else |
|
192 | - { |
|
193 | - $error++; |
|
194 | - $return['error'] = $object->error; |
|
195 | - } |
|
196 | - } |
|
197 | - } |
|
198 | - |
|
199 | - if (! $error) |
|
200 | - { |
|
201 | - if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
202 | - |
|
203 | - // Specific for add_object_linked() |
|
204 | - // TODO add a function for variable treatment |
|
205 | - $object->ext_fk_element = $newvalue; |
|
206 | - $object->ext_element = $ext_element; |
|
207 | - $object->fk_element = $fk_element; |
|
208 | - $object->element = $element; |
|
209 | - |
|
210 | - $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
|
211 | - if ($ret > 0) |
|
212 | - { |
|
213 | - if ($type == 'numeric') $value = price($newvalue); |
|
214 | - else if ($type == 'textarea') $value = dol_nl2br($newvalue); |
|
215 | - |
|
216 | - $return['value'] = $value; |
|
217 | - $return['view'] = (! empty($view) ? $view : $value); |
|
218 | - } |
|
219 | - else |
|
220 | - { |
|
221 | - $return['error'] = $object->error; |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - echo json_encode($return); |
|
226 | - } |
|
227 | - else |
|
228 | - { |
|
229 | - echo $langs->trans('NotEnoughPermissions'); |
|
230 | - } |
|
118 | + if ($check_access) |
|
119 | + { |
|
120 | + // Clean parameters |
|
121 | + $newvalue = trim($value); |
|
122 | + |
|
123 | + if ($type == 'numeric') |
|
124 | + { |
|
125 | + $newvalue = price2num($newvalue); |
|
126 | + |
|
127 | + // Check parameters |
|
128 | + if (! is_numeric($newvalue)) |
|
129 | + { |
|
130 | + $error++; |
|
131 | + $return['error'] = $langs->trans('ErrorBadValue'); |
|
132 | + } |
|
133 | + } |
|
134 | + else if ($type == 'datepicker') |
|
135 | + { |
|
136 | + $timestamp = GETPOST('timestamp','int',2); |
|
137 | + $format = 'date'; |
|
138 | + $newvalue = ($timestamp / 1000); |
|
139 | + } |
|
140 | + else if ($type == 'select') |
|
141 | + { |
|
142 | + $loadmethodname = 'load_cache_'.$loadmethod; |
|
143 | + $loadcachename = 'cache_'.$loadmethod; |
|
144 | + $loadviewname = 'view_'.$loadmethod; |
|
145 | + |
|
146 | + $form = new Form($db); |
|
147 | + if (method_exists($form, $loadmethodname)) |
|
148 | + { |
|
149 | + $ret = $form->$loadmethodname(); |
|
150 | + if ($ret > 0) |
|
151 | + { |
|
152 | + $loadcache = $form->$loadcachename; |
|
153 | + $value = $loadcache[$newvalue]; |
|
154 | + |
|
155 | + if (! empty($form->$loadviewname)) |
|
156 | + { |
|
157 | + $loadview = $form->$loadviewname; |
|
158 | + $view = $loadview[$newvalue]; |
|
159 | + } |
|
160 | + } |
|
161 | + else |
|
162 | + { |
|
163 | + $error++; |
|
164 | + $return['error'] = $form->error; |
|
165 | + } |
|
166 | + } |
|
167 | + else |
|
168 | + { |
|
169 | + $module = $subelement = $ext_element; |
|
170 | + if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
|
171 | + { |
|
172 | + $module = $regs[1]; |
|
173 | + $subelement = $regs[2]; |
|
174 | + } |
|
175 | + |
|
176 | + dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); |
|
177 | + $classname = 'Actions'.ucfirst($subelement); |
|
178 | + $object = new $classname($db); |
|
179 | + $ret = $object->$loadmethodname(); |
|
180 | + if ($ret > 0) |
|
181 | + { |
|
182 | + $loadcache = $object->$loadcachename; |
|
183 | + $value = $loadcache[$newvalue]; |
|
184 | + |
|
185 | + if (! empty($object->$loadviewname)) |
|
186 | + { |
|
187 | + $loadview = $object->$loadviewname; |
|
188 | + $view = $loadview[$newvalue]; |
|
189 | + } |
|
190 | + } |
|
191 | + else |
|
192 | + { |
|
193 | + $error++; |
|
194 | + $return['error'] = $object->error; |
|
195 | + } |
|
196 | + } |
|
197 | + } |
|
198 | + |
|
199 | + if (! $error) |
|
200 | + { |
|
201 | + if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
202 | + |
|
203 | + // Specific for add_object_linked() |
|
204 | + // TODO add a function for variable treatment |
|
205 | + $object->ext_fk_element = $newvalue; |
|
206 | + $object->ext_element = $ext_element; |
|
207 | + $object->fk_element = $fk_element; |
|
208 | + $object->element = $element; |
|
209 | + |
|
210 | + $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
|
211 | + if ($ret > 0) |
|
212 | + { |
|
213 | + if ($type == 'numeric') $value = price($newvalue); |
|
214 | + else if ($type == 'textarea') $value = dol_nl2br($newvalue); |
|
215 | + |
|
216 | + $return['value'] = $value; |
|
217 | + $return['view'] = (! empty($view) ? $view : $value); |
|
218 | + } |
|
219 | + else |
|
220 | + { |
|
221 | + $return['error'] = $object->error; |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + echo json_encode($return); |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
229 | + echo $langs->trans('NotEnoughPermissions'); |
|
230 | + } |
|
231 | 231 | } |
232 | 232 |
@@ -20,10 +20,19 @@ discard block |
||
20 | 20 | * \brief File to save field value |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREAJAX')) { |
|
31 | + define('NOREQUIREAJAX','1'); |
|
32 | +} |
|
33 | +if (! defined('NOREQUIRESOC')) { |
|
34 | + define('NOREQUIRESOC','1'); |
|
35 | +} |
|
27 | 36 | |
28 | 37 | |
29 | 38 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -81,19 +90,23 @@ discard block |
||
81 | 90 | $subelement = $regs[2]; |
82 | 91 | } |
83 | 92 | |
84 | - if ($element == 'propal') $newelement = 'propale'; |
|
85 | - else if ($element == 'fichinter') $newelement = 'ficheinter'; |
|
86 | - else if ($element == 'product') $newelement = 'produit'; |
|
87 | - else if ($element == 'member') $newelement = 'adherent'; |
|
88 | - else if ($element == 'order_supplier') { |
|
93 | + if ($element == 'propal') { |
|
94 | + $newelement = 'propale'; |
|
95 | + } else if ($element == 'fichinter') { |
|
96 | + $newelement = 'ficheinter'; |
|
97 | + } else if ($element == 'product') { |
|
98 | + $newelement = 'produit'; |
|
99 | + } else if ($element == 'member') { |
|
100 | + $newelement = 'adherent'; |
|
101 | + } else if ($element == 'order_supplier') { |
|
89 | 102 | $newelement = 'fournisseur'; |
90 | 103 | $subelement = 'commande'; |
91 | - } |
|
92 | - else if ($element == 'invoice_supplier') { |
|
104 | + } else if ($element == 'invoice_supplier') { |
|
93 | 105 | $newelement = 'fournisseur'; |
94 | 106 | $subelement = 'facture'; |
107 | + } else { |
|
108 | + $newelement = $element; |
|
95 | 109 | } |
96 | - else $newelement = $element; |
|
97 | 110 | |
98 | 111 | $_POST['action']='update'; // Hack so restrictarea will test permissions on write too |
99 | 112 | $feature = $newelement; |
@@ -104,7 +117,9 @@ discard block |
||
104 | 117 | $feature = 'commande'; |
105 | 118 | $object_id = 0; |
106 | 119 | } |
107 | - if ($feature == 'shipping') $feature = 'commande'; |
|
120 | + if ($feature == 'shipping') { |
|
121 | + $feature = 'commande'; |
|
122 | + } |
|
108 | 123 | if ($feature == 'payment') { $feature = 'facture'; } |
109 | 124 | if ($feature == 'payment_supplier') { $feature = 'fournisseur'; $feature2 = 'facture'; } |
110 | 125 | //var_dump(GETPOST('action','aZ09')); |
@@ -133,14 +148,12 @@ discard block |
||
133 | 148 | $error++; |
134 | 149 | $return['error'] = $langs->trans('ErrorBadValue'); |
135 | 150 | } |
136 | - } |
|
137 | - else if ($type == 'datepicker') |
|
151 | + } else if ($type == 'datepicker') |
|
138 | 152 | { |
139 | 153 | $timestamp = GETPOST('timestamp','int',2); |
140 | 154 | $format = 'date'; |
141 | 155 | $newvalue = ($timestamp / 1000); |
142 | - } |
|
143 | - else if ($type == 'select') |
|
156 | + } else if ($type == 'select') |
|
144 | 157 | { |
145 | 158 | $loadmethodname = 'load_cache_'.$loadmethod; |
146 | 159 | $loadcachename = 'cache_'.$loadmethod; |
@@ -160,14 +173,12 @@ discard block |
||
160 | 173 | $loadview = $form->$loadviewname; |
161 | 174 | $view = $loadview[$newvalue]; |
162 | 175 | } |
163 | - } |
|
164 | - else |
|
176 | + } else |
|
165 | 177 | { |
166 | 178 | $error++; |
167 | 179 | $return['error'] = $form->error; |
168 | 180 | } |
169 | - } |
|
170 | - else |
|
181 | + } else |
|
171 | 182 | { |
172 | 183 | $module = $subelement = $ext_element; |
173 | 184 | if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
@@ -190,8 +201,7 @@ discard block |
||
190 | 201 | $loadview = $object->$loadviewname; |
191 | 202 | $view = $loadview[$newvalue]; |
192 | 203 | } |
193 | - } |
|
194 | - else |
|
204 | + } else |
|
195 | 205 | { |
196 | 206 | $error++; |
197 | 207 | $return['error'] = $object->error; |
@@ -201,7 +211,9 @@ discard block |
||
201 | 211 | |
202 | 212 | if (! $error) |
203 | 213 | { |
204 | - if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
214 | + if ((isset($object) && ! is_object($object)) || empty($savemethod)) { |
|
215 | + $object = new GenericObject($db); |
|
216 | + } |
|
205 | 217 | |
206 | 218 | // Specific for add_object_linked() |
207 | 219 | // TODO add a function for variable treatment |
@@ -213,21 +225,22 @@ discard block |
||
213 | 225 | $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
214 | 226 | if ($ret > 0) |
215 | 227 | { |
216 | - if ($type == 'numeric') $value = price($newvalue); |
|
217 | - else if ($type == 'textarea') $value = dol_nl2br($newvalue); |
|
228 | + if ($type == 'numeric') { |
|
229 | + $value = price($newvalue); |
|
230 | + } else if ($type == 'textarea') { |
|
231 | + $value = dol_nl2br($newvalue); |
|
232 | + } |
|
218 | 233 | |
219 | 234 | $return['value'] = $value; |
220 | 235 | $return['view'] = (! empty($view) ? $view : $value); |
221 | - } |
|
222 | - else |
|
236 | + } else |
|
223 | 237 | { |
224 | 238 | $return['error'] = $object->error; |
225 | 239 | } |
226 | 240 | } |
227 | 241 | |
228 | 242 | echo json_encode($return); |
229 | - } |
|
230 | - else |
|
243 | + } else |
|
231 | 244 | { |
232 | 245 | echo $langs->trans('NotEnoughPermissions'); |
233 | 246 | } |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | * \brief File to save field value |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
30 | 30 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
31 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
31 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
33 | 33 | |
34 | -$field = GETPOST('field','alpha',2); |
|
35 | -$element = GETPOST('element','alpha',2); |
|
36 | -$table_element = GETPOST('table_element','alpha',2); |
|
37 | -$fk_element = GETPOST('fk_element','alpha',2); |
|
34 | +$field = GETPOST('field', 'alpha', 2); |
|
35 | +$element = GETPOST('element', 'alpha', 2); |
|
36 | +$table_element = GETPOST('table_element', 'alpha', 2); |
|
37 | +$fk_element = GETPOST('fk_element', 'alpha', 2); |
|
38 | 38 | |
39 | 39 | /* Example: |
40 | 40 | field:editval_ref_customer (8 first chars will removed to know name of property) |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | //print_r($_POST); |
60 | 60 | |
61 | 61 | // Load original field value |
62 | -if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) |
|
62 | +if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) |
|
63 | 63 | { |
64 | - $ext_element = GETPOST('ext_element','alpha',2); |
|
64 | + $ext_element = GETPOST('ext_element', 'alpha', 2); |
|
65 | 65 | $field = substr($field, 8); // remove prefix val_ |
66 | - $type = GETPOST('type','alpha',2); |
|
67 | - $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); |
|
68 | - $loadmethod = GETPOST('loadmethod','alpha',2); |
|
69 | - $savemethod = GETPOST('savemethod','alpha',2); |
|
70 | - $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); |
|
66 | + $type = GETPOST('type', 'alpha', 2); |
|
67 | + $value = ($type == 'ckeditor' ? GETPOST('value', '', 2) : GETPOST('value', 'alpha', 2)); |
|
68 | + $loadmethod = GETPOST('loadmethod', 'alpha', 2); |
|
69 | + $savemethod = GETPOST('savemethod', 'alpha', 2); |
|
70 | + $savemethodname = (!empty($savemethod) ? $savemethod : 'setValueFrom'); |
|
71 | 71 | $newelement = $element; |
72 | 72 | |
73 | - $view=''; |
|
74 | - $format='text'; |
|
75 | - $return=array(); |
|
76 | - $error=0; |
|
73 | + $view = ''; |
|
74 | + $format = 'text'; |
|
75 | + $return = array(); |
|
76 | + $error = 0; |
|
77 | 77 | |
78 | - if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) |
|
78 | + if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) |
|
79 | 79 | { |
80 | 80 | $element = $regs[1]; |
81 | 81 | $subelement = $regs[2]; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | else $newelement = $element; |
97 | 97 | |
98 | - $_POST['action']='update'; // Hack so restrictarea will test permissions on write too |
|
98 | + $_POST['action'] = 'update'; // Hack so restrictarea will test permissions on write too |
|
99 | 99 | $feature = $newelement; |
100 | 100 | $feature2 = $subelement; |
101 | 101 | $object_id = $fk_element; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $newvalue = price2num($newvalue); |
129 | 129 | |
130 | 130 | // Check parameters |
131 | - if (! is_numeric($newvalue)) |
|
131 | + if (!is_numeric($newvalue)) |
|
132 | 132 | { |
133 | 133 | $error++; |
134 | 134 | $return['error'] = $langs->trans('ErrorBadValue'); |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | } |
137 | 137 | else if ($type == 'datepicker') |
138 | 138 | { |
139 | - $timestamp = GETPOST('timestamp','int',2); |
|
140 | - $format = 'date'; |
|
141 | - $newvalue = ($timestamp / 1000); |
|
139 | + $timestamp = GETPOST('timestamp', 'int', 2); |
|
140 | + $format = 'date'; |
|
141 | + $newvalue = ($timestamp / 1000); |
|
142 | 142 | } |
143 | 143 | else if ($type == 'select') |
144 | 144 | { |
145 | - $loadmethodname = 'load_cache_'.$loadmethod; |
|
146 | - $loadcachename = 'cache_'.$loadmethod; |
|
147 | - $loadviewname = 'view_'.$loadmethod; |
|
145 | + $loadmethodname = 'load_cache_'.$loadmethod; |
|
146 | + $loadcachename = 'cache_'.$loadmethod; |
|
147 | + $loadviewname = 'view_'.$loadmethod; |
|
148 | 148 | |
149 | 149 | $form = new Form($db); |
150 | 150 | if (method_exists($form, $loadmethodname)) |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $loadcache = $form->$loadcachename; |
156 | 156 | $value = $loadcache[$newvalue]; |
157 | 157 | |
158 | - if (! empty($form->$loadviewname)) |
|
158 | + if (!empty($form->$loadviewname)) |
|
159 | 159 | { |
160 | 160 | $loadview = $form->$loadviewname; |
161 | 161 | $view = $loadview[$newvalue]; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | else |
171 | 171 | { |
172 | 172 | $module = $subelement = $ext_element; |
173 | - if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
|
173 | + if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs)) |
|
174 | 174 | { |
175 | 175 | $module = $regs[1]; |
176 | 176 | $subelement = $regs[2]; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $loadcache = $object->$loadcachename; |
186 | 186 | $value = $loadcache[$newvalue]; |
187 | 187 | |
188 | - if (! empty($object->$loadviewname)) |
|
188 | + if (!empty($object->$loadviewname)) |
|
189 | 189 | { |
190 | 190 | $loadview = $object->$loadviewname; |
191 | 191 | $view = $loadview[$newvalue]; |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - if (! $error) |
|
202 | + if (!$error) |
|
203 | 203 | { |
204 | - if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
204 | + if ((isset($object) && !is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
205 | 205 | |
206 | 206 | // Specific for add_object_linked() |
207 | 207 | // TODO add a function for variable treatment |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | $object->fk_element = $fk_element; |
211 | 211 | $object->element = $element; |
212 | 212 | |
213 | - $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
|
213 | + $ret = $object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
|
214 | 214 | if ($ret > 0) |
215 | 215 | { |
216 | 216 | if ($type == 'numeric') $value = price($newvalue); |
217 | 217 | else if ($type == 'textarea') $value = dol_nl2br($newvalue); |
218 | 218 | |
219 | 219 | $return['value'] = $value; |
220 | - $return['view'] = (! empty($view) ? $view : $value); |
|
220 | + $return['view'] = (!empty($view) ? $view : $value); |
|
221 | 221 | } |
222 | 222 | else |
223 | 223 | { |
@@ -43,35 +43,35 @@ |
||
43 | 43 | |
44 | 44 | if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) |
45 | 45 | { |
46 | - $value = GETPOST('value','alpha'); |
|
47 | - $params=array(); |
|
46 | + $value = GETPOST('value','alpha'); |
|
47 | + $params=array(); |
|
48 | 48 | |
49 | - dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); |
|
49 | + dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); |
|
50 | 50 | |
51 | - $classpath = $subelement = $element; |
|
51 | + $classpath = $subelement = $element; |
|
52 | 52 | |
53 | - // For compatibility |
|
54 | - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | - else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | - else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | - else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | - else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | - else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | - else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | - else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
53 | + // For compatibility |
|
54 | + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | + else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | + else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | + else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | + else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | + else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | + else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | + else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
62 | 62 | |
63 | - dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); |
|
63 | + dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); |
|
64 | 64 | |
65 | - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | - else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
67 | - else $classname = ucfirst($subelement); |
|
65 | + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | + else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
67 | + else $classname = ucfirst($subelement); |
|
68 | 68 | |
69 | - $object = new $classname($db); |
|
70 | - $object->fetch($id); |
|
69 | + $object = new $classname($db); |
|
70 | + $object->fetch($id); |
|
71 | 71 | |
72 | - $params[$htmlelement] = array($type => $value); |
|
73 | - $object->extraparams = array_merge($object->extraparams, $params); |
|
72 | + $params[$htmlelement] = array($type => $value); |
|
73 | + $object->extraparams = array_merge($object->extraparams, $params); |
|
74 | 74 | |
75 | - $result=$object->setExtraParameters(); |
|
75 | + $result=$object->setExtraParameters(); |
|
76 | 76 | } |
77 | 77 |
@@ -20,17 +20,17 @@ discard block |
||
20 | 20 | * \brief File to return Ajax response on set extra parameters of elements |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | 28 | |
29 | 29 | include '../../main.inc.php'; |
30 | 30 | |
31 | -$id = GETPOST('id','int'); |
|
32 | -$element = GETPOST('element','alpha'); |
|
33 | -$htmlelement = GETPOST('htmlelement','alpha'); |
|
31 | +$id = GETPOST('id', 'int'); |
|
32 | +$element = GETPOST('element', 'alpha'); |
|
33 | +$htmlelement = GETPOST('htmlelement', 'alpha'); |
|
34 | 34 | $type = GETPOST('type', 'alpha'); |
35 | 35 | |
36 | 36 | /* |
@@ -41,37 +41,37 @@ discard block |
||
41 | 41 | |
42 | 42 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
43 | 43 | |
44 | -if(! empty($id) && ! empty($element) && ! empty($htmlelement) && ! empty($type)) |
|
44 | +if (!empty($id) && !empty($element) && !empty($htmlelement) && !empty($type)) |
|
45 | 45 | { |
46 | - $value = GETPOST('value','alpha'); |
|
47 | - $params=array(); |
|
46 | + $value = GETPOST('value', 'alpha'); |
|
47 | + $params = array(); |
|
48 | 48 | |
49 | 49 | dol_syslog("AjaxSetExtraParameters id=".$id." element=".$element." htmlelement=".$htmlelement." type=".$type." value=".$value, LOG_DEBUG); |
50 | 50 | |
51 | 51 | $classpath = $subelement = $element; |
52 | 52 | |
53 | 53 | // For compatibility |
54 | - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | - else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | - else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | - else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | - else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | - else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | - else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | - else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
54 | + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | + else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | + else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | + else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | + else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | + else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | + else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | + else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
62 | 62 | |
63 | 63 | dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); |
64 | 64 | |
65 | - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | - else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
65 | + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | + else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
67 | 67 | else $classname = ucfirst($subelement); |
68 | 68 | |
69 | - $object = new $classname($db); |
|
69 | + $object = new $classname($db); |
|
70 | 70 | $object->fetch($id); |
71 | 71 | |
72 | 72 | $params[$htmlelement] = array($type => $value); |
73 | 73 | $object->extraparams = array_merge($object->extraparams, $params); |
74 | 74 | |
75 | - $result=$object->setExtraParameters(); |
|
75 | + $result = $object->setExtraParameters(); |
|
76 | 76 | } |
77 | 77 |
@@ -20,11 +20,22 @@ discard block |
||
20 | 20 | * \brief File to return Ajax response on set extra parameters of elements |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
25 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
30 | +if (! defined('NOREQUIREHTML')) { |
|
31 | + define('NOREQUIREHTML','1'); |
|
32 | +} |
|
33 | +if (! defined('NOREQUIREAJAX')) { |
|
34 | + define('NOREQUIREAJAX','1'); |
|
35 | +} |
|
36 | +if (! defined('NOREQUIRESOC')) { |
|
37 | + define('NOREQUIRESOC','1'); |
|
38 | +} |
|
28 | 39 | |
29 | 40 | include '../../main.inc.php'; |
30 | 41 | |
@@ -51,20 +62,13 @@ discard block |
||
51 | 62 | $classpath = $subelement = $element; |
52 | 63 | |
53 | 64 | // For compatibility |
54 | - if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } |
|
55 | - else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } |
|
56 | - else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } |
|
57 | - else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } |
|
58 | - else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } |
|
59 | - else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } |
|
60 | - else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } |
|
61 | - else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
65 | + if ($element == 'order' || $element == 'commande') { $classpath = $subelement = 'commande'; } else if ($element == 'propal') { $classpath = 'comm/propal'; $subelement = 'propal'; } else if ($element == 'facture') { $classpath = 'compta/facture'; $subelement = 'facture'; } else if ($element == 'contract') { $classpath = $subelement = 'contrat'; } else if ($element == 'shipping') { $classpath = $subelement = 'expedition'; } else if ($element == 'deplacement') { $classpath = 'compta/deplacement'; $subelement = 'deplacement'; } else if ($element == 'order_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.commande'; } else if ($element == 'invoice_supplier') { $classpath = 'fourn'; $subelement = 'fournisseur.facture'; } |
|
62 | 66 | |
63 | 67 | dol_include_once('/'.$classpath.'/class/'.$subelement.'.class.php'); |
64 | 68 | |
65 | - if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } |
|
66 | - else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } |
|
67 | - else $classname = ucfirst($subelement); |
|
69 | + if ($element == 'order_supplier') { $classname = 'CommandeFournisseur'; } else if ($element == 'invoice_supplier') { $classname = 'FactureFournisseur'; } else { |
|
70 | + $classname = ucfirst($subelement); |
|
71 | + } |
|
68 | 72 | |
69 | 73 | $object = new $classname($db); |
70 | 74 | $object->fetch($id); |
@@ -53,28 +53,28 @@ |
||
53 | 53 | // Add a box |
54 | 54 | if ($boxid > 0 && $zone !='' && $userid > 0) |
55 | 55 | { |
56 | - $tmp=explode('-',$boxorder); |
|
57 | - $nbboxonleft=substr_count($tmp[0],','); |
|
58 | - $nbboxonright=substr_count($tmp[1],','); |
|
59 | - print $nbboxonleft.'-'.$nbboxonright; |
|
60 | - if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
56 | + $tmp=explode('-',$boxorder); |
|
57 | + $nbboxonleft=substr_count($tmp[0],','); |
|
58 | + $nbboxonright=substr_count($tmp[1],','); |
|
59 | + print $nbboxonleft.'-'.$nbboxonright; |
|
60 | + if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
61 | 61 | else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Registering the location of boxes after a move |
65 | 65 | if ($boxorder && $zone != '' && $userid > 0) |
66 | 66 | { |
67 | - // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B" |
|
68 | - dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); |
|
67 | + // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B" |
|
68 | + dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); |
|
69 | 69 | |
70 | - $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); |
|
71 | - if ($result > 0) |
|
72 | - { |
|
73 | - $langs->load("boxes"); |
|
74 | - if (! GETPOST('closing')) |
|
75 | - { |
|
76 | - setEventMessages($langs->trans("BoxAdded"), null); |
|
77 | - } |
|
78 | - } |
|
70 | + $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); |
|
71 | + if ($result > 0) |
|
72 | + { |
|
73 | + $langs->load("boxes"); |
|
74 | + if (! GETPOST('closing')) |
|
75 | + { |
|
76 | + setEventMessages($langs->trans("BoxAdded"), null); |
|
77 | + } |
|
78 | + } |
|
79 | 79 | } |
80 | 80 |
@@ -21,11 +21,22 @@ discard block |
||
21 | 21 | * \brief File to return Ajax response on Box move or close |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
26 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
27 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
28 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
24 | +if (! defined('NOTOKENRENEWAL')) { |
|
25 | + define('NOTOKENRENEWAL','1'); |
|
26 | +} |
|
27 | +// Disables token renewal |
|
28 | +if (! defined('NOREQUIREMENU')) { |
|
29 | + define('NOREQUIREMENU','1'); |
|
30 | +} |
|
31 | +if (! defined('NOREQUIREHTML')) { |
|
32 | + define('NOREQUIREHTML','1'); |
|
33 | +} |
|
34 | +if (! defined('NOREQUIREAJAX')) { |
|
35 | + define('NOREQUIREAJAX','1'); |
|
36 | +} |
|
37 | +if (! defined('NOREQUIRESOC')) { |
|
38 | + define('NOREQUIRESOC','1'); |
|
39 | +} |
|
29 | 40 | |
30 | 41 | |
31 | 42 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -60,8 +71,14 @@ discard block |
||
60 | 71 | $nbboxonleft=substr_count($tmp[0],','); |
61 | 72 | $nbboxonright=substr_count($tmp[1],','); |
62 | 73 | print $nbboxonleft.'-'.$nbboxonright; |
63 | - if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
64 | - else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
74 | + if ($nbboxonleft > $nbboxonright) { |
|
75 | + $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); |
|
76 | + } |
|
77 | + // Insert id of new box into list |
|
78 | + else { |
|
79 | + $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); |
|
80 | + } |
|
81 | + // Insert id of new box into list |
|
65 | 82 | } |
66 | 83 | |
67 | 84 | // Registering the location of boxes after a move |
@@ -21,23 +21,23 @@ discard block |
||
21 | 21 | * \brief File to return Ajax response on Box move or close |
22 | 22 | */ |
23 | 23 | |
24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
26 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
27 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
28 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
24 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
25 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
26 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
27 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
28 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
29 | 29 | |
30 | 30 | |
31 | 31 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
32 | 32 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
33 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
33 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; |
35 | 35 | |
36 | -$boxid=GETPOST('boxid','int'); |
|
37 | -$boxorder=GETPOST('boxorder'); |
|
38 | -$userid=GETPOST('userid'); |
|
39 | -$zone=GETPOST('zone','int'); |
|
40 | -$userid=GETPOST('userid','int'); |
|
36 | +$boxid = GETPOST('boxid', 'int'); |
|
37 | +$boxorder = GETPOST('boxorder'); |
|
38 | +$userid = GETPOST('userid'); |
|
39 | +$zone = GETPOST('zone', 'int'); |
|
40 | +$userid = GETPOST('userid', 'int'); |
|
41 | 41 | |
42 | 42 | |
43 | 43 | /* |
@@ -54,27 +54,27 @@ discard block |
||
54 | 54 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
55 | 55 | |
56 | 56 | // Add a box |
57 | -if ($boxid > 0 && $zone !='' && $userid > 0) |
|
57 | +if ($boxid > 0 && $zone != '' && $userid > 0) |
|
58 | 58 | { |
59 | - $tmp=explode('-',$boxorder); |
|
60 | - $nbboxonleft=substr_count($tmp[0],','); |
|
61 | - $nbboxonright=substr_count($tmp[1],','); |
|
59 | + $tmp = explode('-', $boxorder); |
|
60 | + $nbboxonleft = substr_count($tmp[0], ','); |
|
61 | + $nbboxonright = substr_count($tmp[1], ','); |
|
62 | 62 | print $nbboxonleft.'-'.$nbboxonright; |
63 | - if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
64 | - else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
63 | + if ($nbboxonleft > $nbboxonright) $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list |
|
64 | + else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Registering the location of boxes after a move |
68 | -if ($boxorder && $zone != '' && $userid > 0) |
|
68 | +if ($boxorder && $zone != '' && $userid > 0) |
|
69 | 69 | { |
70 | 70 | // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B" |
71 | 71 | dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); |
72 | 72 | |
73 | - $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); |
|
73 | + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); |
|
74 | 74 | if ($result > 0) |
75 | 75 | { |
76 | 76 | $langs->load("boxes"); |
77 | - if (! GETPOST('closing')) |
|
77 | + if (!GETPOST('closing')) |
|
78 | 78 | { |
79 | 79 | setEventMessages($langs->trans("BoxAdded"), null); |
80 | 80 | } |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | */ |
28 | 28 | class MenuManager |
29 | 29 | { |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * @var DoliDB Database handler. |
32 | 32 | */ |
33 | 33 | public $db; |
34 | 34 | |
35 | - var $type_user; // Put 0 for internal users, 1 for external users |
|
36 | - var $atarget=""; // To store default target to use onto links |
|
37 | - var $name="eldy"; |
|
35 | + var $type_user; // Put 0 for internal users, 1 for external users |
|
36 | + var $atarget=""; // To store default target to use onto links |
|
37 | + var $name="eldy"; |
|
38 | 38 | |
39 | 39 | var $menu_array; |
40 | 40 | var $menu_array_after; |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * Constructor |
47 | 47 | * |
48 | - * @param DoliDB $db Database handler |
|
48 | + * @param DoliDB $db Database handler |
|
49 | 49 | * @param int $type_user Type of user |
50 | 50 | */ |
51 | 51 | function __construct($db, $type_user) |
52 | 52 | { |
53 | - $this->type_user=$type_user; |
|
53 | + $this->type_user=$type_user; |
|
54 | 54 | $this->db=$db; |
55 | 55 | } |
56 | 56 | |
@@ -58,49 +58,49 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * Load this->tabMenu |
60 | 60 | * |
61 | - * @param string $forcemainmenu To force mainmenu to load |
|
62 | - * @param string $forceleftmenu To force leftmenu to load |
|
61 | + * @param string $forcemainmenu To force mainmenu to load |
|
62 | + * @param string $forceleftmenu To force leftmenu to load |
|
63 | 63 | * @return void |
64 | 64 | */ |
65 | 65 | function loadMenu($forcemainmenu='',$forceleftmenu='') |
66 | 66 | { |
67 | - // On sauve en session le menu principal choisi |
|
68 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
69 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
67 | + // On sauve en session le menu principal choisi |
|
68 | + if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
69 | + if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
70 | 70 | |
71 | - // Read mainmenu and leftmenu that define which menu to show |
|
71 | + // Read mainmenu and leftmenu that define which menu to show |
|
72 | 72 | if (isset($_GET["mainmenu"])) |
73 | 73 | { |
74 | - // On sauve en session le menu principal choisi |
|
75 | - $mainmenu=$_GET["mainmenu"]; |
|
76 | - $_SESSION["mainmenu"]=$mainmenu; |
|
77 | - $_SESSION["leftmenuopened"]=""; |
|
74 | + // On sauve en session le menu principal choisi |
|
75 | + $mainmenu=$_GET["mainmenu"]; |
|
76 | + $_SESSION["mainmenu"]=$mainmenu; |
|
77 | + $_SESSION["leftmenuopened"]=""; |
|
78 | 78 | } |
79 | 79 | else |
80 | - { |
|
81 | - // On va le chercher en session si non defini par le lien |
|
82 | - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
80 | + { |
|
81 | + // On va le chercher en session si non defini par le lien |
|
82 | + $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
83 | 83 | } |
84 | 84 | if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
85 | 85 | |
86 | 86 | if (isset($_GET["leftmenu"])) |
87 | 87 | { |
88 | - // On sauve en session le menu principal choisi |
|
89 | - $leftmenu=$_GET["leftmenu"]; |
|
90 | - $_SESSION["leftmenu"]=$leftmenu; |
|
91 | - |
|
92 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
93 | - { |
|
94 | - //$leftmenu=""; |
|
95 | - $_SESSION["leftmenuopened"]=""; |
|
96 | - } |
|
97 | - else |
|
98 | - { |
|
99 | - $_SESSION["leftmenuopened"]=$leftmenu; |
|
100 | - } |
|
88 | + // On sauve en session le menu principal choisi |
|
89 | + $leftmenu=$_GET["leftmenu"]; |
|
90 | + $_SESSION["leftmenu"]=$leftmenu; |
|
91 | + |
|
92 | + if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
93 | + { |
|
94 | + //$leftmenu=""; |
|
95 | + $_SESSION["leftmenuopened"]=""; |
|
96 | + } |
|
97 | + else |
|
98 | + { |
|
99 | + $_SESSION["leftmenuopened"]=$leftmenu; |
|
100 | + } |
|
101 | 101 | } else { |
102 | - // On va le chercher en session si non defini par le lien |
|
103 | - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
102 | + // On va le chercher en session si non defini par le lien |
|
103 | + $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
104 | 104 | } |
105 | 105 | if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
106 | 106 | |
@@ -125,38 +125,38 @@ discard block |
||
125 | 125 | */ |
126 | 126 | function showmenu($mode, $moredata=null) |
127 | 127 | { |
128 | - global $conf, $langs, $user; |
|
128 | + global $conf, $langs, $user; |
|
129 | 129 | |
130 | - //var_dump($this->tabMenu); |
|
130 | + //var_dump($this->tabMenu); |
|
131 | 131 | |
132 | 132 | require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; |
133 | 133 | |
134 | 134 | if ($this->type_user == 1) |
135 | 135 | { |
136 | - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
137 | - $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
136 | + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
137 | + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
138 | 138 | } |
139 | 139 | |
140 | - require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
|
140 | + require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
|
141 | 141 | $this->menu=new Menu(); |
142 | 142 | |
143 | 143 | if (empty($conf->global->MAIN_MENU_INVERT)) |
144 | 144 | { |
145 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
146 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
145 | + if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
146 | + if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
147 | 147 | } |
148 | 148 | else |
149 | - { |
|
150 | - $conf->global->MAIN_SHOW_LOGO=0; |
|
151 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
152 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
153 | - } |
|
154 | - |
|
155 | - if ($mode == 'topnb') |
|
156 | - { |
|
157 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output |
|
158 | - return $this->menu->getNbOfVisibleMenuEntries(); |
|
159 | - } |
|
149 | + { |
|
150 | + $conf->global->MAIN_SHOW_LOGO=0; |
|
151 | + if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
152 | + if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
153 | + } |
|
154 | + |
|
155 | + if ($mode == 'topnb') |
|
156 | + { |
|
157 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output |
|
158 | + return $this->menu->getNbOfVisibleMenuEntries(); |
|
159 | + } |
|
160 | 160 | |
161 | 161 | if ($mode == 'jmobile') // Used to get menu in xml ul/li |
162 | 162 | { |
@@ -165,170 +165,170 @@ discard block |
||
165 | 165 | // $this->menu->liste is top menu |
166 | 166 | //var_dump($this->menu->liste);exit; |
167 | 167 | $lastlevel = array(); |
168 | - print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
169 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
170 | - { |
|
171 | - print '<ul class="ulmenu" data-inset="true">'; |
|
172 | - print '<li class="lilevel0">'; |
|
173 | - |
|
174 | - if ($val['enabled'] == 1) |
|
175 | - { |
|
176 | - $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
|
177 | - $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
178 | - $val['url'] = make_substitutions($val['url'], $substitarray); |
|
179 | - |
|
180 | - $relurl=dol_buildpath($val['url'],1); |
|
181 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
182 | - |
|
183 | - print '<a class="alilevel0" href="#">'; |
|
184 | - |
|
185 | - // Add font-awesome |
|
186 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
187 | - |
|
188 | - print $val['titre']; |
|
189 | - print '</a>'."\n"; |
|
190 | - |
|
191 | - // Search submenu fot this mainmenu entry |
|
192 | - $tmpmainmenu=$val['mainmenu']; |
|
193 | - $tmpleftmenu='all'; |
|
194 | - $submenu=new Menu(); |
|
195 | - print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
196 | - // Note: $submenu contains menu entry with substitution not yet done |
|
197 | - //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
|
168 | + print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
|
169 | + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
170 | + { |
|
171 | + print '<ul class="ulmenu" data-inset="true">'; |
|
172 | + print '<li class="lilevel0">'; |
|
173 | + |
|
174 | + if ($val['enabled'] == 1) |
|
175 | + { |
|
176 | + $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
|
177 | + $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
178 | + $val['url'] = make_substitutions($val['url'], $substitarray); |
|
179 | + |
|
180 | + $relurl=dol_buildpath($val['url'],1); |
|
181 | + $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
182 | + |
|
183 | + print '<a class="alilevel0" href="#">'; |
|
184 | + |
|
185 | + // Add font-awesome |
|
186 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
187 | + |
|
188 | + print $val['titre']; |
|
189 | + print '</a>'."\n"; |
|
190 | + |
|
191 | + // Search submenu fot this mainmenu entry |
|
192 | + $tmpmainmenu=$val['mainmenu']; |
|
193 | + $tmpleftmenu='all'; |
|
194 | + $submenu=new Menu(); |
|
195 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
196 | + // Note: $submenu contains menu entry with substitution not yet done |
|
197 | + //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
|
198 | 198 | //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
199 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
200 | - |
|
201 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
202 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
203 | - //var_dump($canonrelurl); |
|
204 | - //var_dump($canonnexturl); |
|
205 | - print '<ul>'."\n"; |
|
206 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
207 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
208 | - { |
|
209 | - // We add sub entry |
|
210 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
211 | - print '<a href="'.$relurl.'">'; |
|
212 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
213 | - { |
|
214 | - if (in_array($val['mainmenu'], array('cashdesk', 'externalsite', 'website', 'collab'))) print $langs->trans("Access"); |
|
215 | - else print $langs->trans("Dashboard"); |
|
216 | - } |
|
217 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
218 | - print '</a>'; |
|
219 | - print '</li>'."\n"; |
|
220 | - } |
|
221 | - |
|
222 | - if ($val['level']==0) |
|
223 | - { |
|
224 | - if ($val['enabled']) |
|
225 | - { |
|
226 | - $lastlevel[0]='enabled'; |
|
227 | - } |
|
228 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
229 | - { |
|
230 | - $lastlevel[0]='greyed'; |
|
231 | - } |
|
232 | - else |
|
233 | - { |
|
234 | - $lastlevel[0]='hidden'; |
|
235 | - } |
|
236 | - } |
|
237 | - |
|
238 | - $lastlevel2 = array(); |
|
239 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
240 | - { |
|
241 | - $showmenu=true; |
|
242 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
243 | - |
|
244 | - // If at least one parent is not enabled, we do not show any menu of all children |
|
245 | - if ($val2['level'] > 0) |
|
246 | - { |
|
247 | - $levelcursor = $val2['level']-1; |
|
248 | - while ($levelcursor >= 0) |
|
249 | - { |
|
199 | + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
200 | + |
|
201 | + $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
202 | + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
203 | + //var_dump($canonrelurl); |
|
204 | + //var_dump($canonnexturl); |
|
205 | + print '<ul>'."\n"; |
|
206 | + if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
207 | + || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
208 | + { |
|
209 | + // We add sub entry |
|
210 | + print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
211 | + print '<a href="'.$relurl.'">'; |
|
212 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
213 | + { |
|
214 | + if (in_array($val['mainmenu'], array('cashdesk', 'externalsite', 'website', 'collab'))) print $langs->trans("Access"); |
|
215 | + else print $langs->trans("Dashboard"); |
|
216 | + } |
|
217 | + else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
218 | + print '</a>'; |
|
219 | + print '</li>'."\n"; |
|
220 | + } |
|
221 | + |
|
222 | + if ($val['level']==0) |
|
223 | + { |
|
224 | + if ($val['enabled']) |
|
225 | + { |
|
226 | + $lastlevel[0]='enabled'; |
|
227 | + } |
|
228 | + else if ($showmenu) // Not enabled but visible (so greyed) |
|
229 | + { |
|
230 | + $lastlevel[0]='greyed'; |
|
231 | + } |
|
232 | + else |
|
233 | + { |
|
234 | + $lastlevel[0]='hidden'; |
|
235 | + } |
|
236 | + } |
|
237 | + |
|
238 | + $lastlevel2 = array(); |
|
239 | + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
240 | + { |
|
241 | + $showmenu=true; |
|
242 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
243 | + |
|
244 | + // If at least one parent is not enabled, we do not show any menu of all children |
|
245 | + if ($val2['level'] > 0) |
|
246 | + { |
|
247 | + $levelcursor = $val2['level']-1; |
|
248 | + while ($levelcursor >= 0) |
|
249 | + { |
|
250 | 250 | if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
251 | 251 | $levelcursor--; |
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
256 | - { |
|
257 | - $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
|
258 | - $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
259 | - $val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__ |
|
260 | - |
|
261 | - if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) |
|
262 | - { |
|
263 | - $relurl2=dol_buildpath($val2['url'],1); |
|
264 | - } |
|
265 | - else |
|
266 | - { |
|
267 | - $relurl2=$val2['url']; |
|
268 | - } |
|
269 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
270 | - //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
271 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
272 | - |
|
273 | - $disabled=''; |
|
274 | - if (! $val2['enabled']) |
|
275 | - { |
|
276 | - $disabled=" vsmenudisabled"; |
|
277 | - } |
|
278 | - |
|
279 | - print str_pad('',$val2['level']+1); |
|
280 | - print '<li class="lilevel'.($val2['level']+1); |
|
281 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
282 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
283 | - if ($relurl2) |
|
284 | - { |
|
285 | - if ($val2['enabled']) // Allowed |
|
286 | - { |
|
287 | - print '<a href="'.$relurl2.'"'; |
|
288 | - //print ' data-ajax="false"'; |
|
289 | - print '>'; |
|
290 | - $lastlevel2[$val2['level']]='enabled'; |
|
291 | - } |
|
292 | - else // Not allowed but visible (greyed) |
|
293 | - { |
|
294 | - print '<a href="#" class="vsmenudisabled">'; |
|
295 | - $lastlevel2[$val2['level']]='greyed'; |
|
296 | - } |
|
297 | - } |
|
298 | - else |
|
299 | - { |
|
300 | - if ($val2['enabled']) // Allowed |
|
301 | - { |
|
302 | - $lastlevel2[$val2['level']]='enabled'; |
|
303 | - } |
|
304 | - else |
|
305 | - { |
|
306 | - $lastlevel2[$val2['level']]='greyed'; |
|
307 | - } |
|
308 | - } |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
256 | + { |
|
257 | + $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
|
258 | + $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
259 | + $val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__ |
|
260 | + |
|
261 | + if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) |
|
262 | + { |
|
263 | + $relurl2=dol_buildpath($val2['url'],1); |
|
264 | + } |
|
265 | + else |
|
266 | + { |
|
267 | + $relurl2=$val2['url']; |
|
268 | + } |
|
269 | + $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
270 | + //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
|
271 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
272 | + |
|
273 | + $disabled=''; |
|
274 | + if (! $val2['enabled']) |
|
275 | + { |
|
276 | + $disabled=" vsmenudisabled"; |
|
277 | + } |
|
278 | + |
|
279 | + print str_pad('',$val2['level']+1); |
|
280 | + print '<li class="lilevel'.($val2['level']+1); |
|
281 | + if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
282 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
283 | + if ($relurl2) |
|
284 | + { |
|
285 | + if ($val2['enabled']) // Allowed |
|
286 | + { |
|
287 | + print '<a href="'.$relurl2.'"'; |
|
288 | + //print ' data-ajax="false"'; |
|
289 | + print '>'; |
|
290 | + $lastlevel2[$val2['level']]='enabled'; |
|
291 | + } |
|
292 | + else // Not allowed but visible (greyed) |
|
293 | + { |
|
294 | + print '<a href="#" class="vsmenudisabled">'; |
|
295 | + $lastlevel2[$val2['level']]='greyed'; |
|
296 | + } |
|
297 | + } |
|
298 | + else |
|
299 | + { |
|
300 | + if ($val2['enabled']) // Allowed |
|
301 | + { |
|
302 | + $lastlevel2[$val2['level']]='enabled'; |
|
303 | + } |
|
304 | + else |
|
305 | + { |
|
306 | + $lastlevel2[$val2['level']]='greyed'; |
|
307 | + } |
|
308 | + } |
|
309 | 309 | //var_dump($val2['level']); |
310 | - //var_dump($lastlevel2); |
|
310 | + //var_dump($lastlevel2); |
|
311 | 311 | print $val2['titre']; |
312 | - if ($relurl2) |
|
313 | - { |
|
314 | - if ($val2['enabled']) // Allowed |
|
315 | - print '</a>'; |
|
316 | - else |
|
317 | - print '</a>'; |
|
318 | - } |
|
319 | - print '</li>'."\n"; |
|
320 | - } |
|
321 | - } |
|
322 | - //var_dump($submenu); |
|
323 | - print '</ul>'; |
|
324 | - } |
|
325 | - if ($val['enabled'] == 2) |
|
326 | - { |
|
327 | - print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
328 | - } |
|
329 | - print '</li>'; |
|
330 | - print '</ul>'."\n"; |
|
331 | - } |
|
312 | + if ($relurl2) |
|
313 | + { |
|
314 | + if ($val2['enabled']) // Allowed |
|
315 | + print '</a>'; |
|
316 | + else |
|
317 | + print '</a>'; |
|
318 | + } |
|
319 | + print '</li>'."\n"; |
|
320 | + } |
|
321 | + } |
|
322 | + //var_dump($submenu); |
|
323 | + print '</ul>'; |
|
324 | + } |
|
325 | + if ($val['enabled'] == 2) |
|
326 | + { |
|
327 | + print '<font class="vsmenudisabled">'.$val['titre'].'</font>'; |
|
328 | + } |
|
329 | + print '</li>'; |
|
330 | + print '</ul>'."\n"; |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | unset($this->menu); |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public $db; |
34 | 34 | |
35 | - var $type_user; // Put 0 for internal users, 1 for external users |
|
36 | - var $atarget=""; // To store default target to use onto links |
|
37 | - var $name="eldy"; |
|
35 | + var $type_user; // Put 0 for internal users, 1 for external users |
|
36 | + var $atarget = ""; // To store default target to use onto links |
|
37 | + var $name = "eldy"; |
|
38 | 38 | |
39 | 39 | var $menu_array; |
40 | 40 | var $menu_array_after; |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | */ |
51 | 51 | function __construct($db, $type_user) |
52 | 52 | { |
53 | - $this->type_user=$type_user; |
|
54 | - $this->db=$db; |
|
53 | + $this->type_user = $type_user; |
|
54 | + $this->db = $db; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -62,53 +62,53 @@ discard block |
||
62 | 62 | * @param string $forceleftmenu To force leftmenu to load |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - function loadMenu($forcemainmenu='',$forceleftmenu='') |
|
65 | + function loadMenu($forcemainmenu = '', $forceleftmenu = '') |
|
66 | 66 | { |
67 | 67 | // On sauve en session le menu principal choisi |
68 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
69 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
68 | + if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"] = $_GET["mainmenu"]; |
|
69 | + if (isset($_GET["idmenu"])) $_SESSION["idmenu"] = $_GET["idmenu"]; |
|
70 | 70 | |
71 | 71 | // Read mainmenu and leftmenu that define which menu to show |
72 | 72 | if (isset($_GET["mainmenu"])) |
73 | 73 | { |
74 | 74 | // On sauve en session le menu principal choisi |
75 | - $mainmenu=$_GET["mainmenu"]; |
|
76 | - $_SESSION["mainmenu"]=$mainmenu; |
|
77 | - $_SESSION["leftmenuopened"]=""; |
|
75 | + $mainmenu = $_GET["mainmenu"]; |
|
76 | + $_SESSION["mainmenu"] = $mainmenu; |
|
77 | + $_SESSION["leftmenuopened"] = ""; |
|
78 | 78 | } |
79 | 79 | else |
80 | 80 | { |
81 | 81 | // On va le chercher en session si non defini par le lien |
82 | - $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
|
82 | + $mainmenu = isset($_SESSION["mainmenu"]) ? $_SESSION["mainmenu"] : ''; |
|
83 | 83 | } |
84 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
84 | + if (!empty($forcemainmenu)) $mainmenu = $forcemainmenu; |
|
85 | 85 | |
86 | 86 | if (isset($_GET["leftmenu"])) |
87 | 87 | { |
88 | 88 | // On sauve en session le menu principal choisi |
89 | - $leftmenu=$_GET["leftmenu"]; |
|
90 | - $_SESSION["leftmenu"]=$leftmenu; |
|
89 | + $leftmenu = $_GET["leftmenu"]; |
|
90 | + $_SESSION["leftmenu"] = $leftmenu; |
|
91 | 91 | |
92 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
92 | + if ($_SESSION["leftmenuopened"] == $leftmenu) // To collapse |
|
93 | 93 | { |
94 | 94 | //$leftmenu=""; |
95 | - $_SESSION["leftmenuopened"]=""; |
|
95 | + $_SESSION["leftmenuopened"] = ""; |
|
96 | 96 | } |
97 | 97 | else |
98 | 98 | { |
99 | - $_SESSION["leftmenuopened"]=$leftmenu; |
|
99 | + $_SESSION["leftmenuopened"] = $leftmenu; |
|
100 | 100 | } |
101 | 101 | } else { |
102 | 102 | // On va le chercher en session si non defini par le lien |
103 | - $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
|
103 | + $leftmenu = isset($_SESSION["leftmenu"]) ? $_SESSION["leftmenu"] : ''; |
|
104 | 104 | } |
105 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
105 | + if (!empty($forceleftmenu)) $leftmenu = $forceleftmenu; |
|
106 | 106 | |
107 | 107 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
108 | - $tabMenu=array(); |
|
109 | - $menuArbo = new Menubase($this->db,'eldy'); |
|
108 | + $tabMenu = array(); |
|
109 | + $menuArbo = new Menubase($this->db, 'eldy'); |
|
110 | 110 | $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu); |
111 | - $this->tabMenu=$tabMenu; |
|
111 | + $this->tabMenu = $tabMenu; |
|
112 | 112 | //var_dump($tabMenu); |
113 | 113 | |
114 | 114 | //if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @param array $moredata An array with more data to output |
124 | 124 | * @return int 0 or nb of top menu entries if $mode = 'topnb' |
125 | 125 | */ |
126 | - function showmenu($mode, $moredata=null) |
|
126 | + function showmenu($mode, $moredata = null) |
|
127 | 127 | { |
128 | 128 | global $conf, $langs, $user; |
129 | 129 | |
@@ -133,40 +133,40 @@ discard block |
||
133 | 133 | |
134 | 134 | if ($this->type_user == 1) |
135 | 135 | { |
136 | - $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED=1; |
|
137 | - $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED=1; |
|
136 | + $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED = 1; |
|
137 | + $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED = 1; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php'; |
141 | - $this->menu=new Menu(); |
|
141 | + $this->menu = new Menu(); |
|
142 | 142 | |
143 | 143 | if (empty($conf->global->MAIN_MENU_INVERT)) |
144 | 144 | { |
145 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
146 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
145 | + if ($mode == 'top') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); |
|
146 | + if ($mode == 'left') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0, '', '', $moredata); |
|
147 | 147 | } |
148 | 148 | else |
149 | 149 | { |
150 | - $conf->global->MAIN_SHOW_LOGO=0; |
|
151 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
152 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
150 | + $conf->global->MAIN_SHOW_LOGO = 0; |
|
151 | + if ($mode == 'top') print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $this->menu, 0); |
|
152 | + if ($mode == 'left') print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 0, $mode); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | if ($mode == 'topnb') |
156 | 156 | { |
157 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // no output |
|
157 | + print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // no output |
|
158 | 158 | return $this->menu->getNbOfVisibleMenuEntries(); |
159 | 159 | } |
160 | 160 | |
161 | 161 | if ($mode == 'jmobile') // Used to get menu in xml ul/li |
162 | 162 | { |
163 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
163 | + print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // Fill this->menu that is empty with top menu |
|
164 | 164 | |
165 | 165 | // $this->menu->liste is top menu |
166 | 166 | //var_dump($this->menu->liste);exit; |
167 | 167 | $lastlevel = array(); |
168 | 168 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
169 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
169 | + foreach ($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
170 | 170 | { |
171 | 171 | print '<ul class="ulmenu" data-inset="true">'; |
172 | 172 | print '<li class="lilevel0">'; |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | if ($val['enabled'] == 1) |
175 | 175 | { |
176 | 176 | $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
177 | - $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
177 | + $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
178 | 178 | $val['url'] = make_substitutions($val['url'], $substitarray); |
179 | 179 | |
180 | - $relurl=dol_buildpath($val['url'],1); |
|
181 | - $canonurl=preg_replace('/\?.*$/','',$val['url']); |
|
180 | + $relurl = dol_buildpath($val['url'], 1); |
|
181 | + $canonurl = preg_replace('/\?.*$/', '', $val['url']); |
|
182 | 182 | |
183 | 183 | print '<a class="alilevel0" href="#">'; |
184 | 184 | |
@@ -189,25 +189,25 @@ discard block |
||
189 | 189 | print '</a>'."\n"; |
190 | 190 | |
191 | 191 | // Search submenu fot this mainmenu entry |
192 | - $tmpmainmenu=$val['mainmenu']; |
|
193 | - $tmpleftmenu='all'; |
|
194 | - $submenu=new Menu(); |
|
195 | - print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$tmpmainmenu,$tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
192 | + $tmpmainmenu = $val['mainmenu']; |
|
193 | + $tmpleftmenu = 'all'; |
|
194 | + $submenu = new Menu(); |
|
195 | + print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home) |
|
196 | 196 | // Note: $submenu contains menu entry with substitution not yet done |
197 | 197 | //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; } |
198 | 198 | //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; } |
199 | - $nexturl=dol_buildpath($submenu->liste[0]['url'],1); |
|
199 | + $nexturl = dol_buildpath($submenu->liste[0]['url'], 1); |
|
200 | 200 | |
201 | - $canonrelurl=preg_replace('/\?.*$/','',$relurl); |
|
202 | - $canonnexturl=preg_replace('/\?.*$/','',$nexturl); |
|
201 | + $canonrelurl = preg_replace('/\?.*$/', '', $relurl); |
|
202 | + $canonnexturl = preg_replace('/\?.*$/', '', $nexturl); |
|
203 | 203 | //var_dump($canonrelurl); |
204 | 204 | //var_dump($canonnexturl); |
205 | 205 | print '<ul>'."\n"; |
206 | - if (($canonrelurl != $canonnexturl && ! in_array($val['mainmenu'],array('tools'))) |
|
207 | - || (strpos($canonrelurl,'/product/index.php') !== false || strpos($canonrelurl,'/compta/bank/list.php') !== false)) |
|
206 | + if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools'))) |
|
207 | + || (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) |
|
208 | 208 | { |
209 | 209 | // We add sub entry |
210 | - print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
210 | + print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
|
211 | 211 | print '<a href="'.$relurl.'">'; |
212 | 212 | if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
213 | 213 | { |
@@ -219,35 +219,35 @@ discard block |
||
219 | 219 | print '</li>'."\n"; |
220 | 220 | } |
221 | 221 | |
222 | - if ($val['level']==0) |
|
222 | + if ($val['level'] == 0) |
|
223 | 223 | { |
224 | 224 | if ($val['enabled']) |
225 | 225 | { |
226 | - $lastlevel[0]='enabled'; |
|
226 | + $lastlevel[0] = 'enabled'; |
|
227 | 227 | } |
228 | 228 | else if ($showmenu) // Not enabled but visible (so greyed) |
229 | 229 | { |
230 | - $lastlevel[0]='greyed'; |
|
230 | + $lastlevel[0] = 'greyed'; |
|
231 | 231 | } |
232 | 232 | else |
233 | 233 | { |
234 | - $lastlevel[0]='hidden'; |
|
234 | + $lastlevel[0] = 'hidden'; |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | 238 | $lastlevel2 = array(); |
239 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
239 | + foreach ($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
240 | 240 | { |
241 | - $showmenu=true; |
|
242 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
241 | + $showmenu = true; |
|
242 | + if (!empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu = false; |
|
243 | 243 | |
244 | 244 | // If at least one parent is not enabled, we do not show any menu of all children |
245 | 245 | if ($val2['level'] > 0) |
246 | 246 | { |
247 | - $levelcursor = $val2['level']-1; |
|
247 | + $levelcursor = $val2['level'] - 1; |
|
248 | 248 | while ($levelcursor >= 0) |
249 | 249 | { |
250 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
250 | + if ($lastlevel2[$levelcursor] != 'enabled') $showmenu = false; |
|
251 | 251 | $levelcursor--; |
252 | 252 | } |
253 | 253 | } |
@@ -255,31 +255,31 @@ discard block |
||
255 | 255 | if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
256 | 256 | { |
257 | 257 | $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
258 | - $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
259 | - $val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__ |
|
258 | + $substitarray['__USERID__'] = $user->id; // For backward compatibility |
|
259 | + $val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__ |
|
260 | 260 | |
261 | - if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) |
|
261 | + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) |
|
262 | 262 | { |
263 | - $relurl2=dol_buildpath($val2['url'],1); |
|
263 | + $relurl2 = dol_buildpath($val2['url'], 1); |
|
264 | 264 | } |
265 | 265 | else |
266 | 266 | { |
267 | - $relurl2=$val2['url']; |
|
267 | + $relurl2 = $val2['url']; |
|
268 | 268 | } |
269 | - $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
|
269 | + $canonurl2 = preg_replace('/\?.*$/', '', $val2['url']); |
|
270 | 270 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
271 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
271 | + if (in_array($canonurl2, array('/admin/index.php', '/admin/tools/index.php', '/core/tools.php'))) $relurl2 = ''; |
|
272 | 272 | |
273 | - $disabled=''; |
|
274 | - if (! $val2['enabled']) |
|
273 | + $disabled = ''; |
|
274 | + if (!$val2['enabled']) |
|
275 | 275 | { |
276 | - $disabled=" vsmenudisabled"; |
|
276 | + $disabled = " vsmenudisabled"; |
|
277 | 277 | } |
278 | 278 | |
279 | - print str_pad('',$val2['level']+1); |
|
280 | - print '<li class="lilevel'.($val2['level']+1); |
|
281 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
282 | - print $disabled.'">'; // ui-btn to highlight on clic |
|
279 | + print str_pad('', $val2['level'] + 1); |
|
280 | + print '<li class="lilevel'.($val2['level'] + 1); |
|
281 | + if ($val2['level'] == 0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
282 | + print $disabled.'">'; // ui-btn to highlight on clic |
|
283 | 283 | if ($relurl2) |
284 | 284 | { |
285 | 285 | if ($val2['enabled']) // Allowed |
@@ -287,23 +287,23 @@ discard block |
||
287 | 287 | print '<a href="'.$relurl2.'"'; |
288 | 288 | //print ' data-ajax="false"'; |
289 | 289 | print '>'; |
290 | - $lastlevel2[$val2['level']]='enabled'; |
|
290 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
291 | 291 | } |
292 | 292 | else // Not allowed but visible (greyed) |
293 | 293 | { |
294 | 294 | print '<a href="#" class="vsmenudisabled">'; |
295 | - $lastlevel2[$val2['level']]='greyed'; |
|
295 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
296 | 296 | } |
297 | 297 | } |
298 | 298 | else |
299 | 299 | { |
300 | 300 | if ($val2['enabled']) // Allowed |
301 | 301 | { |
302 | - $lastlevel2[$val2['level']]='enabled'; |
|
302 | + $lastlevel2[$val2['level']] = 'enabled'; |
|
303 | 303 | } |
304 | 304 | else |
305 | 305 | { |
306 | - $lastlevel2[$val2['level']]='greyed'; |
|
306 | + $lastlevel2[$val2['level']] = 'greyed'; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | //var_dump($val2['level']); |
@@ -65,8 +65,12 @@ discard block |
||
65 | 65 | function loadMenu($forcemainmenu='',$forceleftmenu='') |
66 | 66 | { |
67 | 67 | // On sauve en session le menu principal choisi |
68 | - if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
69 | - if (isset($_GET["idmenu"])) $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
68 | + if (isset($_GET["mainmenu"])) { |
|
69 | + $_SESSION["mainmenu"]=$_GET["mainmenu"]; |
|
70 | + } |
|
71 | + if (isset($_GET["idmenu"])) { |
|
72 | + $_SESSION["idmenu"]=$_GET["idmenu"]; |
|
73 | + } |
|
70 | 74 | |
71 | 75 | // Read mainmenu and leftmenu that define which menu to show |
72 | 76 | if (isset($_GET["mainmenu"])) |
@@ -75,13 +79,14 @@ discard block |
||
75 | 79 | $mainmenu=$_GET["mainmenu"]; |
76 | 80 | $_SESSION["mainmenu"]=$mainmenu; |
77 | 81 | $_SESSION["leftmenuopened"]=""; |
78 | - } |
|
79 | - else |
|
82 | + } else |
|
80 | 83 | { |
81 | 84 | // On va le chercher en session si non defini par le lien |
82 | 85 | $mainmenu=isset($_SESSION["mainmenu"])?$_SESSION["mainmenu"]:''; |
83 | 86 | } |
84 | - if (! empty($forcemainmenu)) $mainmenu=$forcemainmenu; |
|
87 | + if (! empty($forcemainmenu)) { |
|
88 | + $mainmenu=$forcemainmenu; |
|
89 | + } |
|
85 | 90 | |
86 | 91 | if (isset($_GET["leftmenu"])) |
87 | 92 | { |
@@ -89,12 +94,13 @@ discard block |
||
89 | 94 | $leftmenu=$_GET["leftmenu"]; |
90 | 95 | $_SESSION["leftmenu"]=$leftmenu; |
91 | 96 | |
92 | - if ($_SESSION["leftmenuopened"]==$leftmenu) // To collapse |
|
97 | + if ($_SESSION["leftmenuopened"]==$leftmenu) { |
|
98 | + // To collapse |
|
93 | 99 | { |
94 | 100 | //$leftmenu=""; |
95 | 101 | $_SESSION["leftmenuopened"]=""; |
96 | 102 | } |
97 | - else |
|
103 | + } else |
|
98 | 104 | { |
99 | 105 | $_SESSION["leftmenuopened"]=$leftmenu; |
100 | 106 | } |
@@ -102,7 +108,9 @@ discard block |
||
102 | 108 | // On va le chercher en session si non defini par le lien |
103 | 109 | $leftmenu=isset($_SESSION["leftmenu"])?$_SESSION["leftmenu"]:''; |
104 | 110 | } |
105 | - if (! empty($forceleftmenu)) $leftmenu=$forceleftmenu; |
|
111 | + if (! empty($forceleftmenu)) { |
|
112 | + $leftmenu=$forceleftmenu; |
|
113 | + } |
|
106 | 114 | |
107 | 115 | require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; |
108 | 116 | $tabMenu=array(); |
@@ -142,14 +150,21 @@ discard block |
||
142 | 150 | |
143 | 151 | if (empty($conf->global->MAIN_MENU_INVERT)) |
144 | 152 | { |
145 | - if ($mode == 'top') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
146 | - if ($mode == 'left') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
147 | - } |
|
148 | - else |
|
153 | + if ($mode == 'top') { |
|
154 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
155 | + } |
|
156 | + if ($mode == 'left') { |
|
157 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0,'','',$moredata); |
|
158 | + } |
|
159 | + } else |
|
149 | 160 | { |
150 | 161 | $conf->global->MAIN_SHOW_LOGO=0; |
151 | - if ($mode == 'top') print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
152 | - if ($mode == 'left') print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
162 | + if ($mode == 'top') { |
|
163 | + print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu,0); |
|
164 | + } |
|
165 | + if ($mode == 'left') { |
|
166 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,0,$mode); |
|
167 | + } |
|
153 | 168 | } |
154 | 169 | |
155 | 170 | if ($mode == 'topnb') |
@@ -158,17 +173,22 @@ discard block |
||
158 | 173 | return $this->menu->getNbOfVisibleMenuEntries(); |
159 | 174 | } |
160 | 175 | |
161 | - if ($mode == 'jmobile') // Used to get menu in xml ul/li |
|
176 | + if ($mode == 'jmobile') { |
|
177 | + // Used to get menu in xml ul/li |
|
162 | 178 | { |
163 | - print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); // Fill this->menu that is empty with top menu |
|
179 | + print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1,$mode); |
|
180 | + } |
|
181 | + // Fill this->menu that is empty with top menu |
|
164 | 182 | |
165 | 183 | // $this->menu->liste is top menu |
166 | 184 | //var_dump($this->menu->liste);exit; |
167 | 185 | $lastlevel = array(); |
168 | 186 | print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n"; |
169 | - foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
187 | + foreach($this->menu->liste as $key => $val) { |
|
188 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
170 | 189 | { |
171 | 190 | print '<ul class="ulmenu" data-inset="true">'; |
191 | + } |
|
172 | 192 | print '<li class="lilevel0">'; |
173 | 193 | |
174 | 194 | if ($val['enabled'] == 1) |
@@ -183,7 +203,9 @@ discard block |
||
183 | 203 | print '<a class="alilevel0" href="#">'; |
184 | 204 | |
185 | 205 | // Add font-awesome |
186 | - if ($val['level'] == 0 && $val['mainmenu'] == 'home') print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
206 | + if ($val['level'] == 0 && $val['mainmenu'] == 'home') { |
|
207 | + print '<span class="fa fa-home fa-fw paddingright" aria-hidden="true"></span>'; |
|
208 | + } |
|
187 | 209 | |
188 | 210 | print $val['titre']; |
189 | 211 | print '</a>'."\n"; |
@@ -209,12 +231,16 @@ discard block |
||
209 | 231 | // We add sub entry |
210 | 232 | print str_pad('',1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic |
211 | 233 | print '<a href="'.$relurl.'">'; |
212 | - if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") // No translation |
|
234 | + if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") { |
|
235 | + // No translation |
|
213 | 236 | { |
214 | 237 | if (in_array($val['mainmenu'], array('cashdesk', 'externalsite', 'website', 'collab'))) print $langs->trans("Access"); |
215 | - else print $langs->trans("Dashboard"); |
|
238 | + } else { |
|
239 | + print $langs->trans("Dashboard"); |
|
240 | + } |
|
241 | + } else { |
|
242 | + print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
216 | 243 | } |
217 | - else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); |
|
218 | 244 | print '</a>'; |
219 | 245 | print '</li>'."\n"; |
220 | 246 | } |
@@ -224,22 +250,26 @@ discard block |
||
224 | 250 | if ($val['enabled']) |
225 | 251 | { |
226 | 252 | $lastlevel[0]='enabled'; |
227 | - } |
|
228 | - else if ($showmenu) // Not enabled but visible (so greyed) |
|
253 | + } else if ($showmenu) { |
|
254 | + // Not enabled but visible (so greyed) |
|
229 | 255 | { |
230 | 256 | $lastlevel[0]='greyed'; |
231 | 257 | } |
232 | - else |
|
258 | + } else |
|
233 | 259 | { |
234 | 260 | $lastlevel[0]='hidden'; |
235 | 261 | } |
236 | 262 | } |
237 | 263 | |
238 | 264 | $lastlevel2 = array(); |
239 | - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
265 | + foreach($submenu->liste as $key2 => $val2) { |
|
266 | + // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' |
|
240 | 267 | { |
241 | 268 | $showmenu=true; |
242 | - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) $showmenu=false; |
|
269 | + } |
|
270 | + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($val2['enabled'])) { |
|
271 | + $showmenu=false; |
|
272 | + } |
|
243 | 273 | |
244 | 274 | // If at least one parent is not enabled, we do not show any menu of all children |
245 | 275 | if ($val2['level'] > 0) |
@@ -247,28 +277,33 @@ discard block |
||
247 | 277 | $levelcursor = $val2['level']-1; |
248 | 278 | while ($levelcursor >= 0) |
249 | 279 | { |
250 | - if ($lastlevel2[$levelcursor] != 'enabled') $showmenu=false; |
|
280 | + if ($lastlevel2[$levelcursor] != 'enabled') { |
|
281 | + $showmenu=false; |
|
282 | + } |
|
251 | 283 | $levelcursor--; |
252 | 284 | } |
253 | 285 | } |
254 | 286 | |
255 | - if ($showmenu) // Visible (option to hide when not allowed is off or allowed) |
|
287 | + if ($showmenu) { |
|
288 | + // Visible (option to hide when not allowed is off or allowed) |
|
256 | 289 | { |
257 | 290 | $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user); |
291 | + } |
|
258 | 292 | $substitarray['__USERID__'] = $user->id; // For backward compatibility |
259 | 293 | $val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__ |
260 | 294 | |
261 | 295 | if (! preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) |
262 | 296 | { |
263 | 297 | $relurl2=dol_buildpath($val2['url'],1); |
264 | - } |
|
265 | - else |
|
298 | + } else |
|
266 | 299 | { |
267 | 300 | $relurl2=$val2['url']; |
268 | 301 | } |
269 | 302 | $canonurl2=preg_replace('/\?.*$/','',$val2['url']); |
270 | 303 | //var_dump($val2['url'].' - '.$canonurl2.' - '.$val2['level']); |
271 | - if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; |
|
304 | + if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) { |
|
305 | + $relurl2=''; |
|
306 | + } |
|
272 | 307 | |
273 | 308 | $disabled=''; |
274 | 309 | if (! $val2['enabled']) |
@@ -278,30 +313,34 @@ discard block |
||
278 | 313 | |
279 | 314 | print str_pad('',$val2['level']+1); |
280 | 315 | print '<li class="lilevel'.($val2['level']+1); |
281 | - if ($val2['level']==0) print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic |
|
316 | + if ($val2['level']==0) { |
|
317 | + print ' ui-btn-icon-right ui-btn'; |
|
318 | + } |
|
319 | + // ui-btn to highlight on clic |
|
282 | 320 | print $disabled.'">'; // ui-btn to highlight on clic |
283 | 321 | if ($relurl2) |
284 | 322 | { |
285 | - if ($val2['enabled']) // Allowed |
|
323 | + if ($val2['enabled']) { |
|
324 | + // Allowed |
|
286 | 325 | { |
287 | 326 | print '<a href="'.$relurl2.'"'; |
327 | + } |
|
288 | 328 | //print ' data-ajax="false"'; |
289 | 329 | print '>'; |
290 | 330 | $lastlevel2[$val2['level']]='enabled'; |
291 | - } |
|
292 | - else // Not allowed but visible (greyed) |
|
331 | + } else // Not allowed but visible (greyed) |
|
293 | 332 | { |
294 | 333 | print '<a href="#" class="vsmenudisabled">'; |
295 | 334 | $lastlevel2[$val2['level']]='greyed'; |
296 | 335 | } |
297 | - } |
|
298 | - else |
|
336 | + } else |
|
299 | 337 | { |
300 | - if ($val2['enabled']) // Allowed |
|
338 | + if ($val2['enabled']) { |
|
339 | + // Allowed |
|
301 | 340 | { |
302 | 341 | $lastlevel2[$val2['level']]='enabled'; |
303 | 342 | } |
304 | - else |
|
343 | + } else |
|
305 | 344 | { |
306 | 345 | $lastlevel2[$val2['level']]='greyed'; |
307 | 346 | } |
@@ -311,10 +350,12 @@ discard block |
||
311 | 350 | print $val2['titre']; |
312 | 351 | if ($relurl2) |
313 | 352 | { |
314 | - if ($val2['enabled']) // Allowed |
|
315 | - print '</a>'; |
|
316 | - else |
|
353 | + if ($val2['enabled']) { |
|
354 | + // Allowed |
|
317 | 355 | print '</a>'; |
356 | + } else { |
|
357 | + print '</a>'; |
|
358 | + } |
|
318 | 359 | } |
319 | 360 | print '</li>'."\n"; |
320 | 361 | } |