@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * This ajax page is called when doing an up or down drag and drop. |
23 | 23 | */ |
24 | 24 | |
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable token renewal |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
28 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
29 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
30 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
31 | -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks |
|
25 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disable token renewal |
|
26 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
27 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
28 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
29 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
30 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
31 | +if (!defined('NOREQUIREHOOK')) define('NOREQUIREHOOK', '1'); // Disable "main.inc.php" hooks |
|
32 | 32 | |
33 | 33 | require '../../main.inc.php'; |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
@@ -43,23 +43,23 @@ 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 | // Registering the location of boxes |
46 | -if ((isset($_POST['roworder']) && ! empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && ! empty($_POST['table_element_line'])) |
|
47 | - && (isset($_POST['fk_element']) && ! empty($_POST['fk_element'])) && (isset($_POST['element_id']) && ! empty($_POST['element_id'])) ) |
|
46 | +if ((isset($_POST['roworder']) && !empty($_POST['roworder'])) && (isset($_POST['table_element_line']) && !empty($_POST['table_element_line'])) |
|
47 | + && (isset($_POST['fk_element']) && !empty($_POST['fk_element'])) && (isset($_POST['element_id']) && !empty($_POST['element_id']))) |
|
48 | 48 | { |
49 | - $roworder=GETPOST('roworder','alpha',2); |
|
50 | - $table_element_line=GETPOST('table_element_line','alpha',2); |
|
51 | - $fk_element=GETPOST('fk_element','alpha',2); |
|
52 | - $element_id=GETPOST('element_id','int',2); |
|
49 | + $roworder = GETPOST('roworder', 'alpha', 2); |
|
50 | + $table_element_line = GETPOST('table_element_line', 'alpha', 2); |
|
51 | + $fk_element = GETPOST('fk_element', 'alpha', 2); |
|
52 | + $element_id = GETPOST('element_id', 'int', 2); |
|
53 | 53 | |
54 | 54 | dol_syslog("AjaxRow roworder=".$roworder." table_element_line=".$table_element_line." fk_element=".$fk_element." element_id=".$element_id, LOG_DEBUG); |
55 | 55 | |
56 | - $rowordertab = explode(',',$roworder); |
|
57 | - foreach($rowordertab as $value) |
|
56 | + $rowordertab = explode(',', $roworder); |
|
57 | + foreach ($rowordertab as $value) |
|
58 | 58 | { |
59 | - if (! empty($value)) $newrowordertab[] = $value; |
|
59 | + if (!empty($value)) $newrowordertab[] = $value; |
|
60 | 60 | } |
61 | 61 | |
62 | - $row=new GenericObject($db); |
|
62 | + $row = new GenericObject($db); |
|
63 | 63 | $row->table_element_line = $table_element_line; |
64 | 64 | $row->fk_element = $fk_element; |
65 | 65 | $row->id = $element_id; |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | |
68 | 68 | // Reorder line to have position of chilren lines sharing same counter than parent lines |
69 | 69 | // This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database. |
70 | - if (in_array($fk_element,array('fk_facture','fk_propal','fk_commande'))) |
|
70 | + if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande'))) |
|
71 | 71 | { |
72 | - $result=$row->line_order(true); |
|
72 | + $result = $row->line_order(true); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 |
@@ -22,13 +22,29 @@ discard block |
||
22 | 22 | * This ajax page is called when doing an up or down drag and drop. |
23 | 23 | */ |
24 | 24 | |
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disable token renewal |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
28 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
29 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
30 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
31 | -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks |
|
25 | +if (! defined('NOTOKENRENEWAL')) { |
|
26 | + define('NOTOKENRENEWAL','1'); |
|
27 | +} |
|
28 | +// Disable token renewal |
|
29 | +if (! defined('NOREQUIREMENU')) { |
|
30 | + define('NOREQUIREMENU','1'); |
|
31 | +} |
|
32 | +if (! defined('NOREQUIREHTML')) { |
|
33 | + define('NOREQUIREHTML','1'); |
|
34 | +} |
|
35 | +if (! defined('NOREQUIREAJAX')) { |
|
36 | + define('NOREQUIREAJAX','1'); |
|
37 | +} |
|
38 | +if (! defined('NOREQUIRESOC')) { |
|
39 | + define('NOREQUIRESOC','1'); |
|
40 | +} |
|
41 | +if (! defined('NOREQUIRETRAN')) { |
|
42 | + define('NOREQUIRETRAN','1'); |
|
43 | +} |
|
44 | +if (! defined('NOREQUIREHOOK')) { |
|
45 | + define('NOREQUIREHOOK','1'); |
|
46 | +} |
|
47 | +// Disable "main.inc.php" hooks |
|
32 | 48 | |
33 | 49 | require '../../main.inc.php'; |
34 | 50 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
@@ -56,7 +72,9 @@ discard block |
||
56 | 72 | $rowordertab = explode(',',$roworder); |
57 | 73 | foreach($rowordertab as $value) |
58 | 74 | { |
59 | - if (! empty($value)) $newrowordertab[] = $value; |
|
75 | + if (! empty($value)) { |
|
76 | + $newrowordertab[] = $value; |
|
77 | + } |
|
60 | 78 | } |
61 | 79 | |
62 | 80 | $row=new GenericObject($db); |
@@ -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 | require '../../main.inc.php'; |
@@ -51,47 +51,47 @@ |
||
51 | 51 | { |
52 | 52 | // Increase date |
53 | 53 | $al = new AccountLine($db); |
54 | - $al->datev_next(GETPOST('rowid','int')); |
|
55 | - $al->fetch(GETPOST('rowid','int')); |
|
54 | + $al->datev_next(GETPOST('rowid','int')); |
|
55 | + $al->fetch(GETPOST('rowid','int')); |
|
56 | 56 | |
57 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
57 | + print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
58 | 58 | |
59 | - exit; |
|
59 | + exit; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') |
63 | 63 | { |
64 | 64 | // Decrease date |
65 | 65 | $al =new AccountLine($db); |
66 | - $al->datev_previous(GETPOST('rowid','int')); |
|
67 | - $al->fetch(GETPOST('rowid','int')); |
|
66 | + $al->datev_previous(GETPOST('rowid','int')); |
|
67 | + $al->fetch(GETPOST('rowid','int')); |
|
68 | 68 | |
69 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
69 | + print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
70 | 70 | |
71 | - exit; |
|
71 | + exit; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') |
75 | 75 | { |
76 | 76 | // Increase date |
77 | 77 | $al = new AccountLine($db); |
78 | - $al->dateo_next(GETPOST('rowid','int')); |
|
79 | - $al->fetch(GETPOST('rowid','int')); |
|
78 | + $al->dateo_next(GETPOST('rowid','int')); |
|
79 | + $al->fetch(GETPOST('rowid','int')); |
|
80 | 80 | |
81 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
81 | + print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
82 | 82 | |
83 | - exit; |
|
83 | + exit; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') |
87 | 87 | { |
88 | 88 | // Decrease date |
89 | 89 | $al =new AccountLine($db); |
90 | - $al->dateo_previous(GETPOST('rowid','int')); |
|
91 | - $al->fetch(GETPOST('rowid','int')); |
|
90 | + $al->dateo_previous(GETPOST('rowid','int')); |
|
91 | + $al->fetch(GETPOST('rowid','int')); |
|
92 | 92 | |
93 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
93 | + print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
94 | 94 | |
95 | - exit; |
|
95 | + exit; |
|
96 | 96 | } |
97 | 97 |
@@ -20,18 +20,18 @@ 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 | require '../../main.inc.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; |
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
33 | 33 | |
34 | -$action=GETPOST('action','aZ09'); |
|
34 | +$action = GETPOST('action', 'aZ09'); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /* |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | { |
52 | 52 | // Increase date |
53 | 53 | $al = new AccountLine($db); |
54 | - $al->datev_next(GETPOST('rowid','int')); |
|
55 | - $al->fetch(GETPOST('rowid','int')); |
|
54 | + $al->datev_next(GETPOST('rowid', 'int')); |
|
55 | + $al->fetch(GETPOST('rowid', 'int')); |
|
56 | 56 | |
57 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
57 | + print '<span>'.dol_print_date($db->jdate($al->datev), "day").'</span>'; |
|
58 | 58 | |
59 | 59 | exit; |
60 | 60 | } |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') |
63 | 63 | { |
64 | 64 | // Decrease date |
65 | - $al =new AccountLine($db); |
|
66 | - $al->datev_previous(GETPOST('rowid','int')); |
|
67 | - $al->fetch(GETPOST('rowid','int')); |
|
65 | + $al = new AccountLine($db); |
|
66 | + $al->datev_previous(GETPOST('rowid', 'int')); |
|
67 | + $al->fetch(GETPOST('rowid', 'int')); |
|
68 | 68 | |
69 | - print '<span>'.dol_print_date($db->jdate($al->datev),"day").'</span>'; |
|
69 | + print '<span>'.dol_print_date($db->jdate($al->datev), "day").'</span>'; |
|
70 | 70 | |
71 | 71 | exit; |
72 | 72 | } |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | { |
76 | 76 | // Increase date |
77 | 77 | $al = new AccountLine($db); |
78 | - $al->dateo_next(GETPOST('rowid','int')); |
|
79 | - $al->fetch(GETPOST('rowid','int')); |
|
78 | + $al->dateo_next(GETPOST('rowid', 'int')); |
|
79 | + $al->fetch(GETPOST('rowid', 'int')); |
|
80 | 80 | |
81 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
81 | + print '<span>'.dol_print_date($db->jdate($al->dateo), "day").'</span>'; |
|
82 | 82 | |
83 | 83 | exit; |
84 | 84 | } |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') |
87 | 87 | { |
88 | 88 | // Decrease date |
89 | - $al =new AccountLine($db); |
|
90 | - $al->dateo_previous(GETPOST('rowid','int')); |
|
91 | - $al->fetch(GETPOST('rowid','int')); |
|
89 | + $al = new AccountLine($db); |
|
90 | + $al->dateo_previous(GETPOST('rowid', 'int')); |
|
91 | + $al->fetch(GETPOST('rowid', 'int')); |
|
92 | 92 | |
93 | - print '<span>'.dol_print_date($db->jdate($al->dateo),"day").'</span>'; |
|
93 | + print '<span>'.dol_print_date($db->jdate($al->dateo), "day").'</span>'; |
|
94 | 94 | |
95 | 95 | exit; |
96 | 96 | } |
@@ -46,4 +46,4 @@ |
||
46 | 46 | |
47 | 47 | // Registering new values |
48 | 48 | if (($action == 'set') && ! empty($id)) |
49 | - $object->setValueFrom($field, $value, $element, $id); |
|
49 | + $object->setValueFrom($field, $value, $element, $id); |
@@ -19,21 +19,21 @@ discard block |
||
19 | 19 | * \brief File to set tosell and tobuy for product |
20 | 20 | */ |
21 | 21 | |
22 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
23 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
24 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
27 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
22 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
23 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
24 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
25 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
26 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
27 | +if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); |
|
28 | 28 | |
29 | 29 | require '../../main.inc.php'; |
30 | 30 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
31 | 31 | |
32 | -$action=GETPOST('action','alpha'); |
|
33 | -$id=GETPOST('id', 'int'); |
|
34 | -$value=GETPOST('value', 'int'); |
|
35 | -$field=GETPOST('field', 'alpha'); |
|
36 | -$element=GETPOST('element', 'alpha'); |
|
32 | +$action = GETPOST('action', 'alpha'); |
|
33 | +$id = GETPOST('id', 'int'); |
|
34 | +$value = GETPOST('value', 'int'); |
|
35 | +$field = GETPOST('field', 'alpha'); |
|
36 | +$element = GETPOST('element', 'alpha'); |
|
37 | 37 | |
38 | 38 | $object = new GenericObject($db); |
39 | 39 | /* |
@@ -45,5 +45,5 @@ discard block |
||
45 | 45 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
46 | 46 | |
47 | 47 | // Registering new values |
48 | -if (($action == 'set') && ! empty($id)) |
|
48 | +if (($action == 'set') && !empty($id)) |
|
49 | 49 | $object->setValueFrom($field, $value, $element, $id); |
@@ -19,12 +19,25 @@ discard block |
||
19 | 19 | * \brief File to set tosell and tobuy for product |
20 | 20 | */ |
21 | 21 | |
22 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
23 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
24 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
25 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
27 | -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
|
22 | +if (! defined('NOTOKENRENEWAL')) { |
|
23 | + define('NOTOKENRENEWAL','1'); |
|
24 | +} |
|
25 | +// Disables token renewal |
|
26 | +if (! defined('NOREQUIREMENU')) { |
|
27 | + define('NOREQUIREMENU','1'); |
|
28 | +} |
|
29 | +if (! defined('NOREQUIREHTML')) { |
|
30 | + define('NOREQUIREHTML','1'); |
|
31 | +} |
|
32 | +if (! defined('NOREQUIREAJAX')) { |
|
33 | + define('NOREQUIREAJAX','1'); |
|
34 | +} |
|
35 | +if (! defined('NOREQUIRESOC')) { |
|
36 | + define('NOREQUIRESOC','1'); |
|
37 | +} |
|
38 | +if (! defined('NOREQUIRETRAN')) { |
|
39 | + define('NOREQUIRETRAN','1'); |
|
40 | +} |
|
28 | 41 | |
29 | 42 | require '../../main.inc.php'; |
30 | 43 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
@@ -45,5 +58,6 @@ discard block |
||
45 | 58 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
46 | 59 | |
47 | 60 | // Registering new values |
48 | -if (($action == 'set') && ! empty($id)) |
|
61 | +if (($action == 'set') && ! empty($id)) { |
|
49 | 62 | $object->setValueFrom($field, $value, $element, $id); |
63 | +} |
@@ -20,18 +20,18 @@ 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'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | 25 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | 28 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
29 | 29 | |
30 | 30 | require('../../main.inc.php'); |
31 | 31 | |
32 | -$output = GETPOST('output','alpha'); |
|
33 | -$amount = price2num(GETPOST('amount','alpha')); |
|
34 | -$tva_tx = str_replace('*','',GETPOST('tva_tx','alpha')); |
|
32 | +$output = GETPOST('output', 'alpha'); |
|
33 | +$amount = price2num(GETPOST('amount', 'alpha')); |
|
34 | +$tva_tx = str_replace('*', '', GETPOST('tva_tx', 'alpha')); |
|
35 | 35 | |
36 | 36 | /* |
37 | 37 | * View |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
43 | 43 | |
44 | 44 | // Load original field value |
45 | -if (! empty($output) && isset($amount) && isset($tva_tx)) |
|
45 | +if (!empty($output) && isset($amount) && isset($tva_tx)) |
|
46 | 46 | { |
47 | - $return=array(); |
|
48 | - $price=''; |
|
47 | + $return = array(); |
|
48 | + $price = ''; |
|
49 | 49 | |
50 | 50 | if (is_numeric($amount) && $amount != '') |
51 | 51 | { |
52 | 52 | if ($output == 'price_ttc') { |
53 | 53 | |
54 | - $price = price2num($amount * (1 + ($tva_tx/100)), 'MU'); |
|
54 | + $price = price2num($amount * (1 + ($tva_tx / 100)), 'MU'); |
|
55 | 55 | $return['price_ht'] = $amount; |
56 | 56 | $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); |
57 | 57 | |
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 | } |
@@ -20,11 +20,20 @@ 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'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
25 | 30 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
31 | +if (! defined('NOREQUIREAJAX')) { |
|
32 | + define('NOREQUIREAJAX','1'); |
|
33 | +} |
|
34 | +if (! defined('NOREQUIRESOC')) { |
|
35 | + define('NOREQUIRESOC','1'); |
|
36 | +} |
|
28 | 37 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
29 | 38 | |
30 | 39 | require('../../main.inc.php'); |
@@ -55,8 +64,7 @@ discard block |
||
55 | 64 | $return['price_ht'] = $amount; |
56 | 65 | $return['price_ttc'] = (isset($price) && $price != '' ? price($price) : ''); |
57 | 66 | |
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) : ''); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $nbboxonright=substr_count($tmp[1],','); |
61 | 61 | print $nbboxonleft.'-'.$nbboxonright; |
62 | 62 | if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
63 | - else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
63 | + else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // Registering the location of boxes after a move |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); |
73 | 73 | if ($result > 0) |
74 | 74 | { |
75 | - $langs->load("boxes"); |
|
76 | - if (! GETPOST('closing')) |
|
77 | - { |
|
78 | - setEventMessages($langs->trans("BoxAdded"), null); |
|
79 | - } |
|
75 | + $langs->load("boxes"); |
|
76 | + if (! GETPOST('closing')) |
|
77 | + { |
|
78 | + setEventMessages($langs->trans("BoxAdded"), null); |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 |
@@ -21,22 +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')) 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 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
30 | -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); |
|
30 | +if (!defined('NOREQUIREHOOK')) define('NOREQUIREHOOK', '1'); |
|
31 | 31 | |
32 | 32 | require '../../main.inc.php'; |
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; |
34 | 34 | |
35 | -$boxid=GETPOST('boxid','int'); |
|
36 | -$boxorder=GETPOST('boxorder'); |
|
37 | -$userid=GETPOST('userid'); |
|
38 | -$zone=GETPOST('zone','int'); |
|
39 | -$userid=GETPOST('userid','int'); |
|
35 | +$boxid = GETPOST('boxid', 'int'); |
|
36 | +$boxorder = GETPOST('boxorder'); |
|
37 | +$userid = GETPOST('userid'); |
|
38 | +$zone = GETPOST('zone', 'int'); |
|
39 | +$userid = GETPOST('userid', 'int'); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /* |
@@ -53,27 +53,27 @@ discard block |
||
53 | 53 | print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
54 | 54 | |
55 | 55 | // Add a box |
56 | -if ($boxid > 0 && $zone !='' && $userid > 0) |
|
56 | +if ($boxid > 0 && $zone != '' && $userid > 0) |
|
57 | 57 | { |
58 | - $tmp=explode('-',$boxorder); |
|
59 | - $nbboxonleft=substr_count($tmp[0],','); |
|
60 | - $nbboxonright=substr_count($tmp[1],','); |
|
58 | + $tmp = explode('-', $boxorder); |
|
59 | + $nbboxonleft = substr_count($tmp[0], ','); |
|
60 | + $nbboxonright = substr_count($tmp[1], ','); |
|
61 | 61 | print $nbboxonleft.'-'.$nbboxonright; |
62 | - if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
63 | - else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
62 | + if ($nbboxonleft > $nbboxonright) $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list |
|
63 | + else $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // Registering the location of boxes after a move |
67 | -if ($boxorder && $zone != '' && $userid > 0) |
|
67 | +if ($boxorder && $zone != '' && $userid > 0) |
|
68 | 68 | { |
69 | 69 | // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B" |
70 | 70 | dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); |
71 | 71 | |
72 | - $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); |
|
72 | + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); |
|
73 | 73 | if ($result > 0) |
74 | 74 | { |
75 | 75 | $langs->load("boxes"); |
76 | - if (! GETPOST('closing')) |
|
76 | + if (!GETPOST('closing')) |
|
77 | 77 | { |
78 | 78 | setEventMessages($langs->trans("BoxAdded"), null); |
79 | 79 | } |
@@ -21,13 +21,26 @@ 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 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
30 | -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); |
|
41 | +if (! defined('NOREQUIREHOOK')) { |
|
42 | + define('NOREQUIREHOOK','1'); |
|
43 | +} |
|
31 | 44 | |
32 | 45 | require '../../main.inc.php'; |
33 | 46 | require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; |
@@ -59,8 +72,14 @@ discard block |
||
59 | 72 | $nbboxonleft=substr_count($tmp[0],','); |
60 | 73 | $nbboxonright=substr_count($tmp[1],','); |
61 | 74 | print $nbboxonleft.'-'.$nbboxonright; |
62 | - if ($nbboxonleft > $nbboxonright) $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
63 | - else $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); // Insert id of new box into list |
|
75 | + if ($nbboxonleft > $nbboxonright) { |
|
76 | + $boxorder=preg_replace('/B:/','B:'.$boxid.',',$boxorder); |
|
77 | + } |
|
78 | + // Insert id of new box into list |
|
79 | + else { |
|
80 | + $boxorder=preg_replace('/^A:/','A:'.$boxid.',',$boxorder); |
|
81 | + } |
|
82 | + // Insert id of new box into list |
|
64 | 83 | } |
65 | 84 | |
66 | 85 | // Registering the location of boxes after a move |
@@ -62,36 +62,36 @@ discard block |
||
62 | 62 | |
63 | 63 | if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
64 | 64 | { |
65 | - $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
|
66 | - $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
67 | - $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
68 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
69 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; |
|
70 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
71 | - $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
|
72 | - $sql.= " WHERE z.fk_pays = c.rowid"; |
|
73 | - $sql.= " AND z.active = 1 AND c.active = 1"; |
|
74 | - if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
75 | - if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
76 | - $sql.= " ORDER BY z.zip, z.town"; |
|
77 | - $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
65 | + $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
|
66 | + $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
67 | + $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
68 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
69 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; |
|
70 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
71 | + $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
|
72 | + $sql.= " WHERE z.fk_pays = c.rowid"; |
|
73 | + $sql.= " AND z.active = 1 AND c.active = 1"; |
|
74 | + if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
75 | + if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
76 | + $sql.= " ORDER BY z.zip, z.town"; |
|
77 | + $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
78 | 78 | } |
79 | 79 | else // Use table of third parties |
80 | 80 | { |
81 | - $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
|
82 | - $sql.= ", c.code as country_code, c.label as country"; |
|
83 | - $sql.= ", d.code_departement as county_code , d.nom as county"; |
|
84 | - $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; |
|
85 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; |
|
86 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
87 | - $sql.= " WHERE"; |
|
88 | - if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
89 | - if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
90 | - $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
|
91 | - $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
81 | + $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
|
82 | + $sql.= ", c.code as country_code, c.label as country"; |
|
83 | + $sql.= ", d.code_departement as county_code , d.nom as county"; |
|
84 | + $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; |
|
85 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; |
|
86 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
87 | + $sql.= " WHERE"; |
|
88 | + if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
89 | + if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
90 | + $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
|
91 | + $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
92 | 92 | } |
93 | 93 | |
94 | - //print $sql; |
|
94 | + //print $sql; |
|
95 | 95 | $resql=$db->query($sql); |
96 | 96 | //var_dump($db); |
97 | 97 | if ($resql) |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | $row_array['label'] = $row['zip'].' '.$row['town']; |
105 | 105 | $row_array['label'] .= ($county || $country)?' (':''; |
106 | - $row_array['label'] .= $county; |
|
106 | + $row_array['label'] .= $county; |
|
107 | 107 | $row_array['label'] .= ($county && $country?' - ':''); |
108 | - $row_array['label'] .= $country; |
|
109 | - $row_array['label'] .= ($county || $country)?')':''; |
|
110 | - if ($zipcode) |
|
108 | + $row_array['label'] .= $country; |
|
109 | + $row_array['label'] .= ($county || $country)?')':''; |
|
110 | + if ($zipcode) |
|
111 | 111 | { |
112 | 112 | $row_array['value'] = $row['zip']; |
113 | 113 | $row_array['town'] = $row['town']; |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | * \brief File to return Ajax response on zipcode or town request |
23 | 23 | */ |
24 | 24 | |
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
28 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
29 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
30 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
25 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal |
|
26 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
27 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); |
|
28 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
29 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
30 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
31 | 31 | |
32 | 32 | require '../../main.inc.php'; |
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
@@ -47,66 +47,66 @@ discard block |
||
47 | 47 | |
48 | 48 | //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n"; |
49 | 49 | |
50 | -dol_syslog("GET is ".join(',',$_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)?'':$conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); |
|
50 | +dol_syslog("GET is ".join(',', $_GET).', MAIN_USE_ZIPTOWN_DICTIONNARY='.(empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY) ? '' : $conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)); |
|
51 | 51 | //var_dump($_GET); |
52 | 52 | |
53 | 53 | // Generation of list of zip-town |
54 | -if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) |
|
54 | +if (!empty($_GET['zipcode']) || !empty($_GET['town'])) |
|
55 | 55 | { |
56 | 56 | $return_arr = array(); |
57 | 57 | $formcompany = new FormCompany($db); |
58 | 58 | |
59 | 59 | // Define filter on text typed |
60 | - $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; |
|
61 | - $town = $_GET['town']?$_GET['town']:''; |
|
60 | + $zipcode = $_GET['zipcode'] ? $_GET['zipcode'] : ''; |
|
61 | + $town = $_GET['town'] ? $_GET['town'] : ''; |
|
62 | 62 | |
63 | - if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
63 | + if (!empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
64 | 64 | { |
65 | 65 | $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
66 | - $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
67 | - $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
68 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
69 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; |
|
70 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
71 | - $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
|
72 | - $sql.= " WHERE z.fk_pays = c.rowid"; |
|
73 | - $sql.= " AND z.active = 1 AND c.active = 1"; |
|
74 | - if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
75 | - if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
76 | - $sql.= " ORDER BY z.zip, z.town"; |
|
77 | - $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
66 | + $sql .= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
|
67 | + $sql .= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
|
68 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
|
69 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON z.fk_county = d.rowid"; |
|
70 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; |
|
71 | + $sql .= " ".MAIN_DB_PREFIX."c_country as c"; |
|
72 | + $sql .= " WHERE z.fk_pays = c.rowid"; |
|
73 | + $sql .= " AND z.active = 1 AND c.active = 1"; |
|
74 | + if ($zipcode) $sql .= " AND z.zip LIKE '".$db->escape($zipcode)."%'"; |
|
75 | + if ($town) $sql .= " AND z.town LIKE '%".$db->escape($town)."%'"; |
|
76 | + $sql .= " ORDER BY z.zip, z.town"; |
|
77 | + $sql .= $db->plimit(100); // Avoid pb with bad criteria |
|
78 | 78 | } |
79 | 79 | else // Use table of third parties |
80 | 80 | { |
81 | 81 | $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
82 | - $sql.= ", c.code as country_code, c.label as country"; |
|
83 | - $sql.= ", d.code_departement as county_code , d.nom as county"; |
|
84 | - $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; |
|
85 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; |
|
86 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
87 | - $sql.= " WHERE"; |
|
88 | - if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
89 | - if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
90 | - $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
|
91 | - $sql.= $db->plimit(100); // Avoid pb with bad criteria |
|
82 | + $sql .= ", c.code as country_code, c.label as country"; |
|
83 | + $sql .= ", d.code_departement as county_code , d.nom as county"; |
|
84 | + $sql .= " FROM ".MAIN_DB_PREFIX.'societe as s'; |
|
85 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON s.fk_departement = d.rowid"; |
|
86 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
|
87 | + $sql .= " WHERE"; |
|
88 | + if ($zipcode) $sql .= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
89 | + if ($town) $sql .= " s.town LIKE '%".$db->escape($town)."%'"; |
|
90 | + $sql .= " ORDER BY s.fk_pays, s.zip, s.town"; |
|
91 | + $sql .= $db->plimit(100); // Avoid pb with bad criteria |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | //print $sql; |
95 | - $resql=$db->query($sql); |
|
95 | + $resql = $db->query($sql); |
|
96 | 96 | //var_dump($db); |
97 | 97 | if ($resql) |
98 | 98 | { |
99 | 99 | while ($row = $db->fetch_array($resql)) |
100 | 100 | { |
101 | - $country = $row['fk_country']?($langs->transnoentitiesnoconv('Country'.$row['country_code'])!='Country'.$row['country_code']?$langs->transnoentitiesnoconv('Country'.$row['country_code']):$row['country']):''; |
|
102 | - $county = $row['fk_county']?($langs->transnoentitiesnoconv($row['county_code'])!=$row['county_code']?$langs->transnoentitiesnoconv($row['county_code']):($row['county']!='-'?$row['county']:'')):''; |
|
101 | + $country = $row['fk_country'] ? ($langs->transnoentitiesnoconv('Country'.$row['country_code']) != 'Country'.$row['country_code'] ? $langs->transnoentitiesnoconv('Country'.$row['country_code']) : $row['country']) : ''; |
|
102 | + $county = $row['fk_county'] ? ($langs->transnoentitiesnoconv($row['county_code']) != $row['county_code'] ? $langs->transnoentitiesnoconv($row['county_code']) : ($row['county'] != '-' ? $row['county'] : '')) : ''; |
|
103 | 103 | |
104 | 104 | $row_array['label'] = $row['zip'].' '.$row['town']; |
105 | - $row_array['label'] .= ($county || $country)?' (':''; |
|
105 | + $row_array['label'] .= ($county || $country) ? ' (' : ''; |
|
106 | 106 | $row_array['label'] .= $county; |
107 | - $row_array['label'] .= ($county && $country?' - ':''); |
|
107 | + $row_array['label'] .= ($county && $country ? ' - ' : ''); |
|
108 | 108 | $row_array['label'] .= $country; |
109 | - $row_array['label'] .= ($county || $country)?')':''; |
|
109 | + $row_array['label'] .= ($county || $country) ? ')' : ''; |
|
110 | 110 | if ($zipcode) |
111 | 111 | { |
112 | 112 | $row_array['value'] = $row['zip']; |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | $row_array['selectcountry_id'] = $row['fk_country']; |
121 | 121 | $row_array['state_id'] = $row['fk_county']; |
122 | 122 | |
123 | - $row_array['states'] = $formcompany->select_state('',$row['fk_country'],''); |
|
123 | + $row_array['states'] = $formcompany->select_state('', $row['fk_country'], ''); |
|
124 | 124 | |
125 | - array_push($return_arr,$row_array); |
|
125 | + array_push($return_arr, $row_array); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 |
@@ -22,12 +22,25 @@ discard block |
||
22 | 22 | * \brief File to return Ajax response on zipcode or town request |
23 | 23 | */ |
24 | 24 | |
25 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal |
|
26 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
27 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
|
28 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
29 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
30 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
25 | +if (! defined('NOTOKENRENEWAL')) { |
|
26 | + define('NOTOKENRENEWAL',1); |
|
27 | +} |
|
28 | +// Disables token renewal |
|
29 | +if (! defined('NOREQUIREMENU')) { |
|
30 | + define('NOREQUIREMENU','1'); |
|
31 | +} |
|
32 | +if (! defined('NOREQUIREHTML')) { |
|
33 | + define('NOREQUIREHTML','1'); |
|
34 | +} |
|
35 | +if (! defined('NOREQUIREAJAX')) { |
|
36 | + define('NOREQUIREAJAX','1'); |
|
37 | +} |
|
38 | +if (! defined('NOREQUIRESOC')) { |
|
39 | + define('NOREQUIRESOC','1'); |
|
40 | +} |
|
41 | +if (! defined('NOCSRFCHECK')) { |
|
42 | + define('NOCSRFCHECK','1'); |
|
43 | +} |
|
31 | 44 | |
32 | 45 | require '../../main.inc.php'; |
33 | 46 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; |
@@ -60,9 +73,11 @@ discard block |
||
60 | 73 | $zipcode = $_GET['zipcode']?$_GET['zipcode']:''; |
61 | 74 | $town = $_GET['town']?$_GET['town']:''; |
62 | 75 | |
63 | - if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table |
|
76 | + if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) { |
|
77 | + // Use zip-town table |
|
64 | 78 | { |
65 | 79 | $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; |
80 | + } |
|
66 | 81 | $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; |
67 | 82 | $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; |
68 | 83 | $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; |
@@ -71,12 +86,15 @@ discard block |
||
71 | 86 | $sql.= " ".MAIN_DB_PREFIX."c_country as c"; |
72 | 87 | $sql.= " WHERE z.fk_pays = c.rowid"; |
73 | 88 | $sql.= " AND z.active = 1 AND c.active = 1"; |
74 | - if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
75 | - if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
89 | + if ($zipcode) { |
|
90 | + $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; |
|
91 | + } |
|
92 | + if ($town) { |
|
93 | + $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; |
|
94 | + } |
|
76 | 95 | $sql.= " ORDER BY z.zip, z.town"; |
77 | 96 | $sql.= $db->plimit(100); // Avoid pb with bad criteria |
78 | - } |
|
79 | - else // Use table of third parties |
|
97 | + } else // Use table of third parties |
|
80 | 98 | { |
81 | 99 | $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; |
82 | 100 | $sql.= ", c.code as country_code, c.label as country"; |
@@ -85,8 +103,12 @@ discard block |
||
85 | 103 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; |
86 | 104 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; |
87 | 105 | $sql.= " WHERE"; |
88 | - if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
89 | - if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
106 | + if ($zipcode) { |
|
107 | + $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; |
|
108 | + } |
|
109 | + if ($town) { |
|
110 | + $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; |
|
111 | + } |
|
90 | 112 | $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; |
91 | 113 | $sql.= $db->plimit(100); // Avoid pb with bad criteria |
92 | 114 | } |
@@ -127,8 +149,7 @@ discard block |
||
127 | 149 | } |
128 | 150 | |
129 | 151 | echo json_encode($return_arr); |
130 | -} |
|
131 | -else |
|
152 | +} else |
|
132 | 153 | { |
133 | 154 | |
134 | 155 | } |
@@ -20,20 +20,20 @@ discard block |
||
20 | 20 | * \brief File to load field value |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | 25 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | 28 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
29 | 29 | |
30 | 30 | require '../../main.inc.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
32 | 32 | |
33 | -$field = GETPOST('field','alpha'); |
|
34 | -$element = GETPOST('element','alpha'); |
|
35 | -$table_element = GETPOST('table_element','alpha'); |
|
36 | -$fk_element = GETPOST('fk_element','alpha'); |
|
33 | +$field = GETPOST('field', 'alpha'); |
|
34 | +$element = GETPOST('element', 'alpha'); |
|
35 | +$table_element = GETPOST('table_element', 'alpha'); |
|
36 | +$fk_element = GETPOST('fk_element', 'alpha'); |
|
37 | 37 | |
38 | 38 | /* |
39 | 39 | * View |
@@ -44,14 +44,14 @@ 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($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) |
|
47 | +if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) |
|
48 | 48 | { |
49 | - $ext_element = GETPOST('ext_element','alpha'); |
|
50 | - $field = substr($field, 8); // remove prefix val_ |
|
51 | - $type = GETPOST('type','alpha'); |
|
52 | - $loadmethod = (GETPOST('loadmethod','alpha') ? GETPOST('loadmethod','alpha') : 'getValueFrom'); |
|
49 | + $ext_element = GETPOST('ext_element', 'alpha'); |
|
50 | + $field = substr($field, 8); // remove prefix val_ |
|
51 | + $type = GETPOST('type', 'alpha'); |
|
52 | + $loadmethod = (GETPOST('loadmethod', 'alpha') ? GETPOST('loadmethod', 'alpha') : 'getValueFrom'); |
|
53 | 53 | |
54 | - if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) |
|
54 | + if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) |
|
55 | 55 | { |
56 | 56 | $element = $regs[1]; |
57 | 57 | $subelement = $regs[2]; |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | { |
78 | 78 | if ($type == 'select') |
79 | 79 | { |
80 | - $methodname = 'load_cache_'.$loadmethod; |
|
81 | - $cachename = 'cache_'.GETPOST('loadmethod','alpha'); |
|
80 | + $methodname = 'load_cache_'.$loadmethod; |
|
81 | + $cachename = 'cache_'.GETPOST('loadmethod', 'alpha'); |
|
82 | 82 | |
83 | 83 | $form = new Form($db); |
84 | 84 | if (method_exists($form, $methodname)) |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | $ret = $form->$methodname(); |
87 | 87 | if ($ret > 0) echo json_encode($form->$cachename); |
88 | 88 | } |
89 | - else if (! empty($ext_element)) |
|
89 | + else if (!empty($ext_element)) |
|
90 | 90 | { |
91 | 91 | $module = $subelement = $ext_element; |
92 | - if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
|
92 | + if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs)) |
|
93 | 93 | { |
94 | 94 | $module = $regs[1]; |
95 | 95 | $subelement = $regs[2]; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | else |
106 | 106 | { |
107 | 107 | $object = new GenericObject($db); |
108 | - $value=$object->$loadmethod($table_element, $fk_element, $field); |
|
108 | + $value = $object->$loadmethod($table_element, $fk_element, $field); |
|
109 | 109 | echo $value; |
110 | 110 | } |
111 | 111 | } |
@@ -20,11 +20,20 @@ discard block |
||
20 | 20 | * \brief File to load field value |
21 | 21 | */ |
22 | 22 | |
23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
25 | 30 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
31 | +if (! defined('NOREQUIREAJAX')) { |
|
32 | + define('NOREQUIREAJAX','1'); |
|
33 | +} |
|
34 | +if (! defined('NOREQUIRESOC')) { |
|
35 | + define('NOREQUIRESOC','1'); |
|
36 | +} |
|
28 | 37 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
29 | 38 | |
30 | 39 | require '../../main.inc.php'; |
@@ -57,15 +66,18 @@ discard block |
||
57 | 66 | $subelement = $regs[2]; |
58 | 67 | } |
59 | 68 | |
60 | - if ($element == 'propal') $element = 'propale'; |
|
61 | - else if ($element == 'fichinter') $element = 'ficheinter'; |
|
62 | - else if ($element == 'product') $element = 'produit'; |
|
63 | - else if ($element == 'member') $element = 'adherent'; |
|
64 | - else if ($element == 'order_supplier') { |
|
69 | + if ($element == 'propal') { |
|
70 | + $element = 'propale'; |
|
71 | + } else if ($element == 'fichinter') { |
|
72 | + $element = 'ficheinter'; |
|
73 | + } else if ($element == 'product') { |
|
74 | + $element = 'produit'; |
|
75 | + } else if ($element == 'member') { |
|
76 | + $element = 'adherent'; |
|
77 | + } else if ($element == 'order_supplier') { |
|
65 | 78 | $element = 'fournisseur'; |
66 | 79 | $subelement = 'commande'; |
67 | - } |
|
68 | - else if ($element == 'invoice_supplier') { |
|
80 | + } else if ($element == 'invoice_supplier') { |
|
69 | 81 | $element = 'fournisseur'; |
70 | 82 | $subelement = 'facture'; |
71 | 83 | } |
@@ -84,9 +96,10 @@ discard block |
||
84 | 96 | if (method_exists($form, $methodname)) |
85 | 97 | { |
86 | 98 | $ret = $form->$methodname(); |
87 | - if ($ret > 0) echo json_encode($form->$cachename); |
|
88 | - } |
|
89 | - else if (! empty($ext_element)) |
|
99 | + if ($ret > 0) { |
|
100 | + echo json_encode($form->$cachename); |
|
101 | + } |
|
102 | + } else if (! empty($ext_element)) |
|
90 | 103 | { |
91 | 104 | $module = $subelement = $ext_element; |
92 | 105 | if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
@@ -99,17 +112,17 @@ discard block |
||
99 | 112 | $classname = 'Actions'.ucfirst($subelement); |
100 | 113 | $object = new $classname($db); |
101 | 114 | $ret = $object->$methodname($fk_element); |
102 | - if ($ret > 0) echo json_encode($object->$cachename); |
|
115 | + if ($ret > 0) { |
|
116 | + echo json_encode($object->$cachename); |
|
117 | + } |
|
103 | 118 | } |
104 | - } |
|
105 | - else |
|
119 | + } else |
|
106 | 120 | { |
107 | 121 | $object = new GenericObject($db); |
108 | 122 | $value=$object->$loadmethod($table_element, $fk_element, $field); |
109 | 123 | echo $value; |
110 | 124 | } |
111 | - } |
|
112 | - else |
|
125 | + } else |
|
113 | 126 | { |
114 | 127 | echo $langs->transnoentities('NotEnoughPermissions'); |
115 | 128 | } |
@@ -59,23 +59,23 @@ |
||
59 | 59 | switch ($_SERVER['REQUEST_METHOD']) { |
60 | 60 | case 'OPTIONS': |
61 | 61 | break; |
62 | - case 'HEAD': |
|
63 | - case 'GET': |
|
64 | - $upload_handler->get(); |
|
65 | - break; |
|
66 | - case 'POST': |
|
67 | - if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { |
|
68 | - $upload_handler->delete(); |
|
69 | - } else { |
|
70 | - $upload_handler->post(); |
|
71 | - } |
|
72 | - break; |
|
73 | - case 'DELETE': |
|
74 | - $upload_handler->delete(); |
|
75 | - break; |
|
76 | - default: |
|
77 | - header('HTTP/1.0 405 Method Not Allowed'); |
|
78 | - exit; |
|
62 | + case 'HEAD': |
|
63 | + case 'GET': |
|
64 | + $upload_handler->get(); |
|
65 | + break; |
|
66 | + case 'POST': |
|
67 | + if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { |
|
68 | + $upload_handler->delete(); |
|
69 | + } else { |
|
70 | + $upload_handler->post(); |
|
71 | + } |
|
72 | + break; |
|
73 | + case 'DELETE': |
|
74 | + $upload_handler->delete(); |
|
75 | + break; |
|
76 | + default: |
|
77 | + header('HTTP/1.0 405 Method Not Allowed'); |
|
78 | + exit; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $db->close(); |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
26 | 26 | //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
27 | 27 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
28 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
29 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
30 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
31 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
28 | +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); |
|
29 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); |
|
30 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show |
|
31 | +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
|
32 | 32 | //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
33 | 33 | //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
34 | 34 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | //print_r($_GET); |
43 | 43 | //print 'upload_dir='.GETPOST('upload_dir'); |
44 | 44 | |
45 | -$fk_element = GETPOST('fk_element','int'); |
|
46 | -$element = GETPOST('element','alpha'); |
|
45 | +$fk_element = GETPOST('fk_element', 'int'); |
|
46 | +$element = GETPOST('element', 'alpha'); |
|
47 | 47 | |
48 | 48 | |
49 | -$upload_handler = new FileUpload(null,$fk_element,$element); |
|
49 | +$upload_handler = new FileUpload(null, $fk_element, $element); |
|
50 | 50 | |
51 | 51 | header('Pragma: no-cache'); |
52 | 52 | header('Cache-Control: no-store, no-cache, must-revalidate'); |
@@ -25,10 +25,20 @@ |
||
25 | 25 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
26 | 26 | //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
27 | 27 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
28 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); |
|
29 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); |
|
30 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show |
|
31 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
28 | +if (! defined('NOCSRFCHECK')) { |
|
29 | + define('NOCSRFCHECK','1'); |
|
30 | +} |
|
31 | +if (! defined('NOTOKENRENEWAL')) { |
|
32 | + define('NOTOKENRENEWAL','1'); |
|
33 | +} |
|
34 | +if (! defined('NOREQUIREMENU')) { |
|
35 | + define('NOREQUIREMENU','1'); |
|
36 | +} |
|
37 | +// If there is no menu to show |
|
38 | +if (! defined('NOREQUIREHTML')) { |
|
39 | + define('NOREQUIREHTML','1'); |
|
40 | +} |
|
41 | +// If we don't need to load the html.form.class.php |
|
32 | 42 | //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
33 | 43 | //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
34 | 44 |
@@ -20,20 +20,20 @@ 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'); |
|
23 | +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal |
|
24 | +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); |
|
25 | 25 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
26 | +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); |
|
27 | +if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
28 | 28 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
29 | 29 | |
30 | 30 | require '../../main.inc.php'; |
31 | 31 | require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
32 | 32 | |
33 | -$field = GETPOST('field','alpha',2); |
|
34 | -$element = GETPOST('element','alpha',2); |
|
35 | -$table_element = GETPOST('table_element','alpha',2); |
|
36 | -$fk_element = GETPOST('fk_element','alpha',2); |
|
33 | +$field = GETPOST('field', 'alpha', 2); |
|
34 | +$element = GETPOST('element', 'alpha', 2); |
|
35 | +$table_element = GETPOST('table_element', 'alpha', 2); |
|
36 | +$fk_element = GETPOST('fk_element', 'alpha', 2); |
|
37 | 37 | |
38 | 38 | /* Example: |
39 | 39 | field:editval_ref_customer (8 first chars will removed to know name of property) |
@@ -58,23 +58,23 @@ discard block |
||
58 | 58 | //print_r($_POST); |
59 | 59 | |
60 | 60 | // Load original field value |
61 | -if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($fk_element)) |
|
61 | +if (!empty($field) && !empty($element) && !empty($table_element) && !empty($fk_element)) |
|
62 | 62 | { |
63 | - $ext_element = GETPOST('ext_element','alpha',2); |
|
63 | + $ext_element = GETPOST('ext_element', 'alpha', 2); |
|
64 | 64 | $field = substr($field, 8); // remove prefix val_ |
65 | - $type = GETPOST('type','alpha',2); |
|
66 | - $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); |
|
67 | - $loadmethod = GETPOST('loadmethod','alpha',2); |
|
68 | - $savemethod = GETPOST('savemethod','alpha',2); |
|
69 | - $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); |
|
65 | + $type = GETPOST('type', 'alpha', 2); |
|
66 | + $value = ($type == 'ckeditor' ? GETPOST('value', '', 2) : GETPOST('value', 'alpha', 2)); |
|
67 | + $loadmethod = GETPOST('loadmethod', 'alpha', 2); |
|
68 | + $savemethod = GETPOST('savemethod', 'alpha', 2); |
|
69 | + $savemethodname = (!empty($savemethod) ? $savemethod : 'setValueFrom'); |
|
70 | 70 | $newelement = $element; |
71 | 71 | |
72 | - $view=''; |
|
73 | - $format='text'; |
|
74 | - $return=array(); |
|
75 | - $error=0; |
|
72 | + $view = ''; |
|
73 | + $format = 'text'; |
|
74 | + $return = array(); |
|
75 | + $error = 0; |
|
76 | 76 | |
77 | - if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i',$element,$regs)) |
|
77 | + if ($element != 'order_supplier' && $element != 'invoice_supplier' && preg_match('/^([^_]+)_([^_]+)/i', $element, $regs)) |
|
78 | 78 | { |
79 | 79 | $element = $regs[1]; |
80 | 80 | $subelement = $regs[2]; |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | } |
95 | 95 | else $newelement = $element; |
96 | 96 | |
97 | - if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->create) || ! empty($user->rights->$newelement->write) |
|
98 | - || (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write))) |
|
97 | + if (!empty($user->rights->$newelement->creer) || !empty($user->rights->$newelement->create) || !empty($user->rights->$newelement->write) |
|
98 | + || (isset($subelement) && (!empty($user->rights->$newelement->$subelement->creer) || !empty($user->rights->$newelement->$subelement->write))) |
|
99 | 99 | || ($element == 'payment' && $user->rights->facture->paiement) |
100 | 100 | || ($element == 'payment_supplier' && $user->rights->fournisseur->facture->creer)) |
101 | 101 | { |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $newvalue = price2num($newvalue); |
108 | 108 | |
109 | 109 | // Check parameters |
110 | - if (! is_numeric($newvalue)) |
|
110 | + if (!is_numeric($newvalue)) |
|
111 | 111 | { |
112 | 112 | $error++; |
113 | 113 | $return['error'] = $langs->trans('ErrorBadValue'); |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | } |
116 | 116 | else if ($type == 'datepicker') |
117 | 117 | { |
118 | - $timestamp = GETPOST('timestamp','int',2); |
|
119 | - $format = 'date'; |
|
120 | - $newvalue = ($timestamp / 1000); |
|
118 | + $timestamp = GETPOST('timestamp', 'int', 2); |
|
119 | + $format = 'date'; |
|
120 | + $newvalue = ($timestamp / 1000); |
|
121 | 121 | } |
122 | 122 | else if ($type == 'select') |
123 | 123 | { |
124 | - $loadmethodname = 'load_cache_'.$loadmethod; |
|
125 | - $loadcachename = 'cache_'.$loadmethod; |
|
126 | - $loadviewname = 'view_'.$loadmethod; |
|
124 | + $loadmethodname = 'load_cache_'.$loadmethod; |
|
125 | + $loadcachename = 'cache_'.$loadmethod; |
|
126 | + $loadviewname = 'view_'.$loadmethod; |
|
127 | 127 | |
128 | 128 | $form = new Form($db); |
129 | 129 | if (method_exists($form, $loadmethodname)) |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $loadcache = $form->$loadcachename; |
135 | 135 | $value = $loadcache[$newvalue]; |
136 | 136 | |
137 | - if (! empty($form->$loadviewname)) |
|
137 | + if (!empty($form->$loadviewname)) |
|
138 | 138 | { |
139 | 139 | $loadview = $form->$loadviewname; |
140 | 140 | $view = $loadview[$newvalue]; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | else |
150 | 150 | { |
151 | 151 | $module = $subelement = $ext_element; |
152 | - if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
|
152 | + if (preg_match('/^([^_]+)_([^_]+)/i', $ext_element, $regs)) |
|
153 | 153 | { |
154 | 154 | $module = $regs[1]; |
155 | 155 | $subelement = $regs[2]; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $loadcache = $object->$loadcachename; |
165 | 165 | $value = $loadcache[$newvalue]; |
166 | 166 | |
167 | - if (! empty($object->$loadviewname)) |
|
167 | + if (!empty($object->$loadviewname)) |
|
168 | 168 | { |
169 | 169 | $loadview = $object->$loadviewname; |
170 | 170 | $view = $loadview[$newvalue]; |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - if (! $error) |
|
181 | + if (!$error) |
|
182 | 182 | { |
183 | - if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
183 | + if ((isset($object) && !is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
184 | 184 | |
185 | 185 | // Specific for add_object_linked() |
186 | 186 | // TODO add a function for variable treatment |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | $object->fk_element = $fk_element; |
190 | 190 | $object->element = $element; |
191 | 191 | |
192 | - $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
|
192 | + $ret = $object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
|
193 | 193 | if ($ret > 0) |
194 | 194 | { |
195 | 195 | if ($type == 'numeric') $value = price($newvalue); |
196 | 196 | else if ($type == 'textarea') $value = dol_nl2br($newvalue); |
197 | 197 | |
198 | 198 | $return['value'] = $value; |
199 | - $return['view'] = (! empty($view) ? $view : $value); |
|
199 | + $return['view'] = (!empty($view) ? $view : $value); |
|
200 | 200 | } |
201 | 201 | else |
202 | 202 | { |
@@ -20,11 +20,20 @@ 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'); |
|
23 | +if (! defined('NOTOKENRENEWAL')) { |
|
24 | + define('NOTOKENRENEWAL','1'); |
|
25 | +} |
|
26 | +// Disables token renewal |
|
27 | +if (! defined('NOREQUIREMENU')) { |
|
28 | + define('NOREQUIREMENU','1'); |
|
29 | +} |
|
25 | 30 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
27 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
31 | +if (! defined('NOREQUIREAJAX')) { |
|
32 | + define('NOREQUIREAJAX','1'); |
|
33 | +} |
|
34 | +if (! defined('NOREQUIRESOC')) { |
|
35 | + define('NOREQUIRESOC','1'); |
|
36 | +} |
|
28 | 37 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
29 | 38 | |
30 | 39 | require '../../main.inc.php'; |
@@ -80,19 +89,23 @@ discard block |
||
80 | 89 | $subelement = $regs[2]; |
81 | 90 | } |
82 | 91 | |
83 | - if ($element == 'propal') $newelement = 'propale'; |
|
84 | - else if ($element == 'fichinter') $newelement = 'ficheinter'; |
|
85 | - else if ($element == 'product') $newelement = 'produit'; |
|
86 | - else if ($element == 'member') $newelement = 'adherent'; |
|
87 | - else if ($element == 'order_supplier') { |
|
92 | + if ($element == 'propal') { |
|
93 | + $newelement = 'propale'; |
|
94 | + } else if ($element == 'fichinter') { |
|
95 | + $newelement = 'ficheinter'; |
|
96 | + } else if ($element == 'product') { |
|
97 | + $newelement = 'produit'; |
|
98 | + } else if ($element == 'member') { |
|
99 | + $newelement = 'adherent'; |
|
100 | + } else if ($element == 'order_supplier') { |
|
88 | 101 | $newelement = 'fournisseur'; |
89 | 102 | $subelement = 'commande'; |
90 | - } |
|
91 | - else if ($element == 'invoice_supplier') { |
|
103 | + } else if ($element == 'invoice_supplier') { |
|
92 | 104 | $newelement = 'fournisseur'; |
93 | 105 | $subelement = 'facture'; |
106 | + } else { |
|
107 | + $newelement = $element; |
|
94 | 108 | } |
95 | - else $newelement = $element; |
|
96 | 109 | |
97 | 110 | if (! empty($user->rights->$newelement->creer) || ! empty($user->rights->$newelement->create) || ! empty($user->rights->$newelement->write) |
98 | 111 | || (isset($subelement) && (! empty($user->rights->$newelement->$subelement->creer) || ! empty($user->rights->$newelement->$subelement->write))) |
@@ -112,14 +125,12 @@ discard block |
||
112 | 125 | $error++; |
113 | 126 | $return['error'] = $langs->trans('ErrorBadValue'); |
114 | 127 | } |
115 | - } |
|
116 | - else if ($type == 'datepicker') |
|
128 | + } else if ($type == 'datepicker') |
|
117 | 129 | { |
118 | 130 | $timestamp = GETPOST('timestamp','int',2); |
119 | 131 | $format = 'date'; |
120 | 132 | $newvalue = ($timestamp / 1000); |
121 | - } |
|
122 | - else if ($type == 'select') |
|
133 | + } else if ($type == 'select') |
|
123 | 134 | { |
124 | 135 | $loadmethodname = 'load_cache_'.$loadmethod; |
125 | 136 | $loadcachename = 'cache_'.$loadmethod; |
@@ -139,14 +150,12 @@ discard block |
||
139 | 150 | $loadview = $form->$loadviewname; |
140 | 151 | $view = $loadview[$newvalue]; |
141 | 152 | } |
142 | - } |
|
143 | - else |
|
153 | + } else |
|
144 | 154 | { |
145 | 155 | $error++; |
146 | 156 | $return['error'] = $form->error; |
147 | 157 | } |
148 | - } |
|
149 | - else |
|
158 | + } else |
|
150 | 159 | { |
151 | 160 | $module = $subelement = $ext_element; |
152 | 161 | if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) |
@@ -169,8 +178,7 @@ discard block |
||
169 | 178 | $loadview = $object->$loadviewname; |
170 | 179 | $view = $loadview[$newvalue]; |
171 | 180 | } |
172 | - } |
|
173 | - else |
|
181 | + } else |
|
174 | 182 | { |
175 | 183 | $error++; |
176 | 184 | $return['error'] = $object->error; |
@@ -180,7 +188,9 @@ discard block |
||
180 | 188 | |
181 | 189 | if (! $error) |
182 | 190 | { |
183 | - if ((isset($object) && ! is_object($object)) || empty($savemethod)) $object = new GenericObject($db); |
|
191 | + if ((isset($object) && ! is_object($object)) || empty($savemethod)) { |
|
192 | + $object = new GenericObject($db); |
|
193 | + } |
|
184 | 194 | |
185 | 195 | // Specific for add_object_linked() |
186 | 196 | // TODO add a function for variable treatment |
@@ -192,21 +202,22 @@ discard block |
||
192 | 202 | $ret=$object->$savemethodname($field, $newvalue, $table_element, $fk_element, $format); |
193 | 203 | if ($ret > 0) |
194 | 204 | { |
195 | - if ($type == 'numeric') $value = price($newvalue); |
|
196 | - else if ($type == 'textarea') $value = dol_nl2br($newvalue); |
|
205 | + if ($type == 'numeric') { |
|
206 | + $value = price($newvalue); |
|
207 | + } else if ($type == 'textarea') { |
|
208 | + $value = dol_nl2br($newvalue); |
|
209 | + } |
|
197 | 210 | |
198 | 211 | $return['value'] = $value; |
199 | 212 | $return['view'] = (! empty($view) ? $view : $value); |
200 | - } |
|
201 | - else |
|
213 | + } else |
|
202 | 214 | { |
203 | 215 | $return['error'] = $object->error; |
204 | 216 | } |
205 | 217 | } |
206 | 218 | |
207 | 219 | echo json_encode($return); |
208 | - } |
|
209 | - else |
|
220 | + } else |
|
210 | 221 | { |
211 | 222 | echo $langs->trans('NotEnoughPermissions'); |
212 | 223 | } |