@@ -46,169 +46,169 @@ discard block |
||
46 | 46 | |
47 | 47 | if ($action == 'setcodeclient') |
48 | 48 | { |
49 | - if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) |
|
50 | - { |
|
51 | - header("Location: ".$_SERVER["PHP_SELF"]); |
|
52 | - exit; |
|
53 | - } |
|
54 | - else |
|
55 | - { |
|
56 | - dol_print_error($db); |
|
57 | - } |
|
49 | + if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) |
|
50 | + { |
|
51 | + header("Location: ".$_SERVER["PHP_SELF"]); |
|
52 | + exit; |
|
53 | + } |
|
54 | + else |
|
55 | + { |
|
56 | + dol_print_error($db); |
|
57 | + } |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if ($action == 'setcodecompta') |
61 | 61 | { |
62 | - if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$value,'chaine',0,'',$conf->entity) > 0) |
|
63 | - { |
|
64 | - header("Location: ".$_SERVER["PHP_SELF"]); |
|
65 | - exit; |
|
66 | - } |
|
67 | - else |
|
68 | - { |
|
69 | - dol_print_error($db); |
|
70 | - } |
|
62 | + if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$value,'chaine',0,'',$conf->entity) > 0) |
|
63 | + { |
|
64 | + header("Location: ".$_SERVER["PHP_SELF"]); |
|
65 | + exit; |
|
66 | + } |
|
67 | + else |
|
68 | + { |
|
69 | + dol_print_error($db); |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | if ($action == 'updateoptions') |
74 | 74 | { |
75 | - if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT')) |
|
76 | - { |
|
77 | - $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT','alpha'); |
|
78 | - $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity); |
|
79 | - if (! $res > 0) $error++; |
|
80 | - if (! $error) |
|
81 | - { |
|
82 | - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
83 | - } |
|
84 | - else |
|
85 | - { |
|
86 | - setEventMessages($langs->trans("Error"), null, 'errors'); |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) |
|
91 | - { |
|
92 | - $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha'); |
|
93 | - $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity); |
|
94 | - if (! $res > 0) $error++; |
|
95 | - if (! $error) |
|
96 | - { |
|
97 | - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
98 | - } |
|
99 | - else |
|
100 | - { |
|
101 | - setEventMessages($langs->trans("Error"), null, 'errors'); |
|
102 | - } |
|
103 | - } |
|
75 | + if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT')) |
|
76 | + { |
|
77 | + $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT','alpha'); |
|
78 | + $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity); |
|
79 | + if (! $res > 0) $error++; |
|
80 | + if (! $error) |
|
81 | + { |
|
82 | + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
83 | + } |
|
84 | + else |
|
85 | + { |
|
86 | + setEventMessages($langs->trans("Error"), null, 'errors'); |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) |
|
91 | + { |
|
92 | + $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha'); |
|
93 | + $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity); |
|
94 | + if (! $res > 0) $error++; |
|
95 | + if (! $error) |
|
96 | + { |
|
97 | + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
98 | + } |
|
99 | + else |
|
100 | + { |
|
101 | + setEventMessages($langs->trans("Error"), null, 'errors'); |
|
102 | + } |
|
103 | + } |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // Activate a document generator module |
107 | 107 | if ($action == 'set') |
108 | 108 | { |
109 | - $label = GETPOST('label','alpha'); |
|
110 | - $scandir = GETPOST('scan_dir','alpha'); |
|
109 | + $label = GETPOST('label','alpha'); |
|
110 | + $scandir = GETPOST('scan_dir','alpha'); |
|
111 | 111 | |
112 | - $type='company'; |
|
113 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; |
|
114 | - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; |
|
115 | - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; |
|
116 | - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); |
|
117 | - $sql.= ")"; |
|
112 | + $type='company'; |
|
113 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; |
|
114 | + $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; |
|
115 | + $sql.= ($label?"'".$db->escape($label)."'":'null').", "; |
|
116 | + $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); |
|
117 | + $sql.= ")"; |
|
118 | 118 | |
119 | - $resql=$db->query($sql); |
|
120 | - if (! $resql) dol_print_error($db); |
|
119 | + $resql=$db->query($sql); |
|
120 | + if (! $resql) dol_print_error($db); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Disable a document generator module |
124 | 124 | if ($action== 'del') |
125 | 125 | { |
126 | - $type='company'; |
|
127 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
|
128 | - $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; |
|
129 | - $resql=$db->query($sql); |
|
130 | - if (! $resql) dol_print_error($db); |
|
126 | + $type='company'; |
|
127 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
|
128 | + $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; |
|
129 | + $resql=$db->query($sql); |
|
130 | + if (! $resql) dol_print_error($db); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Define default generator |
134 | 134 | if ($action == 'setdoc') |
135 | 135 | { |
136 | - $label = GETPOST('label','alpha'); |
|
137 | - $scandir = GETPOST('scan_dir','alpha'); |
|
136 | + $label = GETPOST('label','alpha'); |
|
137 | + $scandir = GETPOST('scan_dir','alpha'); |
|
138 | 138 | |
139 | - $db->begin(); |
|
139 | + $db->begin(); |
|
140 | 140 | |
141 | - dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity); |
|
141 | + dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity); |
|
142 | 142 | |
143 | - // On active le modele |
|
144 | - $type='company'; |
|
145 | - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
|
146 | - $sql_del.= " WHERE nom = '".$db->escape(GETPOST('value','alpha'))."'"; |
|
147 | - $sql_del.= " AND type = '".$type."'"; |
|
148 | - $sql_del.= " AND entity = ".$conf->entity; |
|
143 | + // On active le modele |
|
144 | + $type='company'; |
|
145 | + $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
|
146 | + $sql_del.= " WHERE nom = '".$db->escape(GETPOST('value','alpha'))."'"; |
|
147 | + $sql_del.= " AND type = '".$type."'"; |
|
148 | + $sql_del.= " AND entity = ".$conf->entity; |
|
149 | 149 | dol_syslog("societe.php ".$sql); |
150 | - $result1=$db->query($sql_del); |
|
150 | + $result1=$db->query($sql_del); |
|
151 | 151 | |
152 | - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; |
|
153 | - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; |
|
154 | - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; |
|
155 | - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); |
|
156 | - $sql.= ")"; |
|
152 | + $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; |
|
153 | + $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; |
|
154 | + $sql.= ($label?"'".$db->escape($label)."'":'null').", "; |
|
155 | + $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); |
|
156 | + $sql.= ")"; |
|
157 | 157 | dol_syslog("societe.php", LOG_DEBUG); |
158 | - $result2=$db->query($sql); |
|
159 | - if ($result1 && $result2) |
|
160 | - { |
|
161 | - $db->commit(); |
|
162 | - } |
|
163 | - else |
|
164 | - { |
|
165 | - $db->rollback(); |
|
166 | - } |
|
158 | + $result2=$db->query($sql); |
|
159 | + if ($result1 && $result2) |
|
160 | + { |
|
161 | + $db->commit(); |
|
162 | + } |
|
163 | + else |
|
164 | + { |
|
165 | + $db->rollback(); |
|
166 | + } |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | //Activate Set ref in list |
170 | 170 | if ($action=="setaddrefinlist") { |
171 | - $setaddrefinlist = GETPOST('value','int'); |
|
172 | - $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity); |
|
173 | - if (! $res > 0) $error++; |
|
174 | - if (! $error) |
|
175 | - { |
|
176 | - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
177 | - } |
|
178 | - else |
|
179 | - { |
|
180 | - setEventMessages($langs->trans("Error"), null, 'errors'); |
|
181 | - } |
|
171 | + $setaddrefinlist = GETPOST('value','int'); |
|
172 | + $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity); |
|
173 | + if (! $res > 0) $error++; |
|
174 | + if (! $error) |
|
175 | + { |
|
176 | + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
177 | + } |
|
178 | + else |
|
179 | + { |
|
180 | + setEventMessages($langs->trans("Error"), null, 'errors'); |
|
181 | + } |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | //Activate Set adress in list |
185 | 185 | if ($action=="setaddadressinlist") { |
186 | - $val = GETPOST('value','int'); |
|
187 | - $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val,'yesno',0,'',$conf->entity); |
|
188 | - if (! $res > 0) $error++; |
|
189 | - if (! $error) |
|
190 | - { |
|
191 | - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
192 | - } |
|
193 | - else |
|
194 | - { |
|
195 | - setEventMessages($langs->trans("Error"), null, 'errors'); |
|
196 | - } |
|
186 | + $val = GETPOST('value','int'); |
|
187 | + $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val,'yesno',0,'',$conf->entity); |
|
188 | + if (! $res > 0) $error++; |
|
189 | + if (! $error) |
|
190 | + { |
|
191 | + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
192 | + } |
|
193 | + else |
|
194 | + { |
|
195 | + setEventMessages($langs->trans("Error"), null, 'errors'); |
|
196 | + } |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | //Activate Ask For Preferred Shipping Method |
200 | 200 | if ($action=="setaskforshippingmet") { |
201 | - $setaskforshippingmet = GETPOST('value','int'); |
|
202 | - $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity); |
|
203 | - if (! $res > 0) $error++; |
|
204 | - if (! $error) |
|
205 | - { |
|
206 | - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
207 | - } |
|
208 | - else |
|
209 | - { |
|
210 | - setEventMessages($langs->trans("Error"), null, 'errors'); |
|
211 | - } |
|
201 | + $setaskforshippingmet = GETPOST('value','int'); |
|
202 | + $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity); |
|
203 | + if (! $res > 0) $error++; |
|
204 | + if (! $error) |
|
205 | + { |
|
206 | + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
207 | + } |
|
208 | + else |
|
209 | + { |
|
210 | + setEventMessages($langs->trans("Error"), null, 'errors'); |
|
211 | + } |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | //Activate "Disable prospect/customer type" |
@@ -229,81 +229,81 @@ discard block |
||
229 | 229 | //Activate ProfId unique |
230 | 230 | if ($action == 'setprofid') |
231 | 231 | { |
232 | - $status = GETPOST('status','alpha'); |
|
232 | + $status = GETPOST('status','alpha'); |
|
233 | 233 | |
234 | - $idprof="SOCIETE_".$value."_UNIQUE"; |
|
235 | - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
|
236 | - { |
|
237 | - //header("Location: ".$_SERVER["PHP_SELF"]); |
|
238 | - //exit; |
|
239 | - } |
|
240 | - else |
|
241 | - { |
|
242 | - dol_print_error($db); |
|
243 | - } |
|
234 | + $idprof="SOCIETE_".$value."_UNIQUE"; |
|
235 | + if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
|
236 | + { |
|
237 | + //header("Location: ".$_SERVER["PHP_SELF"]); |
|
238 | + //exit; |
|
239 | + } |
|
240 | + else |
|
241 | + { |
|
242 | + dol_print_error($db); |
|
243 | + } |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | //Activate ProfId mandatory |
247 | 247 | if ($action == 'setprofidmandatory') |
248 | 248 | { |
249 | - $status = GETPOST('status','alpha'); |
|
249 | + $status = GETPOST('status','alpha'); |
|
250 | 250 | |
251 | - $idprof="SOCIETE_".$value."_MANDATORY"; |
|
252 | - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
|
253 | - { |
|
254 | - //header("Location: ".$_SERVER["PHP_SELF"]); |
|
255 | - //exit; |
|
256 | - } |
|
257 | - else |
|
258 | - { |
|
259 | - dol_print_error($db); |
|
260 | - } |
|
251 | + $idprof="SOCIETE_".$value."_MANDATORY"; |
|
252 | + if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
|
253 | + { |
|
254 | + //header("Location: ".$_SERVER["PHP_SELF"]); |
|
255 | + //exit; |
|
256 | + } |
|
257 | + else |
|
258 | + { |
|
259 | + dol_print_error($db); |
|
260 | + } |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | //Activate ProfId invoice mandatory |
264 | 264 | if ($action == 'setprofidinvoicemandatory') |
265 | 265 | { |
266 | - $status = GETPOST('status','alpha'); |
|
266 | + $status = GETPOST('status','alpha'); |
|
267 | 267 | |
268 | - $idprof="SOCIETE_".$value."_INVOICE_MANDATORY"; |
|
269 | - if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
|
270 | - { |
|
271 | - //header("Location: ".$_SERVER["PHP_SELF"]); |
|
272 | - //exit; |
|
273 | - } |
|
274 | - else |
|
275 | - { |
|
276 | - dol_print_error($db); |
|
277 | - } |
|
268 | + $idprof="SOCIETE_".$value."_INVOICE_MANDATORY"; |
|
269 | + if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
|
270 | + { |
|
271 | + //header("Location: ".$_SERVER["PHP_SELF"]); |
|
272 | + //exit; |
|
273 | + } |
|
274 | + else |
|
275 | + { |
|
276 | + dol_print_error($db); |
|
277 | + } |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | //Set hide closed customer into combox or select |
281 | 281 | if ($action == 'sethideinactivethirdparty') |
282 | 282 | { |
283 | - $status = GETPOST('status','alpha'); |
|
283 | + $status = GETPOST('status','alpha'); |
|
284 | 284 | |
285 | - if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0) |
|
286 | - { |
|
287 | - header("Location: ".$_SERVER["PHP_SELF"]); |
|
288 | - exit; |
|
289 | - } |
|
290 | - else |
|
291 | - { |
|
292 | - dol_print_error($db); |
|
293 | - } |
|
285 | + if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0) |
|
286 | + { |
|
287 | + header("Location: ".$_SERVER["PHP_SELF"]); |
|
288 | + exit; |
|
289 | + } |
|
290 | + else |
|
291 | + { |
|
292 | + dol_print_error($db); |
|
293 | + } |
|
294 | 294 | } |
295 | 295 | if($action=='setonsearchandlistgooncustomerorsuppliercard'){ |
296 | - $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value','int'); |
|
297 | - $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard,'yesno',0,'',$conf->entity); |
|
298 | - if (! $res > 0) $error++; |
|
299 | - if (! $error) |
|
300 | - { |
|
301 | - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
302 | - } |
|
303 | - else |
|
304 | - { |
|
305 | - setEventMessages($langs->trans("Error"), null, 'errors'); |
|
306 | - } |
|
296 | + $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value','int'); |
|
297 | + $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard,'yesno',0,'',$conf->entity); |
|
298 | + if (! $res > 0) $error++; |
|
299 | + if (! $error) |
|
300 | + { |
|
301 | + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
|
302 | + } |
|
303 | + else |
|
304 | + { |
|
305 | + setEventMessages($langs->trans("Error"), null, 'errors'); |
|
306 | + } |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -343,63 +343,63 @@ discard block |
||
343 | 343 | |
344 | 344 | foreach ($dirsociete as $dirroot) |
345 | 345 | { |
346 | - $dir = dol_buildpath($dirroot,0); |
|
346 | + $dir = dol_buildpath($dirroot,0); |
|
347 | 347 | |
348 | 348 | $handle = @opendir($dir); |
349 | 349 | if (is_resource($handle)) |
350 | 350 | { |
351 | - // Loop on each module find in opened directory |
|
352 | - while (($file = readdir($handle))!==false) |
|
353 | - { |
|
354 | - if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') |
|
355 | - { |
|
356 | - $file = substr($file, 0, dol_strlen($file)-4); |
|
357 | - |
|
358 | - try { |
|
359 | - dol_include_once($dirroot.$file.'.php'); |
|
360 | - } |
|
361 | - catch(Exception $e) |
|
362 | - { |
|
363 | - dol_syslog($e->getMessage(), LOG_ERR); |
|
364 | - } |
|
365 | - |
|
366 | - $modCodeTiers = new $file; |
|
367 | - |
|
368 | - // Show modules according to features level |
|
369 | - if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
370 | - if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
|
371 | - |
|
372 | - print '<tr class="oddeven">'."\n"; |
|
373 | - print '<td width="140">'.$modCodeTiers->name.'</td>'."\n"; |
|
374 | - print '<td>'.$modCodeTiers->info($langs).'</td>'."\n"; |
|
375 | - print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n"; |
|
376 | - |
|
377 | - if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") |
|
378 | - { |
|
379 | - print '<td align="center">'."\n"; |
|
380 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
381 | - print "</td>\n"; |
|
382 | - } |
|
383 | - else |
|
384 | - { |
|
385 | - $disabled = false; |
|
386 | - if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); |
|
387 | - print '<td align="center">'; |
|
388 | - if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">'; |
|
389 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
390 | - if (! $disabled) print '</a>'; |
|
391 | - print '</td>'; |
|
392 | - } |
|
393 | - |
|
394 | - print '<td align="center">'; |
|
395 | - $s=$modCodeTiers->getToolTip($langs,null,-1); |
|
396 | - print $form->textwithpicto('',$s,1); |
|
397 | - print '</td>'; |
|
398 | - |
|
399 | - print '</tr>'; |
|
400 | - } |
|
401 | - } |
|
402 | - closedir($handle); |
|
351 | + // Loop on each module find in opened directory |
|
352 | + while (($file = readdir($handle))!==false) |
|
353 | + { |
|
354 | + if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') |
|
355 | + { |
|
356 | + $file = substr($file, 0, dol_strlen($file)-4); |
|
357 | + |
|
358 | + try { |
|
359 | + dol_include_once($dirroot.$file.'.php'); |
|
360 | + } |
|
361 | + catch(Exception $e) |
|
362 | + { |
|
363 | + dol_syslog($e->getMessage(), LOG_ERR); |
|
364 | + } |
|
365 | + |
|
366 | + $modCodeTiers = new $file; |
|
367 | + |
|
368 | + // Show modules according to features level |
|
369 | + if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
370 | + if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
|
371 | + |
|
372 | + print '<tr class="oddeven">'."\n"; |
|
373 | + print '<td width="140">'.$modCodeTiers->name.'</td>'."\n"; |
|
374 | + print '<td>'.$modCodeTiers->info($langs).'</td>'."\n"; |
|
375 | + print '<td class="nowrap">'.$modCodeTiers->getExample($langs).'</td>'."\n"; |
|
376 | + |
|
377 | + if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") |
|
378 | + { |
|
379 | + print '<td align="center">'."\n"; |
|
380 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
381 | + print "</td>\n"; |
|
382 | + } |
|
383 | + else |
|
384 | + { |
|
385 | + $disabled = false; |
|
386 | + if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); |
|
387 | + print '<td align="center">'; |
|
388 | + if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">'; |
|
389 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
390 | + if (! $disabled) print '</a>'; |
|
391 | + print '</td>'; |
|
392 | + } |
|
393 | + |
|
394 | + print '<td align="center">'; |
|
395 | + $s=$modCodeTiers->getToolTip($langs,null,-1); |
|
396 | + print $form->textwithpicto('',$s,1); |
|
397 | + print '</td>'; |
|
398 | + |
|
399 | + print '</tr>'; |
|
400 | + } |
|
401 | + } |
|
402 | + closedir($handle); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | print '</table>'; |
@@ -423,53 +423,53 @@ discard block |
||
423 | 423 | |
424 | 424 | foreach ($dirsociete as $dirroot) |
425 | 425 | { |
426 | - $dir = dol_buildpath($dirroot,0); |
|
426 | + $dir = dol_buildpath($dirroot,0); |
|
427 | 427 | |
428 | - $handle = @opendir($dir); |
|
428 | + $handle = @opendir($dir); |
|
429 | 429 | if (is_resource($handle)) |
430 | 430 | { |
431 | - while (($file = readdir($handle))!==false) |
|
432 | - { |
|
433 | - if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') |
|
434 | - { |
|
435 | - $file = substr($file, 0, dol_strlen($file)-4); |
|
436 | - |
|
437 | - try { |
|
438 | - dol_include_once($dirroot.$file.'.php'); |
|
439 | - } |
|
440 | - catch(Exception $e) |
|
441 | - { |
|
442 | - dol_syslog($e->getMessage(), LOG_ERR); |
|
443 | - } |
|
444 | - |
|
445 | - $modCodeCompta = new $file; |
|
446 | - |
|
447 | - print '<tr class="oddeven">'; |
|
448 | - print '<td>'.$modCodeCompta->name."</td><td>\n"; |
|
449 | - print $modCodeCompta->info($langs); |
|
450 | - print '</td>'; |
|
451 | - print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n"; |
|
452 | - |
|
453 | - if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") |
|
454 | - { |
|
455 | - print '<td align="center">'; |
|
456 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
457 | - print '</td>'; |
|
458 | - } |
|
459 | - else |
|
460 | - { |
|
461 | - print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">'; |
|
462 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
463 | - print '</a></td>'; |
|
464 | - } |
|
465 | - print '<td align="center">'; |
|
466 | - $s=$modCodeCompta->getToolTip($langs,null,-1); |
|
467 | - print $form->textwithpicto('',$s,1); |
|
468 | - print '</td>'; |
|
469 | - print "</tr>\n"; |
|
470 | - } |
|
471 | - } |
|
472 | - closedir($handle); |
|
431 | + while (($file = readdir($handle))!==false) |
|
432 | + { |
|
433 | + if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') |
|
434 | + { |
|
435 | + $file = substr($file, 0, dol_strlen($file)-4); |
|
436 | + |
|
437 | + try { |
|
438 | + dol_include_once($dirroot.$file.'.php'); |
|
439 | + } |
|
440 | + catch(Exception $e) |
|
441 | + { |
|
442 | + dol_syslog($e->getMessage(), LOG_ERR); |
|
443 | + } |
|
444 | + |
|
445 | + $modCodeCompta = new $file; |
|
446 | + |
|
447 | + print '<tr class="oddeven">'; |
|
448 | + print '<td>'.$modCodeCompta->name."</td><td>\n"; |
|
449 | + print $modCodeCompta->info($langs); |
|
450 | + print '</td>'; |
|
451 | + print '<td class="nowrap">'.$modCodeCompta->getExample($langs)."</td>\n"; |
|
452 | + |
|
453 | + if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") |
|
454 | + { |
|
455 | + print '<td align="center">'; |
|
456 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
457 | + print '</td>'; |
|
458 | + } |
|
459 | + else |
|
460 | + { |
|
461 | + print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">'; |
|
462 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
463 | + print '</a></td>'; |
|
464 | + } |
|
465 | + print '<td align="center">'; |
|
466 | + $s=$modCodeCompta->getToolTip($langs,null,-1); |
|
467 | + print $form->textwithpicto('',$s,1); |
|
468 | + print '</td>'; |
|
469 | + print "</tr>\n"; |
|
470 | + } |
|
471 | + } |
|
472 | + closedir($handle); |
|
473 | 473 | } |
474 | 474 | } |
475 | 475 | print "</table>\n"; |
@@ -490,18 +490,18 @@ discard block |
||
490 | 490 | $resql=$db->query($sql); |
491 | 491 | if ($resql) |
492 | 492 | { |
493 | - $i = 0; |
|
494 | - $num_rows=$db->num_rows($resql); |
|
495 | - while ($i < $num_rows) |
|
496 | - { |
|
497 | - $array = $db->fetch_array($resql); |
|
498 | - array_push($def, $array[0]); |
|
499 | - $i++; |
|
500 | - } |
|
493 | + $i = 0; |
|
494 | + $num_rows=$db->num_rows($resql); |
|
495 | + while ($i < $num_rows) |
|
496 | + { |
|
497 | + $array = $db->fetch_array($resql); |
|
498 | + array_push($def, $array[0]); |
|
499 | + $i++; |
|
500 | + } |
|
501 | 501 | } |
502 | 502 | else |
503 | 503 | { |
504 | - dol_print_error($db); |
|
504 | + dol_print_error($db); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | print '<table class="noborder" width="100%">'; |
@@ -515,108 +515,108 @@ discard block |
||
515 | 515 | |
516 | 516 | foreach ($dirsociete as $dirroot) |
517 | 517 | { |
518 | - $dir = dol_buildpath($dirroot.'doc/',0); |
|
519 | - |
|
520 | - $handle=@opendir($dir); |
|
521 | - if (is_resource($handle)) |
|
522 | - { |
|
523 | - while (($file = readdir($handle))!==false) |
|
524 | - { |
|
525 | - if (preg_match('/\.modules\.php$/i',$file)) |
|
526 | - { |
|
527 | - $name = substr($file, 4, dol_strlen($file) -16); |
|
528 | - $classname = substr($file, 0, dol_strlen($file) -12); |
|
529 | - |
|
530 | - try { |
|
531 | - dol_include_once($dirroot.'doc/'.$file); |
|
532 | - } |
|
533 | - catch(Exception $e) |
|
534 | - { |
|
535 | - dol_syslog($e->getMessage(), LOG_ERR); |
|
536 | - } |
|
537 | - |
|
538 | - $module = new $classname($db); |
|
539 | - |
|
540 | - $modulequalified=1; |
|
541 | - if (! empty($module->version)) { |
|
542 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
543 | - else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
544 | - } |
|
545 | - |
|
546 | - if ($modulequalified) |
|
547 | - { |
|
548 | - print '<tr class="oddeven"><td width="100">'; |
|
549 | - print $module->name; |
|
550 | - print "</td><td>\n"; |
|
551 | - if (method_exists($module,'info')) print $module->info($langs); |
|
552 | - else print $module->description; |
|
553 | - print '</td>'; |
|
554 | - |
|
555 | - // Activate / Disable |
|
556 | - if (in_array($name, $def)) |
|
557 | - { |
|
558 | - print "<td align=\"center\">\n"; |
|
559 | - //if ($conf->global->COMPANY_ADDON_PDF != "$name") |
|
560 | - //{ |
|
561 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'; |
|
562 | - print img_picto($langs->trans("Enabled"),'switch_on'); |
|
563 | - print '</a>'; |
|
564 | - //} |
|
565 | - //else |
|
566 | - //{ |
|
567 | - // print img_picto($langs->trans("Enabled"),'on'); |
|
568 | - //} |
|
569 | - print "</td>"; |
|
570 | - } |
|
571 | - else |
|
572 | - { |
|
573 | - if (versioncompare($module->phpmin,versionphparray()) > 0) |
|
574 | - { |
|
575 | - print "<td align=\"center\">\n"; |
|
576 | - print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off'); |
|
577 | - print "</td>"; |
|
578 | - } |
|
579 | - else |
|
580 | - { |
|
581 | - print "<td align=\"center\">\n"; |
|
582 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
583 | - print "</td>"; |
|
584 | - } |
|
585 | - } |
|
586 | - |
|
587 | - // Info |
|
588 | - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
589 | - $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); |
|
590 | - if ($module->type == 'pdf') |
|
591 | - { |
|
592 | - $htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; |
|
593 | - } |
|
594 | - $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
595 | - $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1); |
|
596 | - |
|
597 | - print '<td align="center" class="nowrap">'; |
|
598 | - print $form->textwithpicto('',$htmltooltip,1,0); |
|
599 | - print '</td>'; |
|
600 | - |
|
601 | - // Preview |
|
602 | - print '<td align="center" class="nowrap">'; |
|
603 | - if ($module->type == 'pdf') |
|
604 | - { |
|
605 | - $linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
|
606 | - } |
|
607 | - else |
|
608 | - { |
|
609 | - $linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic'); |
|
610 | - } |
|
611 | - print $linkspec; |
|
612 | - print '</td>'; |
|
613 | - |
|
614 | - print "</tr>\n"; |
|
615 | - } |
|
616 | - } |
|
617 | - } |
|
618 | - closedir($handle); |
|
619 | - } |
|
518 | + $dir = dol_buildpath($dirroot.'doc/',0); |
|
519 | + |
|
520 | + $handle=@opendir($dir); |
|
521 | + if (is_resource($handle)) |
|
522 | + { |
|
523 | + while (($file = readdir($handle))!==false) |
|
524 | + { |
|
525 | + if (preg_match('/\.modules\.php$/i',$file)) |
|
526 | + { |
|
527 | + $name = substr($file, 4, dol_strlen($file) -16); |
|
528 | + $classname = substr($file, 0, dol_strlen($file) -12); |
|
529 | + |
|
530 | + try { |
|
531 | + dol_include_once($dirroot.'doc/'.$file); |
|
532 | + } |
|
533 | + catch(Exception $e) |
|
534 | + { |
|
535 | + dol_syslog($e->getMessage(), LOG_ERR); |
|
536 | + } |
|
537 | + |
|
538 | + $module = new $classname($db); |
|
539 | + |
|
540 | + $modulequalified=1; |
|
541 | + if (! empty($module->version)) { |
|
542 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
543 | + else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
544 | + } |
|
545 | + |
|
546 | + if ($modulequalified) |
|
547 | + { |
|
548 | + print '<tr class="oddeven"><td width="100">'; |
|
549 | + print $module->name; |
|
550 | + print "</td><td>\n"; |
|
551 | + if (method_exists($module,'info')) print $module->info($langs); |
|
552 | + else print $module->description; |
|
553 | + print '</td>'; |
|
554 | + |
|
555 | + // Activate / Disable |
|
556 | + if (in_array($name, $def)) |
|
557 | + { |
|
558 | + print "<td align=\"center\">\n"; |
|
559 | + //if ($conf->global->COMPANY_ADDON_PDF != "$name") |
|
560 | + //{ |
|
561 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'; |
|
562 | + print img_picto($langs->trans("Enabled"),'switch_on'); |
|
563 | + print '</a>'; |
|
564 | + //} |
|
565 | + //else |
|
566 | + //{ |
|
567 | + // print img_picto($langs->trans("Enabled"),'on'); |
|
568 | + //} |
|
569 | + print "</td>"; |
|
570 | + } |
|
571 | + else |
|
572 | + { |
|
573 | + if (versioncompare($module->phpmin,versionphparray()) > 0) |
|
574 | + { |
|
575 | + print "<td align=\"center\">\n"; |
|
576 | + print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off'); |
|
577 | + print "</td>"; |
|
578 | + } |
|
579 | + else |
|
580 | + { |
|
581 | + print "<td align=\"center\">\n"; |
|
582 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
583 | + print "</td>"; |
|
584 | + } |
|
585 | + } |
|
586 | + |
|
587 | + // Info |
|
588 | + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
589 | + $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); |
|
590 | + if ($module->type == 'pdf') |
|
591 | + { |
|
592 | + $htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; |
|
593 | + } |
|
594 | + $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
595 | + $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1); |
|
596 | + |
|
597 | + print '<td align="center" class="nowrap">'; |
|
598 | + print $form->textwithpicto('',$htmltooltip,1,0); |
|
599 | + print '</td>'; |
|
600 | + |
|
601 | + // Preview |
|
602 | + print '<td align="center" class="nowrap">'; |
|
603 | + if ($module->type == 'pdf') |
|
604 | + { |
|
605 | + $linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
|
606 | + } |
|
607 | + else |
|
608 | + { |
|
609 | + $linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic'); |
|
610 | + } |
|
611 | + print $linkspec; |
|
612 | + print '</td>'; |
|
613 | + |
|
614 | + print "</tr>\n"; |
|
615 | + } |
|
616 | + } |
|
617 | + } |
|
618 | + closedir($handle); |
|
619 | + } |
|
620 | 620 | } |
621 | 621 | print '</table>'; |
622 | 622 | |
@@ -652,63 +652,63 @@ discard block |
||
652 | 652 | $nbofloop=count($profid); |
653 | 653 | foreach($profid as $key => $val) |
654 | 654 | { |
655 | - if ($profid[$key][1]!='-') |
|
656 | - { |
|
657 | - print '<tr class="oddeven">'; |
|
658 | - print '<td>'.$profid[$key][0]."</td><td>\n"; |
|
659 | - print $profid[$key][1]; |
|
660 | - print '</td>'; |
|
661 | - |
|
662 | - $idprof_unique ='SOCIETE_'.$key.'_UNIQUE'; |
|
663 | - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; |
|
664 | - $idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; |
|
665 | - |
|
666 | - $verif=(empty($conf->global->$idprof_unique)?false:true); |
|
667 | - $mandatory=(empty($conf->global->$idprof_mandatory)?false:true); |
|
668 | - $invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true); |
|
669 | - |
|
670 | - if ($verif) |
|
671 | - { |
|
672 | - print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=0">'; |
|
673 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
674 | - print '</a></td>'; |
|
675 | - } |
|
676 | - else |
|
677 | - { |
|
678 | - print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=1">'; |
|
679 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
680 | - print '</a></td>'; |
|
681 | - } |
|
682 | - |
|
683 | - if ($mandatory) |
|
684 | - { |
|
685 | - print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=0">'; |
|
686 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
687 | - print '</a></td>'; |
|
688 | - } |
|
689 | - else |
|
690 | - { |
|
691 | - print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=1">'; |
|
692 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
693 | - print '</a></td>'; |
|
694 | - } |
|
695 | - |
|
696 | - if ($invoice_mandatory) |
|
697 | - { |
|
698 | - print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=0">'; |
|
699 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
700 | - print '</a></td>'; |
|
701 | - } |
|
702 | - else |
|
703 | - { |
|
704 | - print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=1">'; |
|
705 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
706 | - print '</a></td>'; |
|
707 | - } |
|
708 | - |
|
709 | - print "</tr>\n"; |
|
710 | - } |
|
711 | - $i++; |
|
655 | + if ($profid[$key][1]!='-') |
|
656 | + { |
|
657 | + print '<tr class="oddeven">'; |
|
658 | + print '<td>'.$profid[$key][0]."</td><td>\n"; |
|
659 | + print $profid[$key][1]; |
|
660 | + print '</td>'; |
|
661 | + |
|
662 | + $idprof_unique ='SOCIETE_'.$key.'_UNIQUE'; |
|
663 | + $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; |
|
664 | + $idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; |
|
665 | + |
|
666 | + $verif=(empty($conf->global->$idprof_unique)?false:true); |
|
667 | + $mandatory=(empty($conf->global->$idprof_mandatory)?false:true); |
|
668 | + $invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true); |
|
669 | + |
|
670 | + if ($verif) |
|
671 | + { |
|
672 | + print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=0">'; |
|
673 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
674 | + print '</a></td>'; |
|
675 | + } |
|
676 | + else |
|
677 | + { |
|
678 | + print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=1">'; |
|
679 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
680 | + print '</a></td>'; |
|
681 | + } |
|
682 | + |
|
683 | + if ($mandatory) |
|
684 | + { |
|
685 | + print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=0">'; |
|
686 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
687 | + print '</a></td>'; |
|
688 | + } |
|
689 | + else |
|
690 | + { |
|
691 | + print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=1">'; |
|
692 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
693 | + print '</a></td>'; |
|
694 | + } |
|
695 | + |
|
696 | + if ($invoice_mandatory) |
|
697 | + { |
|
698 | + print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=0">'; |
|
699 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
700 | + print '</a></td>'; |
|
701 | + } |
|
702 | + else |
|
703 | + { |
|
704 | + print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=1">'; |
|
705 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
706 | + print '</a></td>'; |
|
707 | + } |
|
708 | + |
|
709 | + print "</tr>\n"; |
|
710 | + } |
|
711 | + $i++; |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | print "</table><br>\n"; |
@@ -735,22 +735,22 @@ discard block |
||
735 | 735 | print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"),$langs->trans('UseSearchToSelectCompanyTooltip'),1).' </td>'; |
736 | 736 | if (! $conf->use_javascript_ajax) |
737 | 737 | { |
738 | - print '<td class="nowrap" align="right" colspan="2">'; |
|
739 | - print $langs->trans("NotAvailableWhenAjaxDisabled"); |
|
740 | - print "</td>"; |
|
738 | + print '<td class="nowrap" align="right" colspan="2">'; |
|
739 | + print $langs->trans("NotAvailableWhenAjaxDisabled"); |
|
740 | + print "</td>"; |
|
741 | 741 | } |
742 | 742 | else |
743 | 743 | { |
744 | - print '<td width="60" align="right">'; |
|
745 | - $arrval=array('0'=>$langs->trans("No"), |
|
746 | - '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
744 | + print '<td width="60" align="right">'; |
|
745 | + $arrval=array('0'=>$langs->trans("No"), |
|
746 | + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
747 | 747 | '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', |
748 | 748 | '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', |
749 | - ); |
|
750 | - print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); |
|
751 | - print '</td><td align="right">'; |
|
752 | - print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">'; |
|
753 | - print "</td>"; |
|
749 | + ); |
|
750 | + print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); |
|
751 | + print '</td><td align="right">'; |
|
752 | + print '<input type="submit" class="button" name="COMPANY_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">'; |
|
753 | + print "</td>"; |
|
754 | 754 | } |
755 | 755 | print '</tr>'; |
756 | 756 | |
@@ -759,22 +759,22 @@ discard block |
||
759 | 759 | print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"),$langs->trans('UseSearchToSelectContactTooltip'),1).'</td>'; |
760 | 760 | if (! $conf->use_javascript_ajax) |
761 | 761 | { |
762 | - print '<td class="nowrap" align="right" colspan="2">'; |
|
763 | - print $langs->trans("NotAvailableWhenAjaxDisabled"); |
|
764 | - print "</td>"; |
|
762 | + print '<td class="nowrap" align="right" colspan="2">'; |
|
763 | + print $langs->trans("NotAvailableWhenAjaxDisabled"); |
|
764 | + print "</td>"; |
|
765 | 765 | } |
766 | 766 | else |
767 | 767 | { |
768 | - print '<td width="60" align="right">'; |
|
769 | - $arrval=array('0'=>$langs->trans("No"), |
|
770 | - '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
771 | - '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', |
|
772 | - '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', |
|
773 | - ); |
|
774 | - print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); |
|
775 | - print '</td><td align="right">'; |
|
776 | - print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">'; |
|
777 | - print "</td>"; |
|
768 | + print '<td width="60" align="right">'; |
|
769 | + $arrval=array('0'=>$langs->trans("No"), |
|
770 | + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
771 | + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', |
|
772 | + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', |
|
773 | + ); |
|
774 | + print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); |
|
775 | + print '</td><td align="right">'; |
|
776 | + print '<input type="submit" class="button" name="CONTACT_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">'; |
|
777 | + print "</td>"; |
|
778 | 778 | } |
779 | 779 | print '</tr>'; |
780 | 780 | |
@@ -786,13 +786,13 @@ discard block |
||
786 | 786 | print '<td align="center">'; |
787 | 787 | if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) |
788 | 788 | { |
789 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=0">'; |
|
790 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
789 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=0">'; |
|
790 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
791 | 791 | } |
792 | 792 | else |
793 | 793 | { |
794 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=1">'; |
|
795 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
794 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=1">'; |
|
795 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
796 | 796 | } |
797 | 797 | print '</a></td>'; |
798 | 798 | print '</tr>'; |
@@ -803,13 +803,13 @@ discard block |
||
803 | 803 | print '<td align="center">'; |
804 | 804 | if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) |
805 | 805 | { |
806 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=0">'; |
|
807 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
806 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=0">'; |
|
807 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
808 | 808 | } |
809 | 809 | else |
810 | 810 | { |
811 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=1">'; |
|
812 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
811 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=1">'; |
|
812 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
813 | 813 | } |
814 | 814 | print '</a></td>'; |
815 | 815 | print '</tr>'; |
@@ -822,13 +822,13 @@ discard block |
||
822 | 822 | print '<td align="center">'; |
823 | 823 | if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) |
824 | 824 | { |
825 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">'; |
|
826 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
825 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">'; |
|
826 | + print img_picto($langs->trans("Activated"),'switch_on'); |
|
827 | 827 | } |
828 | 828 | else |
829 | 829 | { |
830 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">'; |
|
831 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
830 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">'; |
|
831 | + print img_picto($langs->trans("Disabled"),'switch_off'); |
|
832 | 832 | } |
833 | 833 | print '</a></td>'; |
834 | 834 | print '</tr>'; |
@@ -34,7 +34,9 @@ discard block |
||
34 | 34 | $action=GETPOST('action','alpha'); |
35 | 35 | $value=GETPOST('value','alpha'); |
36 | 36 | |
37 | -if (!$user->admin) accessforbidden(); |
|
37 | +if (!$user->admin) { |
|
38 | + accessforbidden(); |
|
39 | +} |
|
38 | 40 | |
39 | 41 | |
40 | 42 | |
@@ -50,8 +52,7 @@ discard block |
||
50 | 52 | { |
51 | 53 | header("Location: ".$_SERVER["PHP_SELF"]); |
52 | 54 | exit; |
53 | - } |
|
54 | - else |
|
55 | + } else |
|
55 | 56 | { |
56 | 57 | dol_print_error($db); |
57 | 58 | } |
@@ -63,8 +64,7 @@ discard block |
||
63 | 64 | { |
64 | 65 | header("Location: ".$_SERVER["PHP_SELF"]); |
65 | 66 | exit; |
66 | - } |
|
67 | - else |
|
67 | + } else |
|
68 | 68 | { |
69 | 69 | dol_print_error($db); |
70 | 70 | } |
@@ -76,12 +76,13 @@ discard block |
||
76 | 76 | { |
77 | 77 | $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT','alpha'); |
78 | 78 | $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity); |
79 | - if (! $res > 0) $error++; |
|
79 | + if (! $res > 0) { |
|
80 | + $error++; |
|
81 | + } |
|
80 | 82 | if (! $error) |
81 | 83 | { |
82 | 84 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
83 | - } |
|
84 | - else |
|
85 | + } else |
|
85 | 86 | { |
86 | 87 | setEventMessages($langs->trans("Error"), null, 'errors'); |
87 | 88 | } |
@@ -91,12 +92,13 @@ discard block |
||
91 | 92 | { |
92 | 93 | $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha'); |
93 | 94 | $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity); |
94 | - if (! $res > 0) $error++; |
|
95 | + if (! $res > 0) { |
|
96 | + $error++; |
|
97 | + } |
|
95 | 98 | if (! $error) |
96 | 99 | { |
97 | 100 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
98 | - } |
|
99 | - else |
|
101 | + } else |
|
100 | 102 | { |
101 | 103 | setEventMessages($langs->trans("Error"), null, 'errors'); |
102 | 104 | } |
@@ -117,8 +119,10 @@ discard block |
||
117 | 119 | $sql.= ")"; |
118 | 120 | |
119 | 121 | $resql=$db->query($sql); |
120 | - if (! $resql) dol_print_error($db); |
|
121 | -} |
|
122 | + if (! $resql) { |
|
123 | + dol_print_error($db); |
|
124 | + } |
|
125 | + } |
|
122 | 126 | |
123 | 127 | // Disable a document generator module |
124 | 128 | if ($action== 'del') |
@@ -127,8 +131,10 @@ discard block |
||
127 | 131 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
128 | 132 | $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; |
129 | 133 | $resql=$db->query($sql); |
130 | - if (! $resql) dol_print_error($db); |
|
131 | -} |
|
134 | + if (! $resql) { |
|
135 | + dol_print_error($db); |
|
136 | + } |
|
137 | + } |
|
132 | 138 | |
133 | 139 | // Define default generator |
134 | 140 | if ($action == 'setdoc') |
@@ -159,8 +165,7 @@ discard block |
||
159 | 165 | if ($result1 && $result2) |
160 | 166 | { |
161 | 167 | $db->commit(); |
162 | - } |
|
163 | - else |
|
168 | + } else |
|
164 | 169 | { |
165 | 170 | $db->rollback(); |
166 | 171 | } |
@@ -170,12 +175,13 @@ discard block |
||
170 | 175 | if ($action=="setaddrefinlist") { |
171 | 176 | $setaddrefinlist = GETPOST('value','int'); |
172 | 177 | $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity); |
173 | - if (! $res > 0) $error++; |
|
178 | + if (! $res > 0) { |
|
179 | + $error++; |
|
180 | + } |
|
174 | 181 | if (! $error) |
175 | 182 | { |
176 | 183 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
177 | - } |
|
178 | - else |
|
184 | + } else |
|
179 | 185 | { |
180 | 186 | setEventMessages($langs->trans("Error"), null, 'errors'); |
181 | 187 | } |
@@ -185,12 +191,13 @@ discard block |
||
185 | 191 | if ($action=="setaddadressinlist") { |
186 | 192 | $val = GETPOST('value','int'); |
187 | 193 | $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val,'yesno',0,'',$conf->entity); |
188 | - if (! $res > 0) $error++; |
|
194 | + if (! $res > 0) { |
|
195 | + $error++; |
|
196 | + } |
|
189 | 197 | if (! $error) |
190 | 198 | { |
191 | 199 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
192 | - } |
|
193 | - else |
|
200 | + } else |
|
194 | 201 | { |
195 | 202 | setEventMessages($langs->trans("Error"), null, 'errors'); |
196 | 203 | } |
@@ -200,12 +207,13 @@ discard block |
||
200 | 207 | if ($action=="setaskforshippingmet") { |
201 | 208 | $setaskforshippingmet = GETPOST('value','int'); |
202 | 209 | $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity); |
203 | - if (! $res > 0) $error++; |
|
210 | + if (! $res > 0) { |
|
211 | + $error++; |
|
212 | + } |
|
204 | 213 | if (! $error) |
205 | 214 | { |
206 | 215 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
207 | - } |
|
208 | - else |
|
216 | + } else |
|
209 | 217 | { |
210 | 218 | setEventMessages($langs->trans("Error"), null, 'errors'); |
211 | 219 | } |
@@ -215,12 +223,13 @@ discard block |
||
215 | 223 | if ($action=="setdisableprospectcustomer") { |
216 | 224 | $setdisableprospectcustomer = GETPOST('value','int'); |
217 | 225 | $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer,'yesno',0,'',$conf->entity); |
218 | - if (! $res > 0) $error++; |
|
226 | + if (! $res > 0) { |
|
227 | + $error++; |
|
228 | + } |
|
219 | 229 | if (! $error) |
220 | 230 | { |
221 | 231 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
222 | - } |
|
223 | - else |
|
232 | + } else |
|
224 | 233 | { |
225 | 234 | setEventMessages($langs->trans("Error"), null, 'errors'); |
226 | 235 | } |
@@ -236,8 +245,7 @@ discard block |
||
236 | 245 | { |
237 | 246 | //header("Location: ".$_SERVER["PHP_SELF"]); |
238 | 247 | //exit; |
239 | - } |
|
240 | - else |
|
248 | + } else |
|
241 | 249 | { |
242 | 250 | dol_print_error($db); |
243 | 251 | } |
@@ -253,8 +261,7 @@ discard block |
||
253 | 261 | { |
254 | 262 | //header("Location: ".$_SERVER["PHP_SELF"]); |
255 | 263 | //exit; |
256 | - } |
|
257 | - else |
|
264 | + } else |
|
258 | 265 | { |
259 | 266 | dol_print_error($db); |
260 | 267 | } |
@@ -270,8 +277,7 @@ discard block |
||
270 | 277 | { |
271 | 278 | //header("Location: ".$_SERVER["PHP_SELF"]); |
272 | 279 | //exit; |
273 | - } |
|
274 | - else |
|
280 | + } else |
|
275 | 281 | { |
276 | 282 | dol_print_error($db); |
277 | 283 | } |
@@ -286,8 +292,7 @@ discard block |
||
286 | 292 | { |
287 | 293 | header("Location: ".$_SERVER["PHP_SELF"]); |
288 | 294 | exit; |
289 | - } |
|
290 | - else |
|
295 | + } else |
|
291 | 296 | { |
292 | 297 | dol_print_error($db); |
293 | 298 | } |
@@ -295,12 +300,13 @@ discard block |
||
295 | 300 | if($action=='setonsearchandlistgooncustomerorsuppliercard'){ |
296 | 301 | $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value','int'); |
297 | 302 | $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard,'yesno',0,'',$conf->entity); |
298 | - if (! $res > 0) $error++; |
|
303 | + if (! $res > 0) { |
|
304 | + $error++; |
|
305 | + } |
|
299 | 306 | if (! $error) |
300 | 307 | { |
301 | 308 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
302 | - } |
|
303 | - else |
|
309 | + } else |
|
304 | 310 | { |
305 | 311 | setEventMessages($langs->trans("Error"), null, 'errors'); |
306 | 312 | } |
@@ -357,8 +363,7 @@ discard block |
||
357 | 363 | |
358 | 364 | try { |
359 | 365 | dol_include_once($dirroot.$file.'.php'); |
360 | - } |
|
361 | - catch(Exception $e) |
|
366 | + } catch(Exception $e) |
|
362 | 367 | { |
363 | 368 | dol_syslog($e->getMessage(), LOG_ERR); |
364 | 369 | } |
@@ -366,8 +371,12 @@ discard block |
||
366 | 371 | $modCodeTiers = new $file; |
367 | 372 | |
368 | 373 | // Show modules according to features level |
369 | - if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
370 | - if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
|
374 | + if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { |
|
375 | + continue; |
|
376 | + } |
|
377 | + if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { |
|
378 | + continue; |
|
379 | + } |
|
371 | 380 | |
372 | 381 | print '<tr class="oddeven">'."\n"; |
373 | 382 | print '<td width="140">'.$modCodeTiers->name.'</td>'."\n"; |
@@ -379,15 +388,18 @@ discard block |
||
379 | 388 | print '<td align="center">'."\n"; |
380 | 389 | print img_picto($langs->trans("Activated"),'switch_on'); |
381 | 390 | print "</td>\n"; |
382 | - } |
|
383 | - else |
|
391 | + } else |
|
384 | 392 | { |
385 | 393 | $disabled = false; |
386 | 394 | if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); |
387 | 395 | print '<td align="center">'; |
388 | - if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">'; |
|
396 | + if (! $disabled) { |
|
397 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">'; |
|
398 | + } |
|
389 | 399 | print img_picto($langs->trans("Disabled"),'switch_off'); |
390 | - if (! $disabled) print '</a>'; |
|
400 | + if (! $disabled) { |
|
401 | + print '</a>'; |
|
402 | + } |
|
391 | 403 | print '</td>'; |
392 | 404 | } |
393 | 405 | |
@@ -436,8 +448,7 @@ discard block |
||
436 | 448 | |
437 | 449 | try { |
438 | 450 | dol_include_once($dirroot.$file.'.php'); |
439 | - } |
|
440 | - catch(Exception $e) |
|
451 | + } catch(Exception $e) |
|
441 | 452 | { |
442 | 453 | dol_syslog($e->getMessage(), LOG_ERR); |
443 | 454 | } |
@@ -455,8 +466,7 @@ discard block |
||
455 | 466 | print '<td align="center">'; |
456 | 467 | print img_picto($langs->trans("Activated"),'switch_on'); |
457 | 468 | print '</td>'; |
458 | - } |
|
459 | - else |
|
469 | + } else |
|
460 | 470 | { |
461 | 471 | print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">'; |
462 | 472 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -498,8 +508,7 @@ discard block |
||
498 | 508 | array_push($def, $array[0]); |
499 | 509 | $i++; |
500 | 510 | } |
501 | -} |
|
502 | -else |
|
511 | +} else |
|
503 | 512 | { |
504 | 513 | dol_print_error($db); |
505 | 514 | } |
@@ -529,8 +538,7 @@ discard block |
||
529 | 538 | |
530 | 539 | try { |
531 | 540 | dol_include_once($dirroot.'doc/'.$file); |
532 | - } |
|
533 | - catch(Exception $e) |
|
541 | + } catch(Exception $e) |
|
534 | 542 | { |
535 | 543 | dol_syslog($e->getMessage(), LOG_ERR); |
536 | 544 | } |
@@ -539,8 +547,11 @@ discard block |
||
539 | 547 | |
540 | 548 | $modulequalified=1; |
541 | 549 | if (! empty($module->version)) { |
542 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
543 | - else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
550 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { |
|
551 | + $modulequalified=0; |
|
552 | + } else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { |
|
553 | + $modulequalified=0; |
|
554 | + } |
|
544 | 555 | } |
545 | 556 | |
546 | 557 | if ($modulequalified) |
@@ -548,8 +559,11 @@ discard block |
||
548 | 559 | print '<tr class="oddeven"><td width="100">'; |
549 | 560 | print $module->name; |
550 | 561 | print "</td><td>\n"; |
551 | - if (method_exists($module,'info')) print $module->info($langs); |
|
552 | - else print $module->description; |
|
562 | + if (method_exists($module,'info')) { |
|
563 | + print $module->info($langs); |
|
564 | + } else { |
|
565 | + print $module->description; |
|
566 | + } |
|
553 | 567 | print '</td>'; |
554 | 568 | |
555 | 569 | // Activate / Disable |
@@ -567,16 +581,14 @@ discard block |
||
567 | 581 | // print img_picto($langs->trans("Enabled"),'on'); |
568 | 582 | //} |
569 | 583 | print "</td>"; |
570 | - } |
|
571 | - else |
|
584 | + } else |
|
572 | 585 | { |
573 | 586 | if (versioncompare($module->phpmin,versionphparray()) > 0) |
574 | 587 | { |
575 | 588 | print "<td align=\"center\">\n"; |
576 | 589 | print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off'); |
577 | 590 | print "</td>"; |
578 | - } |
|
579 | - else |
|
591 | + } else |
|
580 | 592 | { |
581 | 593 | print "<td align=\"center\">\n"; |
582 | 594 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
@@ -603,8 +615,7 @@ discard block |
||
603 | 615 | if ($module->type == 'pdf') |
604 | 616 | { |
605 | 617 | $linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
606 | - } |
|
607 | - else |
|
618 | + } else |
|
608 | 619 | { |
609 | 620 | $linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic'); |
610 | 621 | } |
@@ -672,8 +683,7 @@ discard block |
||
672 | 683 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=0">'; |
673 | 684 | print img_picto($langs->trans("Activated"),'switch_on'); |
674 | 685 | print '</a></td>'; |
675 | - } |
|
676 | - else |
|
686 | + } else |
|
677 | 687 | { |
678 | 688 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=1">'; |
679 | 689 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -685,8 +695,7 @@ discard block |
||
685 | 695 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=0">'; |
686 | 696 | print img_picto($langs->trans("Activated"),'switch_on'); |
687 | 697 | print '</a></td>'; |
688 | - } |
|
689 | - else |
|
698 | + } else |
|
690 | 699 | { |
691 | 700 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=1">'; |
692 | 701 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -698,8 +707,7 @@ discard block |
||
698 | 707 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=0">'; |
699 | 708 | print img_picto($langs->trans("Activated"),'switch_on'); |
700 | 709 | print '</a></td>'; |
701 | - } |
|
702 | - else |
|
710 | + } else |
|
703 | 711 | { |
704 | 712 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=1">'; |
705 | 713 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -738,8 +746,7 @@ discard block |
||
738 | 746 | print '<td class="nowrap" align="right" colspan="2">'; |
739 | 747 | print $langs->trans("NotAvailableWhenAjaxDisabled"); |
740 | 748 | print "</td>"; |
741 | -} |
|
742 | -else |
|
749 | +} else |
|
743 | 750 | { |
744 | 751 | print '<td width="60" align="right">'; |
745 | 752 | $arrval=array('0'=>$langs->trans("No"), |
@@ -762,8 +769,7 @@ discard block |
||
762 | 769 | print '<td class="nowrap" align="right" colspan="2">'; |
763 | 770 | print $langs->trans("NotAvailableWhenAjaxDisabled"); |
764 | 771 | print "</td>"; |
765 | -} |
|
766 | -else |
|
772 | +} else |
|
767 | 773 | { |
768 | 774 | print '<td width="60" align="right">'; |
769 | 775 | $arrval=array('0'=>$langs->trans("No"), |
@@ -788,8 +794,7 @@ discard block |
||
788 | 794 | { |
789 | 795 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=0">'; |
790 | 796 | print img_picto($langs->trans("Activated"),'switch_on'); |
791 | -} |
|
792 | -else |
|
797 | +} else |
|
793 | 798 | { |
794 | 799 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=1">'; |
795 | 800 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -805,8 +810,7 @@ discard block |
||
805 | 810 | { |
806 | 811 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=0">'; |
807 | 812 | print img_picto($langs->trans("Activated"),'switch_on'); |
808 | -} |
|
809 | -else |
|
813 | +} else |
|
810 | 814 | { |
811 | 815 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=1">'; |
812 | 816 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -824,8 +828,7 @@ discard block |
||
824 | 828 | { |
825 | 829 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">'; |
826 | 830 | print img_picto($langs->trans("Activated"),'switch_on'); |
827 | -} |
|
828 | -else |
|
831 | +} else |
|
829 | 832 | { |
830 | 833 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">'; |
831 | 834 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -842,8 +845,7 @@ discard block |
||
842 | 845 | { |
843 | 846 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&value=0">'; |
844 | 847 | print img_picto($langs->trans("Activated"),'switch_on'); |
845 | -} |
|
846 | -else |
|
848 | +} else |
|
847 | 849 | { |
848 | 850 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&value=1">'; |
849 | 851 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -28,14 +28,14 @@ discard block |
||
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/lib/admin.lib.php'; |
33 | 33 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
34 | 34 | |
35 | 35 | $langs->loadLangs(array("admin", "other")); |
36 | 36 | |
37 | -$action=GETPOST('action','alpha'); |
|
38 | -$value=GETPOST('value','alpha'); |
|
37 | +$action = GETPOST('action', 'alpha'); |
|
38 | +$value = GETPOST('value', 'alpha'); |
|
39 | 39 | |
40 | 40 | if (!$user->admin) accessforbidden(); |
41 | 41 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | if ($action == 'setcodeclient') |
51 | 51 | { |
52 | - if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON",$value,'chaine',0,'',$conf->entity) > 0) |
|
52 | + if (dolibarr_set_const($db, "SOCIETE_CODECLIENT_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) |
|
53 | 53 | { |
54 | 54 | header("Location: ".$_SERVER["PHP_SELF"]); |
55 | 55 | exit; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | if ($action == 'setcodecompta') |
64 | 64 | { |
65 | - if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON",$value,'chaine',0,'',$conf->entity) > 0) |
|
65 | + if (dolibarr_set_const($db, "SOCIETE_CODECOMPTA_ADDON", $value, 'chaine', 0, '', $conf->entity) > 0) |
|
66 | 66 | { |
67 | 67 | header("Location: ".$_SERVER["PHP_SELF"]); |
68 | 68 | exit; |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | { |
78 | 78 | if (GETPOST('COMPANY_USE_SEARCH_TO_SELECT')) |
79 | 79 | { |
80 | - $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT','alpha'); |
|
81 | - $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch,'chaine',0,'',$conf->entity); |
|
82 | - if (! $res > 0) $error++; |
|
83 | - if (! $error) |
|
80 | + $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha'); |
|
81 | + $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity); |
|
82 | + if (!$res > 0) $error++; |
|
83 | + if (!$error) |
|
84 | 84 | { |
85 | 85 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
86 | 86 | } |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | |
93 | 93 | if (GETPOST('CONTACT_USE_SEARCH_TO_SELECT')) |
94 | 94 | { |
95 | - $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT','alpha'); |
|
96 | - $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch,'chaine',0,'',$conf->entity); |
|
97 | - if (! $res > 0) $error++; |
|
98 | - if (! $error) |
|
95 | + $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha'); |
|
96 | + $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity); |
|
97 | + if (!$res > 0) $error++; |
|
98 | + if (!$error) |
|
99 | 99 | { |
100 | 100 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
101 | 101 | } |
@@ -109,56 +109,56 @@ discard block |
||
109 | 109 | // Activate a document generator module |
110 | 110 | if ($action == 'set') |
111 | 111 | { |
112 | - $label = GETPOST('label','alpha'); |
|
113 | - $scandir = GETPOST('scan_dir','alpha'); |
|
112 | + $label = GETPOST('label', 'alpha'); |
|
113 | + $scandir = GETPOST('scan_dir', 'alpha'); |
|
114 | 114 | |
115 | - $type='company'; |
|
115 | + $type = 'company'; |
|
116 | 116 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; |
117 | - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; |
|
118 | - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; |
|
119 | - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); |
|
120 | - $sql.= ")"; |
|
117 | + $sql .= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; |
|
118 | + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; |
|
119 | + $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null"); |
|
120 | + $sql .= ")"; |
|
121 | 121 | |
122 | - $resql=$db->query($sql); |
|
123 | - if (! $resql) dol_print_error($db); |
|
122 | + $resql = $db->query($sql); |
|
123 | + if (!$resql) dol_print_error($db); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Disable a document generator module |
127 | -if ($action== 'del') |
|
127 | +if ($action == 'del') |
|
128 | 128 | { |
129 | - $type='company'; |
|
129 | + $type = 'company'; |
|
130 | 130 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
131 | - $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; |
|
132 | - $resql=$db->query($sql); |
|
133 | - if (! $resql) dol_print_error($db); |
|
131 | + $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; |
|
132 | + $resql = $db->query($sql); |
|
133 | + if (!$resql) dol_print_error($db); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Define default generator |
137 | 137 | if ($action == 'setdoc') |
138 | 138 | { |
139 | - $label = GETPOST('label','alpha'); |
|
140 | - $scandir = GETPOST('scan_dir','alpha'); |
|
139 | + $label = GETPOST('label', 'alpha'); |
|
140 | + $scandir = GETPOST('scan_dir', 'alpha'); |
|
141 | 141 | |
142 | 142 | $db->begin(); |
143 | 143 | |
144 | - dolibarr_set_const($db, "COMPANY_ADDON_PDF",$value,'chaine',0,'',$conf->entity); |
|
144 | + dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity); |
|
145 | 145 | |
146 | 146 | // On active le modele |
147 | - $type='company'; |
|
147 | + $type = 'company'; |
|
148 | 148 | $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; |
149 | - $sql_del.= " WHERE nom = '".$db->escape(GETPOST('value','alpha'))."'"; |
|
150 | - $sql_del.= " AND type = '".$type."'"; |
|
151 | - $sql_del.= " AND entity = ".$conf->entity; |
|
149 | + $sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'"; |
|
150 | + $sql_del .= " AND type = '".$type."'"; |
|
151 | + $sql_del .= " AND entity = ".$conf->entity; |
|
152 | 152 | dol_syslog("societe.php ".$sql); |
153 | - $result1=$db->query($sql_del); |
|
153 | + $result1 = $db->query($sql_del); |
|
154 | 154 | |
155 | 155 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; |
156 | - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; |
|
157 | - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; |
|
158 | - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); |
|
159 | - $sql.= ")"; |
|
156 | + $sql .= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; |
|
157 | + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; |
|
158 | + $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null"); |
|
159 | + $sql .= ")"; |
|
160 | 160 | dol_syslog("societe.php", LOG_DEBUG); |
161 | - $result2=$db->query($sql); |
|
161 | + $result2 = $db->query($sql); |
|
162 | 162 | if ($result1 && $result2) |
163 | 163 | { |
164 | 164 | $db->commit(); |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | //Activate Set ref in list |
173 | -if ($action=="setaddrefinlist") { |
|
174 | - $setaddrefinlist = GETPOST('value','int'); |
|
175 | - $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist,'yesno',0,'',$conf->entity); |
|
176 | - if (! $res > 0) $error++; |
|
177 | - if (! $error) |
|
173 | +if ($action == "setaddrefinlist") { |
|
174 | + $setaddrefinlist = GETPOST('value', 'int'); |
|
175 | + $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity); |
|
176 | + if (!$res > 0) $error++; |
|
177 | + if (!$error) |
|
178 | 178 | { |
179 | 179 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
180 | 180 | } |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | //Activate Set adress in list |
188 | -if ($action=="setaddadressinlist") { |
|
189 | - $val = GETPOST('value','int'); |
|
190 | - $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val,'yesno',0,'',$conf->entity); |
|
191 | - if (! $res > 0) $error++; |
|
192 | - if (! $error) |
|
188 | +if ($action == "setaddadressinlist") { |
|
189 | + $val = GETPOST('value', 'int'); |
|
190 | + $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity); |
|
191 | + if (!$res > 0) $error++; |
|
192 | + if (!$error) |
|
193 | 193 | { |
194 | 194 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
195 | 195 | } |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | //Activate Ask For Preferred Shipping Method |
203 | -if ($action=="setaskforshippingmet") { |
|
204 | - $setaskforshippingmet = GETPOST('value','int'); |
|
205 | - $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity); |
|
206 | - if (! $res > 0) $error++; |
|
207 | - if (! $error) |
|
203 | +if ($action == "setaskforshippingmet") { |
|
204 | + $setaskforshippingmet = GETPOST('value', 'int'); |
|
205 | + $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity); |
|
206 | + if (!$res > 0) $error++; |
|
207 | + if (!$error) |
|
208 | 208 | { |
209 | 209 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
210 | 210 | } |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | //Activate "Disable prospect/customer type" |
218 | -if ($action=="setdisableprospectcustomer") { |
|
219 | - $setdisableprospectcustomer = GETPOST('value','int'); |
|
220 | - $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer,'yesno',0,'',$conf->entity); |
|
221 | - if (! $res > 0) $error++; |
|
222 | - if (! $error) |
|
218 | +if ($action == "setdisableprospectcustomer") { |
|
219 | + $setdisableprospectcustomer = GETPOST('value', 'int'); |
|
220 | + $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); |
|
221 | + if (!$res > 0) $error++; |
|
222 | + if (!$error) |
|
223 | 223 | { |
224 | 224 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
225 | 225 | } |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | //Activate ProfId unique |
233 | 233 | if ($action == 'setprofid') |
234 | 234 | { |
235 | - $status = GETPOST('status','alpha'); |
|
235 | + $status = GETPOST('status', 'alpha'); |
|
236 | 236 | |
237 | - $idprof="SOCIETE_".$value."_UNIQUE"; |
|
237 | + $idprof = "SOCIETE_".$value."_UNIQUE"; |
|
238 | 238 | if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
239 | 239 | { |
240 | 240 | //header("Location: ".$_SERVER["PHP_SELF"]); |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | //Activate ProfId mandatory |
250 | 250 | if ($action == 'setprofidmandatory') |
251 | 251 | { |
252 | - $status = GETPOST('status','alpha'); |
|
252 | + $status = GETPOST('status', 'alpha'); |
|
253 | 253 | |
254 | - $idprof="SOCIETE_".$value."_MANDATORY"; |
|
254 | + $idprof = "SOCIETE_".$value."_MANDATORY"; |
|
255 | 255 | if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
256 | 256 | { |
257 | 257 | //header("Location: ".$_SERVER["PHP_SELF"]); |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | //Activate ProfId invoice mandatory |
267 | 267 | if ($action == 'setprofidinvoicemandatory') |
268 | 268 | { |
269 | - $status = GETPOST('status','alpha'); |
|
269 | + $status = GETPOST('status', 'alpha'); |
|
270 | 270 | |
271 | - $idprof="SOCIETE_".$value."_INVOICE_MANDATORY"; |
|
271 | + $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; |
|
272 | 272 | if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) |
273 | 273 | { |
274 | 274 | //header("Location: ".$_SERVER["PHP_SELF"]); |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | //Set hide closed customer into combox or select |
284 | 284 | if ($action == 'sethideinactivethirdparty') |
285 | 285 | { |
286 | - $status = GETPOST('status','alpha'); |
|
286 | + $status = GETPOST('status', 'alpha'); |
|
287 | 287 | |
288 | - if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX",$status,'chaine',0,'',$conf->entity) > 0) |
|
288 | + if (dolibarr_set_const($db, "COMPANY_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) |
|
289 | 289 | { |
290 | 290 | header("Location: ".$_SERVER["PHP_SELF"]); |
291 | 291 | exit; |
@@ -295,11 +295,11 @@ discard block |
||
295 | 295 | dol_print_error($db); |
296 | 296 | } |
297 | 297 | } |
298 | -if($action=='setonsearchandlistgooncustomerorsuppliercard'){ |
|
299 | - $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value','int'); |
|
300 | - $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard,'yesno',0,'',$conf->entity); |
|
301 | - if (! $res > 0) $error++; |
|
302 | - if (! $error) |
|
298 | +if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { |
|
299 | + $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); |
|
300 | + $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); |
|
301 | + if (!$res > 0) $error++; |
|
302 | + if (!$error) |
|
303 | 303 | { |
304 | 304 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
305 | 305 | } |
@@ -316,24 +316,24 @@ discard block |
||
316 | 316 | |
317 | 317 | clearstatcache(); |
318 | 318 | |
319 | -$form=new Form($db); |
|
319 | +$form = new Form($db); |
|
320 | 320 | |
321 | -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros'; |
|
322 | -llxHeader('',$langs->trans("CompanySetup"),$help_url); |
|
321 | +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros'; |
|
322 | +llxHeader('', $langs->trans("CompanySetup"), $help_url); |
|
323 | 323 | |
324 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
325 | -print load_fiche_titre($langs->trans("CompanySetup"),$linkback,'title_setup'); |
|
324 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
325 | +print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); |
|
326 | 326 | |
327 | 327 | |
328 | 328 | $head = societe_admin_prepare_head(); |
329 | 329 | |
330 | 330 | dol_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company'); |
331 | 331 | |
332 | -$dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['societe']); |
|
332 | +$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); |
|
333 | 333 | |
334 | 334 | // Module to manage customer/supplier code |
335 | 335 | |
336 | -print load_fiche_titre($langs->trans("CompanyCodeChecker"),'',''); |
|
336 | +print load_fiche_titre($langs->trans("CompanyCodeChecker"), '', ''); |
|
337 | 337 | |
338 | 338 | print '<table class="noborder" width="100%">'."\n"; |
339 | 339 | print '<tr class="liste_titre">'."\n"; |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | |
347 | 347 | foreach ($dirsociete as $dirroot) |
348 | 348 | { |
349 | - $dir = dol_buildpath($dirroot,0); |
|
349 | + $dir = dol_buildpath($dirroot, 0); |
|
350 | 350 | |
351 | 351 | $handle = @opendir($dir); |
352 | 352 | if (is_resource($handle)) |
353 | 353 | { |
354 | 354 | // Loop on each module find in opened directory |
355 | - while (($file = readdir($handle))!==false) |
|
355 | + while (($file = readdir($handle)) !== false) |
|
356 | 356 | { |
357 | 357 | if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') |
358 | 358 | { |
359 | - $file = substr($file, 0, dol_strlen($file)-4); |
|
359 | + $file = substr($file, 0, dol_strlen($file) - 4); |
|
360 | 360 | |
361 | 361 | try { |
362 | 362 | dol_include_once($dirroot.$file.'.php'); |
363 | 363 | } |
364 | - catch(Exception $e) |
|
364 | + catch (Exception $e) |
|
365 | 365 | { |
366 | 366 | dol_syslog($e->getMessage(), LOG_ERR); |
367 | 367 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | $modCodeTiers = new $file; |
370 | 370 | |
371 | 371 | // Show modules according to features level |
372 | - if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
372 | + if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; |
|
373 | 373 | if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; |
374 | 374 | |
375 | 375 | print '<tr class="oddeven">'."\n"; |
@@ -380,23 +380,23 @@ discard block |
||
380 | 380 | if ($conf->global->SOCIETE_CODECLIENT_ADDON == "$file") |
381 | 381 | { |
382 | 382 | print '<td align="center">'."\n"; |
383 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
383 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
384 | 384 | print "</td>\n"; |
385 | 385 | } |
386 | 386 | else |
387 | 387 | { |
388 | 388 | $disabled = false; |
389 | - if (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); |
|
389 | + if (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] == $conf->entity) ? false : true); |
|
390 | 390 | print '<td align="center">'; |
391 | - if (! $disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">'; |
|
392 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
393 | - if (! $disabled) print '</a>'; |
|
391 | + if (!$disabled) print '<a href="'.$_SERVER['PHP_SELF'].'?action=setcodeclient&value='.$file.'">'; |
|
392 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
393 | + if (!$disabled) print '</a>'; |
|
394 | 394 | print '</td>'; |
395 | 395 | } |
396 | 396 | |
397 | 397 | print '<td align="center">'; |
398 | - $s=$modCodeTiers->getToolTip($langs,null,-1); |
|
399 | - print $form->textwithpicto('',$s,1); |
|
398 | + $s = $modCodeTiers->getToolTip($langs, null, -1); |
|
399 | + print $form->textwithpicto('', $s, 1); |
|
400 | 400 | print '</td>'; |
401 | 401 | |
402 | 402 | print '</tr>'; |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | |
414 | 414 | // Select accountancy code numbering module |
415 | 415 | |
416 | -print load_fiche_titre($langs->trans("AccountCodeManager"),'',''); |
|
416 | +print load_fiche_titre($langs->trans("AccountCodeManager"), '', ''); |
|
417 | 417 | |
418 | 418 | print '<table class="noborder" width="100%">'; |
419 | 419 | print '<tr class="liste_titre">'; |
@@ -426,21 +426,21 @@ discard block |
||
426 | 426 | |
427 | 427 | foreach ($dirsociete as $dirroot) |
428 | 428 | { |
429 | - $dir = dol_buildpath($dirroot,0); |
|
429 | + $dir = dol_buildpath($dirroot, 0); |
|
430 | 430 | |
431 | 431 | $handle = @opendir($dir); |
432 | 432 | if (is_resource($handle)) |
433 | 433 | { |
434 | - while (($file = readdir($handle))!==false) |
|
434 | + while (($file = readdir($handle)) !== false) |
|
435 | 435 | { |
436 | 436 | if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') |
437 | 437 | { |
438 | - $file = substr($file, 0, dol_strlen($file)-4); |
|
438 | + $file = substr($file, 0, dol_strlen($file) - 4); |
|
439 | 439 | |
440 | 440 | try { |
441 | 441 | dol_include_once($dirroot.$file.'.php'); |
442 | 442 | } |
443 | - catch(Exception $e) |
|
443 | + catch (Exception $e) |
|
444 | 444 | { |
445 | 445 | dol_syslog($e->getMessage(), LOG_ERR); |
446 | 446 | } |
@@ -456,18 +456,18 @@ discard block |
||
456 | 456 | if ($conf->global->SOCIETE_CODECOMPTA_ADDON == "$file") |
457 | 457 | { |
458 | 458 | print '<td align="center">'; |
459 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
459 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
460 | 460 | print '</td>'; |
461 | 461 | } |
462 | 462 | else |
463 | 463 | { |
464 | 464 | print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setcodecompta&value='.$file.'">'; |
465 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
465 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
466 | 466 | print '</a></td>'; |
467 | 467 | } |
468 | 468 | print '<td align="center">'; |
469 | - $s=$modCodeCompta->getToolTip($langs,null,-1); |
|
470 | - print $form->textwithpicto('',$s,1); |
|
469 | + $s = $modCodeCompta->getToolTip($langs, null, -1); |
|
470 | + print $form->textwithpicto('', $s, 1); |
|
471 | 471 | print '</td>'; |
472 | 472 | print "</tr>\n"; |
473 | 473 | } |
@@ -482,19 +482,19 @@ discard block |
||
482 | 482 | * Document templates generators |
483 | 483 | */ |
484 | 484 | print '<br>'; |
485 | -print load_fiche_titre($langs->trans("ModelModules"),'',''); |
|
485 | +print load_fiche_titre($langs->trans("ModelModules"), '', ''); |
|
486 | 486 | |
487 | 487 | // Load array def with activated templates |
488 | 488 | $def = array(); |
489 | 489 | $sql = "SELECT nom"; |
490 | -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
491 | -$sql.= " WHERE type = 'company'"; |
|
492 | -$sql.= " AND entity = ".$conf->entity; |
|
493 | -$resql=$db->query($sql); |
|
490 | +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; |
|
491 | +$sql .= " WHERE type = 'company'"; |
|
492 | +$sql .= " AND entity = ".$conf->entity; |
|
493 | +$resql = $db->query($sql); |
|
494 | 494 | if ($resql) |
495 | 495 | { |
496 | 496 | $i = 0; |
497 | - $num_rows=$db->num_rows($resql); |
|
497 | + $num_rows = $db->num_rows($resql); |
|
498 | 498 | while ($i < $num_rows) |
499 | 499 | { |
500 | 500 | $array = $db->fetch_array($resql); |
@@ -518,32 +518,32 @@ discard block |
||
518 | 518 | |
519 | 519 | foreach ($dirsociete as $dirroot) |
520 | 520 | { |
521 | - $dir = dol_buildpath($dirroot.'doc/',0); |
|
521 | + $dir = dol_buildpath($dirroot.'doc/', 0); |
|
522 | 522 | |
523 | - $handle=@opendir($dir); |
|
523 | + $handle = @opendir($dir); |
|
524 | 524 | if (is_resource($handle)) |
525 | 525 | { |
526 | - while (($file = readdir($handle))!==false) |
|
526 | + while (($file = readdir($handle)) !== false) |
|
527 | 527 | { |
528 | - if (preg_match('/\.modules\.php$/i',$file)) |
|
528 | + if (preg_match('/\.modules\.php$/i', $file)) |
|
529 | 529 | { |
530 | - $name = substr($file, 4, dol_strlen($file) -16); |
|
531 | - $classname = substr($file, 0, dol_strlen($file) -12); |
|
530 | + $name = substr($file, 4, dol_strlen($file) - 16); |
|
531 | + $classname = substr($file, 0, dol_strlen($file) - 12); |
|
532 | 532 | |
533 | 533 | try { |
534 | 534 | dol_include_once($dirroot.'doc/'.$file); |
535 | 535 | } |
536 | - catch(Exception $e) |
|
536 | + catch (Exception $e) |
|
537 | 537 | { |
538 | 538 | dol_syslog($e->getMessage(), LOG_ERR); |
539 | 539 | } |
540 | 540 | |
541 | 541 | $module = new $classname($db); |
542 | 542 | |
543 | - $modulequalified=1; |
|
544 | - if (! empty($module->version)) { |
|
545 | - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; |
|
546 | - else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; |
|
543 | + $modulequalified = 1; |
|
544 | + if (!empty($module->version)) { |
|
545 | + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; |
|
546 | + else if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | if ($modulequalified) |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | print '<tr class="oddeven"><td width="100">'; |
552 | 552 | print $module->name; |
553 | 553 | print "</td><td>\n"; |
554 | - if (method_exists($module,'info')) print $module->info($langs); |
|
554 | + if (method_exists($module, 'info')) print $module->info($langs); |
|
555 | 555 | else print $module->description; |
556 | 556 | print '</td>'; |
557 | 557 | |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | //if ($conf->global->COMPANY_ADDON_PDF != "$name") |
563 | 563 | //{ |
564 | 564 | print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'; |
565 | - print img_picto($langs->trans("Enabled"),'switch_on'); |
|
565 | + print img_picto($langs->trans("Enabled"), 'switch_on'); |
|
566 | 566 | print '</a>'; |
567 | 567 | //} |
568 | 568 | //else |
@@ -573,43 +573,43 @@ discard block |
||
573 | 573 | } |
574 | 574 | else |
575 | 575 | { |
576 | - if (versioncompare($module->phpmin,versionphparray()) > 0) |
|
576 | + if (versioncompare($module->phpmin, versionphparray()) > 0) |
|
577 | 577 | { |
578 | 578 | print "<td align=\"center\">\n"; |
579 | - print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion",join('.',$module->phpmin))),'switch_off'); |
|
579 | + print img_picto(dol_escape_htmltag($langs->trans("ErrorModuleRequirePHPVersion", join('.', $module->phpmin))), 'switch_off'); |
|
580 | 580 | print "</td>"; |
581 | 581 | } |
582 | 582 | else |
583 | 583 | { |
584 | 584 | print "<td align=\"center\">\n"; |
585 | - print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>'; |
|
585 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; |
|
586 | 586 | print "</td>"; |
587 | 587 | } |
588 | 588 | } |
589 | 589 | |
590 | 590 | // Info |
591 | - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
592 | - $htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); |
|
591 | + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; |
|
592 | + $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); |
|
593 | 593 | if ($module->type == 'pdf') |
594 | 594 | { |
595 | - $htmltooltip.='<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; |
|
595 | + $htmltooltip .= '<br>'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; |
|
596 | 596 | } |
597 | - $htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
598 | - $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1); |
|
597 | + $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; |
|
598 | + $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraft").': '.yn((!empty($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1); |
|
599 | 599 | |
600 | 600 | print '<td align="center" class="nowrap">'; |
601 | - print $form->textwithpicto('',$htmltooltip,1,0); |
|
601 | + print $form->textwithpicto('', $htmltooltip, 1, 0); |
|
602 | 602 | print '</td>'; |
603 | 603 | |
604 | 604 | // Preview |
605 | 605 | print '<td align="center" class="nowrap">'; |
606 | 606 | if ($module->type == 'pdf') |
607 | 607 | { |
608 | - $linkspec='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>'; |
|
608 | + $linkspec = '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>'; |
|
609 | 609 | } |
610 | 610 | else |
611 | 611 | { |
612 | - $linkspec=img_object($langs->trans("PreviewNotAvailable"),'generic'); |
|
612 | + $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); |
|
613 | 613 | } |
614 | 614 | print $linkspec; |
615 | 615 | print '</td>'; |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | print '<br>'; |
627 | 627 | |
628 | 628 | //IDProf |
629 | -print load_fiche_titre($langs->trans("CompanyIdProfChecker"),'',''); |
|
629 | +print load_fiche_titre($langs->trans("CompanyIdProfChecker"), '', ''); |
|
630 | 630 | |
631 | 631 | print '<table class="noborder" width="100%">'; |
632 | 632 | print '<tr class="liste_titre">'; |
@@ -637,75 +637,75 @@ discard block |
||
637 | 637 | print '<td align="center">'.$langs->trans("MustBeInvoiceMandatory").'</td>'; |
638 | 638 | print "</tr>\n"; |
639 | 639 | |
640 | -$profid['IDPROF1'][0]=$langs->trans("ProfId1"); |
|
641 | -$profid['IDPROF1'][1]=$langs->transcountry('ProfId1', $mysoc->country_code); |
|
642 | -$profid['IDPROF2'][0]=$langs->trans("ProfId2"); |
|
643 | -$profid['IDPROF2'][1]=$langs->transcountry('ProfId2', $mysoc->country_code); |
|
644 | -$profid['IDPROF3'][0]=$langs->trans("ProfId3"); |
|
645 | -$profid['IDPROF3'][1]=$langs->transcountry('ProfId3', $mysoc->country_code); |
|
646 | -$profid['IDPROF4'][0]=$langs->trans("ProfId4"); |
|
647 | -$profid['IDPROF4'][1]=$langs->transcountry('ProfId4', $mysoc->country_code); |
|
648 | -$profid['IDPROF5'][0]=$langs->trans("ProfId5"); |
|
649 | -$profid['IDPROF5'][1]=$langs->transcountry('ProfId5', $mysoc->country_code); |
|
650 | -$profid['IDPROF6'][0]=$langs->trans("ProfId6"); |
|
651 | -$profid['IDPROF6'][1]=$langs->transcountry('ProfId6', $mysoc->country_code); |
|
652 | -$profid['EMAIL'][0]=$langs->trans("EMail"); |
|
653 | -$profid['EMAIL'][1]=$langs->trans('Email'); |
|
654 | - |
|
655 | -$nbofloop=count($profid); |
|
656 | -foreach($profid as $key => $val) |
|
657 | -{ |
|
658 | - if ($profid[$key][1]!='-') |
|
640 | +$profid['IDPROF1'][0] = $langs->trans("ProfId1"); |
|
641 | +$profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code); |
|
642 | +$profid['IDPROF2'][0] = $langs->trans("ProfId2"); |
|
643 | +$profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code); |
|
644 | +$profid['IDPROF3'][0] = $langs->trans("ProfId3"); |
|
645 | +$profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code); |
|
646 | +$profid['IDPROF4'][0] = $langs->trans("ProfId4"); |
|
647 | +$profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code); |
|
648 | +$profid['IDPROF5'][0] = $langs->trans("ProfId5"); |
|
649 | +$profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code); |
|
650 | +$profid['IDPROF6'][0] = $langs->trans("ProfId6"); |
|
651 | +$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code); |
|
652 | +$profid['EMAIL'][0] = $langs->trans("EMail"); |
|
653 | +$profid['EMAIL'][1] = $langs->trans('Email'); |
|
654 | + |
|
655 | +$nbofloop = count($profid); |
|
656 | +foreach ($profid as $key => $val) |
|
657 | +{ |
|
658 | + if ($profid[$key][1] != '-') |
|
659 | 659 | { |
660 | 660 | print '<tr class="oddeven">'; |
661 | 661 | print '<td>'.$profid[$key][0]."</td><td>\n"; |
662 | 662 | print $profid[$key][1]; |
663 | 663 | print '</td>'; |
664 | 664 | |
665 | - $idprof_unique ='SOCIETE_'.$key.'_UNIQUE'; |
|
666 | - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; |
|
667 | - $idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; |
|
665 | + $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE'; |
|
666 | + $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY'; |
|
667 | + $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; |
|
668 | 668 | |
669 | - $verif=(empty($conf->global->$idprof_unique)?false:true); |
|
670 | - $mandatory=(empty($conf->global->$idprof_mandatory)?false:true); |
|
671 | - $invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true); |
|
669 | + $verif = (empty($conf->global->$idprof_unique) ?false:true); |
|
670 | + $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true); |
|
671 | + $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true); |
|
672 | 672 | |
673 | 673 | if ($verif) |
674 | 674 | { |
675 | 675 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=0">'; |
676 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
676 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
677 | 677 | print '</a></td>'; |
678 | 678 | } |
679 | 679 | else |
680 | 680 | { |
681 | 681 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofid&value='.$key.'&status=1">'; |
682 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
682 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
683 | 683 | print '</a></td>'; |
684 | 684 | } |
685 | 685 | |
686 | 686 | if ($mandatory) |
687 | 687 | { |
688 | 688 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=0">'; |
689 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
689 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
690 | 690 | print '</a></td>'; |
691 | 691 | } |
692 | 692 | else |
693 | 693 | { |
694 | 694 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidmandatory&value='.$key.'&status=1">'; |
695 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
695 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
696 | 696 | print '</a></td>'; |
697 | 697 | } |
698 | 698 | |
699 | 699 | if ($invoice_mandatory) |
700 | 700 | { |
701 | 701 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=0">'; |
702 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
702 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
703 | 703 | print '</a></td>'; |
704 | 704 | } |
705 | 705 | else |
706 | 706 | { |
707 | 707 | print '<td align="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setprofidinvoicemandatory&value='.$key.'&status=1">'; |
708 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
708 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
709 | 709 | print '</a></td>'; |
710 | 710 | } |
711 | 711 | |
@@ -717,10 +717,10 @@ discard block |
||
717 | 717 | print "</table><br>\n"; |
718 | 718 | |
719 | 719 | |
720 | -print load_fiche_titre($langs->trans("Other"),'',''); |
|
720 | +print load_fiche_titre($langs->trans("Other"), '', ''); |
|
721 | 721 | |
722 | 722 | // Autres options |
723 | -$form=new Form($db); |
|
723 | +$form = new Form($db); |
|
724 | 724 | |
725 | 725 | print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; |
726 | 726 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
@@ -735,8 +735,8 @@ discard block |
||
735 | 735 | // Utilisation formulaire Ajax sur choix societe |
736 | 736 | |
737 | 737 | print '<tr class="oddeven">'; |
738 | -print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"),$langs->trans('UseSearchToSelectCompanyTooltip'),1).' </td>'; |
|
739 | -if (! $conf->use_javascript_ajax) |
|
738 | +print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' </td>'; |
|
739 | +if (!$conf->use_javascript_ajax) |
|
740 | 740 | { |
741 | 741 | print '<td class="nowrap" align="right" colspan="2">'; |
742 | 742 | print $langs->trans("NotAvailableWhenAjaxDisabled"); |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | else |
746 | 746 | { |
747 | 747 | print '<td width="60" align="right">'; |
748 | - $arrval=array('0'=>$langs->trans("No"), |
|
749 | - '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
750 | - '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', |
|
751 | - '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', |
|
748 | + $arrval = array('0'=>$langs->trans("No"), |
|
749 | + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', |
|
750 | + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', |
|
751 | + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', |
|
752 | 752 | ); |
753 | 753 | print $form->selectarray("activate_COMPANY_USE_SEARCH_TO_SELECT", $arrval, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); |
754 | 754 | print '</td><td align="right">'; |
@@ -759,8 +759,8 @@ discard block |
||
759 | 759 | |
760 | 760 | |
761 | 761 | print '<tr class="oddeven">'; |
762 | -print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"),$langs->trans('UseSearchToSelectContactTooltip'),1).'</td>'; |
|
763 | -if (! $conf->use_javascript_ajax) |
|
762 | +print '<td width="80%">'.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).'</td>'; |
|
763 | +if (!$conf->use_javascript_ajax) |
|
764 | 764 | { |
765 | 765 | print '<td class="nowrap" align="right" colspan="2">'; |
766 | 766 | print $langs->trans("NotAvailableWhenAjaxDisabled"); |
@@ -769,10 +769,10 @@ discard block |
||
769 | 769 | else |
770 | 770 | { |
771 | 771 | print '<td width="60" align="right">'; |
772 | - $arrval=array('0'=>$langs->trans("No"), |
|
773 | - '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', |
|
774 | - '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', |
|
775 | - '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', |
|
772 | + $arrval = array('0'=>$langs->trans("No"), |
|
773 | + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', |
|
774 | + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', |
|
775 | + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', |
|
776 | 776 | ); |
777 | 777 | print $form->selectarray("activate_CONTACT_USE_SEARCH_TO_SELECT", $arrval, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); |
778 | 778 | print '</td><td align="right">'; |
@@ -790,12 +790,12 @@ discard block |
||
790 | 790 | if (!empty($conf->global->SOCIETE_ADD_REF_IN_LIST)) |
791 | 791 | { |
792 | 792 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=0">'; |
793 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
793 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
794 | 794 | } |
795 | 795 | else |
796 | 796 | { |
797 | 797 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddrefinlist&value=1">'; |
798 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
798 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
799 | 799 | } |
800 | 800 | print '</a></td>'; |
801 | 801 | print '</tr>'; |
@@ -807,12 +807,12 @@ discard block |
||
807 | 807 | if (!empty($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST)) |
808 | 808 | { |
809 | 809 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=0">'; |
810 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
810 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
811 | 811 | } |
812 | 812 | else |
813 | 813 | { |
814 | 814 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaddadressinlist&value=1">'; |
815 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
815 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
816 | 816 | } |
817 | 817 | print '</a></td>'; |
818 | 818 | print '</tr>'; |
@@ -826,12 +826,12 @@ discard block |
||
826 | 826 | if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) |
827 | 827 | { |
828 | 828 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">'; |
829 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
829 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
830 | 830 | } |
831 | 831 | else |
832 | 832 | { |
833 | 833 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">'; |
834 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
834 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
835 | 835 | } |
836 | 836 | print '</a></td>'; |
837 | 837 | print '</tr>'; |
@@ -844,12 +844,12 @@ discard block |
||
844 | 844 | if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) |
845 | 845 | { |
846 | 846 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&value=0">'; |
847 | - print img_picto($langs->trans("Activated"),'switch_on'); |
|
847 | + print img_picto($langs->trans("Activated"), 'switch_on'); |
|
848 | 848 | } |
849 | 849 | else |
850 | 850 | { |
851 | 851 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisableprospectcustomer&value=1">'; |
852 | - print img_picto($langs->trans("Disabled"),'switch_off'); |
|
852 | + print img_picto($langs->trans("Disabled"), 'switch_off'); |
|
853 | 853 | } |
854 | 854 | print '</a></td>'; |
855 | 855 | print '</tr>'; |
@@ -36,13 +36,17 @@ |
||
36 | 36 | // List of supported format |
37 | 37 | $tmptype2label=ExtraFields::$type2label; |
38 | 38 | $type2label=array(''); |
39 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
39 | +foreach ($tmptype2label as $key => $val) { |
|
40 | + $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
41 | +} |
|
40 | 42 | |
41 | 43 | $action=GETPOST('action', 'alpha'); |
42 | 44 | $attrname=GETPOST('attrname', 'alpha'); |
43 | 45 | $elementtype='societe'; //Must be the $element of the class that manage extrafield |
44 | 46 | |
45 | -if (!$user->admin) accessforbidden(); |
|
47 | +if (!$user->admin) { |
|
48 | + accessforbidden(); |
|
49 | +} |
|
46 | 50 | |
47 | 51 | |
48 | 52 | /* |
@@ -27,7 +27,7 @@ discard block |
||
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 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
33 | 33 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | $form = new Form($db); |
38 | 38 | |
39 | 39 | // List of supported format |
40 | -$tmptype2label=ExtraFields::$type2label; |
|
41 | -$type2label=array(''); |
|
42 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
40 | +$tmptype2label = ExtraFields::$type2label; |
|
41 | +$type2label = array(''); |
|
42 | +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
43 | 43 | |
44 | -$action=GETPOST('action', 'alpha'); |
|
45 | -$attrname=GETPOST('attrname', 'alpha'); |
|
46 | -$elementtype='societe'; //Must be the $element of the class that manage extrafield |
|
44 | +$action = GETPOST('action', 'alpha'); |
|
45 | +$attrname = GETPOST('attrname', 'alpha'); |
|
46 | +$elementtype = 'societe'; //Must be the $element of the class that manage extrafield |
|
47 | 47 | |
48 | 48 | if (!$user->admin) accessforbidden(); |
49 | 49 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * View |
61 | 61 | */ |
62 | 62 | |
63 | -$textobject=$langs->transnoentitiesnoconv("ThirdParty"); |
|
63 | +$textobject = $langs->transnoentitiesnoconv("ThirdParty"); |
|
64 | 64 | |
65 | -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; |
|
66 | -llxHeader('',$langs->trans("CompanySetup"),$help_url); |
|
65 | +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; |
|
66 | +llxHeader('', $langs->trans("CompanySetup"), $help_url); |
|
67 | 67 | |
68 | 68 | |
69 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
70 | -print load_fiche_titre($langs->trans("CompanySetup"),$linkback,'title_setup'); |
|
69 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
70 | +print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | $head = societe_admin_prepare_head(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /* Edition d'un champ optionnel */ |
108 | 108 | /* */ |
109 | 109 | /* ************************************************************************** */ |
110 | -if ($action == 'edit' && ! empty($attrname)) |
|
110 | +if ($action == 'edit' && !empty($attrname)) |
|
111 | 111 | { |
112 | 112 | print '<br><div id="editattrib"></div>'; |
113 | 113 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
@@ -93,8 +93,8 @@ |
||
93 | 93 | |
94 | 94 | if ($action == 'create') |
95 | 95 | { |
96 | - print '<br><div id="newattrib"></div>'; |
|
97 | - print load_fiche_titre($langs->trans('NewAttribute')); |
|
96 | + print '<br><div id="newattrib"></div>'; |
|
97 | + print load_fiche_titre($langs->trans('NewAttribute')); |
|
98 | 98 | |
99 | 99 | require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; |
100 | 100 | } |
@@ -36,13 +36,17 @@ |
||
36 | 36 | // List of supported format |
37 | 37 | $tmptype2label=ExtraFields::$type2label; |
38 | 38 | $type2label=array(''); |
39 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
39 | +foreach ($tmptype2label as $key => $val) { |
|
40 | + $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
41 | +} |
|
40 | 42 | |
41 | 43 | $action=GETPOST('action', 'alpha'); |
42 | 44 | $attrname=GETPOST('attrname', 'alpha'); |
43 | 45 | $elementtype='socpeople'; //Must be the $element of the class that manage extrafield |
44 | 46 | |
45 | -if (!$user->admin) accessforbidden(); |
|
47 | +if (!$user->admin) { |
|
48 | + accessforbidden(); |
|
49 | +} |
|
46 | 50 | |
47 | 51 | |
48 | 52 | /* |
@@ -27,7 +27,7 @@ discard block |
||
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 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
32 | 32 | require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; |
33 | 33 | |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | $form = new Form($db); |
38 | 38 | |
39 | 39 | // List of supported format |
40 | -$tmptype2label=ExtraFields::$type2label; |
|
41 | -$type2label=array(''); |
|
42 | -foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->transnoentitiesnoconv($val); |
|
40 | +$tmptype2label = ExtraFields::$type2label; |
|
41 | +$type2label = array(''); |
|
42 | +foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); |
|
43 | 43 | |
44 | -$action=GETPOST('action', 'alpha'); |
|
45 | -$attrname=GETPOST('attrname', 'alpha'); |
|
46 | -$elementtype='socpeople'; //Must be the $element of the class that manage extrafield |
|
44 | +$action = GETPOST('action', 'alpha'); |
|
45 | +$attrname = GETPOST('attrname', 'alpha'); |
|
46 | +$elementtype = 'socpeople'; //Must be the $element of the class that manage extrafield |
|
47 | 47 | |
48 | 48 | if (!$user->admin) accessforbidden(); |
49 | 49 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * View |
61 | 61 | */ |
62 | 62 | |
63 | -$textobject=$langs->transnoentitiesnoconv("ContactsAddresses"); |
|
63 | +$textobject = $langs->transnoentitiesnoconv("ContactsAddresses"); |
|
64 | 64 | |
65 | -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; |
|
66 | -llxHeader('',$langs->trans("CompanySetup"),$help_url); |
|
65 | +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers'; |
|
66 | +llxHeader('', $langs->trans("CompanySetup"), $help_url); |
|
67 | 67 | |
68 | 68 | |
69 | -$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
70 | -print load_fiche_titre($langs->trans("CompanySetup"),$linkback,'title_setup'); |
|
69 | +$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>'; |
|
70 | +print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | $head = societe_admin_prepare_head(); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | /* Edition of an optional field */ |
108 | 108 | /* */ |
109 | 109 | /* ************************************************************************** */ |
110 | -if ($action == 'edit' && ! empty($attrname)) |
|
110 | +if ($action == 'edit' && !empty($attrname)) |
|
111 | 111 | { |
112 | 112 | print "<br>"; |
113 | 113 | print load_fiche_titre($langs->trans("FieldEdition", $attrname)); |
@@ -50,48 +50,48 @@ |
||
50 | 50 | |
51 | 51 | if (! empty($action) && $action == 'fetch' && ! empty($id)) |
52 | 52 | { |
53 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
53 | + require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
54 | 54 | |
55 | - $outjson=array(); |
|
55 | + $outjson=array(); |
|
56 | 56 | |
57 | - $object = new Societe($db); |
|
58 | - $ret=$object->fetch($id); |
|
59 | - if ($ret > 0) |
|
60 | - { |
|
61 | - $outname=$object->name; |
|
62 | - $outlabel = ''; |
|
63 | - $outdesc = ''; |
|
64 | - $outtype = $object->type; |
|
57 | + $object = new Societe($db); |
|
58 | + $ret=$object->fetch($id); |
|
59 | + if ($ret > 0) |
|
60 | + { |
|
61 | + $outname=$object->name; |
|
62 | + $outlabel = ''; |
|
63 | + $outdesc = ''; |
|
64 | + $outtype = $object->type; |
|
65 | 65 | |
66 | - $outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype); |
|
67 | - } |
|
66 | + $outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype); |
|
67 | + } |
|
68 | 68 | |
69 | - echo json_encode($outjson); |
|
69 | + echo json_encode($outjson); |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
73 | + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
|
74 | 74 | |
75 | - $langs->load("companies"); |
|
75 | + $langs->load("companies"); |
|
76 | 76 | |
77 | - top_httphead(); |
|
77 | + top_httphead(); |
|
78 | 78 | |
79 | - if (empty($htmlname)) return; |
|
79 | + if (empty($htmlname)) return; |
|
80 | 80 | |
81 | - $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); |
|
82 | - sort($match); |
|
83 | - $id = (! empty($match[0]) ? $match[0] : ''); |
|
81 | + $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); |
|
82 | + sort($match); |
|
83 | + $id = (! empty($match[0]) ? $match[0] : ''); |
|
84 | 84 | |
85 | - // When used from jQuery, the search term is added as GET param "term". |
|
86 | - $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):'')); |
|
85 | + // When used from jQuery, the search term is added as GET param "term". |
|
86 | + $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):'')); |
|
87 | 87 | |
88 | - if (! $searchkey) return; |
|
88 | + if (! $searchkey) return; |
|
89 | 89 | |
90 | - if (! is_object($form)) $form = new Form($db); |
|
91 | - $arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); |
|
90 | + if (! is_object($form)) $form = new Form($db); |
|
91 | + $arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); |
|
92 | 92 | |
93 | - $db->close(); |
|
93 | + $db->close(); |
|
94 | 94 | |
95 | - if ($outjson) print json_encode($arrayresult); |
|
95 | + if ($outjson) print json_encode($arrayresult); |
|
96 | 96 | } |
97 | 97 |
@@ -22,12 +22,25 @@ discard block |
||
22 | 22 | * \brief File to return Ajax response on thirdparty list 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 | |
33 | 46 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
@@ -70,8 +83,7 @@ discard block |
||
70 | 83 | } |
71 | 84 | |
72 | 85 | echo json_encode($outjson); |
73 | -} |
|
74 | -else |
|
86 | +} else |
|
75 | 87 | { |
76 | 88 | require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; |
77 | 89 | |
@@ -79,7 +91,9 @@ discard block |
||
79 | 91 | |
80 | 92 | top_httphead(); |
81 | 93 | |
82 | - if (empty($htmlname)) return; |
|
94 | + if (empty($htmlname)) { |
|
95 | + return; |
|
96 | + } |
|
83 | 97 | |
84 | 98 | $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); |
85 | 99 | sort($match); |
@@ -88,13 +102,19 @@ discard block |
||
88 | 102 | // When used from jQuery, the search term is added as GET param "term". |
89 | 103 | $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):'')); |
90 | 104 | |
91 | - if (! $searchkey) return; |
|
105 | + if (! $searchkey) { |
|
106 | + return; |
|
107 | + } |
|
92 | 108 | |
93 | - if (! is_object($form)) $form = new Form($db); |
|
109 | + if (! is_object($form)) { |
|
110 | + $form = new Form($db); |
|
111 | + } |
|
94 | 112 | $arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); |
95 | 113 | |
96 | 114 | $db->close(); |
97 | 115 | |
98 | - if ($outjson) print json_encode($arrayresult); |
|
99 | -} |
|
116 | + if ($outjson) { |
|
117 | + print json_encode($arrayresult); |
|
118 | + } |
|
119 | + } |
|
100 | 120 |
@@ -22,24 +22,24 @@ discard block |
||
22 | 22 | * \brief File to return Ajax response on thirdparty list 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 | |
33 | 33 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
34 | 34 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
35 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
35 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
36 | 36 | |
37 | -$htmlname=GETPOST('htmlname','alpha'); |
|
38 | -$filter=GETPOST('filter','alpha'); |
|
39 | -$outjson=(GETPOST('outjson','int') ? GETPOST('outjson','int') : 0); |
|
40 | -$action=GETPOST('action', 'alpha'); |
|
41 | -$id=GETPOST('id', 'int'); |
|
42 | -$showtype=GETPOST('showtype','int'); |
|
37 | +$htmlname = GETPOST('htmlname', 'alpha'); |
|
38 | +$filter = GETPOST('filter', 'alpha'); |
|
39 | +$outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0); |
|
40 | +$action = GETPOST('action', 'alpha'); |
|
41 | +$id = GETPOST('id', 'int'); |
|
42 | +$showtype = GETPOST('showtype', 'int'); |
|
43 | 43 | |
44 | 44 | |
45 | 45 | /* |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | dol_syslog(join(',', $_GET)); |
52 | 52 | //print_r($_GET); |
53 | 53 | |
54 | -if (! empty($action) && $action == 'fetch' && ! empty($id)) |
|
54 | +if (!empty($action) && $action == 'fetch' && !empty($id)) |
|
55 | 55 | { |
56 | - require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
56 | + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
57 | 57 | |
58 | - $outjson=array(); |
|
58 | + $outjson = array(); |
|
59 | 59 | |
60 | 60 | $object = new Societe($db); |
61 | - $ret=$object->fetch($id); |
|
61 | + $ret = $object->fetch($id); |
|
62 | 62 | if ($ret > 0) |
63 | 63 | { |
64 | - $outname=$object->name; |
|
64 | + $outname = $object->name; |
|
65 | 65 | $outlabel = ''; |
66 | 66 | $outdesc = ''; |
67 | 67 | $outtype = $object->type; |
68 | 68 | |
69 | - $outjson = array('ref' => $outref,'name' => $outname,'desc' => $outdesc,'type' => $outtype); |
|
69 | + $outjson = array('ref' => $outref, 'name' => $outname, 'desc' => $outdesc, 'type' => $outtype); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | echo json_encode($outjson); |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | |
82 | 82 | if (empty($htmlname)) return; |
83 | 83 | |
84 | - $match = preg_grep('/('.$htmlname.'[0-9]+)/',array_keys($_GET)); |
|
84 | + $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET)); |
|
85 | 85 | sort($match); |
86 | - $id = (! empty($match[0]) ? $match[0] : ''); |
|
86 | + $id = (!empty($match[0]) ? $match[0] : ''); |
|
87 | 87 | |
88 | 88 | // When used from jQuery, the search term is added as GET param "term". |
89 | - $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):'')); |
|
89 | + $searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : '')); |
|
90 | 90 | |
91 | - if (! $searchkey) return; |
|
91 | + if (!$searchkey) return; |
|
92 | 92 | |
93 | - if (! is_object($form)) $form = new Form($db); |
|
94 | - $arrayresult=$form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); |
|
93 | + if (!is_object($form)) $form = new Form($db); |
|
94 | + $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson); |
|
95 | 95 | |
96 | 96 | $db->close(); |
97 | 97 |
@@ -49,117 +49,117 @@ discard block |
||
49 | 49 | |
50 | 50 | if (! $vatNumber) |
51 | 51 | { |
52 | - print '<br>'; |
|
53 | - print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>'; |
|
52 | + print '<br>'; |
|
53 | + print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>'; |
|
54 | 54 | } |
55 | 55 | else |
56 | 56 | { |
57 | - $vatNumber = preg_replace('/\^\w/', '', $vatNumber); |
|
58 | - $countryCode=substr($vatNumber,0,2); |
|
59 | - $vatNumber=substr($vatNumber,2); |
|
57 | + $vatNumber = preg_replace('/\^\w/', '', $vatNumber); |
|
58 | + $countryCode=substr($vatNumber,0,2); |
|
59 | + $vatNumber=substr($vatNumber,2); |
|
60 | 60 | |
61 | - print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>'; |
|
62 | - print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>'; |
|
63 | - print '<br>'; |
|
61 | + print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>'; |
|
62 | + print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>'; |
|
63 | + print '<br>'; |
|
64 | 64 | |
65 | - // Set the parameters to send to the WebService |
|
66 | - $parameters = array("countryCode" => $countryCode, |
|
67 | - "vatNumber" => $vatNumber); |
|
65 | + // Set the parameters to send to the WebService |
|
66 | + $parameters = array("countryCode" => $countryCode, |
|
67 | + "vatNumber" => $vatNumber); |
|
68 | 68 | |
69 | - // Set the WebService URL |
|
70 | - dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL); |
|
69 | + // Set the WebService URL |
|
70 | + dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL); |
|
71 | 71 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
72 | 72 | $params=getSoapParams(); |
73 | 73 | //ini_set('default_socket_timeout', $params['response_timeout']); |
74 | 74 | //$soapclient = new SoapClient($WS_DOL_URL_WSDL,$params); |
75 | - $soapclient = new nusoap_client($WS_DOL_URL_WSDL,true,$params['proxy_host'],$params['proxy_port'],$params['proxy_login'],$params['proxy_password'],$params['connection_timeout'],$params['response_timeout']); |
|
76 | - $soapclient->soap_defencoding = 'utf-8'; |
|
77 | - $soapclient->xml_encoding = 'utf-8'; |
|
78 | - $soapclient->decode_utf8 = false; |
|
79 | - |
|
80 | - // Check for an error |
|
81 | - $err = $soapclient->getError(); |
|
82 | - if ($err) |
|
83 | - { |
|
84 | - dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR); |
|
85 | - } |
|
86 | - |
|
87 | - // Call the WebService and store its result in $result. |
|
88 | - dol_syslog("Call method ".$WS_METHOD); |
|
89 | - $result = $soapclient->call($WS_METHOD,$parameters); |
|
90 | - |
|
91 | - //var_dump($parameters); |
|
92 | - //var_dump($soapclient); |
|
93 | - //print "x".is_array($result)."i"; |
|
94 | - //var_dump($result); |
|
95 | - //print $soapclient->request.'<br>'; |
|
96 | - //print $soapclient->response.'<br>'; |
|
97 | - |
|
98 | - $messagetoshow=''; |
|
99 | - print '<b>'.$langs->trans("Response").'</b>:<br>'; |
|
100 | - |
|
101 | - // Service indisponible |
|
102 | - if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring'])) |
|
103 | - { |
|
104 | - print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
|
105 | - $messagetoshow=$soapclient->response; |
|
106 | - } |
|
107 | - elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
108 | - { |
|
109 | - print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
|
110 | - $messagetoshow=$soapclient->response; |
|
111 | - } |
|
112 | - elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
113 | - { |
|
114 | - print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
|
115 | - $messagetoshow=$soapclient->response; |
|
116 | - } |
|
117 | - elseif ($result['faultstring']) |
|
118 | - { |
|
119 | - print '<font class="error">'.$langs->trans("Error").'</font><br>'; |
|
120 | - $messagetoshow=$result['faultstring']; |
|
121 | - } |
|
122 | - // Syntaxe ko |
|
123 | - elseif (preg_match('/INVALID_INPUT/i',$result['faultstring']) |
|
124 | - || ($result['requestDate'] && ! $result['valid'])) |
|
125 | - { |
|
126 | - if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
127 | - print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
|
128 | - print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
|
129 | - //$messagetoshow=$soapclient->response; |
|
130 | - } |
|
131 | - else |
|
132 | - { |
|
133 | - // Syntaxe ok |
|
134 | - if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
135 | - print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>'; |
|
136 | - print $langs->trans("ValueIsValid").': '; |
|
137 | - if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring'])) |
|
138 | - { |
|
139 | - print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>'; |
|
140 | - } |
|
141 | - else |
|
142 | - { |
|
143 | - if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true')) |
|
144 | - { |
|
145 | - print '<font class="ok">'.$langs->trans("Yes").'</font>'; |
|
146 | - print '<br>'; |
|
147 | - print $langs->trans("Name").': '.$result['name'].'<br>'; |
|
148 | - print $langs->trans("Address").': '.$result['address'].'<br>'; |
|
149 | - } |
|
150 | - else |
|
151 | - { |
|
152 | - print '<font class="error">'.$langs->trans("No").'</font>'; |
|
153 | - print '<br>'."\n"; |
|
154 | - } |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - // Show log data into page |
|
159 | - print "\n"; |
|
160 | - print '<!-- '; |
|
161 | - var_dump($result); |
|
162 | - print '-->'; |
|
75 | + $soapclient = new nusoap_client($WS_DOL_URL_WSDL,true,$params['proxy_host'],$params['proxy_port'],$params['proxy_login'],$params['proxy_password'],$params['connection_timeout'],$params['response_timeout']); |
|
76 | + $soapclient->soap_defencoding = 'utf-8'; |
|
77 | + $soapclient->xml_encoding = 'utf-8'; |
|
78 | + $soapclient->decode_utf8 = false; |
|
79 | + |
|
80 | + // Check for an error |
|
81 | + $err = $soapclient->getError(); |
|
82 | + if ($err) |
|
83 | + { |
|
84 | + dol_syslog("Constructor error ".$WS_DOL_URL, LOG_ERR); |
|
85 | + } |
|
86 | + |
|
87 | + // Call the WebService and store its result in $result. |
|
88 | + dol_syslog("Call method ".$WS_METHOD); |
|
89 | + $result = $soapclient->call($WS_METHOD,$parameters); |
|
90 | + |
|
91 | + //var_dump($parameters); |
|
92 | + //var_dump($soapclient); |
|
93 | + //print "x".is_array($result)."i"; |
|
94 | + //var_dump($result); |
|
95 | + //print $soapclient->request.'<br>'; |
|
96 | + //print $soapclient->response.'<br>'; |
|
97 | + |
|
98 | + $messagetoshow=''; |
|
99 | + print '<b>'.$langs->trans("Response").'</b>:<br>'; |
|
100 | + |
|
101 | + // Service indisponible |
|
102 | + if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring'])) |
|
103 | + { |
|
104 | + print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
|
105 | + $messagetoshow=$soapclient->response; |
|
106 | + } |
|
107 | + elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
108 | + { |
|
109 | + print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
|
110 | + $messagetoshow=$soapclient->response; |
|
111 | + } |
|
112 | + elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
113 | + { |
|
114 | + print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
|
115 | + $messagetoshow=$soapclient->response; |
|
116 | + } |
|
117 | + elseif ($result['faultstring']) |
|
118 | + { |
|
119 | + print '<font class="error">'.$langs->trans("Error").'</font><br>'; |
|
120 | + $messagetoshow=$result['faultstring']; |
|
121 | + } |
|
122 | + // Syntaxe ko |
|
123 | + elseif (preg_match('/INVALID_INPUT/i',$result['faultstring']) |
|
124 | + || ($result['requestDate'] && ! $result['valid'])) |
|
125 | + { |
|
126 | + if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
127 | + print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
|
128 | + print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
|
129 | + //$messagetoshow=$soapclient->response; |
|
130 | + } |
|
131 | + else |
|
132 | + { |
|
133 | + // Syntaxe ok |
|
134 | + if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
135 | + print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>'; |
|
136 | + print $langs->trans("ValueIsValid").': '; |
|
137 | + if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring'])) |
|
138 | + { |
|
139 | + print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>'; |
|
140 | + } |
|
141 | + else |
|
142 | + { |
|
143 | + if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true')) |
|
144 | + { |
|
145 | + print '<font class="ok">'.$langs->trans("Yes").'</font>'; |
|
146 | + print '<br>'; |
|
147 | + print $langs->trans("Name").': '.$result['name'].'<br>'; |
|
148 | + print $langs->trans("Address").': '.$result['address'].'<br>'; |
|
149 | + } |
|
150 | + else |
|
151 | + { |
|
152 | + print '<font class="error">'.$langs->trans("No").'</font>'; |
|
153 | + print '<br>'."\n"; |
|
154 | + } |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + // Show log data into page |
|
159 | + print "\n"; |
|
160 | + print '<!-- '; |
|
161 | + var_dump($result); |
|
162 | + print '-->'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | print '<br>'; |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | |
170 | 170 | if ($messagetoshow) |
171 | 171 | { |
172 | - print '<br><br>'; |
|
173 | - print "\n".'Error returned:<br>'; |
|
174 | - print nl2br($messagetoshow); |
|
172 | + print '<br><br>'; |
|
173 | + print "\n".'Error returned:<br>'; |
|
174 | + print nl2br($messagetoshow); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | // End of page |
@@ -28,35 +28,35 @@ discard block |
||
28 | 28 | $langs->load("companies"); |
29 | 29 | |
30 | 30 | //http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl |
31 | -$WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService'; |
|
31 | +$WS_DOL_URL = 'http://ec.europa.eu/taxation_customs/vies/services/checkVatService'; |
|
32 | 32 | //$WS_DOL_URL_WSDL=$WS_DOL_URL.'?wsdl'; |
33 | -$WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'; |
|
34 | -$WS_METHOD ='checkVat'; |
|
33 | +$WS_DOL_URL_WSDL = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl'; |
|
34 | +$WS_METHOD = 'checkVat'; |
|
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | -$conf->dol_hide_topmenu=1; |
|
39 | -$conf->dol_hide_leftmenu=1; |
|
38 | +$conf->dol_hide_topmenu = 1; |
|
39 | +$conf->dol_hide_leftmenu = 1; |
|
40 | 40 | |
41 | 41 | llxHeader('', $langs->trans("VATIntraCheckableOnEUSite")); |
42 | 42 | |
43 | 43 | print '<div>'; |
44 | 44 | print '<div>'; |
45 | 45 | |
46 | -print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"),'','title_setup'); |
|
46 | +print load_fiche_titre($langs->trans("VATIntraCheckableOnEUSite"), '', 'title_setup'); |
|
47 | 47 | |
48 | -$vatNumber = GETPOST("vatNumber",'alpha'); |
|
48 | +$vatNumber = GETPOST("vatNumber", 'alpha'); |
|
49 | 49 | |
50 | -if (! $vatNumber) |
|
50 | +if (!$vatNumber) |
|
51 | 51 | { |
52 | 52 | print '<br>'; |
53 | - print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>'; |
|
53 | + print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired", $langs->trans("VATIntraShort")).'</font><br>'; |
|
54 | 54 | } |
55 | 55 | else |
56 | 56 | { |
57 | 57 | $vatNumber = preg_replace('/\^\w/', '', $vatNumber); |
58 | - $countryCode=substr($vatNumber,0,2); |
|
59 | - $vatNumber=substr($vatNumber,2); |
|
58 | + $countryCode = substr($vatNumber, 0, 2); |
|
59 | + $vatNumber = substr($vatNumber, 2); |
|
60 | 60 | |
61 | 61 | print '<b>'.$langs->trans("Country").'</b>: '.$countryCode.'<br>'; |
62 | 62 | print '<b>'.$langs->trans("VATIntraShort").'</b>: '.$vatNumber.'<br>'; |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | // Set the WebService URL |
70 | 70 | dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL." WSDL=".$WS_DOL_URL_WSDL); |
71 | 71 | require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; |
72 | - $params=getSoapParams(); |
|
72 | + $params = getSoapParams(); |
|
73 | 73 | //ini_set('default_socket_timeout', $params['response_timeout']); |
74 | 74 | //$soapclient = new SoapClient($WS_DOL_URL_WSDL,$params); |
75 | - $soapclient = new nusoap_client($WS_DOL_URL_WSDL,true,$params['proxy_host'],$params['proxy_port'],$params['proxy_login'],$params['proxy_password'],$params['connection_timeout'],$params['response_timeout']); |
|
75 | + $soapclient = new nusoap_client($WS_DOL_URL_WSDL, true, $params['proxy_host'], $params['proxy_port'], $params['proxy_login'], $params['proxy_password'], $params['connection_timeout'], $params['response_timeout']); |
|
76 | 76 | $soapclient->soap_defencoding = 'utf-8'; |
77 | 77 | $soapclient->xml_encoding = 'utf-8'; |
78 | 78 | $soapclient->decode_utf8 = false; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | // Call the WebService and store its result in $result. |
88 | 88 | dol_syslog("Call method ".$WS_METHOD); |
89 | - $result = $soapclient->call($WS_METHOD,$parameters); |
|
89 | + $result = $soapclient->call($WS_METHOD, $parameters); |
|
90 | 90 | |
91 | 91 | //var_dump($parameters); |
92 | 92 | //var_dump($soapclient); |
@@ -95,33 +95,33 @@ discard block |
||
95 | 95 | //print $soapclient->request.'<br>'; |
96 | 96 | //print $soapclient->response.'<br>'; |
97 | 97 | |
98 | - $messagetoshow=''; |
|
98 | + $messagetoshow = ''; |
|
99 | 99 | print '<b>'.$langs->trans("Response").'</b>:<br>'; |
100 | 100 | |
101 | 101 | // Service indisponible |
102 | - if (! is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i',$result['faultstring'])) |
|
102 | + if (!is_array($result) || preg_match('/SERVICE_UNAVAILABLE/i', $result['faultstring'])) |
|
103 | 103 | { |
104 | 104 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
105 | - $messagetoshow=$soapclient->response; |
|
105 | + $messagetoshow = $soapclient->response; |
|
106 | 106 | } |
107 | - elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
107 | + elseif (preg_match('/TIMEOUT/i', $result['faultstring'])) |
|
108 | 108 | { |
109 | 109 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
110 | - $messagetoshow=$soapclient->response; |
|
110 | + $messagetoshow = $soapclient->response; |
|
111 | 111 | } |
112 | - elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
112 | + elseif (preg_match('/SERVER_BUSY/i', $result['faultstring'])) |
|
113 | 113 | { |
114 | 114 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
115 | - $messagetoshow=$soapclient->response; |
|
115 | + $messagetoshow = $soapclient->response; |
|
116 | 116 | } |
117 | 117 | elseif ($result['faultstring']) |
118 | 118 | { |
119 | 119 | print '<font class="error">'.$langs->trans("Error").'</font><br>'; |
120 | - $messagetoshow=$result['faultstring']; |
|
120 | + $messagetoshow = $result['faultstring']; |
|
121 | 121 | } |
122 | 122 | // Syntaxe ko |
123 | - elseif (preg_match('/INVALID_INPUT/i',$result['faultstring']) |
|
124 | - || ($result['requestDate'] && ! $result['valid'])) |
|
123 | + elseif (preg_match('/INVALID_INPUT/i', $result['faultstring']) |
|
124 | + || ($result['requestDate'] && !$result['valid'])) |
|
125 | 125 | { |
126 | 126 | if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
127 | 127 | print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
135 | 135 | print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>'; |
136 | 136 | print $langs->trans("ValueIsValid").': '; |
137 | - if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring'])) |
|
137 | + if (preg_match('/MS_UNAVAILABLE/i', $result['faultstring'])) |
|
138 | 138 | { |
139 | - print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>'; |
|
139 | + print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE", $countryCode).'</font><br>'; |
|
140 | 140 | } |
141 | 141 | else |
142 | 142 | { |
143 | - if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true')) |
|
143 | + if (!empty($result['valid']) && ($result['valid'] == 1 || $result['valid'] == 'true')) |
|
144 | 144 | { |
145 | 145 | print '<font class="ok">'.$langs->trans("Yes").'</font>'; |
146 | 146 | print '<br>'; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | print '<br>'; |
166 | -print $langs->trans("VATIntraManualCheck",$langs->trans("VATIntraCheckURL"),$langs->trans("VATIntraCheckURL")).'<br>'; |
|
166 | +print $langs->trans("VATIntraManualCheck", $langs->trans("VATIntraCheckURL"), $langs->trans("VATIntraCheckURL")).'<br>'; |
|
167 | 167 | print '<br>'; |
168 | 168 | print '<div class="center"><input type="button" class="button" value="'.$langs->trans("CloseWindow").'" onclick="javascript: window.close()"></div>'; |
169 | 169 |
@@ -51,8 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | print '<br>'; |
53 | 53 | print '<font class="error">'.$langs->transnoentities("ErrorFieldRequired",$langs->trans("VATIntraShort")).'</font><br>'; |
54 | -} |
|
55 | -else |
|
54 | +} else |
|
56 | 55 | { |
57 | 56 | $vatNumber = preg_replace('/\^\w/', '', $vatNumber); |
58 | 57 | $countryCode=substr($vatNumber,0,2); |
@@ -103,18 +102,15 @@ discard block |
||
103 | 102 | { |
104 | 103 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
105 | 104 | $messagetoshow=$soapclient->response; |
106 | - } |
|
107 | - elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
105 | + } elseif (preg_match('/TIMEOUT/i',$result['faultstring'])) |
|
108 | 106 | { |
109 | 107 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
110 | 108 | $messagetoshow=$soapclient->response; |
111 | - } |
|
112 | - elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
109 | + } elseif (preg_match('/SERVER_BUSY/i',$result['faultstring'])) |
|
113 | 110 | { |
114 | 111 | print '<font class="error">'.$langs->trans("ErrorServiceUnavailableTryLater").'</font><br>'; |
115 | 112 | $messagetoshow=$soapclient->response; |
116 | - } |
|
117 | - elseif ($result['faultstring']) |
|
113 | + } elseif ($result['faultstring']) |
|
118 | 114 | { |
119 | 115 | print '<font class="error">'.$langs->trans("Error").'</font><br>'; |
120 | 116 | $messagetoshow=$result['faultstring']; |
@@ -123,22 +119,24 @@ discard block |
||
123 | 119 | elseif (preg_match('/INVALID_INPUT/i',$result['faultstring']) |
124 | 120 | || ($result['requestDate'] && ! $result['valid'])) |
125 | 121 | { |
126 | - if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
122 | + if ($result['requestDate']) { |
|
123 | + print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
124 | + } |
|
127 | 125 | print $langs->trans("VATIntraSyntaxIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
128 | 126 | print $langs->trans("ValueIsValid").': <font class="error">'.$langs->trans("No").'</font> (Might be a non europeen VAT)<br>'; |
129 | 127 | //$messagetoshow=$soapclient->response; |
130 | - } |
|
131 | - else |
|
128 | + } else |
|
132 | 129 | { |
133 | 130 | // Syntaxe ok |
134 | - if ($result['requestDate']) print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
131 | + if ($result['requestDate']) { |
|
132 | + print $langs->trans("Date").': '.$result['requestDate'].'<br>'; |
|
133 | + } |
|
135 | 134 | print $langs->trans("VATIntraSyntaxIsValid").': <font class="ok">'.$langs->trans("Yes").'</font><br>'; |
136 | 135 | print $langs->trans("ValueIsValid").': '; |
137 | 136 | if (preg_match('/MS_UNAVAILABLE/i',$result['faultstring'])) |
138 | 137 | { |
139 | 138 | print '<font class="error">'.$langs->trans("ErrorVATCheckMS_UNAVAILABLE",$countryCode).'</font><br>'; |
140 | - } |
|
141 | - else |
|
139 | + } else |
|
142 | 140 | { |
143 | 141 | if (! empty($result['valid']) && ($result['valid']==1 || $result['valid']=='true')) |
144 | 142 | { |
@@ -146,8 +144,7 @@ discard block |
||
146 | 144 | print '<br>'; |
147 | 145 | print $langs->trans("Name").': '.$result['name'].'<br>'; |
148 | 146 | print $langs->trans("Address").': '.$result['address'].'<br>'; |
149 | - } |
|
150 | - else |
|
147 | + } else |
|
151 | 148 | { |
152 | 149 | print '<font class="error">'.$langs->trans("No").'</font>'; |
153 | 150 | print '<br>'."\n"; |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | |
72 | 72 | if (! empty($conf->stripe->enabled)) |
73 | 73 | { |
74 | - $service = 'StripeTest'; |
|
75 | - $servicestatus = 0; |
|
76 | - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) |
|
77 | - { |
|
78 | - $service = 'StripeLive'; |
|
79 | - $servicestatus = 1; |
|
80 | - } |
|
81 | - |
|
82 | - $stripe = new Stripe($db); |
|
83 | - $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) |
|
84 | - $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) |
|
74 | + $service = 'StripeTest'; |
|
75 | + $servicestatus = 0; |
|
76 | + if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) |
|
77 | + { |
|
78 | + $service = 'StripeLive'; |
|
79 | + $servicestatus = 1; |
|
80 | + } |
|
81 | + |
|
82 | + $stripe = new Stripe($db); |
|
83 | + $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) |
|
84 | + $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | if ($cancel) |
94 | 94 | { |
95 | - $action=''; |
|
95 | + $action=''; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); |
@@ -101,546 +101,546 @@ discard block |
||
101 | 101 | |
102 | 102 | if (empty($reshook)) |
103 | 103 | { |
104 | - if ($cancel) |
|
105 | - { |
|
106 | - $action=''; |
|
107 | - if (! empty($backtopage)) |
|
108 | - { |
|
109 | - header("Location: ".$backtopage); |
|
110 | - exit; |
|
111 | - } |
|
112 | - } |
|
113 | - |
|
114 | - if ($action == 'update') |
|
115 | - { |
|
116 | - // Modification |
|
117 | - if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
|
118 | - { |
|
119 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
120 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
121 | - $action='edit'; |
|
122 | - $error++; |
|
123 | - } |
|
124 | - if ($companybankaccount->needIBAN() == 1) |
|
125 | - { |
|
126 | - if (! GETPOST('iban')) |
|
127 | - { |
|
128 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); |
|
129 | - $action='edit'; |
|
130 | - $error++; |
|
131 | - } |
|
132 | - if (! GETPOST('bic')) |
|
133 | - { |
|
134 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); |
|
135 | - $action='edit'; |
|
136 | - $error++; |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - $companybankaccount->fetch($id); |
|
141 | - if (! $error) |
|
142 | - { |
|
143 | - $companybankaccount->socid = $object->id; |
|
144 | - |
|
145 | - $companybankaccount->bank = GETPOST('bank','alpha'); |
|
146 | - $companybankaccount->label = GETPOST('label','alpha'); |
|
147 | - $companybankaccount->courant = GETPOST('courant','alpha'); |
|
148 | - $companybankaccount->clos = GETPOST('clos','alpha'); |
|
149 | - $companybankaccount->code_banque = GETPOST('code_banque','alpha'); |
|
150 | - $companybankaccount->code_guichet = GETPOST('code_guichet','alpha'); |
|
151 | - $companybankaccount->number = GETPOST('number','alpha'); |
|
152 | - $companybankaccount->cle_rib = GETPOST('cle_rib','alpha'); |
|
153 | - $companybankaccount->bic = GETPOST('bic','alpha'); |
|
154 | - $companybankaccount->iban = GETPOST('iban','alpha'); |
|
155 | - $companybankaccount->domiciliation = GETPOST('domiciliation','alpha'); |
|
156 | - $companybankaccount->proprio = GETPOST('proprio','alpha'); |
|
157 | - $companybankaccount->owner_address = GETPOST('owner_address','alpha'); |
|
158 | - $companybankaccount->frstrecur = GETPOST('frstrecur','alpha'); |
|
159 | - $companybankaccount->rum = GETPOST('rum','alpha'); |
|
160 | - if (empty($companybankaccount->rum)) |
|
161 | - { |
|
162 | - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
163 | - $companybankaccount->date_rum = dol_now(); |
|
164 | - } |
|
165 | - |
|
166 | - $result = $companybankaccount->update($user); |
|
167 | - if (! $result) |
|
168 | - { |
|
169 | - setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
170 | - } |
|
171 | - else |
|
172 | - { |
|
173 | - // If this account is the default bank account, we disable others |
|
174 | - if ($companybankaccount->default_rib) |
|
175 | - { |
|
176 | - $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib |
|
177 | - } |
|
178 | - |
|
179 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
180 | - header('Location: '.$url); |
|
181 | - exit; |
|
182 | - } |
|
183 | - } |
|
184 | - } |
|
185 | - |
|
186 | - if ($action == 'updatecard') |
|
187 | - { |
|
188 | - // Modification |
|
189 | - if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
|
190 | - { |
|
191 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
192 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
193 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
194 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
195 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
196 | - $action='createcard'; |
|
197 | - $error++; |
|
198 | - } |
|
199 | - |
|
200 | - $companypaymentmode->fetch($id); |
|
201 | - if (! $error) |
|
202 | - { |
|
203 | - $companypaymentmode->fk_soc = $object->id; |
|
204 | - |
|
205 | - $companypaymentmode->bank = GETPOST('bank','alpha'); |
|
206 | - $companypaymentmode->label = GETPOST('label','alpha'); |
|
207 | - $companypaymentmode->number = GETPOST('cardnumber','alpha'); |
|
208 | - $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4); |
|
209 | - $companypaymentmode->proprio = GETPOST('proprio','alpha'); |
|
210 | - $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); |
|
211 | - $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); |
|
212 | - $companypaymentmode->cvn = GETPOST('cvn','alpha'); |
|
213 | - $companypaymentmode->country_code = $object->country_code; |
|
214 | - |
|
215 | - $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); |
|
216 | - |
|
217 | - $result = $companypaymentmode->update($user); |
|
218 | - if (! $result) |
|
219 | - { |
|
220 | - setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
221 | - } |
|
222 | - else |
|
223 | - { |
|
224 | - // If this account is the default bank account, we disable others |
|
225 | - if ($companypaymentmode->default_rib) |
|
226 | - { |
|
227 | - $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib |
|
228 | - } |
|
229 | - |
|
230 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
231 | - header('Location: '.$url); |
|
232 | - exit; |
|
233 | - } |
|
234 | - } |
|
235 | - } |
|
236 | - |
|
237 | - if ($action == 'add') |
|
238 | - { |
|
239 | - $error=0; |
|
240 | - |
|
241 | - if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
|
242 | - { |
|
243 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
244 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
245 | - $action='create'; |
|
246 | - $error++; |
|
247 | - } |
|
248 | - |
|
249 | - if (! $error) |
|
250 | - { |
|
251 | - // Ajout |
|
252 | - $companybankaccount = new CompanyBankAccount($db); |
|
253 | - |
|
254 | - $companybankaccount->socid = $object->id; |
|
255 | - |
|
256 | - $companybankaccount->bank = GETPOST('bank','alpha'); |
|
257 | - $companybankaccount->label = GETPOST('label','alpha'); |
|
258 | - $companybankaccount->courant = GETPOST('courant','alpha'); |
|
259 | - $companybankaccount->clos = GETPOST('clos','alpha'); |
|
260 | - $companybankaccount->code_banque = GETPOST('code_banque','alpha'); |
|
261 | - $companybankaccount->code_guichet = GETPOST('code_guichet','alpha'); |
|
262 | - $companybankaccount->number = GETPOST('number','alpha'); |
|
263 | - $companybankaccount->cle_rib = GETPOST('cle_rib','alpha'); |
|
264 | - $companybankaccount->bic = GETPOST('bic','alpha'); |
|
265 | - $companybankaccount->iban = GETPOST('iban','alpha'); |
|
266 | - $companybankaccount->domiciliation = GETPOST('domiciliation','alpha'); |
|
267 | - $companybankaccount->proprio = GETPOST('proprio','alpha'); |
|
268 | - $companybankaccount->owner_address = GETPOST('owner_address','alpha'); |
|
269 | - $companybankaccount->frstrecur = GETPOST('frstrecur'); |
|
270 | - $companybankaccount->rum = GETPOST('rum','alpha'); |
|
271 | - $companybankaccount->datec = dol_now(); |
|
272 | - $companybankaccount->status = 1; |
|
273 | - |
|
274 | - $db->begin(); |
|
275 | - |
|
276 | - // This test can be done only once properties were set |
|
277 | - if ($companybankaccount->needIBAN() == 1) |
|
278 | - { |
|
279 | - if (! GETPOST('iban')) |
|
280 | - { |
|
281 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); |
|
282 | - $action='create'; |
|
283 | - $error++; |
|
284 | - } |
|
285 | - if (! GETPOST('bic')) |
|
286 | - { |
|
287 | - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); |
|
288 | - $action='create'; |
|
289 | - $error++; |
|
290 | - } |
|
291 | - } |
|
292 | - |
|
293 | - if (! $error) |
|
294 | - { |
|
295 | - $result = $companybankaccount->create($user); |
|
296 | - if ($result < 0) |
|
297 | - { |
|
298 | - $error++; |
|
299 | - setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
300 | - $action='create'; // Force chargement page création |
|
301 | - } |
|
302 | - |
|
303 | - if (empty($companybankaccount->rum)) |
|
304 | - { |
|
305 | - $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
306 | - $companybankaccount->date_rum = dol_now(); |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - if (! $error) |
|
311 | - { |
|
312 | - $result = $companybankaccount->update($user); // This will set the UMR number. |
|
313 | - if ($result < 0) |
|
314 | - { |
|
315 | - $error++; |
|
316 | - setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
317 | - $action='create'; |
|
318 | - } |
|
319 | - } |
|
320 | - |
|
321 | - if (! $error) |
|
322 | - { |
|
323 | - $db->commit(); |
|
324 | - |
|
325 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
326 | - header('Location: '.$url); |
|
327 | - exit; |
|
328 | - } |
|
329 | - else |
|
330 | - { |
|
331 | - $db->rollback(); |
|
332 | - } |
|
333 | - } |
|
334 | - } |
|
335 | - |
|
336 | - if ($action == 'addcard') |
|
337 | - { |
|
338 | - $error=0; |
|
339 | - |
|
340 | - if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
|
341 | - { |
|
342 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
343 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
344 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
345 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
346 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
347 | - $action='createcard'; |
|
348 | - $error++; |
|
349 | - } |
|
350 | - |
|
351 | - if (! $error) |
|
352 | - { |
|
353 | - // Ajout |
|
354 | - $companypaymentmode = new CompanyPaymentMode($db); |
|
355 | - |
|
356 | - $companypaymentmode->fk_soc = $object->id; |
|
357 | - $companypaymentmode->bank = GETPOST('bank','alpha'); |
|
358 | - $companypaymentmode->label = GETPOST('label','alpha'); |
|
359 | - $companypaymentmode->number = GETPOST('cardnumber','alpha'); |
|
360 | - $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4); |
|
361 | - $companypaymentmode->proprio = GETPOST('proprio','alpha'); |
|
362 | - $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); |
|
363 | - $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); |
|
364 | - $companypaymentmode->cvn = GETPOST('cvn','alpha'); |
|
365 | - $companypaymentmode->datec = dol_now(); |
|
366 | - $companypaymentmode->default_rib = 0; |
|
367 | - $companypaymentmode->type = 'card'; |
|
368 | - $companypaymentmode->country_code = $object->country_code; |
|
369 | - $companypaymentmode->status = $servicestatus; |
|
370 | - |
|
371 | - $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); |
|
372 | - |
|
373 | - $db->begin(); |
|
374 | - |
|
375 | - if (! $error) |
|
376 | - { |
|
377 | - $result = $companypaymentmode->create($user); |
|
378 | - if ($result < 0) |
|
379 | - { |
|
380 | - $error++; |
|
381 | - setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
382 | - $action='createcard'; // Force chargement page création |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - if (! $error) |
|
387 | - { |
|
388 | - $db->commit(); |
|
389 | - |
|
390 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
391 | - header('Location: '.$url); |
|
392 | - exit; |
|
393 | - } |
|
394 | - else |
|
395 | - { |
|
396 | - $db->rollback(); |
|
397 | - } |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0) |
|
402 | - { |
|
403 | - $companybankaccount = new CompanyBankAccount($db); |
|
404 | - $res = $companybankaccount->setAsDefault(GETPOST('ribid','int')); |
|
405 | - if ($res) |
|
406 | - { |
|
407 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
408 | - header('Location: '.$url); |
|
409 | - exit; |
|
410 | - } |
|
411 | - else |
|
412 | - { |
|
413 | - setEventMessages($db->lasterror, null, 'errors'); |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes') |
|
418 | - { |
|
419 | - $companypaymentmode = new CompanyPaymentMode($db); |
|
420 | - if ($companypaymentmode->fetch($ribid?$ribid:$id)) |
|
421 | - { |
|
422 | - $result = $companypaymentmode->delete($user); |
|
423 | - if ($result > 0) |
|
424 | - { |
|
425 | - $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
|
426 | - header('Location: '.$url); |
|
427 | - exit; |
|
428 | - } |
|
429 | - else |
|
430 | - { |
|
431 | - setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
432 | - } |
|
433 | - } |
|
434 | - else |
|
435 | - { |
|
436 | - setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
437 | - } |
|
438 | - } |
|
439 | - if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes') |
|
440 | - { |
|
441 | - $companybankaccount = new CompanyBankAccount($db); |
|
442 | - if ($companybankaccount->fetch($ribid?$ribid:$id)) |
|
443 | - { |
|
444 | - $result = $companybankaccount->delete($user); |
|
445 | - if ($result > 0) |
|
446 | - { |
|
447 | - $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
|
448 | - header('Location: '.$url); |
|
449 | - exit; |
|
450 | - } |
|
451 | - else |
|
452 | - { |
|
453 | - setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
454 | - } |
|
455 | - } |
|
456 | - else |
|
457 | - { |
|
458 | - setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
459 | - } |
|
460 | - } |
|
461 | - |
|
462 | - $savid=$id; |
|
463 | - |
|
464 | - // Actions to build doc |
|
465 | - if ($action == 'builddocrib') |
|
466 | - { |
|
467 | - $action = 'builddoc'; |
|
468 | - $moreparams = array( |
|
469 | - 'use_companybankid'=>GETPOST('companybankid'), |
|
470 | - 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) |
|
471 | - ); |
|
472 | - $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha'); |
|
473 | - $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha'); |
|
474 | - } |
|
475 | - |
|
476 | - $id = $socid; |
|
477 | - $upload_dir = $conf->societe->multidir_output[$object->entity]; |
|
478 | - $permissioncreate=$user->rights->societe->creer; |
|
479 | - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
|
480 | - |
|
481 | - $id = $savid; |
|
482 | - |
|
483 | - // Action for stripe |
|
484 | - if (! empty($conf->stripe->enabled) && class_exists('Stripe')) |
|
485 | - { |
|
486 | - if ($action == 'synccustomertostripe') |
|
487 | - { |
|
488 | - if ($object->client == 0) |
|
489 | - { |
|
490 | - $error++; |
|
491 | - setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors'); |
|
492 | - } |
|
493 | - else |
|
494 | - { |
|
495 | - // Creation of Stripe customer + update of societe_account |
|
496 | - $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); |
|
497 | - if (! $cu) |
|
498 | - { |
|
499 | - $error++; |
|
500 | - setEventMessages($stripe->error, $stripe->errors, 'errors'); |
|
501 | - } |
|
502 | - else |
|
503 | - { |
|
504 | - $stripecu = $cu->id; |
|
505 | - } |
|
506 | - } |
|
507 | - } |
|
508 | - if ($action == 'synccardtostripe') |
|
509 | - { |
|
510 | - $companypaymentmode = new CompanyPaymentMode($db); |
|
511 | - $companypaymentmode->fetch($id); |
|
512 | - |
|
513 | - if ($companypaymentmode->type != 'card') |
|
514 | - { |
|
515 | - $error++; |
|
516 | - setEventMessages('ThisPaymentModeIsNotACard', null, 'errors'); |
|
517 | - } |
|
518 | - else |
|
519 | - { |
|
520 | - // Get the Stripe customer |
|
521 | - $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
522 | - if (! $cu) |
|
523 | - { |
|
524 | - $error++; |
|
525 | - setEventMessages($stripe->error, $stripe->errors, 'errors'); |
|
526 | - } |
|
527 | - |
|
528 | - if (! $error) |
|
529 | - { |
|
530 | - // Creation of Stripe card + update of societe_account |
|
531 | - $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); |
|
532 | - if (! $card) |
|
533 | - { |
|
534 | - $error++; |
|
535 | - setEventMessages($stripe->error, $stripe->errors, 'errors'); |
|
536 | - } |
|
537 | - else |
|
538 | - { |
|
539 | - $stripecard = $card->id; |
|
540 | - } |
|
541 | - } |
|
542 | - } |
|
543 | - } |
|
544 | - |
|
545 | - if ($action == 'setkey_account') |
|
546 | - { |
|
547 | - $error = 0; |
|
548 | - |
|
549 | - $newcu = GETPOST('key_account', 'alpha'); |
|
550 | - |
|
551 | - $db->begin(); |
|
104 | + if ($cancel) |
|
105 | + { |
|
106 | + $action=''; |
|
107 | + if (! empty($backtopage)) |
|
108 | + { |
|
109 | + header("Location: ".$backtopage); |
|
110 | + exit; |
|
111 | + } |
|
112 | + } |
|
113 | + |
|
114 | + if ($action == 'update') |
|
115 | + { |
|
116 | + // Modification |
|
117 | + if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
|
118 | + { |
|
119 | + if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
120 | + if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
121 | + $action='edit'; |
|
122 | + $error++; |
|
123 | + } |
|
124 | + if ($companybankaccount->needIBAN() == 1) |
|
125 | + { |
|
126 | + if (! GETPOST('iban')) |
|
127 | + { |
|
128 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); |
|
129 | + $action='edit'; |
|
130 | + $error++; |
|
131 | + } |
|
132 | + if (! GETPOST('bic')) |
|
133 | + { |
|
134 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); |
|
135 | + $action='edit'; |
|
136 | + $error++; |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + $companybankaccount->fetch($id); |
|
141 | + if (! $error) |
|
142 | + { |
|
143 | + $companybankaccount->socid = $object->id; |
|
144 | + |
|
145 | + $companybankaccount->bank = GETPOST('bank','alpha'); |
|
146 | + $companybankaccount->label = GETPOST('label','alpha'); |
|
147 | + $companybankaccount->courant = GETPOST('courant','alpha'); |
|
148 | + $companybankaccount->clos = GETPOST('clos','alpha'); |
|
149 | + $companybankaccount->code_banque = GETPOST('code_banque','alpha'); |
|
150 | + $companybankaccount->code_guichet = GETPOST('code_guichet','alpha'); |
|
151 | + $companybankaccount->number = GETPOST('number','alpha'); |
|
152 | + $companybankaccount->cle_rib = GETPOST('cle_rib','alpha'); |
|
153 | + $companybankaccount->bic = GETPOST('bic','alpha'); |
|
154 | + $companybankaccount->iban = GETPOST('iban','alpha'); |
|
155 | + $companybankaccount->domiciliation = GETPOST('domiciliation','alpha'); |
|
156 | + $companybankaccount->proprio = GETPOST('proprio','alpha'); |
|
157 | + $companybankaccount->owner_address = GETPOST('owner_address','alpha'); |
|
158 | + $companybankaccount->frstrecur = GETPOST('frstrecur','alpha'); |
|
159 | + $companybankaccount->rum = GETPOST('rum','alpha'); |
|
160 | + if (empty($companybankaccount->rum)) |
|
161 | + { |
|
162 | + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
163 | + $companybankaccount->date_rum = dol_now(); |
|
164 | + } |
|
165 | + |
|
166 | + $result = $companybankaccount->update($user); |
|
167 | + if (! $result) |
|
168 | + { |
|
169 | + setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
170 | + } |
|
171 | + else |
|
172 | + { |
|
173 | + // If this account is the default bank account, we disable others |
|
174 | + if ($companybankaccount->default_rib) |
|
175 | + { |
|
176 | + $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib |
|
177 | + } |
|
178 | + |
|
179 | + $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
180 | + header('Location: '.$url); |
|
181 | + exit; |
|
182 | + } |
|
183 | + } |
|
184 | + } |
|
185 | + |
|
186 | + if ($action == 'updatecard') |
|
187 | + { |
|
188 | + // Modification |
|
189 | + if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
|
190 | + { |
|
191 | + if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
192 | + if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
193 | + if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
194 | + if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
195 | + if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
196 | + $action='createcard'; |
|
197 | + $error++; |
|
198 | + } |
|
199 | + |
|
200 | + $companypaymentmode->fetch($id); |
|
201 | + if (! $error) |
|
202 | + { |
|
203 | + $companypaymentmode->fk_soc = $object->id; |
|
204 | + |
|
205 | + $companypaymentmode->bank = GETPOST('bank','alpha'); |
|
206 | + $companypaymentmode->label = GETPOST('label','alpha'); |
|
207 | + $companypaymentmode->number = GETPOST('cardnumber','alpha'); |
|
208 | + $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4); |
|
209 | + $companypaymentmode->proprio = GETPOST('proprio','alpha'); |
|
210 | + $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); |
|
211 | + $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); |
|
212 | + $companypaymentmode->cvn = GETPOST('cvn','alpha'); |
|
213 | + $companypaymentmode->country_code = $object->country_code; |
|
214 | + |
|
215 | + $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); |
|
216 | + |
|
217 | + $result = $companypaymentmode->update($user); |
|
218 | + if (! $result) |
|
219 | + { |
|
220 | + setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
221 | + } |
|
222 | + else |
|
223 | + { |
|
224 | + // If this account is the default bank account, we disable others |
|
225 | + if ($companypaymentmode->default_rib) |
|
226 | + { |
|
227 | + $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib |
|
228 | + } |
|
229 | + |
|
230 | + $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
231 | + header('Location: '.$url); |
|
232 | + exit; |
|
233 | + } |
|
234 | + } |
|
235 | + } |
|
236 | + |
|
237 | + if ($action == 'add') |
|
238 | + { |
|
239 | + $error=0; |
|
240 | + |
|
241 | + if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
|
242 | + { |
|
243 | + if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
244 | + if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
245 | + $action='create'; |
|
246 | + $error++; |
|
247 | + } |
|
248 | + |
|
249 | + if (! $error) |
|
250 | + { |
|
251 | + // Ajout |
|
252 | + $companybankaccount = new CompanyBankAccount($db); |
|
253 | + |
|
254 | + $companybankaccount->socid = $object->id; |
|
255 | + |
|
256 | + $companybankaccount->bank = GETPOST('bank','alpha'); |
|
257 | + $companybankaccount->label = GETPOST('label','alpha'); |
|
258 | + $companybankaccount->courant = GETPOST('courant','alpha'); |
|
259 | + $companybankaccount->clos = GETPOST('clos','alpha'); |
|
260 | + $companybankaccount->code_banque = GETPOST('code_banque','alpha'); |
|
261 | + $companybankaccount->code_guichet = GETPOST('code_guichet','alpha'); |
|
262 | + $companybankaccount->number = GETPOST('number','alpha'); |
|
263 | + $companybankaccount->cle_rib = GETPOST('cle_rib','alpha'); |
|
264 | + $companybankaccount->bic = GETPOST('bic','alpha'); |
|
265 | + $companybankaccount->iban = GETPOST('iban','alpha'); |
|
266 | + $companybankaccount->domiciliation = GETPOST('domiciliation','alpha'); |
|
267 | + $companybankaccount->proprio = GETPOST('proprio','alpha'); |
|
268 | + $companybankaccount->owner_address = GETPOST('owner_address','alpha'); |
|
269 | + $companybankaccount->frstrecur = GETPOST('frstrecur'); |
|
270 | + $companybankaccount->rum = GETPOST('rum','alpha'); |
|
271 | + $companybankaccount->datec = dol_now(); |
|
272 | + $companybankaccount->status = 1; |
|
273 | + |
|
274 | + $db->begin(); |
|
275 | + |
|
276 | + // This test can be done only once properties were set |
|
277 | + if ($companybankaccount->needIBAN() == 1) |
|
278 | + { |
|
279 | + if (! GETPOST('iban')) |
|
280 | + { |
|
281 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); |
|
282 | + $action='create'; |
|
283 | + $error++; |
|
284 | + } |
|
285 | + if (! GETPOST('bic')) |
|
286 | + { |
|
287 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); |
|
288 | + $action='create'; |
|
289 | + $error++; |
|
290 | + } |
|
291 | + } |
|
292 | + |
|
293 | + if (! $error) |
|
294 | + { |
|
295 | + $result = $companybankaccount->create($user); |
|
296 | + if ($result < 0) |
|
297 | + { |
|
298 | + $error++; |
|
299 | + setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
300 | + $action='create'; // Force chargement page création |
|
301 | + } |
|
302 | + |
|
303 | + if (empty($companybankaccount->rum)) |
|
304 | + { |
|
305 | + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
306 | + $companybankaccount->date_rum = dol_now(); |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + if (! $error) |
|
311 | + { |
|
312 | + $result = $companybankaccount->update($user); // This will set the UMR number. |
|
313 | + if ($result < 0) |
|
314 | + { |
|
315 | + $error++; |
|
316 | + setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
317 | + $action='create'; |
|
318 | + } |
|
319 | + } |
|
320 | + |
|
321 | + if (! $error) |
|
322 | + { |
|
323 | + $db->commit(); |
|
324 | + |
|
325 | + $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
326 | + header('Location: '.$url); |
|
327 | + exit; |
|
328 | + } |
|
329 | + else |
|
330 | + { |
|
331 | + $db->rollback(); |
|
332 | + } |
|
333 | + } |
|
334 | + } |
|
335 | + |
|
336 | + if ($action == 'addcard') |
|
337 | + { |
|
338 | + $error=0; |
|
339 | + |
|
340 | + if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
|
341 | + { |
|
342 | + if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
343 | + if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
344 | + if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
345 | + if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
346 | + if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
347 | + $action='createcard'; |
|
348 | + $error++; |
|
349 | + } |
|
350 | + |
|
351 | + if (! $error) |
|
352 | + { |
|
353 | + // Ajout |
|
354 | + $companypaymentmode = new CompanyPaymentMode($db); |
|
355 | + |
|
356 | + $companypaymentmode->fk_soc = $object->id; |
|
357 | + $companypaymentmode->bank = GETPOST('bank','alpha'); |
|
358 | + $companypaymentmode->label = GETPOST('label','alpha'); |
|
359 | + $companypaymentmode->number = GETPOST('cardnumber','alpha'); |
|
360 | + $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4); |
|
361 | + $companypaymentmode->proprio = GETPOST('proprio','alpha'); |
|
362 | + $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); |
|
363 | + $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); |
|
364 | + $companypaymentmode->cvn = GETPOST('cvn','alpha'); |
|
365 | + $companypaymentmode->datec = dol_now(); |
|
366 | + $companypaymentmode->default_rib = 0; |
|
367 | + $companypaymentmode->type = 'card'; |
|
368 | + $companypaymentmode->country_code = $object->country_code; |
|
369 | + $companypaymentmode->status = $servicestatus; |
|
370 | + |
|
371 | + $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); |
|
372 | + |
|
373 | + $db->begin(); |
|
374 | + |
|
375 | + if (! $error) |
|
376 | + { |
|
377 | + $result = $companypaymentmode->create($user); |
|
378 | + if ($result < 0) |
|
379 | + { |
|
380 | + $error++; |
|
381 | + setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
382 | + $action='createcard'; // Force chargement page création |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + if (! $error) |
|
387 | + { |
|
388 | + $db->commit(); |
|
389 | + |
|
390 | + $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
391 | + header('Location: '.$url); |
|
392 | + exit; |
|
393 | + } |
|
394 | + else |
|
395 | + { |
|
396 | + $db->rollback(); |
|
397 | + } |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0) |
|
402 | + { |
|
403 | + $companybankaccount = new CompanyBankAccount($db); |
|
404 | + $res = $companybankaccount->setAsDefault(GETPOST('ribid','int')); |
|
405 | + if ($res) |
|
406 | + { |
|
407 | + $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
408 | + header('Location: '.$url); |
|
409 | + exit; |
|
410 | + } |
|
411 | + else |
|
412 | + { |
|
413 | + setEventMessages($db->lasterror, null, 'errors'); |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes') |
|
418 | + { |
|
419 | + $companypaymentmode = new CompanyPaymentMode($db); |
|
420 | + if ($companypaymentmode->fetch($ribid?$ribid:$id)) |
|
421 | + { |
|
422 | + $result = $companypaymentmode->delete($user); |
|
423 | + if ($result > 0) |
|
424 | + { |
|
425 | + $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
|
426 | + header('Location: '.$url); |
|
427 | + exit; |
|
428 | + } |
|
429 | + else |
|
430 | + { |
|
431 | + setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
432 | + } |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
436 | + setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
|
437 | + } |
|
438 | + } |
|
439 | + if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes') |
|
440 | + { |
|
441 | + $companybankaccount = new CompanyBankAccount($db); |
|
442 | + if ($companybankaccount->fetch($ribid?$ribid:$id)) |
|
443 | + { |
|
444 | + $result = $companybankaccount->delete($user); |
|
445 | + if ($result > 0) |
|
446 | + { |
|
447 | + $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
|
448 | + header('Location: '.$url); |
|
449 | + exit; |
|
450 | + } |
|
451 | + else |
|
452 | + { |
|
453 | + setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
454 | + } |
|
455 | + } |
|
456 | + else |
|
457 | + { |
|
458 | + setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
|
459 | + } |
|
460 | + } |
|
461 | + |
|
462 | + $savid=$id; |
|
463 | + |
|
464 | + // Actions to build doc |
|
465 | + if ($action == 'builddocrib') |
|
466 | + { |
|
467 | + $action = 'builddoc'; |
|
468 | + $moreparams = array( |
|
469 | + 'use_companybankid'=>GETPOST('companybankid'), |
|
470 | + 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) |
|
471 | + ); |
|
472 | + $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha'); |
|
473 | + $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha'); |
|
474 | + } |
|
475 | + |
|
476 | + $id = $socid; |
|
477 | + $upload_dir = $conf->societe->multidir_output[$object->entity]; |
|
478 | + $permissioncreate=$user->rights->societe->creer; |
|
479 | + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
|
480 | + |
|
481 | + $id = $savid; |
|
482 | + |
|
483 | + // Action for stripe |
|
484 | + if (! empty($conf->stripe->enabled) && class_exists('Stripe')) |
|
485 | + { |
|
486 | + if ($action == 'synccustomertostripe') |
|
487 | + { |
|
488 | + if ($object->client == 0) |
|
489 | + { |
|
490 | + $error++; |
|
491 | + setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors'); |
|
492 | + } |
|
493 | + else |
|
494 | + { |
|
495 | + // Creation of Stripe customer + update of societe_account |
|
496 | + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); |
|
497 | + if (! $cu) |
|
498 | + { |
|
499 | + $error++; |
|
500 | + setEventMessages($stripe->error, $stripe->errors, 'errors'); |
|
501 | + } |
|
502 | + else |
|
503 | + { |
|
504 | + $stripecu = $cu->id; |
|
505 | + } |
|
506 | + } |
|
507 | + } |
|
508 | + if ($action == 'synccardtostripe') |
|
509 | + { |
|
510 | + $companypaymentmode = new CompanyPaymentMode($db); |
|
511 | + $companypaymentmode->fetch($id); |
|
512 | + |
|
513 | + if ($companypaymentmode->type != 'card') |
|
514 | + { |
|
515 | + $error++; |
|
516 | + setEventMessages('ThisPaymentModeIsNotACard', null, 'errors'); |
|
517 | + } |
|
518 | + else |
|
519 | + { |
|
520 | + // Get the Stripe customer |
|
521 | + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
522 | + if (! $cu) |
|
523 | + { |
|
524 | + $error++; |
|
525 | + setEventMessages($stripe->error, $stripe->errors, 'errors'); |
|
526 | + } |
|
527 | + |
|
528 | + if (! $error) |
|
529 | + { |
|
530 | + // Creation of Stripe card + update of societe_account |
|
531 | + $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); |
|
532 | + if (! $card) |
|
533 | + { |
|
534 | + $error++; |
|
535 | + setEventMessages($stripe->error, $stripe->errors, 'errors'); |
|
536 | + } |
|
537 | + else |
|
538 | + { |
|
539 | + $stripecard = $card->id; |
|
540 | + } |
|
541 | + } |
|
542 | + } |
|
543 | + } |
|
544 | + |
|
545 | + if ($action == 'setkey_account') |
|
546 | + { |
|
547 | + $error = 0; |
|
548 | + |
|
549 | + $newcu = GETPOST('key_account', 'alpha'); |
|
550 | + |
|
551 | + $db->begin(); |
|
552 | 552 | |
553 | 553 | if (empty($newcu)) { |
554 | 554 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; |
555 | 555 | } else { |
556 | - $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; |
|
557 | - $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; |
|
558 | - $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! |
|
556 | + $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; |
|
557 | + $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; |
|
558 | + $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! |
|
559 | 559 | } |
560 | 560 | |
561 | - $resql = $db->query($sql); |
|
562 | - $num = $db->num_rows($resql); |
|
563 | - if (empty($num) && !empty($newcu)) |
|
564 | - { |
|
565 | - $societeaccount = new SocieteAccount($db); |
|
566 | - $societeaccount->fk_soc = $object->id; |
|
567 | - $societeaccount->login = ''; |
|
568 | - $societeaccount->pass_encoding = ''; |
|
569 | - $societeaccount->site = 'stripe'; |
|
570 | - $societeaccount->status = $servicestatus; |
|
571 | - $societeaccount->key_account = $newcu; |
|
572 | - $result = $societeaccount->create($user); |
|
573 | - if ($result < 0) |
|
574 | - { |
|
575 | - $error++; |
|
576 | - } |
|
577 | - } |
|
578 | - |
|
579 | - if (! $error) |
|
580 | - { |
|
581 | - $stripecu = $newcu; |
|
582 | - $db->commit(); |
|
583 | - } |
|
584 | - else |
|
585 | - { |
|
586 | - $db->rollback(); |
|
587 | - } |
|
588 | - } |
|
589 | - if ($action == 'setlocalassourcedefault') |
|
590 | - { |
|
591 | - try { |
|
592 | - $companypaymentmode->setAsDefault($id); |
|
593 | - |
|
594 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
595 | - header('Location: '.$url); |
|
596 | - exit; |
|
597 | - } |
|
598 | - catch(Exception $e) |
|
599 | - { |
|
600 | - $error++; |
|
601 | - setEventMessages($e->getMessage(), null, 'errors'); |
|
602 | - } |
|
603 | - } |
|
604 | - elseif ($action == 'setassourcedefault') |
|
605 | - { |
|
606 | - try { |
|
607 | - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
608 | - $cu->default_source = (string) $source; |
|
609 | - $result = $cu->save(); |
|
610 | - |
|
611 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
612 | - header('Location: '.$url); |
|
613 | - exit; |
|
614 | - } |
|
615 | - catch(Exception $e) |
|
616 | - { |
|
617 | - $error++; |
|
618 | - setEventMessages($e->getMessage(), null, 'errors'); |
|
619 | - } |
|
620 | - } |
|
621 | - elseif ($action == 'deletecard' && $source) |
|
622 | - { |
|
623 | - try { |
|
624 | - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
625 | - $card=$cu->sources->retrieve("$source"); |
|
626 | - if ($card) |
|
627 | - { |
|
628 | - // $card->detach(); Does not work with card_, only with src_ |
|
629 | - if (method_exists($card, 'detach')) $card->detach(); |
|
630 | - else $card->delete(); |
|
631 | - } |
|
632 | - |
|
633 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
634 | - header('Location: '.$url); |
|
635 | - exit; |
|
636 | - } |
|
637 | - catch(Exception $e) |
|
638 | - { |
|
639 | - $error++; |
|
640 | - setEventMessages($e->getMessage(), null, 'errors'); |
|
641 | - } |
|
642 | - } |
|
643 | - } |
|
561 | + $resql = $db->query($sql); |
|
562 | + $num = $db->num_rows($resql); |
|
563 | + if (empty($num) && !empty($newcu)) |
|
564 | + { |
|
565 | + $societeaccount = new SocieteAccount($db); |
|
566 | + $societeaccount->fk_soc = $object->id; |
|
567 | + $societeaccount->login = ''; |
|
568 | + $societeaccount->pass_encoding = ''; |
|
569 | + $societeaccount->site = 'stripe'; |
|
570 | + $societeaccount->status = $servicestatus; |
|
571 | + $societeaccount->key_account = $newcu; |
|
572 | + $result = $societeaccount->create($user); |
|
573 | + if ($result < 0) |
|
574 | + { |
|
575 | + $error++; |
|
576 | + } |
|
577 | + } |
|
578 | + |
|
579 | + if (! $error) |
|
580 | + { |
|
581 | + $stripecu = $newcu; |
|
582 | + $db->commit(); |
|
583 | + } |
|
584 | + else |
|
585 | + { |
|
586 | + $db->rollback(); |
|
587 | + } |
|
588 | + } |
|
589 | + if ($action == 'setlocalassourcedefault') |
|
590 | + { |
|
591 | + try { |
|
592 | + $companypaymentmode->setAsDefault($id); |
|
593 | + |
|
594 | + $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
595 | + header('Location: '.$url); |
|
596 | + exit; |
|
597 | + } |
|
598 | + catch(Exception $e) |
|
599 | + { |
|
600 | + $error++; |
|
601 | + setEventMessages($e->getMessage(), null, 'errors'); |
|
602 | + } |
|
603 | + } |
|
604 | + elseif ($action == 'setassourcedefault') |
|
605 | + { |
|
606 | + try { |
|
607 | + $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
608 | + $cu->default_source = (string) $source; |
|
609 | + $result = $cu->save(); |
|
610 | + |
|
611 | + $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
612 | + header('Location: '.$url); |
|
613 | + exit; |
|
614 | + } |
|
615 | + catch(Exception $e) |
|
616 | + { |
|
617 | + $error++; |
|
618 | + setEventMessages($e->getMessage(), null, 'errors'); |
|
619 | + } |
|
620 | + } |
|
621 | + elseif ($action == 'deletecard' && $source) |
|
622 | + { |
|
623 | + try { |
|
624 | + $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
625 | + $card=$cu->sources->retrieve("$source"); |
|
626 | + if ($card) |
|
627 | + { |
|
628 | + // $card->detach(); Does not work with card_, only with src_ |
|
629 | + if (method_exists($card, 'detach')) $card->detach(); |
|
630 | + else $card->delete(); |
|
631 | + } |
|
632 | + |
|
633 | + $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
634 | + header('Location: '.$url); |
|
635 | + exit; |
|
636 | + } |
|
637 | + catch(Exception $e) |
|
638 | + { |
|
639 | + $error++; |
|
640 | + setEventMessages($e->getMessage(), null, 'errors'); |
|
641 | + } |
|
642 | + } |
|
643 | + } |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | |
@@ -664,217 +664,217 @@ discard block |
||
664 | 664 | }*/ |
665 | 665 | if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))) |
666 | 666 | { |
667 | - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); |
|
667 | + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | // Load Bank account |
671 | 671 | if (! $id) |
672 | 672 | { |
673 | - $companybankaccount->fetch(0, $object->id); |
|
674 | - $companypaymentmode->fetch(0, null, $object->id, 'card'); |
|
673 | + $companybankaccount->fetch(0, $object->id); |
|
674 | + $companypaymentmode->fetch(0, null, $object->id, 'card'); |
|
675 | 675 | } |
676 | 676 | else |
677 | 677 | { |
678 | - $companybankaccount->fetch($id); |
|
679 | - $companypaymentmode->fetch($id); |
|
678 | + $companybankaccount->fetch($id); |
|
679 | + $companypaymentmode->fetch($id); |
|
680 | 680 | } |
681 | 681 | if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id; |
682 | 682 | |
683 | 683 | if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) |
684 | 684 | { |
685 | - print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
|
686 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
687 | - $actionforadd='update'; |
|
688 | - if ($action == 'editcard') $actionforadd='updatecard'; |
|
689 | - print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
|
690 | - print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">'; |
|
685 | + print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
|
686 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
687 | + $actionforadd='update'; |
|
688 | + if ($action == 'editcard') $actionforadd='updatecard'; |
|
689 | + print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
|
690 | + print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">'; |
|
691 | 691 | } |
692 | 692 | if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) |
693 | 693 | { |
694 | - print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
|
695 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
696 | - $actionforadd='add'; |
|
697 | - if ($action == 'createcard') $actionforadd='addcard'; |
|
698 | - print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
|
694 | + print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
|
695 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
696 | + $actionforadd='add'; |
|
697 | + if ($action == 'createcard') $actionforadd='addcard'; |
|
698 | + print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | |
702 | 702 | // View |
703 | 703 | if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' && $action != 'createcard') |
704 | 704 | { |
705 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); |
|
706 | - |
|
707 | - // Confirm delete ban |
|
708 | - if ($action == 'delete') |
|
709 | - { |
|
710 | - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); |
|
711 | - } |
|
712 | - // Confirm delete card |
|
713 | - if ($action == 'deletecard') |
|
714 | - { |
|
715 | - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); |
|
716 | - } |
|
717 | - |
|
718 | - $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
719 | - |
|
720 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
721 | - |
|
722 | - |
|
723 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
724 | - { |
|
725 | - print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
|
726 | - } |
|
727 | - |
|
728 | - //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); |
|
729 | - |
|
730 | - print '<div class="fichecenter">'; |
|
731 | - |
|
732 | - print '<div class="underbanner clearboth"></div>'; |
|
733 | - print '<table class="border tableforfield" width="100%">'; |
|
734 | - |
|
735 | - if ($object->client) |
|
736 | - { |
|
737 | - print '<tr><td class="titlefield">'; |
|
738 | - print $langs->trans('CustomerCode').'</td><td colspan="2">'; |
|
739 | - print $object->code_client; |
|
740 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
741 | - print '</td></tr>'; |
|
742 | - $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; |
|
743 | - $resql=$db->query($sql); |
|
744 | - if (!$resql) dol_print_error($db); |
|
745 | - |
|
746 | - $obj = $db->fetch_object($resql); |
|
747 | - $nbFactsClient = $obj->nb; |
|
748 | - $thirdTypeArray['customer']=$langs->trans("customer"); |
|
749 | - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
750 | - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
751 | - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
752 | - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
753 | - } |
|
754 | - |
|
755 | - if (! empty($conf->stripe->enabled)) |
|
756 | - { |
|
757 | - $permissiontowrite = $user->rights->societe->creer; |
|
758 | - // Stripe customer key 'cu_....' stored into llx_societe_account |
|
759 | - print '<tr><td class="titlefield">'; |
|
760 | - //print $langs->trans('StripeCustomerId'); |
|
761 | - print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); |
|
762 | - print '</td><td>'; |
|
763 | - //print $stripecu; |
|
764 | - print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); |
|
765 | - if ($stripecu && $action != 'editkey_account') |
|
766 | - { |
|
767 | - if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; |
|
768 | - $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; |
|
769 | - if ($servicestatus) |
|
770 | - { |
|
771 | - $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; |
|
772 | - } |
|
773 | - print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>'; |
|
774 | - } |
|
775 | - print '</td><td align="right">'; |
|
776 | - if (empty($stripecu)) |
|
777 | - { |
|
778 | - print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; |
|
779 | - print '<input type="hidden" name="action" value="synccustomertostripe">'; |
|
780 | - print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
781 | - print '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
782 | - print '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
|
783 | - print '<input type="submit" class="button" name="syncstripecustomer" value="'.$langs->trans("CreateCustomerOnStripe").'">'; |
|
784 | - print '</form>'; |
|
785 | - } |
|
786 | - print '</td></tr>'; |
|
787 | - } |
|
788 | - |
|
789 | - print '</table>'; |
|
790 | - print '</div>'; |
|
791 | - |
|
792 | - dol_fiche_end(); |
|
793 | - |
|
794 | - print '<br>'; |
|
795 | - |
|
796 | - // List of Stripe payment modes |
|
797 | - if (! (empty($conf->stripe->enabled))) |
|
798 | - { |
|
799 | - $morehtmlright=''; |
|
800 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
801 | - { |
|
802 | - $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
803 | - } |
|
804 | - print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); |
|
805 | - |
|
806 | - $listofsources = array(); |
|
807 | - if (is_object($stripe)) |
|
808 | - { |
|
809 | - try { |
|
810 | - $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
811 | - if ($customerstripe->id) { |
|
812 | - $listofsources=$customerstripe->sources->data; |
|
813 | - } |
|
814 | - } |
|
815 | - catch(Exception $e) |
|
816 | - { |
|
817 | - dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); |
|
818 | - } |
|
819 | - } |
|
820 | - |
|
821 | - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
822 | - print '<table class="liste" width="100%">'."\n"; |
|
823 | - print '<tr class="liste_titre">'; |
|
824 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
825 | - { |
|
826 | - print '<td>'.$langs->trans('LocalID').'</td>'; |
|
827 | - } |
|
828 | - print '<td>'.$langs->trans('StripeID').'</td>'; |
|
829 | - print '<td>'.$langs->trans('Type').'</td>'; |
|
830 | - print '<td>'.$langs->trans('Informations').'</td>'; |
|
831 | - print '<td></td>'; |
|
832 | - print '<td align="center">'.$langs->trans('Default').'</td>'; |
|
833 | - print '<td>'.$langs->trans('Note').'</td>'; |
|
834 | - print '<td>'.$langs->trans('DateModification').'</td>'; |
|
835 | - print "<td></td>"; |
|
836 | - print "</tr>\n"; |
|
837 | - |
|
838 | - $nbremote = 0; |
|
839 | - $nblocal = 0; |
|
840 | - $arrayofstripecard = array(); |
|
841 | - |
|
842 | - // Show local sources |
|
843 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
844 | - { |
|
845 | - //$societeaccount = new SocieteAccount($db); |
|
846 | - $companypaymentmodetemp = new CompanyPaymentMode($db); |
|
847 | - |
|
848 | - $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; |
|
849 | - $sql.=" WHERE type in ('card', 'paypal')"; |
|
850 | - $sql.=" AND fk_soc = ".$object->id; |
|
851 | - $sql.=" AND status = ".$servicestatus; |
|
852 | - |
|
853 | - $resql = $db->query($sql); |
|
854 | - if ($resql) |
|
855 | - { |
|
856 | - $num_rows = $db->num_rows($resql); |
|
857 | - if ($num_rows) |
|
858 | - { |
|
859 | - $i=0; |
|
860 | - while ($i < $num_rows) |
|
861 | - { |
|
862 | - $nblocal++; |
|
863 | - |
|
864 | - $obj = $db->fetch_object($resql); |
|
865 | - if ($obj) |
|
866 | - { |
|
867 | - $companypaymentmodetemp->fetch($obj->rowid); |
|
868 | - |
|
869 | - $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref; |
|
870 | - |
|
871 | - print '<tr>'; |
|
872 | - print '<td>'; |
|
873 | - print $companypaymentmodetemp->id; |
|
874 | - print '</td>'; |
|
875 | - print '<td>'; |
|
876 | - print $companypaymentmodetemp->stripe_card_ref; |
|
877 | - /*if ($companypaymentmodetemp->stripe_card_ref) |
|
705 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), -1, 'company'); |
|
706 | + |
|
707 | + // Confirm delete ban |
|
708 | + if ($action == 'delete') |
|
709 | + { |
|
710 | + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); |
|
711 | + } |
|
712 | + // Confirm delete card |
|
713 | + if ($action == 'deletecard') |
|
714 | + { |
|
715 | + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); |
|
716 | + } |
|
717 | + |
|
718 | + $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
|
719 | + |
|
720 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
721 | + |
|
722 | + |
|
723 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
724 | + { |
|
725 | + print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
|
726 | + } |
|
727 | + |
|
728 | + //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); |
|
729 | + |
|
730 | + print '<div class="fichecenter">'; |
|
731 | + |
|
732 | + print '<div class="underbanner clearboth"></div>'; |
|
733 | + print '<table class="border tableforfield" width="100%">'; |
|
734 | + |
|
735 | + if ($object->client) |
|
736 | + { |
|
737 | + print '<tr><td class="titlefield">'; |
|
738 | + print $langs->trans('CustomerCode').'</td><td colspan="2">'; |
|
739 | + print $object->code_client; |
|
740 | + if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
741 | + print '</td></tr>'; |
|
742 | + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; |
|
743 | + $resql=$db->query($sql); |
|
744 | + if (!$resql) dol_print_error($db); |
|
745 | + |
|
746 | + $obj = $db->fetch_object($resql); |
|
747 | + $nbFactsClient = $obj->nb; |
|
748 | + $thirdTypeArray['customer']=$langs->trans("customer"); |
|
749 | + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
750 | + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
751 | + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
752 | + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
753 | + } |
|
754 | + |
|
755 | + if (! empty($conf->stripe->enabled)) |
|
756 | + { |
|
757 | + $permissiontowrite = $user->rights->societe->creer; |
|
758 | + // Stripe customer key 'cu_....' stored into llx_societe_account |
|
759 | + print '<tr><td class="titlefield">'; |
|
760 | + //print $langs->trans('StripeCustomerId'); |
|
761 | + print $form->editfieldkey("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); |
|
762 | + print '</td><td>'; |
|
763 | + //print $stripecu; |
|
764 | + print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); |
|
765 | + if ($stripecu && $action != 'editkey_account') |
|
766 | + { |
|
767 | + if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; |
|
768 | + $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; |
|
769 | + if ($servicestatus) |
|
770 | + { |
|
771 | + $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; |
|
772 | + } |
|
773 | + print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>'; |
|
774 | + } |
|
775 | + print '</td><td align="right">'; |
|
776 | + if (empty($stripecu)) |
|
777 | + { |
|
778 | + print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; |
|
779 | + print '<input type="hidden" name="action" value="synccustomertostripe">'; |
|
780 | + print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
781 | + print '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
782 | + print '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
|
783 | + print '<input type="submit" class="button" name="syncstripecustomer" value="'.$langs->trans("CreateCustomerOnStripe").'">'; |
|
784 | + print '</form>'; |
|
785 | + } |
|
786 | + print '</td></tr>'; |
|
787 | + } |
|
788 | + |
|
789 | + print '</table>'; |
|
790 | + print '</div>'; |
|
791 | + |
|
792 | + dol_fiche_end(); |
|
793 | + |
|
794 | + print '<br>'; |
|
795 | + |
|
796 | + // List of Stripe payment modes |
|
797 | + if (! (empty($conf->stripe->enabled))) |
|
798 | + { |
|
799 | + $morehtmlright=''; |
|
800 | + if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
801 | + { |
|
802 | + $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
803 | + } |
|
804 | + print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); |
|
805 | + |
|
806 | + $listofsources = array(); |
|
807 | + if (is_object($stripe)) |
|
808 | + { |
|
809 | + try { |
|
810 | + $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
811 | + if ($customerstripe->id) { |
|
812 | + $listofsources=$customerstripe->sources->data; |
|
813 | + } |
|
814 | + } |
|
815 | + catch(Exception $e) |
|
816 | + { |
|
817 | + dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); |
|
818 | + } |
|
819 | + } |
|
820 | + |
|
821 | + print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
822 | + print '<table class="liste" width="100%">'."\n"; |
|
823 | + print '<tr class="liste_titre">'; |
|
824 | + if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
825 | + { |
|
826 | + print '<td>'.$langs->trans('LocalID').'</td>'; |
|
827 | + } |
|
828 | + print '<td>'.$langs->trans('StripeID').'</td>'; |
|
829 | + print '<td>'.$langs->trans('Type').'</td>'; |
|
830 | + print '<td>'.$langs->trans('Informations').'</td>'; |
|
831 | + print '<td></td>'; |
|
832 | + print '<td align="center">'.$langs->trans('Default').'</td>'; |
|
833 | + print '<td>'.$langs->trans('Note').'</td>'; |
|
834 | + print '<td>'.$langs->trans('DateModification').'</td>'; |
|
835 | + print "<td></td>"; |
|
836 | + print "</tr>\n"; |
|
837 | + |
|
838 | + $nbremote = 0; |
|
839 | + $nblocal = 0; |
|
840 | + $arrayofstripecard = array(); |
|
841 | + |
|
842 | + // Show local sources |
|
843 | + if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
844 | + { |
|
845 | + //$societeaccount = new SocieteAccount($db); |
|
846 | + $companypaymentmodetemp = new CompanyPaymentMode($db); |
|
847 | + |
|
848 | + $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; |
|
849 | + $sql.=" WHERE type in ('card', 'paypal')"; |
|
850 | + $sql.=" AND fk_soc = ".$object->id; |
|
851 | + $sql.=" AND status = ".$servicestatus; |
|
852 | + |
|
853 | + $resql = $db->query($sql); |
|
854 | + if ($resql) |
|
855 | + { |
|
856 | + $num_rows = $db->num_rows($resql); |
|
857 | + if ($num_rows) |
|
858 | + { |
|
859 | + $i=0; |
|
860 | + while ($i < $num_rows) |
|
861 | + { |
|
862 | + $nblocal++; |
|
863 | + |
|
864 | + $obj = $db->fetch_object($resql); |
|
865 | + if ($obj) |
|
866 | + { |
|
867 | + $companypaymentmodetemp->fetch($obj->rowid); |
|
868 | + |
|
869 | + $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref; |
|
870 | + |
|
871 | + print '<tr>'; |
|
872 | + print '<td>'; |
|
873 | + print $companypaymentmodetemp->id; |
|
874 | + print '</td>'; |
|
875 | + print '<td>'; |
|
876 | + print $companypaymentmodetemp->stripe_card_ref; |
|
877 | + /*if ($companypaymentmodetemp->stripe_card_ref) |
|
878 | 878 | { |
879 | 879 | $url='https://dashboard.stripe.com/test/card/'.$companypaymentmodetemp->stripe_card_ref; |
880 | 880 | if ($servicestatus) |
@@ -883,427 +883,427 @@ discard block |
||
883 | 883 | } |
884 | 884 | print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>'; |
885 | 885 | }*/ |
886 | - print '</td>'; |
|
887 | - print '<td>'; |
|
888 | - print img_credit_card($companypaymentmodetemp->type); |
|
889 | - print '</td>'; |
|
890 | - print '<td>'; |
|
891 | - if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four; |
|
892 | - if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; |
|
893 | - print '</td><td>'; |
|
894 | - if ($companypaymentmodetemp->country_code) |
|
895 | - { |
|
896 | - $img=picto_from_langcode($companypaymentmodetemp->country_code); |
|
897 | - print $img?$img.' ':''; |
|
898 | - print getCountry($companypaymentmodetemp->country_code,1); |
|
899 | - } |
|
900 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
901 | - print '</td>'; |
|
902 | - // Default |
|
903 | - print '<td align="center">'; |
|
904 | - if (empty($companypaymentmodetemp->default_rib)) |
|
905 | - { |
|
906 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">'; |
|
907 | - print img_picto($langs->trans("Default"),'off'); |
|
908 | - print '</a>'; |
|
909 | - } else { |
|
910 | - print img_picto($langs->trans("Default"),'on'); |
|
911 | - } |
|
912 | - print '</td>'; |
|
913 | - print '<td>'; |
|
914 | - if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local"); |
|
915 | - else print $langs->trans("LocalAndRemote"); |
|
916 | - print '</td>'; |
|
917 | - print '<td>'; |
|
918 | - print dol_print_date($companypaymentmodetemp->tms, 'dayhour'); |
|
919 | - print '</td>'; |
|
920 | - print '<td align="right" class="nowraponall">'; |
|
921 | - if ($user->rights->societe->creer) |
|
922 | - { |
|
923 | - if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) |
|
924 | - { |
|
925 | - print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>'; |
|
926 | - } |
|
886 | + print '</td>'; |
|
887 | + print '<td>'; |
|
888 | + print img_credit_card($companypaymentmodetemp->type); |
|
889 | + print '</td>'; |
|
890 | + print '<td>'; |
|
891 | + if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four; |
|
892 | + if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; |
|
893 | + print '</td><td>'; |
|
894 | + if ($companypaymentmodetemp->country_code) |
|
895 | + { |
|
896 | + $img=picto_from_langcode($companypaymentmodetemp->country_code); |
|
897 | + print $img?$img.' ':''; |
|
898 | + print getCountry($companypaymentmodetemp->country_code,1); |
|
899 | + } |
|
900 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
901 | + print '</td>'; |
|
902 | + // Default |
|
903 | + print '<td align="center">'; |
|
904 | + if (empty($companypaymentmodetemp->default_rib)) |
|
905 | + { |
|
906 | + print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">'; |
|
907 | + print img_picto($langs->trans("Default"),'off'); |
|
908 | + print '</a>'; |
|
909 | + } else { |
|
910 | + print img_picto($langs->trans("Default"),'on'); |
|
911 | + } |
|
912 | + print '</td>'; |
|
913 | + print '<td>'; |
|
914 | + if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local"); |
|
915 | + else print $langs->trans("LocalAndRemote"); |
|
916 | + print '</td>'; |
|
917 | + print '<td>'; |
|
918 | + print dol_print_date($companypaymentmodetemp->tms, 'dayhour'); |
|
919 | + print '</td>'; |
|
920 | + print '<td align="right" class="nowraponall">'; |
|
921 | + if ($user->rights->societe->creer) |
|
922 | + { |
|
923 | + if ($stripecu && empty($companypaymentmodetemp->stripe_card_ref)) |
|
924 | + { |
|
925 | + print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>'; |
|
926 | + } |
|
927 | + |
|
928 | + print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">'; |
|
929 | + print img_picto($langs->trans("Modify"),'edit'); |
|
930 | + print '</a>'; |
|
931 | + print ' '; |
|
932 | + print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'& |
|
933 | + print img_picto($langs->trans("Delete"), 'delete'); |
|
934 | + print '</a>'; |
|
935 | + } |
|
936 | + print '</td>'; |
|
937 | + print '</tr>'; |
|
938 | + } |
|
939 | + $i++; |
|
940 | + } |
|
941 | + } |
|
942 | + } |
|
943 | + else dol_print_error($db); |
|
944 | + } |
|
945 | + |
|
946 | + // Show remote sources (not already shown as local source) |
|
947 | + if (is_array($listofsources) && count($listofsources)) |
|
948 | + { |
|
949 | + foreach ($listofsources as $src) |
|
950 | + { |
|
951 | + if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list |
|
952 | + |
|
953 | + $nbremote++; |
|
954 | + |
|
955 | + print '<tr class="oddeven">'; |
|
956 | + // Local ID |
|
957 | + if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
958 | + { |
|
959 | + print '<td>'; |
|
960 | + print '</td>'; |
|
961 | + } |
|
962 | + // Src ID |
|
963 | + print '<td>'; |
|
964 | + if (!empty($stripeacc)) $connect=$stripeacc.'/'; |
|
965 | + $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; |
|
966 | + if ($servicestatus) |
|
967 | + { |
|
968 | + $url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; |
|
969 | + } |
|
970 | + print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>"; |
|
971 | + print '</td>'; |
|
972 | + // Img of credit card |
|
973 | + print '<td>'; |
|
974 | + if ($src->object=='card') |
|
975 | + { |
|
976 | + print img_credit_card($src->brand); |
|
977 | + } |
|
978 | + elseif ($src->object=='source' && $src->type=='card') |
|
979 | + { |
|
980 | + print img_credit_card($src->card->brand); |
|
981 | + } |
|
982 | + elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
983 | + { |
|
984 | + print '<span class="fa fa-university fa-2x fa-fw"></span>'; |
|
985 | + } |
|
986 | + print'</td>'; |
|
987 | + print '<td valign="middle">'; |
|
988 | + if ($src->object=='card') |
|
989 | + { |
|
990 | + print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; |
|
991 | + print '</td><td>'; |
|
992 | + if ($src->country) |
|
993 | + { |
|
994 | + $img=picto_from_langcode($src->country); |
|
995 | + print $img?$img.' ':''; |
|
996 | + print getCountry($src->country,1); |
|
997 | + } |
|
998 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
999 | + } |
|
1000 | + elseif ($src->object=='source' && $src->type=='card') |
|
1001 | + { |
|
1002 | + print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; |
|
1003 | + print '</td><td>'; |
|
1004 | + |
|
1005 | + if ($src->card->country) |
|
1006 | + { |
|
1007 | + $img=picto_from_langcode($src->card->country); |
|
1008 | + print $img?$img.' ':''; |
|
1009 | + print getCountry($src->card->country,1); |
|
1010 | + } |
|
1011 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1012 | + } |
|
1013 | + elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1014 | + { |
|
1015 | + print 'info sepa'; |
|
1016 | + print '</td><td>'; |
|
1017 | + if ($src->sepa_debit->country) |
|
1018 | + { |
|
1019 | + $img=picto_from_langcode($src->sepa_debit->country); |
|
1020 | + print $img?$img.' ':''; |
|
1021 | + print getCountry($src->sepa_debit->country,1); |
|
1022 | + } |
|
1023 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1024 | + } |
|
1025 | + print '</td>'; |
|
1026 | + // Default |
|
1027 | + print '<td align="center" width="50">'; |
|
1028 | + if (($customerstripe->default_source != $src->id)) |
|
1029 | + { |
|
1030 | + print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">'; |
|
1031 | + print img_picto($langs->trans("Default"),'off'); |
|
1032 | + print '</a>'; |
|
1033 | + } else { |
|
1034 | + print img_picto($langs->trans("Default"),'on'); |
|
1035 | + } |
|
1036 | + print '</td>'; |
|
1037 | + print '<td>'; |
|
1038 | + print $langs->trans("Remote"); |
|
1039 | + //if ($src->cvc_check == 'fail') print ' - CVC check fail'; |
|
1040 | + print '</td>'; |
|
1041 | + print '<td>'; |
|
1042 | + //var_dump($src); |
|
1043 | + print ''; |
|
1044 | + print '</td>'; |
|
1045 | + print '<td align="right" class="nowraponall">'; |
|
1046 | + if ($user->rights->societe->creer) |
|
1047 | + { |
|
1048 | + print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">'; |
|
1049 | + print img_picto($langs->trans("Delete"), 'delete'); |
|
1050 | + print '</a>'; |
|
1051 | + } |
|
1052 | + print '</td>'; |
|
1053 | + |
|
1054 | + print '</tr>'; |
|
1055 | + } |
|
1056 | + } |
|
1057 | + |
|
1058 | + if ($nbremote == 0 && $nblocal == 0) |
|
1059 | + { |
|
1060 | + print '<tr><td class="opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>'; |
|
1061 | + } |
|
1062 | + print "</table>"; |
|
1063 | + print "</div>"; |
|
1064 | + } |
|
1065 | + |
|
927 | 1066 | |
928 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">'; |
|
929 | - print img_picto($langs->trans("Modify"),'edit'); |
|
930 | - print '</a>'; |
|
931 | - print ' '; |
|
932 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'& |
|
933 | - print img_picto($langs->trans("Delete"), 'delete'); |
|
934 | - print '</a>'; |
|
935 | - } |
|
936 | - print '</td>'; |
|
937 | - print '</tr>'; |
|
938 | - } |
|
939 | - $i++; |
|
940 | - } |
|
941 | - } |
|
942 | - } |
|
943 | - else dol_print_error($db); |
|
944 | - } |
|
945 | - |
|
946 | - // Show remote sources (not already shown as local source) |
|
947 | - if (is_array($listofsources) && count($listofsources)) |
|
948 | - { |
|
949 | - foreach ($listofsources as $src) |
|
950 | - { |
|
951 | - if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list |
|
952 | - |
|
953 | - $nbremote++; |
|
954 | - |
|
955 | - print '<tr class="oddeven">'; |
|
956 | - // Local ID |
|
957 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
958 | - { |
|
959 | - print '<td>'; |
|
960 | - print '</td>'; |
|
961 | - } |
|
962 | - // Src ID |
|
963 | - print '<td>'; |
|
964 | - if (!empty($stripeacc)) $connect=$stripeacc.'/'; |
|
965 | - $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; |
|
966 | - if ($servicestatus) |
|
967 | - { |
|
968 | - $url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; |
|
969 | - } |
|
970 | - print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>"; |
|
971 | - print '</td>'; |
|
972 | - // Img of credit card |
|
973 | - print '<td>'; |
|
974 | - if ($src->object=='card') |
|
975 | - { |
|
976 | - print img_credit_card($src->brand); |
|
977 | - } |
|
978 | - elseif ($src->object=='source' && $src->type=='card') |
|
979 | - { |
|
980 | - print img_credit_card($src->card->brand); |
|
981 | - } |
|
982 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
983 | - { |
|
984 | - print '<span class="fa fa-university fa-2x fa-fw"></span>'; |
|
985 | - } |
|
986 | - print'</td>'; |
|
987 | - print '<td valign="middle">'; |
|
988 | - if ($src->object=='card') |
|
989 | - { |
|
990 | - print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; |
|
991 | - print '</td><td>'; |
|
992 | - if ($src->country) |
|
993 | - { |
|
994 | - $img=picto_from_langcode($src->country); |
|
995 | - print $img?$img.' ':''; |
|
996 | - print getCountry($src->country,1); |
|
997 | - } |
|
998 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
999 | - } |
|
1000 | - elseif ($src->object=='source' && $src->type=='card') |
|
1001 | - { |
|
1002 | - print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; |
|
1003 | - print '</td><td>'; |
|
1004 | - |
|
1005 | - if ($src->card->country) |
|
1006 | - { |
|
1007 | - $img=picto_from_langcode($src->card->country); |
|
1008 | - print $img?$img.' ':''; |
|
1009 | - print getCountry($src->card->country,1); |
|
1010 | - } |
|
1011 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1012 | - } |
|
1013 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1014 | - { |
|
1015 | - print 'info sepa'; |
|
1016 | - print '</td><td>'; |
|
1017 | - if ($src->sepa_debit->country) |
|
1018 | - { |
|
1019 | - $img=picto_from_langcode($src->sepa_debit->country); |
|
1020 | - print $img?$img.' ':''; |
|
1021 | - print getCountry($src->sepa_debit->country,1); |
|
1022 | - } |
|
1023 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1024 | - } |
|
1025 | - print '</td>'; |
|
1026 | - // Default |
|
1027 | - print '<td align="center" width="50">'; |
|
1028 | - if (($customerstripe->default_source != $src->id)) |
|
1029 | - { |
|
1030 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">'; |
|
1031 | - print img_picto($langs->trans("Default"),'off'); |
|
1032 | - print '</a>'; |
|
1033 | - } else { |
|
1034 | - print img_picto($langs->trans("Default"),'on'); |
|
1035 | - } |
|
1036 | - print '</td>'; |
|
1037 | - print '<td>'; |
|
1038 | - print $langs->trans("Remote"); |
|
1039 | - //if ($src->cvc_check == 'fail') print ' - CVC check fail'; |
|
1040 | - print '</td>'; |
|
1041 | - print '<td>'; |
|
1042 | - //var_dump($src); |
|
1043 | - print ''; |
|
1044 | - print '</td>'; |
|
1045 | - print '<td align="right" class="nowraponall">'; |
|
1046 | - if ($user->rights->societe->creer) |
|
1047 | - { |
|
1048 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">'; |
|
1049 | - print img_picto($langs->trans("Delete"), 'delete'); |
|
1050 | - print '</a>'; |
|
1051 | - } |
|
1052 | - print '</td>'; |
|
1053 | - |
|
1054 | - print '</tr>'; |
|
1055 | - } |
|
1056 | - } |
|
1057 | - |
|
1058 | - if ($nbremote == 0 && $nblocal == 0) |
|
1059 | - { |
|
1060 | - print '<tr><td class="opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>'; |
|
1061 | - } |
|
1062 | - print "</table>"; |
|
1063 | - print "</div>"; |
|
1064 | - } |
|
1065 | - |
|
1066 | - |
|
1067 | - // List of bank accounts |
|
1068 | - print '<br>'; |
|
1069 | - |
|
1070 | - $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
1071 | - |
|
1072 | - print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); |
|
1073 | - |
|
1074 | - $rib_list = $object->get_all_rib(); |
|
1075 | - if (is_array($rib_list)) |
|
1076 | - { |
|
1077 | - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
1078 | - print '<table class="liste" width="100%">'; |
|
1079 | - |
|
1080 | - print '<tr class="liste_titre">'; |
|
1081 | - print_liste_field_titre("LabelRIB"); |
|
1082 | - print_liste_field_titre("Bank"); |
|
1083 | - print_liste_field_titre("RIB"); |
|
1084 | - print_liste_field_titre("IBAN"); |
|
1085 | - print_liste_field_titre("BIC"); |
|
1086 | - if (! empty($conf->prelevement->enabled)) |
|
1087 | - { |
|
1088 | - print print_liste_field_titre("RUM"); |
|
1089 | - print print_liste_field_titre("WithdrawMode"); |
|
1090 | - } |
|
1091 | - print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"'); |
|
1092 | - print_liste_field_titre('', '', '', '', '', 'align="center"'); |
|
1093 | - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); |
|
1094 | - print "</tr>\n"; |
|
1095 | - |
|
1096 | - foreach ($rib_list as $rib) |
|
1097 | - { |
|
1098 | - print '<tr class="oddeven">'; |
|
1099 | - // Label |
|
1100 | - print '<td>'.$rib->label.'</td>'; |
|
1101 | - // Bank name |
|
1102 | - print '<td>'.$rib->bank.'</td>'; |
|
1103 | - // Account number |
|
1104 | - print '<td>'; |
|
1105 | - $string=''; |
|
1106 | - foreach ($rib->getFieldsToShow() as $val) { |
|
1107 | - |
|
1108 | - if ($val == 'BankCode') { |
|
1109 | - $string .= $rib->code_banque.' '; |
|
1110 | - } elseif ($val == 'BankAccountNumber') { |
|
1111 | - $string .= $rib->number.' '; |
|
1112 | - } elseif ($val == 'DeskCode') { |
|
1113 | - $string .= $rib->code_guichet.' '; |
|
1114 | - } elseif ($val == 'BankAccountNumberKey') { |
|
1115 | - $string .= $rib->cle_rib.' '; |
|
1116 | - /* Already output after |
|
1067 | + // List of bank accounts |
|
1068 | + print '<br>'; |
|
1069 | + |
|
1070 | + $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
1071 | + |
|
1072 | + print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); |
|
1073 | + |
|
1074 | + $rib_list = $object->get_all_rib(); |
|
1075 | + if (is_array($rib_list)) |
|
1076 | + { |
|
1077 | + print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
1078 | + print '<table class="liste" width="100%">'; |
|
1079 | + |
|
1080 | + print '<tr class="liste_titre">'; |
|
1081 | + print_liste_field_titre("LabelRIB"); |
|
1082 | + print_liste_field_titre("Bank"); |
|
1083 | + print_liste_field_titre("RIB"); |
|
1084 | + print_liste_field_titre("IBAN"); |
|
1085 | + print_liste_field_titre("BIC"); |
|
1086 | + if (! empty($conf->prelevement->enabled)) |
|
1087 | + { |
|
1088 | + print print_liste_field_titre("RUM"); |
|
1089 | + print print_liste_field_titre("WithdrawMode"); |
|
1090 | + } |
|
1091 | + print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"'); |
|
1092 | + print_liste_field_titre('', '', '', '', '', 'align="center"'); |
|
1093 | + print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); |
|
1094 | + print "</tr>\n"; |
|
1095 | + |
|
1096 | + foreach ($rib_list as $rib) |
|
1097 | + { |
|
1098 | + print '<tr class="oddeven">'; |
|
1099 | + // Label |
|
1100 | + print '<td>'.$rib->label.'</td>'; |
|
1101 | + // Bank name |
|
1102 | + print '<td>'.$rib->bank.'</td>'; |
|
1103 | + // Account number |
|
1104 | + print '<td>'; |
|
1105 | + $string=''; |
|
1106 | + foreach ($rib->getFieldsToShow() as $val) { |
|
1107 | + |
|
1108 | + if ($val == 'BankCode') { |
|
1109 | + $string .= $rib->code_banque.' '; |
|
1110 | + } elseif ($val == 'BankAccountNumber') { |
|
1111 | + $string .= $rib->number.' '; |
|
1112 | + } elseif ($val == 'DeskCode') { |
|
1113 | + $string .= $rib->code_guichet.' '; |
|
1114 | + } elseif ($val == 'BankAccountNumberKey') { |
|
1115 | + $string .= $rib->cle_rib.' '; |
|
1116 | + /* Already output after |
|
1117 | 1117 | }elseif ($val == 'BIC') { |
1118 | 1118 | $string .= $rib->bic.' '; |
1119 | 1119 | }elseif ($val == 'IBAN') { |
1120 | 1120 | $string .= $rib->iban.' ';*/ |
1121 | - } |
|
1122 | - } |
|
1123 | - if (! empty($rib->label) && $rib->number) { |
|
1124 | - if (! checkBanForAccount($rib)) { |
|
1125 | - $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); |
|
1126 | - } else { |
|
1127 | - $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); |
|
1128 | - } |
|
1129 | - } |
|
1130 | - |
|
1131 | - print $string; |
|
1132 | - print '</td>'; |
|
1133 | - // IBAN |
|
1134 | - print '<td>'.$rib->iban; |
|
1135 | - if (! empty($rib->iban)) { |
|
1136 | - if (! checkIbanForAccount($rib)) { |
|
1137 | - print ' '.img_picto($langs->trans("IbanNotValid"),'warning'); |
|
1138 | - } else { |
|
1139 | - print ' '.img_picto($langs->trans("IbanValid"),'info'); |
|
1140 | - } |
|
1141 | - } |
|
1142 | - print '</td>'; |
|
1143 | - // BIC |
|
1144 | - print '<td>'.$rib->bic; |
|
1145 | - if (! empty($rib->bic)) { |
|
1146 | - if (! checkSwiftForAccount($rib)) { |
|
1147 | - print ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); |
|
1148 | - } else { |
|
1149 | - print ' '.img_picto($langs->trans("SwiftValid"),'info'); |
|
1150 | - } |
|
1151 | - } |
|
1152 | - print '</td>'; |
|
1153 | - |
|
1154 | - if (! empty($conf->prelevement->enabled)) |
|
1155 | - { |
|
1156 | - // RUM |
|
1157 | - //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>'; |
|
1158 | - print '<td>'.$rib->rum.'</td>'; |
|
1159 | - |
|
1160 | - // FRSTRECUR |
|
1161 | - print '<td>'.$rib->frstrecur.'</td>'; |
|
1162 | - } |
|
1163 | - |
|
1164 | - // Default |
|
1165 | - print '<td align="center" width="70">'; |
|
1166 | - if (!$rib->default_rib) { |
|
1167 | - print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">'; |
|
1168 | - print img_picto($langs->trans("Disabled"),'off'); |
|
1169 | - print '</a>'; |
|
1170 | - } else { |
|
1171 | - print img_picto($langs->trans("Enabled"),'on'); |
|
1172 | - } |
|
1173 | - print '</td>'; |
|
1174 | - |
|
1175 | - // Generate doc |
|
1176 | - print '<td align="center">'; |
|
1177 | - |
|
1178 | - $buttonlabel = $langs->trans("BuildDoc"); |
|
1179 | - $forname='builddocrib'.$rib->id; |
|
1180 | - |
|
1181 | - include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; |
|
1182 | - $modellist=ModeleBankAccountDoc::liste_modeles($db); |
|
1183 | - |
|
1184 | - $out = ''; |
|
1185 | - if (is_array($modellist) && count($modellist)) |
|
1186 | - { |
|
1187 | - $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">'; |
|
1188 | - $out.= '<input type="hidden" name="action" value="builddocrib">'; |
|
1189 | - $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1190 | - $out.= '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
1191 | - $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
|
1192 | - |
|
1193 | - if (is_array($modellist) && count($modellist) == 1) // If there is only one element |
|
1194 | - { |
|
1195 | - $arraykeys=array_keys($modellist); |
|
1196 | - $modelselected=$arraykeys[0]; |
|
1197 | - } |
|
1198 | - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; |
|
1199 | - |
|
1200 | - $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
1201 | - $out.= ajax_combobox('modelrib'.$rib->id); |
|
1202 | - |
|
1203 | - // Language code (if multilang) |
|
1204 | - if ($conf->global->MAIN_MULTILANGS) |
|
1205 | - { |
|
1206 | - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; |
|
1207 | - $formadmin=new FormAdmin($db); |
|
1208 | - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); |
|
1209 | - $morecss='maxwidth150'; |
|
1210 | - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; |
|
1211 | - $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); |
|
1212 | - } |
|
1213 | - // Button |
|
1214 | - $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; |
|
1215 | - $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; |
|
1216 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; |
|
1217 | - $genbutton.= '>'; |
|
1218 | - if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
|
1219 | - { |
|
1220 | - $langs->load("errors"); |
|
1221 | - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
|
1222 | - } |
|
1223 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; |
|
1224 | - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; |
|
1225 | - $out.= $genbutton; |
|
1226 | - $out.= '</form>'; |
|
1227 | - } |
|
1228 | - print $out; |
|
1229 | - print '</td>'; |
|
1230 | - |
|
1231 | - // Edit/Delete |
|
1232 | - print '<td align="right" class="nowraponall">'; |
|
1233 | - if ($user->rights->societe->creer) |
|
1234 | - { |
|
1235 | - print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">'; |
|
1236 | - print img_picto($langs->trans("Modify"),'edit'); |
|
1237 | - print '</a>'; |
|
1238 | - |
|
1239 | - print ' '; |
|
1240 | - |
|
1241 | - print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">'; |
|
1242 | - print img_picto($langs->trans("Delete"),'delete'); |
|
1243 | - print '</a>'; |
|
1244 | - } |
|
1245 | - print '</td>'; |
|
1246 | - |
|
1247 | - print '</tr>'; |
|
1248 | - } |
|
1249 | - |
|
1250 | - if (count($rib_list) == 0) |
|
1251 | - { |
|
1252 | - $colspan=8; |
|
1253 | - if (! empty($conf->prelevement->enabled)) $colspan+=2; |
|
1254 | - print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; |
|
1255 | - } |
|
1256 | - |
|
1257 | - print '</table>'; |
|
1258 | - print '</div>'; |
|
1259 | - } else { |
|
1260 | - dol_print_error($db); |
|
1261 | - } |
|
1262 | - |
|
1263 | - |
|
1264 | - if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) |
|
1265 | - { |
|
1266 | - print '<br>'; |
|
1267 | - |
|
1268 | - print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
1269 | - print '<a name="builddoc"></a>'; // ancre |
|
1270 | - |
|
1271 | - /* |
|
1121 | + } |
|
1122 | + } |
|
1123 | + if (! empty($rib->label) && $rib->number) { |
|
1124 | + if (! checkBanForAccount($rib)) { |
|
1125 | + $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); |
|
1126 | + } else { |
|
1127 | + $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); |
|
1128 | + } |
|
1129 | + } |
|
1130 | + |
|
1131 | + print $string; |
|
1132 | + print '</td>'; |
|
1133 | + // IBAN |
|
1134 | + print '<td>'.$rib->iban; |
|
1135 | + if (! empty($rib->iban)) { |
|
1136 | + if (! checkIbanForAccount($rib)) { |
|
1137 | + print ' '.img_picto($langs->trans("IbanNotValid"),'warning'); |
|
1138 | + } else { |
|
1139 | + print ' '.img_picto($langs->trans("IbanValid"),'info'); |
|
1140 | + } |
|
1141 | + } |
|
1142 | + print '</td>'; |
|
1143 | + // BIC |
|
1144 | + print '<td>'.$rib->bic; |
|
1145 | + if (! empty($rib->bic)) { |
|
1146 | + if (! checkSwiftForAccount($rib)) { |
|
1147 | + print ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); |
|
1148 | + } else { |
|
1149 | + print ' '.img_picto($langs->trans("SwiftValid"),'info'); |
|
1150 | + } |
|
1151 | + } |
|
1152 | + print '</td>'; |
|
1153 | + |
|
1154 | + if (! empty($conf->prelevement->enabled)) |
|
1155 | + { |
|
1156 | + // RUM |
|
1157 | + //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>'; |
|
1158 | + print '<td>'.$rib->rum.'</td>'; |
|
1159 | + |
|
1160 | + // FRSTRECUR |
|
1161 | + print '<td>'.$rib->frstrecur.'</td>'; |
|
1162 | + } |
|
1163 | + |
|
1164 | + // Default |
|
1165 | + print '<td align="center" width="70">'; |
|
1166 | + if (!$rib->default_rib) { |
|
1167 | + print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">'; |
|
1168 | + print img_picto($langs->trans("Disabled"),'off'); |
|
1169 | + print '</a>'; |
|
1170 | + } else { |
|
1171 | + print img_picto($langs->trans("Enabled"),'on'); |
|
1172 | + } |
|
1173 | + print '</td>'; |
|
1174 | + |
|
1175 | + // Generate doc |
|
1176 | + print '<td align="center">'; |
|
1177 | + |
|
1178 | + $buttonlabel = $langs->trans("BuildDoc"); |
|
1179 | + $forname='builddocrib'.$rib->id; |
|
1180 | + |
|
1181 | + include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; |
|
1182 | + $modellist=ModeleBankAccountDoc::liste_modeles($db); |
|
1183 | + |
|
1184 | + $out = ''; |
|
1185 | + if (is_array($modellist) && count($modellist)) |
|
1186 | + { |
|
1187 | + $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">'; |
|
1188 | + $out.= '<input type="hidden" name="action" value="builddocrib">'; |
|
1189 | + $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1190 | + $out.= '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
1191 | + $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
|
1192 | + |
|
1193 | + if (is_array($modellist) && count($modellist) == 1) // If there is only one element |
|
1194 | + { |
|
1195 | + $arraykeys=array_keys($modellist); |
|
1196 | + $modelselected=$arraykeys[0]; |
|
1197 | + } |
|
1198 | + if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; |
|
1199 | + |
|
1200 | + $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
1201 | + $out.= ajax_combobox('modelrib'.$rib->id); |
|
1202 | + |
|
1203 | + // Language code (if multilang) |
|
1204 | + if ($conf->global->MAIN_MULTILANGS) |
|
1205 | + { |
|
1206 | + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; |
|
1207 | + $formadmin=new FormAdmin($db); |
|
1208 | + $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); |
|
1209 | + $morecss='maxwidth150'; |
|
1210 | + if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; |
|
1211 | + $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); |
|
1212 | + } |
|
1213 | + // Button |
|
1214 | + $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; |
|
1215 | + $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; |
|
1216 | + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; |
|
1217 | + $genbutton.= '>'; |
|
1218 | + if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
|
1219 | + { |
|
1220 | + $langs->load("errors"); |
|
1221 | + $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
|
1222 | + } |
|
1223 | + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; |
|
1224 | + if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; |
|
1225 | + $out.= $genbutton; |
|
1226 | + $out.= '</form>'; |
|
1227 | + } |
|
1228 | + print $out; |
|
1229 | + print '</td>'; |
|
1230 | + |
|
1231 | + // Edit/Delete |
|
1232 | + print '<td align="right" class="nowraponall">'; |
|
1233 | + if ($user->rights->societe->creer) |
|
1234 | + { |
|
1235 | + print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">'; |
|
1236 | + print img_picto($langs->trans("Modify"),'edit'); |
|
1237 | + print '</a>'; |
|
1238 | + |
|
1239 | + print ' '; |
|
1240 | + |
|
1241 | + print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">'; |
|
1242 | + print img_picto($langs->trans("Delete"),'delete'); |
|
1243 | + print '</a>'; |
|
1244 | + } |
|
1245 | + print '</td>'; |
|
1246 | + |
|
1247 | + print '</tr>'; |
|
1248 | + } |
|
1249 | + |
|
1250 | + if (count($rib_list) == 0) |
|
1251 | + { |
|
1252 | + $colspan=8; |
|
1253 | + if (! empty($conf->prelevement->enabled)) $colspan+=2; |
|
1254 | + print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; |
|
1255 | + } |
|
1256 | + |
|
1257 | + print '</table>'; |
|
1258 | + print '</div>'; |
|
1259 | + } else { |
|
1260 | + dol_print_error($db); |
|
1261 | + } |
|
1262 | + |
|
1263 | + |
|
1264 | + if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) |
|
1265 | + { |
|
1266 | + print '<br>'; |
|
1267 | + |
|
1268 | + print '<div class="fichecenter"><div class="fichehalfleft">'; |
|
1269 | + print '<a name="builddoc"></a>'; // ancre |
|
1270 | + |
|
1271 | + /* |
|
1272 | 1272 | * Documents generes |
1273 | 1273 | */ |
1274 | - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; |
|
1275 | - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; |
|
1276 | - $genallowed=$user->rights->societe->lire; |
|
1277 | - $delallowed=$user->rights->societe->creer; |
|
1278 | - |
|
1279 | - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); |
|
1280 | - |
|
1281 | - // Show direct download link |
|
1282 | - if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) |
|
1283 | - { |
|
1284 | - $companybankaccounttemp = new CompanyBankAccount($db); |
|
1285 | - $companypaymentmodetemp = new CompanyPaymentMode($db); |
|
1286 | - $result = $companypaymentmodetemp->fetch(0, null, $object->id, 'ban'); |
|
1287 | - |
|
1288 | - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
1289 | - $ecmfile = new EcmFiles($db); |
|
1290 | - $result = $ecmfile->fetch(0, '', '', '', '', $companybankaccounttemp->table_element, $companypaymentmodetemp->id); |
|
1291 | - if ($result > 0) |
|
1292 | - { |
|
1293 | - $companybankaccounttemp->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; |
|
1294 | - print '<br><!-- Link to download main doc -->'."\n"; |
|
1295 | - print showDirectDownloadLink($companybankaccounttemp).'<br>'; |
|
1296 | - } |
|
1297 | - } |
|
1298 | - |
|
1299 | - print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
1300 | - |
|
1301 | - |
|
1302 | - print '</div></div></div>'; |
|
1303 | - |
|
1304 | - print '<br>'; |
|
1305 | - } |
|
1306 | - /* |
|
1274 | + $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; |
|
1275 | + $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; |
|
1276 | + $genallowed=$user->rights->societe->lire; |
|
1277 | + $delallowed=$user->rights->societe->creer; |
|
1278 | + |
|
1279 | + print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); |
|
1280 | + |
|
1281 | + // Show direct download link |
|
1282 | + if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) |
|
1283 | + { |
|
1284 | + $companybankaccounttemp = new CompanyBankAccount($db); |
|
1285 | + $companypaymentmodetemp = new CompanyPaymentMode($db); |
|
1286 | + $result = $companypaymentmodetemp->fetch(0, null, $object->id, 'ban'); |
|
1287 | + |
|
1288 | + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; |
|
1289 | + $ecmfile = new EcmFiles($db); |
|
1290 | + $result = $ecmfile->fetch(0, '', '', '', '', $companybankaccounttemp->table_element, $companypaymentmodetemp->id); |
|
1291 | + if ($result > 0) |
|
1292 | + { |
|
1293 | + $companybankaccounttemp->last_main_doc = $ecmfile->filepath.'/'.$ecmfile->filename; |
|
1294 | + print '<br><!-- Link to download main doc -->'."\n"; |
|
1295 | + print showDirectDownloadLink($companybankaccounttemp).'<br>'; |
|
1296 | + } |
|
1297 | + } |
|
1298 | + |
|
1299 | + print '</div><div class="fichehalfright"><div class="ficheaddleft">'; |
|
1300 | + |
|
1301 | + |
|
1302 | + print '</div></div></div>'; |
|
1303 | + |
|
1304 | + print '<br>'; |
|
1305 | + } |
|
1306 | + /* |
|
1307 | 1307 | include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; |
1308 | 1308 | $modellist=ModeleBankAccountDoc::liste_modeles($db); |
1309 | 1309 | //print '<td>'; |
@@ -1327,310 +1327,310 @@ discard block |
||
1327 | 1327 | // Edit BAN |
1328 | 1328 | if ($socid && $action == 'edit' && $user->rights->societe->creer) |
1329 | 1329 | { |
1330 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1331 | - |
|
1332 | - $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1333 | - |
|
1334 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1335 | - |
|
1336 | - print '<div class="fichecenter">'; |
|
1337 | - |
|
1338 | - print '<div class="underbanner clearboth"></div>'; |
|
1339 | - print '<table class="border centpercent">'; |
|
1340 | - |
|
1341 | - print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>'; |
|
1342 | - print '<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.'"></td></tr>'; |
|
1343 | - |
|
1344 | - print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>'; |
|
1345 | - print '<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.'"></td></tr>'; |
|
1346 | - |
|
1347 | - // Show fields of bank account |
|
1348 | - foreach ($companybankaccount->getFieldsToShow(1) as $val) { |
|
1349 | - |
|
1350 | - $require=false; |
|
1351 | - if ($val == 'BankCode') { |
|
1352 | - $name = 'code_banque'; |
|
1353 | - $size = 8; |
|
1354 | - $content = $companybankaccount->code_banque; |
|
1355 | - } elseif ($val == 'DeskCode') { |
|
1356 | - $name = 'code_guichet'; |
|
1357 | - $size = 8; |
|
1358 | - $content = $companybankaccount->code_guichet; |
|
1359 | - } elseif ($val == 'BankAccountNumber') { |
|
1360 | - $name = 'number'; |
|
1361 | - $size = 18; |
|
1362 | - $content = $companybankaccount->number; |
|
1363 | - } elseif ($val == 'BankAccountNumberKey') { |
|
1364 | - $name = 'cle_rib'; |
|
1365 | - $size = 3; |
|
1366 | - $content = $companybankaccount->cle_rib; |
|
1367 | - } elseif ($val == 'IBAN') { |
|
1368 | - $name = 'iban'; |
|
1369 | - $size = 30; |
|
1370 | - $content = $companybankaccount->iban; |
|
1371 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1372 | - } elseif ($val == 'BIC') { |
|
1373 | - $name = 'bic'; |
|
1374 | - $size = 12; |
|
1375 | - $content = $companybankaccount->bic; |
|
1376 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1377 | - } |
|
1378 | - |
|
1379 | - print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
|
1380 | - print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>'; |
|
1381 | - print '</tr>'; |
|
1382 | - } |
|
1383 | - |
|
1384 | - print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>'; |
|
1385 | - print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">'; |
|
1386 | - print $companybankaccount->domiciliation; |
|
1387 | - print "</textarea></td></tr>"; |
|
1388 | - |
|
1389 | - print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>'; |
|
1390 | - print '<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.'"></td></tr>'; |
|
1391 | - print "</td></tr>\n"; |
|
1392 | - |
|
1393 | - print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>'; |
|
1394 | - print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">'; |
|
1395 | - print $companybankaccount->owner_address; |
|
1396 | - print "</textarea></td></tr>"; |
|
1397 | - |
|
1398 | - print '</table>'; |
|
1399 | - |
|
1400 | - if ($conf->prelevement->enabled) |
|
1401 | - { |
|
1402 | - print '<br>'; |
|
1403 | - |
|
1404 | - print '<table class="border" width="100%">'; |
|
1405 | - |
|
1406 | - if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
1407 | - |
|
1408 | - // RUM |
|
1409 | - print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>'; |
|
1410 | - print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>'; |
|
1411 | - |
|
1412 | - print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>'; |
|
1413 | - $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); |
|
1414 | - print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$companybankaccount->frstrecur), 0); |
|
1415 | - print '</td></tr>'; |
|
1416 | - |
|
1417 | - print '</table>'; |
|
1418 | - } |
|
1419 | - |
|
1420 | - print '</div>'; |
|
1421 | - |
|
1422 | - dol_fiche_end(); |
|
1423 | - |
|
1424 | - print '<div align="center">'; |
|
1425 | - print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">'; |
|
1426 | - print ' '; |
|
1427 | - print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1428 | - print '</div>'; |
|
1330 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1331 | + |
|
1332 | + $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1333 | + |
|
1334 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1335 | + |
|
1336 | + print '<div class="fichecenter">'; |
|
1337 | + |
|
1338 | + print '<div class="underbanner clearboth"></div>'; |
|
1339 | + print '<table class="border centpercent">'; |
|
1340 | + |
|
1341 | + print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>'; |
|
1342 | + print '<td><input class="minwidth300" type="text" name="label" value="'.$companybankaccount->label.'"></td></tr>'; |
|
1343 | + |
|
1344 | + print '<tr><td class="fieldrequired">'.$langs->trans("BankName").'</td>'; |
|
1345 | + print '<td><input class="minwidth200" type="text" name="bank" value="'.$companybankaccount->bank.'"></td></tr>'; |
|
1346 | + |
|
1347 | + // Show fields of bank account |
|
1348 | + foreach ($companybankaccount->getFieldsToShow(1) as $val) { |
|
1349 | + |
|
1350 | + $require=false; |
|
1351 | + if ($val == 'BankCode') { |
|
1352 | + $name = 'code_banque'; |
|
1353 | + $size = 8; |
|
1354 | + $content = $companybankaccount->code_banque; |
|
1355 | + } elseif ($val == 'DeskCode') { |
|
1356 | + $name = 'code_guichet'; |
|
1357 | + $size = 8; |
|
1358 | + $content = $companybankaccount->code_guichet; |
|
1359 | + } elseif ($val == 'BankAccountNumber') { |
|
1360 | + $name = 'number'; |
|
1361 | + $size = 18; |
|
1362 | + $content = $companybankaccount->number; |
|
1363 | + } elseif ($val == 'BankAccountNumberKey') { |
|
1364 | + $name = 'cle_rib'; |
|
1365 | + $size = 3; |
|
1366 | + $content = $companybankaccount->cle_rib; |
|
1367 | + } elseif ($val == 'IBAN') { |
|
1368 | + $name = 'iban'; |
|
1369 | + $size = 30; |
|
1370 | + $content = $companybankaccount->iban; |
|
1371 | + if ($companybankaccount->needIBAN()) $require=true; |
|
1372 | + } elseif ($val == 'BIC') { |
|
1373 | + $name = 'bic'; |
|
1374 | + $size = 12; |
|
1375 | + $content = $companybankaccount->bic; |
|
1376 | + if ($companybankaccount->needIBAN()) $require=true; |
|
1377 | + } |
|
1378 | + |
|
1379 | + print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
|
1380 | + print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>'; |
|
1381 | + print '</tr>'; |
|
1382 | + } |
|
1383 | + |
|
1384 | + print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>'; |
|
1385 | + print '<textarea name="domiciliation" rows="4" cols="40" maxlength="255">'; |
|
1386 | + print $companybankaccount->domiciliation; |
|
1387 | + print "</textarea></td></tr>"; |
|
1388 | + |
|
1389 | + print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>'; |
|
1390 | + print '<td><input class="minwidth300" type="text" name="proprio" value="'.$companybankaccount->proprio.'"></td></tr>'; |
|
1391 | + print "</td></tr>\n"; |
|
1392 | + |
|
1393 | + print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>'; |
|
1394 | + print '<textarea name="owner_address" rows="'.ROWS_4.'" cols="40" maxlength="255">'; |
|
1395 | + print $companybankaccount->owner_address; |
|
1396 | + print "</textarea></td></tr>"; |
|
1397 | + |
|
1398 | + print '</table>'; |
|
1399 | + |
|
1400 | + if ($conf->prelevement->enabled) |
|
1401 | + { |
|
1402 | + print '<br>'; |
|
1403 | + |
|
1404 | + print '<table class="border" width="100%">'; |
|
1405 | + |
|
1406 | + if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
1407 | + |
|
1408 | + // RUM |
|
1409 | + print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>'; |
|
1410 | + print '<td><input class="minwidth300" type="text" name="rum" value="'.dol_escape_htmltag($companybankaccount->rum).'"></td></tr>'; |
|
1411 | + |
|
1412 | + print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>'; |
|
1413 | + $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); |
|
1414 | + print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$companybankaccount->frstrecur), 0); |
|
1415 | + print '</td></tr>'; |
|
1416 | + |
|
1417 | + print '</table>'; |
|
1418 | + } |
|
1419 | + |
|
1420 | + print '</div>'; |
|
1421 | + |
|
1422 | + dol_fiche_end(); |
|
1423 | + |
|
1424 | + print '<div align="center">'; |
|
1425 | + print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">'; |
|
1426 | + print ' '; |
|
1427 | + print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1428 | + print '</div>'; |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | 1431 | // Edit Card |
1432 | 1432 | if ($socid && $action == 'editcard' && $user->rights->societe->creer) |
1433 | 1433 | { |
1434 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1434 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1435 | 1435 | |
1436 | - $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1436 | + $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1437 | 1437 | |
1438 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1438 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1439 | 1439 | |
1440 | - print '<div class="fichecenter">'; |
|
1440 | + print '<div class="fichecenter">'; |
|
1441 | 1441 | |
1442 | - print '<div class="underbanner clearboth"></div>'; |
|
1443 | - print '<table class="border centpercent">'; |
|
1442 | + print '<div class="underbanner clearboth"></div>'; |
|
1443 | + print '<table class="border centpercent">'; |
|
1444 | 1444 | |
1445 | - print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>'; |
|
1446 | - print '<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.'"></td></tr>'; |
|
1445 | + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>'; |
|
1446 | + print '<td><input class="minwidth300" type="text" id="label" name="label" value="'.$companypaymentmode->label.'"></td></tr>'; |
|
1447 | 1447 | |
1448 | - print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>'; |
|
1449 | - print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>'; |
|
1448 | + print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>'; |
|
1449 | + print '<td><input class="minwidth200" type="text" name="proprio" value="'.$companypaymentmode->proprio.'"></td></tr>'; |
|
1450 | 1450 | |
1451 | - print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>'; |
|
1452 | - print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>'; |
|
1451 | + print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>'; |
|
1452 | + print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.$companypaymentmode->number.'"></td></tr>'; |
|
1453 | 1453 | |
1454 | - print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>'; |
|
1455 | - print '<td>'; |
|
1456 | - print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1); |
|
1457 | - print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); |
|
1458 | - print '</td></tr>'; |
|
1454 | + print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>'; |
|
1455 | + print '<td>'; |
|
1456 | + print $formother->select_month($companypaymentmode->exp_date_month, 'exp_date_month', 1); |
|
1457 | + print $formother->select_year($companypaymentmode->exp_date_year, 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); |
|
1458 | + print '</td></tr>'; |
|
1459 | 1459 | |
1460 | - print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>'; |
|
1461 | - print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>'; |
|
1460 | + print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>'; |
|
1461 | + print '<td><input size="8" type="text" name="cvn" value="'.$companypaymentmode->cvn.'"></td></tr>'; |
|
1462 | 1462 | |
1463 | - print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>"; |
|
1464 | - print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.'"></td></tr>'; |
|
1463 | + print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>"; |
|
1464 | + print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.$companypaymentmode->stripe_card_ref.'"></td></tr>'; |
|
1465 | 1465 | |
1466 | - print '</table>'; |
|
1467 | - print '</div>'; |
|
1466 | + print '</table>'; |
|
1467 | + print '</div>'; |
|
1468 | 1468 | |
1469 | - dol_fiche_end(); |
|
1469 | + dol_fiche_end(); |
|
1470 | 1470 | |
1471 | - print '<div align="center">'; |
|
1472 | - print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">'; |
|
1473 | - print ' '; |
|
1474 | - print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1475 | - print '</div>'; |
|
1471 | + print '<div align="center">'; |
|
1472 | + print '<input class="button" value="'.$langs->trans("Modify").'" type="submit">'; |
|
1473 | + print ' '; |
|
1474 | + print '<input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1475 | + print '</div>'; |
|
1476 | 1476 | } |
1477 | 1477 | |
1478 | 1478 | |
1479 | 1479 | // Create BAN |
1480 | 1480 | if ($socid && $action == 'create' && $user->rights->societe->creer) |
1481 | 1481 | { |
1482 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1483 | - |
|
1484 | - $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1485 | - |
|
1486 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1487 | - |
|
1488 | - print '<div class="nofichecenter">'; |
|
1489 | - |
|
1490 | - print '<div class="underbanner clearboth"></div>'; |
|
1491 | - print '<table class="border centpercent">'; |
|
1492 | - |
|
1493 | - print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>'; |
|
1494 | - print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label').'"></td></tr>'; |
|
1495 | - |
|
1496 | - print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>'; |
|
1497 | - print '<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>'; |
|
1498 | - |
|
1499 | - // Show fields of bank account |
|
1500 | - foreach ($companybankaccount->getFieldsToShow(1) as $val) { |
|
1501 | - |
|
1502 | - $require=false; |
|
1503 | - if ($val == 'BankCode') { |
|
1504 | - $name = 'code_banque'; |
|
1505 | - $size = 8; |
|
1506 | - } elseif ($val == 'DeskCode') { |
|
1507 | - $name = 'code_guichet'; |
|
1508 | - $size = 8; |
|
1509 | - } elseif ($val == 'BankAccountNumber') { |
|
1510 | - $name = 'number'; |
|
1511 | - $size = 18; |
|
1512 | - } elseif ($val == 'BankAccountNumberKey') { |
|
1513 | - $name = 'cle_rib'; |
|
1514 | - $size = 3; |
|
1515 | - } elseif ($val == 'IBAN') { |
|
1516 | - $name = 'iban'; |
|
1517 | - $size = 30; |
|
1518 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1519 | - } elseif ($val == 'BIC') { |
|
1520 | - $name = 'bic'; |
|
1521 | - $size = 12; |
|
1522 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1523 | - } |
|
1524 | - |
|
1525 | - print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
|
1526 | - print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>'; |
|
1527 | - print '</tr>'; |
|
1528 | - } |
|
1529 | - |
|
1530 | - print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>'; |
|
1531 | - print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">'; |
|
1532 | - print GETPOST('domiciliation'); |
|
1533 | - print "</textarea></td></tr>"; |
|
1534 | - |
|
1535 | - print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>'; |
|
1536 | - print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>'; |
|
1537 | - print "</td></tr>\n"; |
|
1538 | - |
|
1539 | - print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>'; |
|
1540 | - print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">'; |
|
1541 | - print GETPOST('owner_address'); |
|
1542 | - print "</textarea></td></tr>"; |
|
1543 | - |
|
1544 | - print '</table>'; |
|
1545 | - |
|
1546 | - if ($conf->prelevement->enabled) |
|
1547 | - { |
|
1548 | - print '<br>'; |
|
1549 | - |
|
1550 | - print '<table class="border" width="100%">'; |
|
1551 | - |
|
1552 | - // RUM |
|
1553 | - print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>'; |
|
1554 | - print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>'; |
|
1555 | - |
|
1556 | - print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>'; |
|
1557 | - $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); |
|
1558 | - print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); |
|
1559 | - print '</td></tr>'; |
|
1560 | - |
|
1561 | - print '</table>'; |
|
1562 | - } |
|
1563 | - |
|
1564 | - print '</div>'; |
|
1565 | - |
|
1566 | - dol_fiche_end(); |
|
1567 | - |
|
1568 | - dol_set_focus('#label'); |
|
1569 | - |
|
1570 | - print '<div class="center">'; |
|
1571 | - print '<input class="button" value="'.$langs->trans("Add").'" type="submit">'; |
|
1572 | - print ' '; |
|
1573 | - print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1574 | - print '</div>'; |
|
1482 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1483 | + |
|
1484 | + $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1485 | + |
|
1486 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1487 | + |
|
1488 | + print '<div class="nofichecenter">'; |
|
1489 | + |
|
1490 | + print '<div class="underbanner clearboth"></div>'; |
|
1491 | + print '<table class="border centpercent">'; |
|
1492 | + |
|
1493 | + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("LabelRIB").'</td>'; |
|
1494 | + print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label').'"></td></tr>'; |
|
1495 | + |
|
1496 | + print '<tr><td class="fieldrequired">'.$langs->trans("Bank").'</td>'; |
|
1497 | + print '<td><input class="minwidth200" type="text" name="bank" value="'.GETPOST('bank').'"></td></tr>'; |
|
1498 | + |
|
1499 | + // Show fields of bank account |
|
1500 | + foreach ($companybankaccount->getFieldsToShow(1) as $val) { |
|
1501 | + |
|
1502 | + $require=false; |
|
1503 | + if ($val == 'BankCode') { |
|
1504 | + $name = 'code_banque'; |
|
1505 | + $size = 8; |
|
1506 | + } elseif ($val == 'DeskCode') { |
|
1507 | + $name = 'code_guichet'; |
|
1508 | + $size = 8; |
|
1509 | + } elseif ($val == 'BankAccountNumber') { |
|
1510 | + $name = 'number'; |
|
1511 | + $size = 18; |
|
1512 | + } elseif ($val == 'BankAccountNumberKey') { |
|
1513 | + $name = 'cle_rib'; |
|
1514 | + $size = 3; |
|
1515 | + } elseif ($val == 'IBAN') { |
|
1516 | + $name = 'iban'; |
|
1517 | + $size = 30; |
|
1518 | + if ($companybankaccount->needIBAN()) $require=true; |
|
1519 | + } elseif ($val == 'BIC') { |
|
1520 | + $name = 'bic'; |
|
1521 | + $size = 12; |
|
1522 | + if ($companybankaccount->needIBAN()) $require=true; |
|
1523 | + } |
|
1524 | + |
|
1525 | + print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
|
1526 | + print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>'; |
|
1527 | + print '</tr>'; |
|
1528 | + } |
|
1529 | + |
|
1530 | + print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>'; |
|
1531 | + print '<textarea name="domiciliation" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">'; |
|
1532 | + print GETPOST('domiciliation'); |
|
1533 | + print "</textarea></td></tr>"; |
|
1534 | + |
|
1535 | + print '<tr><td>'.$langs->trans("BankAccountOwner").'</td>'; |
|
1536 | + print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio').'"></td></tr>'; |
|
1537 | + print "</td></tr>\n"; |
|
1538 | + |
|
1539 | + print '<tr><td>'.$langs->trans("BankAccountOwnerAddress").'</td><td>'; |
|
1540 | + print '<textarea name="owner_address" rows="'.ROWS_4.'" class="quatrevingtpercent" maxlength="255">'; |
|
1541 | + print GETPOST('owner_address'); |
|
1542 | + print "</textarea></td></tr>"; |
|
1543 | + |
|
1544 | + print '</table>'; |
|
1545 | + |
|
1546 | + if ($conf->prelevement->enabled) |
|
1547 | + { |
|
1548 | + print '<br>'; |
|
1549 | + |
|
1550 | + print '<table class="border" width="100%">'; |
|
1551 | + |
|
1552 | + // RUM |
|
1553 | + print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>'; |
|
1554 | + print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>'; |
|
1555 | + |
|
1556 | + print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>'; |
|
1557 | + $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); |
|
1558 | + print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); |
|
1559 | + print '</td></tr>'; |
|
1560 | + |
|
1561 | + print '</table>'; |
|
1562 | + } |
|
1563 | + |
|
1564 | + print '</div>'; |
|
1565 | + |
|
1566 | + dol_fiche_end(); |
|
1567 | + |
|
1568 | + dol_set_focus('#label'); |
|
1569 | + |
|
1570 | + print '<div class="center">'; |
|
1571 | + print '<input class="button" value="'.$langs->trans("Add").'" type="submit">'; |
|
1572 | + print ' '; |
|
1573 | + print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1574 | + print '</div>'; |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | // Create Card |
1578 | 1578 | if ($socid && $action == 'createcard' && $user->rights->societe->creer) |
1579 | 1579 | { |
1580 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1580 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1581 | 1581 | |
1582 | - $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1582 | + $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
|
1583 | 1583 | |
1584 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1584 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1585 | 1585 | |
1586 | - print '<div class="nofichecenter">'; |
|
1586 | + print '<div class="nofichecenter">'; |
|
1587 | 1587 | |
1588 | - print '<div class="underbanner clearboth"></div>'; |
|
1589 | - print '<table class="border centpercent">'; |
|
1588 | + print '<div class="underbanner clearboth"></div>'; |
|
1589 | + print '<table class="border centpercent">'; |
|
1590 | 1590 | |
1591 | - print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>'; |
|
1592 | - print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label','alpha').'"></td></tr>'; |
|
1591 | + print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>'; |
|
1592 | + print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label','alpha').'"></td></tr>'; |
|
1593 | 1593 | |
1594 | - print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>'; |
|
1595 | - print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio','alpha').'"></td></tr>'; |
|
1594 | + print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>'; |
|
1595 | + print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio','alpha').'"></td></tr>'; |
|
1596 | 1596 | |
1597 | - print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>'; |
|
1598 | - print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber','alpha').'"></td></tr>'; |
|
1597 | + print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>'; |
|
1598 | + print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber','alpha').'"></td></tr>'; |
|
1599 | 1599 | |
1600 | - print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>'; |
|
1601 | - print '<td>'; |
|
1602 | - print $formother->select_month(GETPOST('exp_date_month','int'), 'exp_date_month', 1); |
|
1603 | - print $formother->select_year(GETPOST('exp_date_year','int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); |
|
1604 | - print '</td></tr>'; |
|
1600 | + print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>'; |
|
1601 | + print '<td>'; |
|
1602 | + print $formother->select_month(GETPOST('exp_date_month','int'), 'exp_date_month', 1); |
|
1603 | + print $formother->select_year(GETPOST('exp_date_year','int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); |
|
1604 | + print '</td></tr>'; |
|
1605 | 1605 | |
1606 | - print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>'; |
|
1607 | - print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn','alpha').'"></td></tr>'; |
|
1606 | + print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>'; |
|
1607 | + print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn','alpha').'"></td></tr>'; |
|
1608 | 1608 | |
1609 | - print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>"; |
|
1610 | - print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref','alpha').'"></td></tr>'; |
|
1609 | + print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>"; |
|
1610 | + print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref','alpha').'"></td></tr>'; |
|
1611 | 1611 | |
1612 | - print '</table>'; |
|
1612 | + print '</table>'; |
|
1613 | 1613 | |
1614 | - print '</div>'; |
|
1614 | + print '</div>'; |
|
1615 | 1615 | |
1616 | - dol_fiche_end(); |
|
1616 | + dol_fiche_end(); |
|
1617 | 1617 | |
1618 | - dol_set_focus('#label'); |
|
1618 | + dol_set_focus('#label'); |
|
1619 | 1619 | |
1620 | - print '<div class="center">'; |
|
1621 | - print '<input class="button" value="'.$langs->trans("Add").'" type="submit">'; |
|
1622 | - print ' '; |
|
1623 | - print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1624 | - print '</div>'; |
|
1620 | + print '<div class="center">'; |
|
1621 | + print '<input class="button" value="'.$langs->trans("Add").'" type="submit">'; |
|
1622 | + print ' '; |
|
1623 | + print '<input name="cancel" class="button" value="'.$langs->trans("Cancel").'" type="submit">'; |
|
1624 | + print '</div>'; |
|
1625 | 1625 | } |
1626 | 1626 | |
1627 | 1627 | if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) |
1628 | 1628 | { |
1629 | - print '</form>'; |
|
1629 | + print '</form>'; |
|
1630 | 1630 | } |
1631 | 1631 | if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) |
1632 | 1632 | { |
1633 | - print '</form>'; |
|
1633 | + print '</form>'; |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | // End of page |
@@ -44,7 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | // Security check |
46 | 46 | $socid = GETPOST("socid","int"); |
47 | -if ($user->societe_id) $socid=$user->societe_id; |
|
47 | +if ($user->societe_id) { |
|
48 | + $socid=$user->societe_id; |
|
49 | +} |
|
48 | 50 | $result = restrictedArea($user, 'societe','',''); |
49 | 51 | |
50 | 52 | $id=GETPOST("id","int"); |
@@ -97,7 +99,9 @@ discard block |
||
97 | 99 | |
98 | 100 | $parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); |
99 | 101 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
100 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
102 | +if ($reshook < 0) { |
|
103 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
104 | +} |
|
101 | 105 | |
102 | 106 | if (empty($reshook)) |
103 | 107 | { |
@@ -116,8 +120,12 @@ discard block |
||
116 | 120 | // Modification |
117 | 121 | if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
118 | 122 | { |
119 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
120 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
123 | + if (! GETPOST('label','alpha')) { |
|
124 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
125 | + } |
|
126 | + if (! GETPOST('bank','alpha')) { |
|
127 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
128 | + } |
|
121 | 129 | $action='edit'; |
122 | 130 | $error++; |
123 | 131 | } |
@@ -167,8 +175,7 @@ discard block |
||
167 | 175 | if (! $result) |
168 | 176 | { |
169 | 177 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
170 | - } |
|
171 | - else |
|
178 | + } else |
|
172 | 179 | { |
173 | 180 | // If this account is the default bank account, we disable others |
174 | 181 | if ($companybankaccount->default_rib) |
@@ -188,11 +195,21 @@ discard block |
||
188 | 195 | // Modification |
189 | 196 | if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
190 | 197 | { |
191 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
192 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
193 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
194 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
195 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
198 | + if (! GETPOST('label','alpha')) { |
|
199 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
200 | + } |
|
201 | + if (! GETPOST('proprio','alpha')) { |
|
202 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
203 | + } |
|
204 | + if (! GETPOST('cardnumber','alpha')) { |
|
205 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
206 | + } |
|
207 | + if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) { |
|
208 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
209 | + } |
|
210 | + if (! GETPOST('cvn','alpha')) { |
|
211 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
212 | + } |
|
196 | 213 | $action='createcard'; |
197 | 214 | $error++; |
198 | 215 | } |
@@ -218,8 +235,7 @@ discard block |
||
218 | 235 | if (! $result) |
219 | 236 | { |
220 | 237 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
221 | - } |
|
222 | - else |
|
238 | + } else |
|
223 | 239 | { |
224 | 240 | // If this account is the default bank account, we disable others |
225 | 241 | if ($companypaymentmode->default_rib) |
@@ -240,8 +256,12 @@ discard block |
||
240 | 256 | |
241 | 257 | if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
242 | 258 | { |
243 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
244 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
259 | + if (! GETPOST('label','alpha')) { |
|
260 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
261 | + } |
|
262 | + if (! GETPOST('bank','alpha')) { |
|
263 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
264 | + } |
|
245 | 265 | $action='create'; |
246 | 266 | $error++; |
247 | 267 | } |
@@ -325,8 +345,7 @@ discard block |
||
325 | 345 | $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
326 | 346 | header('Location: '.$url); |
327 | 347 | exit; |
328 | - } |
|
329 | - else |
|
348 | + } else |
|
330 | 349 | { |
331 | 350 | $db->rollback(); |
332 | 351 | } |
@@ -339,11 +358,21 @@ discard block |
||
339 | 358 | |
340 | 359 | if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
341 | 360 | { |
342 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
343 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
344 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
345 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
346 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
361 | + if (! GETPOST('label','alpha')) { |
|
362 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
363 | + } |
|
364 | + if (! GETPOST('proprio','alpha')) { |
|
365 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
366 | + } |
|
367 | + if (! GETPOST('cardnumber','alpha')) { |
|
368 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
369 | + } |
|
370 | + if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) { |
|
371 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
372 | + } |
|
373 | + if (! GETPOST('cvn','alpha')) { |
|
374 | + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
375 | + } |
|
347 | 376 | $action='createcard'; |
348 | 377 | $error++; |
349 | 378 | } |
@@ -390,8 +419,7 @@ discard block |
||
390 | 419 | $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
391 | 420 | header('Location: '.$url); |
392 | 421 | exit; |
393 | - } |
|
394 | - else |
|
422 | + } else |
|
395 | 423 | { |
396 | 424 | $db->rollback(); |
397 | 425 | } |
@@ -407,8 +435,7 @@ discard block |
||
407 | 435 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
408 | 436 | header('Location: '.$url); |
409 | 437 | exit; |
410 | - } |
|
411 | - else |
|
438 | + } else |
|
412 | 439 | { |
413 | 440 | setEventMessages($db->lasterror, null, 'errors'); |
414 | 441 | } |
@@ -425,13 +452,11 @@ discard block |
||
425 | 452 | $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
426 | 453 | header('Location: '.$url); |
427 | 454 | exit; |
428 | - } |
|
429 | - else |
|
455 | + } else |
|
430 | 456 | { |
431 | 457 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
432 | 458 | } |
433 | - } |
|
434 | - else |
|
459 | + } else |
|
435 | 460 | { |
436 | 461 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
437 | 462 | } |
@@ -447,13 +472,11 @@ discard block |
||
447 | 472 | $url = $_SERVER['PHP_SELF']."?socid=".$object->id; |
448 | 473 | header('Location: '.$url); |
449 | 474 | exit; |
450 | - } |
|
451 | - else |
|
475 | + } else |
|
452 | 476 | { |
453 | 477 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
454 | 478 | } |
455 | - } |
|
456 | - else |
|
479 | + } else |
|
457 | 480 | { |
458 | 481 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
459 | 482 | } |
@@ -489,8 +512,7 @@ discard block |
||
489 | 512 | { |
490 | 513 | $error++; |
491 | 514 | setEventMessages('ThisThirdpartyIsNotACustomer', null, 'errors'); |
492 | - } |
|
493 | - else |
|
515 | + } else |
|
494 | 516 | { |
495 | 517 | // Creation of Stripe customer + update of societe_account |
496 | 518 | $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); |
@@ -498,8 +520,7 @@ discard block |
||
498 | 520 | { |
499 | 521 | $error++; |
500 | 522 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
501 | - } |
|
502 | - else |
|
523 | + } else |
|
503 | 524 | { |
504 | 525 | $stripecu = $cu->id; |
505 | 526 | } |
@@ -514,8 +535,7 @@ discard block |
||
514 | 535 | { |
515 | 536 | $error++; |
516 | 537 | setEventMessages('ThisPaymentModeIsNotACard', null, 'errors'); |
517 | - } |
|
518 | - else |
|
538 | + } else |
|
519 | 539 | { |
520 | 540 | // Get the Stripe customer |
521 | 541 | $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
@@ -533,8 +553,7 @@ discard block |
||
533 | 553 | { |
534 | 554 | $error++; |
535 | 555 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
536 | - } |
|
537 | - else |
|
556 | + } else |
|
538 | 557 | { |
539 | 558 | $stripecard = $card->id; |
540 | 559 | } |
@@ -580,8 +599,7 @@ discard block |
||
580 | 599 | { |
581 | 600 | $stripecu = $newcu; |
582 | 601 | $db->commit(); |
583 | - } |
|
584 | - else |
|
602 | + } else |
|
585 | 603 | { |
586 | 604 | $db->rollback(); |
587 | 605 | } |
@@ -594,14 +612,12 @@ discard block |
||
594 | 612 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
595 | 613 | header('Location: '.$url); |
596 | 614 | exit; |
597 | - } |
|
598 | - catch(Exception $e) |
|
615 | + } catch(Exception $e) |
|
599 | 616 | { |
600 | 617 | $error++; |
601 | 618 | setEventMessages($e->getMessage(), null, 'errors'); |
602 | 619 | } |
603 | - } |
|
604 | - elseif ($action == 'setassourcedefault') |
|
620 | + } elseif ($action == 'setassourcedefault') |
|
605 | 621 | { |
606 | 622 | try { |
607 | 623 | $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
@@ -611,14 +627,12 @@ discard block |
||
611 | 627 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
612 | 628 | header('Location: '.$url); |
613 | 629 | exit; |
614 | - } |
|
615 | - catch(Exception $e) |
|
630 | + } catch(Exception $e) |
|
616 | 631 | { |
617 | 632 | $error++; |
618 | 633 | setEventMessages($e->getMessage(), null, 'errors'); |
619 | 634 | } |
620 | - } |
|
621 | - elseif ($action == 'deletecard' && $source) |
|
635 | + } elseif ($action == 'deletecard' && $source) |
|
622 | 636 | { |
623 | 637 | try { |
624 | 638 | $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
@@ -626,15 +640,17 @@ discard block |
||
626 | 640 | if ($card) |
627 | 641 | { |
628 | 642 | // $card->detach(); Does not work with card_, only with src_ |
629 | - if (method_exists($card, 'detach')) $card->detach(); |
|
630 | - else $card->delete(); |
|
643 | + if (method_exists($card, 'detach')) { |
|
644 | + $card->detach(); |
|
645 | + } else { |
|
646 | + $card->delete(); |
|
647 | + } |
|
631 | 648 | } |
632 | 649 | |
633 | 650 | $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
634 | 651 | header('Location: '.$url); |
635 | 652 | exit; |
636 | - } |
|
637 | - catch(Exception $e) |
|
653 | + } catch(Exception $e) |
|
638 | 654 | { |
639 | 655 | $error++; |
640 | 656 | setEventMessages($e->getMessage(), null, 'errors'); |
@@ -672,20 +688,23 @@ discard block |
||
672 | 688 | { |
673 | 689 | $companybankaccount->fetch(0, $object->id); |
674 | 690 | $companypaymentmode->fetch(0, null, $object->id, 'card'); |
675 | -} |
|
676 | -else |
|
691 | +} else |
|
677 | 692 | { |
678 | 693 | $companybankaccount->fetch($id); |
679 | 694 | $companypaymentmode->fetch($id); |
680 | 695 | } |
681 | -if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id; |
|
696 | +if (empty($companybankaccount->socid)) { |
|
697 | + $companybankaccount->socid=$object->id; |
|
698 | +} |
|
682 | 699 | |
683 | 700 | if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) |
684 | 701 | { |
685 | 702 | print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
686 | 703 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
687 | 704 | $actionforadd='update'; |
688 | - if ($action == 'editcard') $actionforadd='updatecard'; |
|
705 | + if ($action == 'editcard') { |
|
706 | + $actionforadd='updatecard'; |
|
707 | + } |
|
689 | 708 | print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
690 | 709 | print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">'; |
691 | 710 | } |
@@ -694,7 +713,9 @@ discard block |
||
694 | 713 | print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
695 | 714 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
696 | 715 | $actionforadd='add'; |
697 | - if ($action == 'createcard') $actionforadd='addcard'; |
|
716 | + if ($action == 'createcard') { |
|
717 | + $actionforadd='addcard'; |
|
718 | + } |
|
698 | 719 | print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
699 | 720 | } |
700 | 721 | |
@@ -720,10 +741,12 @@ discard block |
||
720 | 741 | dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
721 | 742 | |
722 | 743 | |
723 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
744 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
745 | + // Old not used prefix field |
|
724 | 746 | { |
725 | 747 | print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
726 | 748 | } |
749 | + } |
|
727 | 750 | |
728 | 751 | //if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events'); |
729 | 752 | |
@@ -737,19 +760,31 @@ discard block |
||
737 | 760 | print '<tr><td class="titlefield">'; |
738 | 761 | print $langs->trans('CustomerCode').'</td><td colspan="2">'; |
739 | 762 | print $object->code_client; |
740 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
763 | + if ($object->check_codeclient() <> 0) { |
|
764 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
765 | + } |
|
741 | 766 | print '</td></tr>'; |
742 | 767 | $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; |
743 | 768 | $resql=$db->query($sql); |
744 | - if (!$resql) dol_print_error($db); |
|
769 | + if (!$resql) { |
|
770 | + dol_print_error($db); |
|
771 | + } |
|
745 | 772 | |
746 | 773 | $obj = $db->fetch_object($resql); |
747 | 774 | $nbFactsClient = $obj->nb; |
748 | 775 | $thirdTypeArray['customer']=$langs->trans("customer"); |
749 | - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
750 | - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
751 | - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
752 | - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
776 | + if ($conf->propal->enabled && $user->rights->propal->lire) { |
|
777 | + $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
778 | + } |
|
779 | + if ($conf->commande->enabled && $user->rights->commande->lire) { |
|
780 | + $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
781 | + } |
|
782 | + if ($conf->facture->enabled && $user->rights->facture->lire) { |
|
783 | + $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
784 | + } |
|
785 | + if ($conf->contrat->enabled && $user->rights->contrat->lire) { |
|
786 | + $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
787 | + } |
|
753 | 788 | } |
754 | 789 | |
755 | 790 | if (! empty($conf->stripe->enabled)) |
@@ -764,7 +799,9 @@ discard block |
||
764 | 799 | print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); |
765 | 800 | if ($stripecu && $action != 'editkey_account') |
766 | 801 | { |
767 | - if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; |
|
802 | + if (! empty($conf->stripe->enabled) && !empty($stripeacc)) { |
|
803 | + $connect=$stripeacc.'/'; |
|
804 | + } |
|
768 | 805 | $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; |
769 | 806 | if ($servicestatus) |
770 | 807 | { |
@@ -811,8 +848,7 @@ discard block |
||
811 | 848 | if ($customerstripe->id) { |
812 | 849 | $listofsources=$customerstripe->sources->data; |
813 | 850 | } |
814 | - } |
|
815 | - catch(Exception $e) |
|
851 | + } catch(Exception $e) |
|
816 | 852 | { |
817 | 853 | dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); |
818 | 854 | } |
@@ -888,16 +924,21 @@ discard block |
||
888 | 924 | print img_credit_card($companypaymentmodetemp->type); |
889 | 925 | print '</td>'; |
890 | 926 | print '<td>'; |
891 | - if ($companypaymentmodetemp->last_four) print '....'.$companypaymentmodetemp->last_four; |
|
892 | - if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; |
|
927 | + if ($companypaymentmodetemp->last_four) { |
|
928 | + print '....'.$companypaymentmodetemp->last_four; |
|
929 | + } |
|
930 | + if ($companypaymentmodetemp->exp_date_month || $companypaymentmodetemp->exp_date_year) { |
|
931 | + print ' - '.sprintf("%02d", $companypaymentmodetemp->exp_date_month).'/'.$companypaymentmodetemp->exp_date_year.''; |
|
932 | + } |
|
893 | 933 | print '</td><td>'; |
894 | 934 | if ($companypaymentmodetemp->country_code) |
895 | 935 | { |
896 | 936 | $img=picto_from_langcode($companypaymentmodetemp->country_code); |
897 | 937 | print $img?$img.' ':''; |
898 | 938 | print getCountry($companypaymentmodetemp->country_code,1); |
939 | + } else { |
|
940 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
899 | 941 | } |
900 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
901 | 942 | print '</td>'; |
902 | 943 | // Default |
903 | 944 | print '<td align="center">'; |
@@ -911,8 +952,11 @@ discard block |
||
911 | 952 | } |
912 | 953 | print '</td>'; |
913 | 954 | print '<td>'; |
914 | - if (empty($companypaymentmodetemp->stripe_card_ref)) print $langs->trans("Local"); |
|
915 | - else print $langs->trans("LocalAndRemote"); |
|
955 | + if (empty($companypaymentmodetemp->stripe_card_ref)) { |
|
956 | + print $langs->trans("Local"); |
|
957 | + } else { |
|
958 | + print $langs->trans("LocalAndRemote"); |
|
959 | + } |
|
916 | 960 | print '</td>'; |
917 | 961 | print '<td>'; |
918 | 962 | print dol_print_date($companypaymentmodetemp->tms, 'dayhour'); |
@@ -939,8 +983,9 @@ discard block |
||
939 | 983 | $i++; |
940 | 984 | } |
941 | 985 | } |
986 | + } else { |
|
987 | + dol_print_error($db); |
|
942 | 988 | } |
943 | - else dol_print_error($db); |
|
944 | 989 | } |
945 | 990 | |
946 | 991 | // Show remote sources (not already shown as local source) |
@@ -948,7 +993,10 @@ discard block |
||
948 | 993 | { |
949 | 994 | foreach ($listofsources as $src) |
950 | 995 | { |
951 | - if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list |
|
996 | + if (! empty($arrayofstripecard[$src->id])) { |
|
997 | + continue; |
|
998 | + } |
|
999 | + // Already in previous list |
|
952 | 1000 | |
953 | 1001 | $nbremote++; |
954 | 1002 | |
@@ -961,7 +1009,9 @@ discard block |
||
961 | 1009 | } |
962 | 1010 | // Src ID |
963 | 1011 | print '<td>'; |
964 | - if (!empty($stripeacc)) $connect=$stripeacc.'/'; |
|
1012 | + if (!empty($stripeacc)) { |
|
1013 | + $connect=$stripeacc.'/'; |
|
1014 | + } |
|
965 | 1015 | $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; |
966 | 1016 | if ($servicestatus) |
967 | 1017 | { |
@@ -974,12 +1024,10 @@ discard block |
||
974 | 1024 | if ($src->object=='card') |
975 | 1025 | { |
976 | 1026 | print img_credit_card($src->brand); |
977 | - } |
|
978 | - elseif ($src->object=='source' && $src->type=='card') |
|
1027 | + } elseif ($src->object=='source' && $src->type=='card') |
|
979 | 1028 | { |
980 | 1029 | print img_credit_card($src->card->brand); |
981 | - } |
|
982 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1030 | + } elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
983 | 1031 | { |
984 | 1032 | print '<span class="fa fa-university fa-2x fa-fw"></span>'; |
985 | 1033 | } |
@@ -994,10 +1042,10 @@ discard block |
||
994 | 1042 | $img=picto_from_langcode($src->country); |
995 | 1043 | print $img?$img.' ':''; |
996 | 1044 | print getCountry($src->country,1); |
1045 | + } else { |
|
1046 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
997 | 1047 | } |
998 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
999 | - } |
|
1000 | - elseif ($src->object=='source' && $src->type=='card') |
|
1048 | + } elseif ($src->object=='source' && $src->type=='card') |
|
1001 | 1049 | { |
1002 | 1050 | print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; |
1003 | 1051 | print '</td><td>'; |
@@ -1007,10 +1055,10 @@ discard block |
||
1007 | 1055 | $img=picto_from_langcode($src->card->country); |
1008 | 1056 | print $img?$img.' ':''; |
1009 | 1057 | print getCountry($src->card->country,1); |
1058 | + } else { |
|
1059 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1010 | 1060 | } |
1011 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1012 | - } |
|
1013 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1061 | + } elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1014 | 1062 | { |
1015 | 1063 | print 'info sepa'; |
1016 | 1064 | print '</td><td>'; |
@@ -1019,8 +1067,9 @@ discard block |
||
1019 | 1067 | $img=picto_from_langcode($src->sepa_debit->country); |
1020 | 1068 | print $img?$img.' ':''; |
1021 | 1069 | print getCountry($src->sepa_debit->country,1); |
1070 | + } else { |
|
1071 | + print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1022 | 1072 | } |
1023 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1024 | 1073 | } |
1025 | 1074 | print '</td>'; |
1026 | 1075 | // Default |
@@ -1190,12 +1239,16 @@ discard block |
||
1190 | 1239 | $out.= '<input type="hidden" name="socid" value="'.$object->id.'">'; |
1191 | 1240 | $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
1192 | 1241 | |
1193 | - if (is_array($modellist) && count($modellist) == 1) // If there is only one element |
|
1242 | + if (is_array($modellist) && count($modellist) == 1) { |
|
1243 | + // If there is only one element |
|
1194 | 1244 | { |
1195 | 1245 | $arraykeys=array_keys($modellist); |
1246 | + } |
|
1196 | 1247 | $modelselected=$arraykeys[0]; |
1197 | 1248 | } |
1198 | - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; |
|
1249 | + if (! empty($conf->global->BANKADDON_PDF)) { |
|
1250 | + $modelselected = $conf->global->BANKADDON_PDF; |
|
1251 | + } |
|
1199 | 1252 | |
1200 | 1253 | $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
1201 | 1254 | $out.= ajax_combobox('modelrib'.$rib->id); |
@@ -1207,21 +1260,29 @@ discard block |
||
1207 | 1260 | $formadmin=new FormAdmin($db); |
1208 | 1261 | $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); |
1209 | 1262 | $morecss='maxwidth150'; |
1210 | - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; |
|
1263 | + if ($conf->browser->layout == 'phone') { |
|
1264 | + $morecss='maxwidth100'; |
|
1265 | + } |
|
1211 | 1266 | $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); |
1212 | 1267 | } |
1213 | 1268 | // Button |
1214 | 1269 | $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; |
1215 | 1270 | $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; |
1216 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; |
|
1271 | + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) { |
|
1272 | + $genbutton.= ' disabled'; |
|
1273 | + } |
|
1217 | 1274 | $genbutton.= '>'; |
1218 | 1275 | if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
1219 | 1276 | { |
1220 | 1277 | $langs->load("errors"); |
1221 | 1278 | $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
1222 | 1279 | } |
1223 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; |
|
1224 | - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; |
|
1280 | + if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') { |
|
1281 | + $genbutton=''; |
|
1282 | + } |
|
1283 | + if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') { |
|
1284 | + $genbutton=''; |
|
1285 | + } |
|
1225 | 1286 | $out.= $genbutton; |
1226 | 1287 | $out.= '</form>'; |
1227 | 1288 | } |
@@ -1250,7 +1311,9 @@ discard block |
||
1250 | 1311 | if (count($rib_list) == 0) |
1251 | 1312 | { |
1252 | 1313 | $colspan=8; |
1253 | - if (! empty($conf->prelevement->enabled)) $colspan+=2; |
|
1314 | + if (! empty($conf->prelevement->enabled)) { |
|
1315 | + $colspan+=2; |
|
1316 | + } |
|
1254 | 1317 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; |
1255 | 1318 | } |
1256 | 1319 | |
@@ -1368,12 +1431,16 @@ discard block |
||
1368 | 1431 | $name = 'iban'; |
1369 | 1432 | $size = 30; |
1370 | 1433 | $content = $companybankaccount->iban; |
1371 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1434 | + if ($companybankaccount->needIBAN()) { |
|
1435 | + $require=true; |
|
1436 | + } |
|
1372 | 1437 | } elseif ($val == 'BIC') { |
1373 | 1438 | $name = 'bic'; |
1374 | 1439 | $size = 12; |
1375 | 1440 | $content = $companybankaccount->bic; |
1376 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1441 | + if ($companybankaccount->needIBAN()) { |
|
1442 | + $require=true; |
|
1443 | + } |
|
1377 | 1444 | } |
1378 | 1445 | |
1379 | 1446 | print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
@@ -1403,7 +1470,9 @@ discard block |
||
1403 | 1470 | |
1404 | 1471 | print '<table class="border" width="100%">'; |
1405 | 1472 | |
1406 | - if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
1473 | + if (empty($companybankaccount->rum)) { |
|
1474 | + $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
|
1475 | + } |
|
1407 | 1476 | |
1408 | 1477 | // RUM |
1409 | 1478 | print '<tr><td class="titlefield">'.$langs->trans("RUM").'</td>'; |
@@ -1515,11 +1584,15 @@ discard block |
||
1515 | 1584 | } elseif ($val == 'IBAN') { |
1516 | 1585 | $name = 'iban'; |
1517 | 1586 | $size = 30; |
1518 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1587 | + if ($companybankaccount->needIBAN()) { |
|
1588 | + $require=true; |
|
1589 | + } |
|
1519 | 1590 | } elseif ($val == 'BIC') { |
1520 | 1591 | $name = 'bic'; |
1521 | 1592 | $size = 12; |
1522 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1593 | + if ($companybankaccount->needIBAN()) { |
|
1594 | + $require=true; |
|
1595 | + } |
|
1523 | 1596 | } |
1524 | 1597 | |
1525 | 1598 | print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
33 | 33 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
34 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
34 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
35 | 35 | |
36 | 36 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
37 | 37 | require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php'; |
44 | 44 | require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; |
45 | 45 | |
46 | -$langs->loadLangs(array("companies","commercial","banks","bills",'paypal','stripe','withdrawals')); |
|
46 | +$langs->loadLangs(array("companies", "commercial", "banks", "bills", 'paypal', 'stripe', 'withdrawals')); |
|
47 | 47 | |
48 | 48 | |
49 | 49 | // Security check |
50 | -$socid = GETPOST("socid","int"); |
|
51 | -if ($user->societe_id) $socid=$user->societe_id; |
|
52 | -$result = restrictedArea($user, 'societe','',''); |
|
50 | +$socid = GETPOST("socid", "int"); |
|
51 | +if ($user->societe_id) $socid = $user->societe_id; |
|
52 | +$result = restrictedArea($user, 'societe', '', ''); |
|
53 | 53 | |
54 | -$id=GETPOST("id","int"); |
|
55 | -$source=GETPOST("source","alpha"); |
|
56 | -$ribid=GETPOST("ribid","int"); |
|
57 | -$action=GETPOST("action", 'alpha', 3); |
|
58 | -$cancel=GETPOST('cancel', 'alpha'); |
|
54 | +$id = GETPOST("id", "int"); |
|
55 | +$source = GETPOST("source", "alpha"); |
|
56 | +$ribid = GETPOST("ribid", "int"); |
|
57 | +$action = GETPOST("action", 'alpha', 3); |
|
58 | +$cancel = GETPOST('cancel', 'alpha'); |
|
59 | 59 | |
60 | 60 | $object = new Societe($db); |
61 | 61 | $object->fetch($socid); |
@@ -67,25 +67,25 @@ discard block |
||
67 | 67 | $extrafields = new ExtraFields($db); |
68 | 68 | |
69 | 69 | // fetch optionals attributes and labels |
70 | -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); |
|
70 | +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); |
|
71 | 71 | |
72 | 72 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
73 | -$hookmanager->initHooks(array('thirdpartybancard','globalcard')); |
|
73 | +$hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); |
|
74 | 74 | |
75 | 75 | |
76 | -if (! empty($conf->stripe->enabled)) |
|
76 | +if (!empty($conf->stripe->enabled)) |
|
77 | 77 | { |
78 | 78 | $service = 'StripeTest'; |
79 | 79 | $servicestatus = 0; |
80 | - if (! empty($conf->global->STRIPE_LIVE) && ! GETPOST('forcesandbox','alpha')) |
|
80 | + if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) |
|
81 | 81 | { |
82 | 82 | $service = 'StripeLive'; |
83 | 83 | $servicestatus = 1; |
84 | 84 | } |
85 | 85 | |
86 | 86 | $stripe = new Stripe($db); |
87 | - $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) |
|
88 | - $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) |
|
87 | + $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account (no network access here) |
|
88 | + $stripecu = $stripe->getStripeCustomerAccount($object->id, $servicestatus); // Get remote Stripe customer 'cus_...' (no network access here) |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | |
97 | 97 | if ($cancel) |
98 | 98 | { |
99 | - $action=''; |
|
99 | + $action = ''; |
|
100 | 100 | } |
101 | 101 | |
102 | -$parameters=array('id'=>$socid, 'objcanvas'=>$objcanvas); |
|
103 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
102 | +$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas); |
|
103 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
104 | 104 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
105 | 105 | |
106 | 106 | if (empty($reshook)) |
107 | 107 | { |
108 | 108 | if ($cancel) |
109 | 109 | { |
110 | - $action=''; |
|
111 | - if (! empty($backtopage)) |
|
110 | + $action = ''; |
|
111 | + if (!empty($backtopage)) |
|
112 | 112 | { |
113 | 113 | header("Location: ".$backtopage); |
114 | 114 | exit; |
@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | if ($action == 'update') |
119 | 119 | { |
120 | 120 | // Modification |
121 | - if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
|
121 | + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) |
|
122 | 122 | { |
123 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
124 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
125 | - $action='edit'; |
|
123 | + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
124 | + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
125 | + $action = 'edit'; |
|
126 | 126 | $error++; |
127 | 127 | } |
128 | 128 | if ($companybankaccount->needIBAN() == 1) |
129 | 129 | { |
130 | - if (! GETPOST('iban')) |
|
130 | + if (!GETPOST('iban')) |
|
131 | 131 | { |
132 | 132 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); |
133 | - $action='edit'; |
|
133 | + $action = 'edit'; |
|
134 | 134 | $error++; |
135 | 135 | } |
136 | - if (! GETPOST('bic')) |
|
136 | + if (!GETPOST('bic')) |
|
137 | 137 | { |
138 | 138 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); |
139 | - $action='edit'; |
|
139 | + $action = 'edit'; |
|
140 | 140 | $error++; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | 144 | $companybankaccount->fetch($id); |
145 | - if (! $error) |
|
145 | + if (!$error) |
|
146 | 146 | { |
147 | 147 | $companybankaccount->socid = $object->id; |
148 | 148 | |
149 | - $companybankaccount->bank = GETPOST('bank','alpha'); |
|
150 | - $companybankaccount->label = GETPOST('label','alpha'); |
|
151 | - $companybankaccount->courant = GETPOST('courant','alpha'); |
|
152 | - $companybankaccount->clos = GETPOST('clos','alpha'); |
|
153 | - $companybankaccount->code_banque = GETPOST('code_banque','alpha'); |
|
154 | - $companybankaccount->code_guichet = GETPOST('code_guichet','alpha'); |
|
155 | - $companybankaccount->number = GETPOST('number','alpha'); |
|
156 | - $companybankaccount->cle_rib = GETPOST('cle_rib','alpha'); |
|
157 | - $companybankaccount->bic = GETPOST('bic','alpha'); |
|
158 | - $companybankaccount->iban = GETPOST('iban','alpha'); |
|
159 | - $companybankaccount->domiciliation = GETPOST('domiciliation','alpha'); |
|
160 | - $companybankaccount->proprio = GETPOST('proprio','alpha'); |
|
161 | - $companybankaccount->owner_address = GETPOST('owner_address','alpha'); |
|
162 | - $companybankaccount->frstrecur = GETPOST('frstrecur','alpha'); |
|
163 | - $companybankaccount->rum = GETPOST('rum','alpha'); |
|
149 | + $companybankaccount->bank = GETPOST('bank', 'alpha'); |
|
150 | + $companybankaccount->label = GETPOST('label', 'alpha'); |
|
151 | + $companybankaccount->courant = GETPOST('courant', 'alpha'); |
|
152 | + $companybankaccount->clos = GETPOST('clos', 'alpha'); |
|
153 | + $companybankaccount->code_banque = GETPOST('code_banque', 'alpha'); |
|
154 | + $companybankaccount->code_guichet = GETPOST('code_guichet', 'alpha'); |
|
155 | + $companybankaccount->number = GETPOST('number', 'alpha'); |
|
156 | + $companybankaccount->cle_rib = GETPOST('cle_rib', 'alpha'); |
|
157 | + $companybankaccount->bic = GETPOST('bic', 'alpha'); |
|
158 | + $companybankaccount->iban = GETPOST('iban', 'alpha'); |
|
159 | + $companybankaccount->domiciliation = GETPOST('domiciliation', 'alpha'); |
|
160 | + $companybankaccount->proprio = GETPOST('proprio', 'alpha'); |
|
161 | + $companybankaccount->owner_address = GETPOST('owner_address', 'alpha'); |
|
162 | + $companybankaccount->frstrecur = GETPOST('frstrecur', 'alpha'); |
|
163 | + $companybankaccount->rum = GETPOST('rum', 'alpha'); |
|
164 | 164 | if (empty($companybankaccount->rum)) |
165 | 165 | { |
166 | 166 | $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | $result = $companybankaccount->update($user); |
171 | - if (! $result) |
|
171 | + if (!$result) |
|
172 | 172 | { |
173 | 173 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
174 | 174 | } |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | // If this account is the default bank account, we disable others |
178 | 178 | if ($companybankaccount->default_rib) |
179 | 179 | { |
180 | - $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib |
|
180 | + $companybankaccount->setAsDefault($id); // This will make sure there is only one default rib |
|
181 | 181 | } |
182 | 182 | |
183 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
183 | + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
184 | 184 | header('Location: '.$url); |
185 | 185 | exit; |
186 | 186 | } |
@@ -190,36 +190,36 @@ discard block |
||
190 | 190 | if ($action == 'updatecard') |
191 | 191 | { |
192 | 192 | // Modification |
193 | - if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
|
193 | + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) |
|
194 | 194 | { |
195 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
196 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
197 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
198 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
199 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
200 | - $action='createcard'; |
|
195 | + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
196 | + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
197 | + if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
198 | + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
199 | + if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
200 | + $action = 'createcard'; |
|
201 | 201 | $error++; |
202 | 202 | } |
203 | 203 | |
204 | 204 | $companypaymentmode->fetch($id); |
205 | - if (! $error) |
|
205 | + if (!$error) |
|
206 | 206 | { |
207 | 207 | $companypaymentmode->fk_soc = $object->id; |
208 | 208 | |
209 | - $companypaymentmode->bank = GETPOST('bank','alpha'); |
|
210 | - $companypaymentmode->label = GETPOST('label','alpha'); |
|
211 | - $companypaymentmode->number = GETPOST('cardnumber','alpha'); |
|
212 | - $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4); |
|
213 | - $companypaymentmode->proprio = GETPOST('proprio','alpha'); |
|
214 | - $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); |
|
215 | - $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); |
|
216 | - $companypaymentmode->cvn = GETPOST('cvn','alpha'); |
|
209 | + $companypaymentmode->bank = GETPOST('bank', 'alpha'); |
|
210 | + $companypaymentmode->label = GETPOST('label', 'alpha'); |
|
211 | + $companypaymentmode->number = GETPOST('cardnumber', 'alpha'); |
|
212 | + $companypaymentmode->last_four = substr(GETPOST('cardnumber', 'alpha'), -4); |
|
213 | + $companypaymentmode->proprio = GETPOST('proprio', 'alpha'); |
|
214 | + $companypaymentmode->exp_date_month = GETPOST('exp_date_month', 'int'); |
|
215 | + $companypaymentmode->exp_date_year = GETPOST('exp_date_year', 'int'); |
|
216 | + $companypaymentmode->cvn = GETPOST('cvn', 'alpha'); |
|
217 | 217 | $companypaymentmode->country_code = $object->country_code; |
218 | 218 | |
219 | - $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); |
|
219 | + $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); |
|
220 | 220 | |
221 | 221 | $result = $companypaymentmode->update($user); |
222 | - if (! $result) |
|
222 | + if (!$result) |
|
223 | 223 | { |
224 | 224 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
225 | 225 | } |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | // If this account is the default bank account, we disable others |
229 | 229 | if ($companypaymentmode->default_rib) |
230 | 230 | { |
231 | - $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib |
|
231 | + $companypaymentmode->setAsDefault($id); // This will make sure there is only one default rib |
|
232 | 232 | } |
233 | 233 | |
234 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
234 | + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
235 | 235 | header('Location: '.$url); |
236 | 236 | exit; |
237 | 237 | } |
@@ -240,39 +240,39 @@ discard block |
||
240 | 240 | |
241 | 241 | if ($action == 'add') |
242 | 242 | { |
243 | - $error=0; |
|
243 | + $error = 0; |
|
244 | 244 | |
245 | - if (! GETPOST('label','alpha') || ! GETPOST('bank','alpha')) |
|
245 | + if (!GETPOST('label', 'alpha') || !GETPOST('bank', 'alpha')) |
|
246 | 246 | { |
247 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
248 | - if (! GETPOST('bank','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
249 | - $action='create'; |
|
247 | + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
248 | + if (!GETPOST('bank', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankName")), null, 'errors'); |
|
249 | + $action = 'create'; |
|
250 | 250 | $error++; |
251 | 251 | } |
252 | 252 | |
253 | - if (! $error) |
|
253 | + if (!$error) |
|
254 | 254 | { |
255 | 255 | // Ajout |
256 | 256 | $companybankaccount = new CompanyBankAccount($db); |
257 | 257 | |
258 | 258 | $companybankaccount->socid = $object->id; |
259 | 259 | |
260 | - $companybankaccount->bank = GETPOST('bank','alpha'); |
|
261 | - $companybankaccount->label = GETPOST('label','alpha'); |
|
262 | - $companybankaccount->courant = GETPOST('courant','alpha'); |
|
263 | - $companybankaccount->clos = GETPOST('clos','alpha'); |
|
264 | - $companybankaccount->code_banque = GETPOST('code_banque','alpha'); |
|
265 | - $companybankaccount->code_guichet = GETPOST('code_guichet','alpha'); |
|
266 | - $companybankaccount->number = GETPOST('number','alpha'); |
|
267 | - $companybankaccount->cle_rib = GETPOST('cle_rib','alpha'); |
|
268 | - $companybankaccount->bic = GETPOST('bic','alpha'); |
|
269 | - $companybankaccount->iban = GETPOST('iban','alpha'); |
|
270 | - $companybankaccount->domiciliation = GETPOST('domiciliation','alpha'); |
|
271 | - $companybankaccount->proprio = GETPOST('proprio','alpha'); |
|
272 | - $companybankaccount->owner_address = GETPOST('owner_address','alpha'); |
|
260 | + $companybankaccount->bank = GETPOST('bank', 'alpha'); |
|
261 | + $companybankaccount->label = GETPOST('label', 'alpha'); |
|
262 | + $companybankaccount->courant = GETPOST('courant', 'alpha'); |
|
263 | + $companybankaccount->clos = GETPOST('clos', 'alpha'); |
|
264 | + $companybankaccount->code_banque = GETPOST('code_banque', 'alpha'); |
|
265 | + $companybankaccount->code_guichet = GETPOST('code_guichet', 'alpha'); |
|
266 | + $companybankaccount->number = GETPOST('number', 'alpha'); |
|
267 | + $companybankaccount->cle_rib = GETPOST('cle_rib', 'alpha'); |
|
268 | + $companybankaccount->bic = GETPOST('bic', 'alpha'); |
|
269 | + $companybankaccount->iban = GETPOST('iban', 'alpha'); |
|
270 | + $companybankaccount->domiciliation = GETPOST('domiciliation', 'alpha'); |
|
271 | + $companybankaccount->proprio = GETPOST('proprio', 'alpha'); |
|
272 | + $companybankaccount->owner_address = GETPOST('owner_address', 'alpha'); |
|
273 | 273 | $companybankaccount->frstrecur = GETPOST('frstrecur'); |
274 | - $companybankaccount->rum = GETPOST('rum','alpha'); |
|
275 | - $companybankaccount->datec = dol_now(); |
|
274 | + $companybankaccount->rum = GETPOST('rum', 'alpha'); |
|
275 | + $companybankaccount->datec = dol_now(); |
|
276 | 276 | $companybankaccount->status = 1; |
277 | 277 | |
278 | 278 | $db->begin(); |
@@ -280,28 +280,28 @@ discard block |
||
280 | 280 | // This test can be done only once properties were set |
281 | 281 | if ($companybankaccount->needIBAN() == 1) |
282 | 282 | { |
283 | - if (! GETPOST('iban')) |
|
283 | + if (!GETPOST('iban')) |
|
284 | 284 | { |
285 | 285 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("IBAN")), null, 'errors'); |
286 | - $action='create'; |
|
286 | + $action = 'create'; |
|
287 | 287 | $error++; |
288 | 288 | } |
289 | - if (! GETPOST('bic')) |
|
289 | + if (!GETPOST('bic')) |
|
290 | 290 | { |
291 | 291 | setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BIC")), null, 'errors'); |
292 | - $action='create'; |
|
292 | + $action = 'create'; |
|
293 | 293 | $error++; |
294 | 294 | } |
295 | 295 | } |
296 | 296 | |
297 | - if (! $error) |
|
297 | + if (!$error) |
|
298 | 298 | { |
299 | 299 | $result = $companybankaccount->create($user); |
300 | 300 | if ($result < 0) |
301 | 301 | { |
302 | 302 | $error++; |
303 | 303 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
304 | - $action='create'; // Force chargement page création |
|
304 | + $action = 'create'; // Force chargement page création |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | if (empty($companybankaccount->rum)) |
@@ -311,22 +311,22 @@ discard block |
||
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - if (! $error) |
|
314 | + if (!$error) |
|
315 | 315 | { |
316 | - $result = $companybankaccount->update($user); // This will set the UMR number. |
|
316 | + $result = $companybankaccount->update($user); // This will set the UMR number. |
|
317 | 317 | if ($result < 0) |
318 | 318 | { |
319 | 319 | $error++; |
320 | 320 | setEventMessages($companybankaccount->error, $companybankaccount->errors, 'errors'); |
321 | - $action='create'; |
|
321 | + $action = 'create'; |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | - if (! $error) |
|
325 | + if (!$error) |
|
326 | 326 | { |
327 | 327 | $db->commit(); |
328 | 328 | |
329 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
329 | + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
330 | 330 | header('Location: '.$url); |
331 | 331 | exit; |
332 | 332 | } |
@@ -339,59 +339,59 @@ discard block |
||
339 | 339 | |
340 | 340 | if ($action == 'addcard') |
341 | 341 | { |
342 | - $error=0; |
|
342 | + $error = 0; |
|
343 | 343 | |
344 | - if (! GETPOST('label','alpha') || ! GETPOST('proprio','alpha') || ! GETPOST('cardnumber','alpha') || ! GETPOST('exp_date_month','alpha') || ! GETPOST('exp_date_year','alpha') || ! GETPOST('cvn','alpha')) |
|
344 | + if (!GETPOST('label', 'alpha') || !GETPOST('proprio', 'alpha') || !GETPOST('cardnumber', 'alpha') || !GETPOST('exp_date_month', 'alpha') || !GETPOST('exp_date_year', 'alpha') || !GETPOST('cvn', 'alpha')) |
|
345 | 345 | { |
346 | - if (! GETPOST('label','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
347 | - if (! GETPOST('proprio','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
348 | - if (! GETPOST('cardnumber','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
349 | - if (! (GETPOST('exp_date_month','alpha') > 0) || ! (GETPOST('exp_date_year','alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
350 | - if (! GETPOST('cvn','alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
351 | - $action='createcard'; |
|
346 | + if (!GETPOST('label', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors'); |
|
347 | + if (!GETPOST('proprio', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NameOnCard")), null, 'errors'); |
|
348 | + if (!GETPOST('cardnumber', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardNumber")), null, 'errors'); |
|
349 | + if (!(GETPOST('exp_date_month', 'alpha') > 0) || !(GETPOST('exp_date_year', 'alpha') > 0)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ExpiryDate")), null, 'errors'); |
|
350 | + if (!GETPOST('cvn', 'alpha')) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CVN")), null, 'errors'); |
|
351 | + $action = 'createcard'; |
|
352 | 352 | $error++; |
353 | 353 | } |
354 | 354 | |
355 | - if (! $error) |
|
355 | + if (!$error) |
|
356 | 356 | { |
357 | 357 | // Ajout |
358 | 358 | $companypaymentmode = new CompanyPaymentMode($db); |
359 | 359 | |
360 | 360 | $companypaymentmode->fk_soc = $object->id; |
361 | - $companypaymentmode->bank = GETPOST('bank','alpha'); |
|
362 | - $companypaymentmode->label = GETPOST('label','alpha'); |
|
363 | - $companypaymentmode->number = GETPOST('cardnumber','alpha'); |
|
364 | - $companypaymentmode->last_four = substr(GETPOST('cardnumber','alpha'), -4); |
|
365 | - $companypaymentmode->proprio = GETPOST('proprio','alpha'); |
|
366 | - $companypaymentmode->exp_date_month = GETPOST('exp_date_month','int'); |
|
367 | - $companypaymentmode->exp_date_year = GETPOST('exp_date_year','int'); |
|
368 | - $companypaymentmode->cvn = GETPOST('cvn','alpha'); |
|
361 | + $companypaymentmode->bank = GETPOST('bank', 'alpha'); |
|
362 | + $companypaymentmode->label = GETPOST('label', 'alpha'); |
|
363 | + $companypaymentmode->number = GETPOST('cardnumber', 'alpha'); |
|
364 | + $companypaymentmode->last_four = substr(GETPOST('cardnumber', 'alpha'), -4); |
|
365 | + $companypaymentmode->proprio = GETPOST('proprio', 'alpha'); |
|
366 | + $companypaymentmode->exp_date_month = GETPOST('exp_date_month', 'int'); |
|
367 | + $companypaymentmode->exp_date_year = GETPOST('exp_date_year', 'int'); |
|
368 | + $companypaymentmode->cvn = GETPOST('cvn', 'alpha'); |
|
369 | 369 | $companypaymentmode->datec = dol_now(); |
370 | 370 | $companypaymentmode->default_rib = 0; |
371 | 371 | $companypaymentmode->type = 'card'; |
372 | 372 | $companypaymentmode->country_code = $object->country_code; |
373 | 373 | $companypaymentmode->status = $servicestatus; |
374 | 374 | |
375 | - $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref','alpha'); |
|
375 | + $companypaymentmode->stripe_card_ref = GETPOST('stripe_card_ref', 'alpha'); |
|
376 | 376 | |
377 | 377 | $db->begin(); |
378 | 378 | |
379 | - if (! $error) |
|
379 | + if (!$error) |
|
380 | 380 | { |
381 | 381 | $result = $companypaymentmode->create($user); |
382 | 382 | if ($result < 0) |
383 | 383 | { |
384 | 384 | $error++; |
385 | 385 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
386 | - $action='createcard'; // Force chargement page création |
|
386 | + $action = 'createcard'; // Force chargement page création |
|
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | - if (! $error) |
|
390 | + if (!$error) |
|
391 | 391 | { |
392 | 392 | $db->commit(); |
393 | 393 | |
394 | - $url=$_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
394 | + $url = $_SERVER["PHP_SELF"].'?socid='.$object->id; |
|
395 | 395 | header('Location: '.$url); |
396 | 396 | exit; |
397 | 397 | } |
@@ -402,13 +402,13 @@ discard block |
||
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - if ($action == 'setasbankdefault' && GETPOST('ribid','int') > 0) |
|
405 | + if ($action == 'setasbankdefault' && GETPOST('ribid', 'int') > 0) |
|
406 | 406 | { |
407 | 407 | $companybankaccount = new CompanyBankAccount($db); |
408 | - $res = $companybankaccount->setAsDefault(GETPOST('ribid','int')); |
|
408 | + $res = $companybankaccount->setAsDefault(GETPOST('ribid', 'int')); |
|
409 | 409 | if ($res) |
410 | 410 | { |
411 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
411 | + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
412 | 412 | header('Location: '.$url); |
413 | 413 | exit; |
414 | 414 | } |
@@ -418,10 +418,10 @@ discard block |
||
418 | 418 | } |
419 | 419 | } |
420 | 420 | |
421 | - if ($action == 'confirm_deletecard' && GETPOST('confirm','alpha') == 'yes') |
|
421 | + if ($action == 'confirm_deletecard' && GETPOST('confirm', 'alpha') == 'yes') |
|
422 | 422 | { |
423 | 423 | $companypaymentmode = new CompanyPaymentMode($db); |
424 | - if ($companypaymentmode->fetch($ribid?$ribid:$id)) |
|
424 | + if ($companypaymentmode->fetch($ribid ? $ribid : $id)) |
|
425 | 425 | { |
426 | 426 | $result = $companypaymentmode->delete($user); |
427 | 427 | if ($result > 0) |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | setEventMessages($companypaymentmode->error, $companypaymentmode->errors, 'errors'); |
441 | 441 | } |
442 | 442 | } |
443 | - if ($action == 'confirm_delete' && GETPOST('confirm','alpha') == 'yes') |
|
443 | + if ($action == 'confirm_delete' && GETPOST('confirm', 'alpha') == 'yes') |
|
444 | 444 | { |
445 | 445 | $companybankaccount = new CompanyBankAccount($db); |
446 | - if ($companybankaccount->fetch($ribid?$ribid:$id)) |
|
446 | + if ($companybankaccount->fetch($ribid ? $ribid : $id)) |
|
447 | 447 | { |
448 | 448 | $result = $companybankaccount->delete($user); |
449 | 449 | if ($result > 0) |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | } |
464 | 464 | } |
465 | 465 | |
466 | - $savid=$id; |
|
466 | + $savid = $id; |
|
467 | 467 | |
468 | 468 | // Actions to build doc |
469 | 469 | if ($action == 'builddocrib') |
@@ -473,19 +473,19 @@ discard block |
||
473 | 473 | 'use_companybankid'=>GETPOST('companybankid'), |
474 | 474 | 'force_dir_output'=>$conf->societe->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->id) |
475 | 475 | ); |
476 | - $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid','int'), 'alpha'); |
|
477 | - $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid','int'), 'alpha'); |
|
476 | + $_POST['lang_id'] = GETPOST('lang_idrib'.GETPOST('companybankid', 'int'), 'alpha'); |
|
477 | + $_POST['model'] = GETPOST('modelrib'.GETPOST('companybankid', 'int'), 'alpha'); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | $id = $socid; |
481 | 481 | $upload_dir = $conf->societe->multidir_output[$object->entity]; |
482 | - $permissioncreate=$user->rights->societe->creer; |
|
482 | + $permissioncreate = $user->rights->societe->creer; |
|
483 | 483 | include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; |
484 | 484 | |
485 | 485 | $id = $savid; |
486 | 486 | |
487 | 487 | // Action for stripe |
488 | - if (! empty($conf->stripe->enabled) && class_exists('Stripe')) |
|
488 | + if (!empty($conf->stripe->enabled) && class_exists('Stripe')) |
|
489 | 489 | { |
490 | 490 | if ($action == 'synccustomertostripe') |
491 | 491 | { |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | { |
499 | 499 | // Creation of Stripe customer + update of societe_account |
500 | 500 | $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus, 1); |
501 | - if (! $cu) |
|
501 | + if (!$cu) |
|
502 | 502 | { |
503 | 503 | $error++; |
504 | 504 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
@@ -523,17 +523,17 @@ discard block |
||
523 | 523 | { |
524 | 524 | // Get the Stripe customer |
525 | 525 | $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
526 | - if (! $cu) |
|
526 | + if (!$cu) |
|
527 | 527 | { |
528 | 528 | $error++; |
529 | 529 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
530 | 530 | } |
531 | 531 | |
532 | - if (! $error) |
|
532 | + if (!$error) |
|
533 | 533 | { |
534 | 534 | // Creation of Stripe card + update of societe_account |
535 | 535 | $card = $stripe->cardStripe($cu, $companypaymentmode, $stripeacc, $servicestatus, 1); |
536 | - if (! $card) |
|
536 | + if (!$card) |
|
537 | 537 | { |
538 | 538 | $error++; |
539 | 539 | setEventMessages($stripe->error, $stripe->errors, 'errors'); |
@@ -555,11 +555,11 @@ discard block |
||
555 | 555 | $db->begin(); |
556 | 556 | |
557 | 557 | if (empty($newcu)) { |
558 | - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; |
|
558 | + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_account WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; |
|
559 | 559 | } else { |
560 | 560 | $sql = 'UPDATE '.MAIN_DB_PREFIX."societe_account"; |
561 | - $sql.= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; |
|
562 | - $sql.= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! |
|
561 | + $sql .= " SET key_account = '".$db->escape(GETPOST('key_account', 'alpha'))."'"; |
|
562 | + $sql .= " WHERE site = 'stripe' AND fk_soc = ".$object->id." AND status = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | $resql = $db->query($sql); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
583 | - if (! $error) |
|
583 | + if (!$error) |
|
584 | 584 | { |
585 | 585 | $stripecu = $newcu; |
586 | 586 | $db->commit(); |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | try { |
596 | 596 | $companypaymentmode->setAsDefault($id); |
597 | 597 | |
598 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
598 | + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
599 | 599 | header('Location: '.$url); |
600 | 600 | exit; |
601 | 601 | } |
602 | - catch(Exception $e) |
|
602 | + catch (Exception $e) |
|
603 | 603 | { |
604 | 604 | $error++; |
605 | 605 | setEventMessages($e->getMessage(), null, 'errors'); |
@@ -608,15 +608,15 @@ discard block |
||
608 | 608 | elseif ($action == 'setassourcedefault') |
609 | 609 | { |
610 | 610 | try { |
611 | - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
611 | + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
612 | 612 | $cu->default_source = (string) $source; |
613 | 613 | $result = $cu->save(); |
614 | 614 | |
615 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
615 | + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
616 | 616 | header('Location: '.$url); |
617 | 617 | exit; |
618 | 618 | } |
619 | - catch(Exception $e) |
|
619 | + catch (Exception $e) |
|
620 | 620 | { |
621 | 621 | $error++; |
622 | 622 | setEventMessages($e->getMessage(), null, 'errors'); |
@@ -625,8 +625,8 @@ discard block |
||
625 | 625 | elseif ($action == 'deletecard' && $source) |
626 | 626 | { |
627 | 627 | try { |
628 | - $cu=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
629 | - $card=$cu->sources->retrieve("$source"); |
|
628 | + $cu = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
629 | + $card = $cu->sources->retrieve("$source"); |
|
630 | 630 | if ($card) |
631 | 631 | { |
632 | 632 | // $card->detach(); Does not work with card_, only with src_ |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | else $card->delete(); |
635 | 635 | } |
636 | 636 | |
637 | - $url=DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
637 | + $url = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; |
|
638 | 638 | header('Location: '.$url); |
639 | 639 | exit; |
640 | 640 | } |
641 | - catch(Exception $e) |
|
641 | + catch (Exception $e) |
|
642 | 642 | { |
643 | 643 | $error++; |
644 | 644 | setEventMessages($e->getMessage(), null, 'errors'); |
@@ -659,20 +659,20 @@ discard block |
||
659 | 659 | |
660 | 660 | llxHeader(); |
661 | 661 | |
662 | -$head=societe_prepare_head($object); |
|
662 | +$head = societe_prepare_head($object); |
|
663 | 663 | |
664 | 664 | // Show sandbox warning |
665 | 665 | /*if (! empty($conf->paypal->enabled) && (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha'))) // We can force sand box with param 'forcesandbox' |
666 | 666 | { |
667 | 667 | dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Paypal'),'','warning'); |
668 | 668 | }*/ |
669 | -if (! empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha'))) |
|
669 | +if (!empty($conf->stripe->enabled) && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) |
|
670 | 670 | { |
671 | - dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode','Stripe'),'','warning'); |
|
671 | + dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning'); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | // Load Bank account |
675 | -if (! $id) |
|
675 | +if (!$id) |
|
676 | 676 | { |
677 | 677 | $companybankaccount->fetch(0, $object->id); |
678 | 678 | $companypaymentmode->fetch(0, null, $object->id, 'card'); |
@@ -682,23 +682,23 @@ discard block |
||
682 | 682 | $companybankaccount->fetch($id); |
683 | 683 | $companypaymentmode->fetch($id); |
684 | 684 | } |
685 | -if (empty($companybankaccount->socid)) $companybankaccount->socid=$object->id; |
|
685 | +if (empty($companybankaccount->socid)) $companybankaccount->socid = $object->id; |
|
686 | 686 | |
687 | 687 | if ($socid && ($action == 'edit' || $action == 'editcard') && $user->rights->societe->creer) |
688 | 688 | { |
689 | 689 | print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
690 | 690 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
691 | - $actionforadd='update'; |
|
692 | - if ($action == 'editcard') $actionforadd='updatecard'; |
|
691 | + $actionforadd = 'update'; |
|
692 | + if ($action == 'editcard') $actionforadd = 'updatecard'; |
|
693 | 693 | print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
694 | - print '<input type="hidden" name="id" value="'.GETPOST("id","int").'">'; |
|
694 | + print '<input type="hidden" name="id" value="'.GETPOST("id", "int").'">'; |
|
695 | 695 | } |
696 | 696 | if ($socid && ($action == 'create' || $action == 'createcard') && $user->rights->societe->creer) |
697 | 697 | { |
698 | 698 | print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post">'; |
699 | 699 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
700 | - $actionforadd='add'; |
|
701 | - if ($action == 'createcard') $actionforadd='addcard'; |
|
700 | + $actionforadd = 'add'; |
|
701 | + if ($action == 'createcard') $actionforadd = 'addcard'; |
|
702 | 702 | print '<input type="hidden" name="action" value="'.$actionforadd.'">'; |
703 | 703 | } |
704 | 704 | |
@@ -711,20 +711,20 @@ discard block |
||
711 | 711 | // Confirm delete ban |
712 | 712 | if ($action == 'delete') |
713 | 713 | { |
714 | - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); |
|
714 | + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteARib"), $langs->trans("ConfirmDeleteRib", $companybankaccount->getRibLabel()), "confirm_delete", '', 0, 1); |
|
715 | 715 | } |
716 | 716 | // Confirm delete card |
717 | 717 | if ($action == 'deletecard') |
718 | 718 | { |
719 | - print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid?$ribid:$id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); |
|
719 | + print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id."&ribid=".($ribid ? $ribid : $id), $langs->trans("DeleteACard"), $langs->trans("ConfirmDeleteCard", $companybankaccount->getRibLabel()), "confirm_deletecard", '', 0, 1); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
723 | 723 | |
724 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
724 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
725 | 725 | |
726 | 726 | |
727 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
727 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
728 | 728 | { |
729 | 729 | print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
730 | 730 | } |
@@ -744,19 +744,19 @@ discard block |
||
744 | 744 | if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
745 | 745 | print '</td></tr>'; |
746 | 746 | $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; |
747 | - $resql=$db->query($sql); |
|
747 | + $resql = $db->query($sql); |
|
748 | 748 | if (!$resql) dol_print_error($db); |
749 | 749 | |
750 | 750 | $obj = $db->fetch_object($resql); |
751 | 751 | $nbFactsClient = $obj->nb; |
752 | - $thirdTypeArray['customer']=$langs->trans("customer"); |
|
753 | - if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals'); |
|
754 | - if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders'); |
|
755 | - if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices'); |
|
756 | - if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract']=$langs->transnoentitiesnoconv('Contracts'); |
|
752 | + $thirdTypeArray['customer'] = $langs->trans("customer"); |
|
753 | + if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); |
|
754 | + if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); |
|
755 | + if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); |
|
756 | + if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); |
|
757 | 757 | } |
758 | 758 | |
759 | - if (! empty($conf->stripe->enabled)) |
|
759 | + if (!empty($conf->stripe->enabled)) |
|
760 | 760 | { |
761 | 761 | $permissiontowrite = $user->rights->societe->creer; |
762 | 762 | // Stripe customer key 'cu_....' stored into llx_societe_account |
@@ -768,11 +768,11 @@ discard block |
||
768 | 768 | print $form->editfieldval("StripeCustomerId", 'key_account', $stripecu, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); |
769 | 769 | if ($stripecu && $action != 'editkey_account') |
770 | 770 | { |
771 | - if (! empty($conf->stripe->enabled) && !empty($stripeacc)) $connect=$stripeacc.'/'; |
|
772 | - $url='https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; |
|
771 | + if (!empty($conf->stripe->enabled) && !empty($stripeacc)) $connect = $stripeacc.'/'; |
|
772 | + $url = 'https://dashboard.stripe.com/'.$connect.'test/customers/'.$stripecu; |
|
773 | 773 | if ($servicestatus) |
774 | 774 | { |
775 | - $url='https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; |
|
775 | + $url = 'https://dashboard.stripe.com/'.$connect.'customers/'.$stripecu; |
|
776 | 776 | } |
777 | 777 | print ' <a href="'.$url.'" target="_stripe">'.img_picto($langs->trans('ShowInStripe'), 'object_globe').'</a>'; |
778 | 778 | } |
@@ -798,34 +798,34 @@ discard block |
||
798 | 798 | print '<br>'; |
799 | 799 | |
800 | 800 | // List of Stripe payment modes |
801 | - if (! (empty($conf->stripe->enabled))) |
|
801 | + if (!(empty($conf->stripe->enabled))) |
|
802 | 802 | { |
803 | - $morehtmlright=''; |
|
804 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
803 | + $morehtmlright = ''; |
|
804 | + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
805 | 805 | { |
806 | - $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
806 | + $morehtmlright = '<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=createcard">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
807 | 807 | } |
808 | - print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with StripeConnect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); |
|
808 | + print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc ? ' (Stripe connection with StripeConnect account '.$stripeacc.')' : ' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); |
|
809 | 809 | |
810 | 810 | $listofsources = array(); |
811 | 811 | if (is_object($stripe)) |
812 | 812 | { |
813 | 813 | try { |
814 | - $customerstripe=$stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
814 | + $customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus); |
|
815 | 815 | if ($customerstripe->id) { |
816 | - $listofsources=$customerstripe->sources->data; |
|
816 | + $listofsources = $customerstripe->sources->data; |
|
817 | 817 | } |
818 | 818 | } |
819 | - catch(Exception $e) |
|
819 | + catch (Exception $e) |
|
820 | 820 | { |
821 | 821 | dol_syslog("Error when searching/loading Stripe customer for thirdparty id =".$object->id); |
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
825 | - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
825 | + print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
826 | 826 | print '<table class="liste" width="100%">'."\n"; |
827 | 827 | print '<tr class="liste_titre">'; |
828 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
828 | + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
829 | 829 | { |
830 | 830 | print '<td>'.$langs->trans('LocalID').'</td>'; |
831 | 831 | } |
@@ -844,15 +844,15 @@ discard block |
||
844 | 844 | $arrayofstripecard = array(); |
845 | 845 | |
846 | 846 | // Show local sources |
847 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
847 | + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
848 | 848 | { |
849 | 849 | //$societeaccount = new SocieteAccount($db); |
850 | 850 | $companypaymentmodetemp = new CompanyPaymentMode($db); |
851 | 851 | |
852 | - $sql='SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; |
|
853 | - $sql.=" WHERE type in ('card', 'paypal')"; |
|
854 | - $sql.=" AND fk_soc = ".$object->id; |
|
855 | - $sql.=" AND status = ".$servicestatus; |
|
852 | + $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX."societe_rib"; |
|
853 | + $sql .= " WHERE type in ('card', 'paypal')"; |
|
854 | + $sql .= " AND fk_soc = ".$object->id; |
|
855 | + $sql .= " AND status = ".$servicestatus; |
|
856 | 856 | |
857 | 857 | $resql = $db->query($sql); |
858 | 858 | if ($resql) |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | $num_rows = $db->num_rows($resql); |
861 | 861 | if ($num_rows) |
862 | 862 | { |
863 | - $i=0; |
|
863 | + $i = 0; |
|
864 | 864 | while ($i < $num_rows) |
865 | 865 | { |
866 | 866 | $nblocal++; |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | { |
871 | 871 | $companypaymentmodetemp->fetch($obj->rowid); |
872 | 872 | |
873 | - $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref]=$companypaymentmodetemp->stripe_card_ref; |
|
873 | + $arrayofstripecard[$companypaymentmodetemp->stripe_card_ref] = $companypaymentmodetemp->stripe_card_ref; |
|
874 | 874 | |
875 | 875 | print '<tr>'; |
876 | 876 | print '<td>'; |
@@ -897,21 +897,21 @@ discard block |
||
897 | 897 | print '</td><td>'; |
898 | 898 | if ($companypaymentmodetemp->country_code) |
899 | 899 | { |
900 | - $img=picto_from_langcode($companypaymentmodetemp->country_code); |
|
901 | - print $img?$img.' ':''; |
|
902 | - print getCountry($companypaymentmodetemp->country_code,1); |
|
900 | + $img = picto_from_langcode($companypaymentmodetemp->country_code); |
|
901 | + print $img ? $img.' ' : ''; |
|
902 | + print getCountry($companypaymentmodetemp->country_code, 1); |
|
903 | 903 | } |
904 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
904 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
905 | 905 | print '</td>'; |
906 | 906 | // Default |
907 | 907 | print '<td align="center">'; |
908 | 908 | if (empty($companypaymentmodetemp->default_rib)) |
909 | 909 | { |
910 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">'; |
|
911 | - print img_picto($langs->trans("Default"),'off'); |
|
910 | + print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=setlocalassourcedefault">'; |
|
911 | + print img_picto($langs->trans("Default"), 'off'); |
|
912 | 912 | print '</a>'; |
913 | 913 | } else { |
914 | - print img_picto($langs->trans("Default"),'on'); |
|
914 | + print img_picto($langs->trans("Default"), 'on'); |
|
915 | 915 | } |
916 | 916 | print '</td>'; |
917 | 917 | print '<td>'; |
@@ -929,11 +929,11 @@ discard block |
||
929 | 929 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=synccardtostripe&socid='.$object->id.'&id='.$companypaymentmodetemp->id.'" class="button">'.$langs->trans("CreateCardOnStripe").'</a>'; |
930 | 930 | } |
931 | 931 | |
932 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">'; |
|
933 | - print img_picto($langs->trans("Modify"),'edit'); |
|
932 | + print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=editcard">'; |
|
933 | + print img_picto($langs->trans("Modify"), 'edit'); |
|
934 | 934 | print '</a>'; |
935 | 935 | print ' '; |
936 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'& |
|
936 | + print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&id='.$companypaymentmodetemp->id.'&action=deletecard">'; // source='.$companypaymentmodetemp->stripe_card_ref.'& |
|
937 | 937 | print img_picto($langs->trans("Delete"), 'delete'); |
938 | 938 | print '</a>'; |
939 | 939 | } |
@@ -952,90 +952,90 @@ discard block |
||
952 | 952 | { |
953 | 953 | foreach ($listofsources as $src) |
954 | 954 | { |
955 | - if (! empty($arrayofstripecard[$src->id])) continue; // Already in previous list |
|
955 | + if (!empty($arrayofstripecard[$src->id])) continue; // Already in previous list |
|
956 | 956 | |
957 | 957 | $nbremote++; |
958 | 958 | |
959 | 959 | print '<tr class="oddeven">'; |
960 | 960 | // Local ID |
961 | - if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
961 | + if (!empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) |
|
962 | 962 | { |
963 | 963 | print '<td>'; |
964 | 964 | print '</td>'; |
965 | 965 | } |
966 | 966 | // Src ID |
967 | 967 | print '<td>'; |
968 | - if (!empty($stripeacc)) $connect=$stripeacc.'/'; |
|
969 | - $url='https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; |
|
968 | + if (!empty($stripeacc)) $connect = $stripeacc.'/'; |
|
969 | + $url = 'https://dashboard.stripe.com/'.$connect.'test/sources/'.$src->id; |
|
970 | 970 | if ($servicestatus) |
971 | 971 | { |
972 | - $url='https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; |
|
972 | + $url = 'https://dashboard.stripe.com/'.$connect.'sources/'.$src->id; |
|
973 | 973 | } |
974 | 974 | print $src->id." <a href='".$url."' target='_stripe'>".img_picto($langs->trans('ShowInStripe'), 'object_globe')."</a>"; |
975 | 975 | print '</td>'; |
976 | 976 | // Img of credit card |
977 | 977 | print '<td>'; |
978 | - if ($src->object=='card') |
|
978 | + if ($src->object == 'card') |
|
979 | 979 | { |
980 | 980 | print img_credit_card($src->brand); |
981 | 981 | } |
982 | - elseif ($src->object=='source' && $src->type=='card') |
|
982 | + elseif ($src->object == 'source' && $src->type == 'card') |
|
983 | 983 | { |
984 | 984 | print img_credit_card($src->card->brand); |
985 | 985 | } |
986 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
986 | + elseif ($src->object == 'source' && $src->type == 'sepa_debit') |
|
987 | 987 | { |
988 | 988 | print '<span class="fa fa-university fa-2x fa-fw"></span>'; |
989 | 989 | } |
990 | 990 | print'</td>'; |
991 | 991 | print '<td valign="middle">'; |
992 | - if ($src->object=='card') |
|
992 | + if ($src->object == 'card') |
|
993 | 993 | { |
994 | 994 | print '....'.$src->last4.' - '.$src->exp_month.'/'.$src->exp_year.''; |
995 | 995 | print '</td><td>'; |
996 | 996 | if ($src->country) |
997 | 997 | { |
998 | - $img=picto_from_langcode($src->country); |
|
999 | - print $img?$img.' ':''; |
|
1000 | - print getCountry($src->country,1); |
|
998 | + $img = picto_from_langcode($src->country); |
|
999 | + print $img ? $img.' ' : ''; |
|
1000 | + print getCountry($src->country, 1); |
|
1001 | 1001 | } |
1002 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1002 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1003 | 1003 | } |
1004 | - elseif ($src->object=='source' && $src->type=='card') |
|
1004 | + elseif ($src->object == 'source' && $src->type == 'card') |
|
1005 | 1005 | { |
1006 | 1006 | print $src->owner->name.'<br>....'.$src->card->last4.' - '.$src->card->exp_month.'/'.$src->card->exp_year.''; |
1007 | 1007 | print '</td><td>'; |
1008 | 1008 | |
1009 | 1009 | if ($src->card->country) |
1010 | 1010 | { |
1011 | - $img=picto_from_langcode($src->card->country); |
|
1012 | - print $img?$img.' ':''; |
|
1013 | - print getCountry($src->card->country,1); |
|
1011 | + $img = picto_from_langcode($src->card->country); |
|
1012 | + print $img ? $img.' ' : ''; |
|
1013 | + print getCountry($src->card->country, 1); |
|
1014 | 1014 | } |
1015 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1015 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1016 | 1016 | } |
1017 | - elseif ($src->object=='source' && $src->type=='sepa_debit') |
|
1017 | + elseif ($src->object == 'source' && $src->type == 'sepa_debit') |
|
1018 | 1018 | { |
1019 | 1019 | print 'info sepa'; |
1020 | 1020 | print '</td><td>'; |
1021 | 1021 | if ($src->sepa_debit->country) |
1022 | 1022 | { |
1023 | - $img=picto_from_langcode($src->sepa_debit->country); |
|
1024 | - print $img?$img.' ':''; |
|
1025 | - print getCountry($src->sepa_debit->country,1); |
|
1023 | + $img = picto_from_langcode($src->sepa_debit->country); |
|
1024 | + print $img ? $img.' ' : ''; |
|
1025 | + print getCountry($src->sepa_debit->country, 1); |
|
1026 | 1026 | } |
1027 | - else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1027 | + else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CompanyCountry")).'</font>'; |
|
1028 | 1028 | } |
1029 | 1029 | print '</td>'; |
1030 | 1030 | // Default |
1031 | 1031 | print '<td align="center" width="50">'; |
1032 | 1032 | if (($customerstripe->default_source != $src->id)) |
1033 | 1033 | { |
1034 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">'; |
|
1035 | - print img_picto($langs->trans("Default"),'off'); |
|
1034 | + print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=setassourcedefault">'; |
|
1035 | + print img_picto($langs->trans("Default"), 'off'); |
|
1036 | 1036 | print '</a>'; |
1037 | 1037 | } else { |
1038 | - print img_picto($langs->trans("Default"),'on'); |
|
1038 | + print img_picto($langs->trans("Default"), 'on'); |
|
1039 | 1039 | } |
1040 | 1040 | print '</td>'; |
1041 | 1041 | print '<td>'; |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | print '<td align="right" class="nowraponall">'; |
1050 | 1050 | if ($user->rights->societe->creer) |
1051 | 1051 | { |
1052 | - print '<a href="' . DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">'; |
|
1052 | + print '<a href="'.DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id.'&source='.$src->id.'&action=deletecard">'; |
|
1053 | 1053 | print img_picto($langs->trans("Delete"), 'delete'); |
1054 | 1054 | print '</a>'; |
1055 | 1055 | } |
@@ -1071,14 +1071,14 @@ discard block |
||
1071 | 1071 | // List of bank accounts |
1072 | 1072 | print '<br>'; |
1073 | 1073 | |
1074 | - $morehtmlright='<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
1074 | + $morehtmlright = '<a class="butActionNew" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create">'.$langs->trans("Add").' <span class="fa fa-plus-circle valignmiddle"></span></a>'; |
|
1075 | 1075 | |
1076 | 1076 | print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); |
1077 | 1077 | |
1078 | 1078 | $rib_list = $object->get_all_rib(); |
1079 | 1079 | if (is_array($rib_list)) |
1080 | 1080 | { |
1081 | - print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
1081 | + print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table |
|
1082 | 1082 | print '<table class="liste" width="100%">'; |
1083 | 1083 | |
1084 | 1084 | print '<tr class="liste_titre">'; |
@@ -1087,14 +1087,14 @@ discard block |
||
1087 | 1087 | print_liste_field_titre("RIB"); |
1088 | 1088 | print_liste_field_titre("IBAN"); |
1089 | 1089 | print_liste_field_titre("BIC"); |
1090 | - if (! empty($conf->prelevement->enabled)) |
|
1090 | + if (!empty($conf->prelevement->enabled)) |
|
1091 | 1091 | { |
1092 | 1092 | print print_liste_field_titre("RUM"); |
1093 | 1093 | print print_liste_field_titre("WithdrawMode"); |
1094 | 1094 | } |
1095 | 1095 | print_liste_field_titre("DefaultRIB", '', '', '', '', 'align="center"'); |
1096 | 1096 | print_liste_field_titre('', '', '', '', '', 'align="center"'); |
1097 | - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); |
|
1097 | + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); |
|
1098 | 1098 | print "</tr>\n"; |
1099 | 1099 | |
1100 | 1100 | foreach ($rib_list as $rib) |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | print '<td>'.$rib->bank.'</td>'; |
1107 | 1107 | // Account number |
1108 | 1108 | print '<td>'; |
1109 | - $string=''; |
|
1109 | + $string = ''; |
|
1110 | 1110 | foreach ($rib->getFieldsToShow() as $val) { |
1111 | 1111 | |
1112 | 1112 | if ($val == 'BankCode') { |
@@ -1124,11 +1124,11 @@ discard block |
||
1124 | 1124 | $string .= $rib->iban.' ';*/ |
1125 | 1125 | } |
1126 | 1126 | } |
1127 | - if (! empty($rib->label) && $rib->number) { |
|
1128 | - if (! checkBanForAccount($rib)) { |
|
1129 | - $string.= ' '.img_picto($langs->trans("ValueIsNotValid"),'warning'); |
|
1127 | + if (!empty($rib->label) && $rib->number) { |
|
1128 | + if (!checkBanForAccount($rib)) { |
|
1129 | + $string .= ' '.img_picto($langs->trans("ValueIsNotValid"), 'warning'); |
|
1130 | 1130 | } else { |
1131 | - $string.= ' '.img_picto($langs->trans("ValueIsValid"),'info'); |
|
1131 | + $string .= ' '.img_picto($langs->trans("ValueIsValid"), 'info'); |
|
1132 | 1132 | } |
1133 | 1133 | } |
1134 | 1134 | |
@@ -1136,26 +1136,26 @@ discard block |
||
1136 | 1136 | print '</td>'; |
1137 | 1137 | // IBAN |
1138 | 1138 | print '<td>'.$rib->iban; |
1139 | - if (! empty($rib->iban)) { |
|
1140 | - if (! checkIbanForAccount($rib)) { |
|
1141 | - print ' '.img_picto($langs->trans("IbanNotValid"),'warning'); |
|
1139 | + if (!empty($rib->iban)) { |
|
1140 | + if (!checkIbanForAccount($rib)) { |
|
1141 | + print ' '.img_picto($langs->trans("IbanNotValid"), 'warning'); |
|
1142 | 1142 | } else { |
1143 | - print ' '.img_picto($langs->trans("IbanValid"),'info'); |
|
1143 | + print ' '.img_picto($langs->trans("IbanValid"), 'info'); |
|
1144 | 1144 | } |
1145 | 1145 | } |
1146 | 1146 | print '</td>'; |
1147 | 1147 | // BIC |
1148 | 1148 | print '<td>'.$rib->bic; |
1149 | - if (! empty($rib->bic)) { |
|
1150 | - if (! checkSwiftForAccount($rib)) { |
|
1151 | - print ' '.img_picto($langs->trans("SwiftNotValid"),'warning'); |
|
1149 | + if (!empty($rib->bic)) { |
|
1150 | + if (!checkSwiftForAccount($rib)) { |
|
1151 | + print ' '.img_picto($langs->trans("SwiftNotValid"), 'warning'); |
|
1152 | 1152 | } else { |
1153 | - print ' '.img_picto($langs->trans("SwiftValid"),'info'); |
|
1153 | + print ' '.img_picto($langs->trans("SwiftValid"), 'info'); |
|
1154 | 1154 | } |
1155 | 1155 | } |
1156 | 1156 | print '</td>'; |
1157 | 1157 | |
1158 | - if (! empty($conf->prelevement->enabled)) |
|
1158 | + if (!empty($conf->prelevement->enabled)) |
|
1159 | 1159 | { |
1160 | 1160 | // RUM |
1161 | 1161 | //print '<td>'.$prelevement->buildRumNumber($object->code_client, $rib->datec, $rib->id).'</td>'; |
@@ -1169,10 +1169,10 @@ discard block |
||
1169 | 1169 | print '<td align="center" width="70">'; |
1170 | 1170 | if (!$rib->default_rib) { |
1171 | 1171 | print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&ribid='.$rib->id.'&action=setasbankdefault">'; |
1172 | - print img_picto($langs->trans("Disabled"),'off'); |
|
1172 | + print img_picto($langs->trans("Disabled"), 'off'); |
|
1173 | 1173 | print '</a>'; |
1174 | 1174 | } else { |
1175 | - print img_picto($langs->trans("Enabled"),'on'); |
|
1175 | + print img_picto($langs->trans("Enabled"), 'on'); |
|
1176 | 1176 | } |
1177 | 1177 | print '</td>'; |
1178 | 1178 | |
@@ -1180,54 +1180,54 @@ discard block |
||
1180 | 1180 | print '<td align="center">'; |
1181 | 1181 | |
1182 | 1182 | $buttonlabel = $langs->trans("BuildDoc"); |
1183 | - $forname='builddocrib'.$rib->id; |
|
1183 | + $forname = 'builddocrib'.$rib->id; |
|
1184 | 1184 | |
1185 | 1185 | include_once DOL_DOCUMENT_ROOT.'/core/modules/bank/modules_bank.php'; |
1186 | - $modellist=ModeleBankAccountDoc::liste_modeles($db); |
|
1186 | + $modellist = ModeleBankAccountDoc::liste_modeles($db); |
|
1187 | 1187 | |
1188 | 1188 | $out = ''; |
1189 | 1189 | if (is_array($modellist) && count($modellist)) |
1190 | 1190 | { |
1191 | - $out.= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">'; |
|
1192 | - $out.= '<input type="hidden" name="action" value="builddocrib">'; |
|
1193 | - $out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1194 | - $out.= '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
1195 | - $out.= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
|
1191 | + $out .= '<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc').'" name="'.$forname.'" id="'.$forname.'_form" method="post">'; |
|
1192 | + $out .= '<input type="hidden" name="action" value="builddocrib">'; |
|
1193 | + $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
|
1194 | + $out .= '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
1195 | + $out .= '<input type="hidden" name="companybankid" value="'.$rib->id.'">'; |
|
1196 | 1196 | |
1197 | 1197 | if (is_array($modellist) && count($modellist) == 1) // If there is only one element |
1198 | 1198 | { |
1199 | - $arraykeys=array_keys($modellist); |
|
1200 | - $modelselected=$arraykeys[0]; |
|
1199 | + $arraykeys = array_keys($modellist); |
|
1200 | + $modelselected = $arraykeys[0]; |
|
1201 | 1201 | } |
1202 | - if (! empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; |
|
1202 | + if (!empty($conf->global->BANKADDON_PDF)) $modelselected = $conf->global->BANKADDON_PDF; |
|
1203 | 1203 | |
1204 | - $out.= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
1205 | - $out.= ajax_combobox('modelrib'.$rib->id); |
|
1204 | + $out .= $form->selectarray('modelrib'.$rib->id, $modellist, $modelselected, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth100'); |
|
1205 | + $out .= ajax_combobox('modelrib'.$rib->id); |
|
1206 | 1206 | |
1207 | 1207 | // Language code (if multilang) |
1208 | 1208 | if ($conf->global->MAIN_MULTILANGS) |
1209 | 1209 | { |
1210 | 1210 | include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; |
1211 | - $formadmin=new FormAdmin($db); |
|
1212 | - $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); |
|
1213 | - $morecss='maxwidth150'; |
|
1214 | - if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; |
|
1215 | - $out.= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); |
|
1211 | + $formadmin = new FormAdmin($db); |
|
1212 | + $defaultlang = $codelang ? $codelang : $langs->getDefaultLang(); |
|
1213 | + $morecss = 'maxwidth150'; |
|
1214 | + if ($conf->browser->layout == 'phone') $morecss = 'maxwidth100'; |
|
1215 | + $out .= $formadmin->select_language($defaultlang, 'lang_idrib'.$rib->id, 0, 0, 0, 0, 0, $morecss); |
|
1216 | 1216 | } |
1217 | 1217 | // Button |
1218 | 1218 | $genbutton = '<input class="button buttongen" id="'.$forname.'_generatebutton" name="'.$forname.'_generatebutton"'; |
1219 | - $genbutton.= ' type="submit" value="'.$buttonlabel.'"'; |
|
1220 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist)) $genbutton.= ' disabled'; |
|
1221 | - $genbutton.= '>'; |
|
1222 | - if ($allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
|
1219 | + $genbutton .= ' type="submit" value="'.$buttonlabel.'"'; |
|
1220 | + if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .= ' disabled'; |
|
1221 | + $genbutton .= '>'; |
|
1222 | + if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') |
|
1223 | 1223 | { |
1224 | 1224 | $langs->load("errors"); |
1225 | - $genbutton.= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
|
1225 | + $genbutton .= ' '.img_warning($langs->transnoentitiesnoconv("WarningNoDocumentModelActivated")); |
|
1226 | 1226 | } |
1227 | - if (! $allowgenifempty && ! is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton=''; |
|
1228 | - if (empty($modellist) && ! $showempty && $modulepart != 'unpaid') $genbutton=''; |
|
1229 | - $out.= $genbutton; |
|
1230 | - $out.= '</form>'; |
|
1227 | + if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart != 'unpaid') $genbutton = ''; |
|
1228 | + if (empty($modellist) && !$showempty && $modulepart != 'unpaid') $genbutton = ''; |
|
1229 | + $out .= $genbutton; |
|
1230 | + $out .= '</form>'; |
|
1231 | 1231 | } |
1232 | 1232 | print $out; |
1233 | 1233 | print '</td>'; |
@@ -1237,13 +1237,13 @@ discard block |
||
1237 | 1237 | if ($user->rights->societe->creer) |
1238 | 1238 | { |
1239 | 1239 | print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=edit">'; |
1240 | - print img_picto($langs->trans("Modify"),'edit'); |
|
1240 | + print img_picto($langs->trans("Modify"), 'edit'); |
|
1241 | 1241 | print '</a>'; |
1242 | 1242 | |
1243 | 1243 | print ' '; |
1244 | 1244 | |
1245 | 1245 | print '<a href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&id='.$rib->id.'&action=delete">'; |
1246 | - print img_picto($langs->trans("Delete"),'delete'); |
|
1246 | + print img_picto($langs->trans("Delete"), 'delete'); |
|
1247 | 1247 | print '</a>'; |
1248 | 1248 | } |
1249 | 1249 | print '</td>'; |
@@ -1253,8 +1253,8 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | if (count($rib_list) == 0) |
1255 | 1255 | { |
1256 | - $colspan=8; |
|
1257 | - if (! empty($conf->prelevement->enabled)) $colspan+=2; |
|
1256 | + $colspan = 8; |
|
1257 | + if (!empty($conf->prelevement->enabled)) $colspan += 2; |
|
1258 | 1258 | print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoBANRecord").'</td></tr>'; |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1275,15 +1275,15 @@ discard block |
||
1275 | 1275 | /* |
1276 | 1276 | * Documents generes |
1277 | 1277 | */ |
1278 | - $filedir=$conf->societe->multidir_output[$object->entity].'/'.$object->id; |
|
1279 | - $urlsource=$_SERVER["PHP_SELF"]."?socid=".$object->id; |
|
1280 | - $genallowed=$user->rights->societe->lire; |
|
1281 | - $delallowed=$user->rights->societe->creer; |
|
1278 | + $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id; |
|
1279 | + $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id; |
|
1280 | + $genallowed = $user->rights->societe->lire; |
|
1281 | + $delallowed = $user->rights->societe->creer; |
|
1282 | 1282 | |
1283 | 1283 | print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); |
1284 | 1284 | |
1285 | 1285 | // Show direct download link |
1286 | - if (! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) |
|
1286 | + if (!empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) |
|
1287 | 1287 | { |
1288 | 1288 | $companybankaccounttemp = new CompanyBankAccount($db); |
1289 | 1289 | $companypaymentmodetemp = new CompanyPaymentMode($db); |
@@ -1331,11 +1331,11 @@ discard block |
||
1331 | 1331 | // Edit BAN |
1332 | 1332 | if ($socid && $action == 'edit' && $user->rights->societe->creer) |
1333 | 1333 | { |
1334 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1334 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); |
|
1335 | 1335 | |
1336 | 1336 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
1337 | 1337 | |
1338 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1338 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
1339 | 1339 | |
1340 | 1340 | print '<div class="fichecenter">'; |
1341 | 1341 | |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | // Show fields of bank account |
1352 | 1352 | foreach ($companybankaccount->getFieldsToShow(1) as $val) { |
1353 | 1353 | |
1354 | - $require=false; |
|
1354 | + $require = false; |
|
1355 | 1355 | if ($val == 'BankCode') { |
1356 | 1356 | $name = 'code_banque'; |
1357 | 1357 | $size = 8; |
@@ -1372,15 +1372,15 @@ discard block |
||
1372 | 1372 | $name = 'iban'; |
1373 | 1373 | $size = 30; |
1374 | 1374 | $content = $companybankaccount->iban; |
1375 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1375 | + if ($companybankaccount->needIBAN()) $require = true; |
|
1376 | 1376 | } elseif ($val == 'BIC') { |
1377 | 1377 | $name = 'bic'; |
1378 | 1378 | $size = 12; |
1379 | 1379 | $content = $companybankaccount->bic; |
1380 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1380 | + if ($companybankaccount->needIBAN()) $require = true; |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | - print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
|
1383 | + print '<tr><td'.($require ? ' class="fieldrequired" ' : '').'>'.$langs->trans($val).'</td>'; |
|
1384 | 1384 | print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.$content.'"></td>'; |
1385 | 1385 | print '</tr>'; |
1386 | 1386 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | |
1416 | 1416 | print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>'; |
1417 | 1417 | $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); |
1418 | - print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur','alpha')?GETPOST('frstrecur','alpha'):$companybankaccount->frstrecur), 0); |
|
1418 | + print $form->selectarray("frstrecur", $tblArraychoice, dol_escape_htmltag(GETPOST('frstrecur', 'alpha') ?GETPOST('frstrecur', 'alpha') : $companybankaccount->frstrecur), 0); |
|
1419 | 1419 | print '</td></tr>'; |
1420 | 1420 | |
1421 | 1421 | print '</table>'; |
@@ -1435,11 +1435,11 @@ discard block |
||
1435 | 1435 | // Edit Card |
1436 | 1436 | if ($socid && $action == 'editcard' && $user->rights->societe->creer) |
1437 | 1437 | { |
1438 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1438 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); |
|
1439 | 1439 | |
1440 | 1440 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
1441 | 1441 | |
1442 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1442 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
1443 | 1443 | |
1444 | 1444 | print '<div class="fichecenter">'; |
1445 | 1445 | |
@@ -1483,11 +1483,11 @@ discard block |
||
1483 | 1483 | // Create BAN |
1484 | 1484 | if ($socid && $action == 'create' && $user->rights->societe->creer) |
1485 | 1485 | { |
1486 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1486 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); |
|
1487 | 1487 | |
1488 | 1488 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
1489 | 1489 | |
1490 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1490 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
1491 | 1491 | |
1492 | 1492 | print '<div class="nofichecenter">'; |
1493 | 1493 | |
@@ -1503,7 +1503,7 @@ discard block |
||
1503 | 1503 | // Show fields of bank account |
1504 | 1504 | foreach ($companybankaccount->getFieldsToShow(1) as $val) { |
1505 | 1505 | |
1506 | - $require=false; |
|
1506 | + $require = false; |
|
1507 | 1507 | if ($val == 'BankCode') { |
1508 | 1508 | $name = 'code_banque'; |
1509 | 1509 | $size = 8; |
@@ -1519,14 +1519,14 @@ discard block |
||
1519 | 1519 | } elseif ($val == 'IBAN') { |
1520 | 1520 | $name = 'iban'; |
1521 | 1521 | $size = 30; |
1522 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1522 | + if ($companybankaccount->needIBAN()) $require = true; |
|
1523 | 1523 | } elseif ($val == 'BIC') { |
1524 | 1524 | $name = 'bic'; |
1525 | 1525 | $size = 12; |
1526 | - if ($companybankaccount->needIBAN()) $require=true; |
|
1526 | + if ($companybankaccount->needIBAN()) $require = true; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | - print '<tr><td'.($require?' class="fieldrequired" ':'').'>'.$langs->trans($val).'</td>'; |
|
1529 | + print '<tr><td'.($require ? ' class="fieldrequired" ' : '').'>'.$langs->trans($val).'</td>'; |
|
1530 | 1530 | print '<td><input size="'.$size.'" type="text" class="flat" name="'.$name.'" value="'.GETPOST($name).'"></td>'; |
1531 | 1531 | print '</tr>'; |
1532 | 1532 | } |
@@ -1555,11 +1555,11 @@ discard block |
||
1555 | 1555 | |
1556 | 1556 | // RUM |
1557 | 1557 | print '<tr><td class="titlefieldcreate">'.$langs->trans("RUM").'</td>'; |
1558 | - print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum','alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>'; |
|
1558 | + print '<td colspan="4"><input type="text" class="minwidth300" name="rum" value="'.GETPOST('rum', 'alpha').'"> <div class="opacitymedium">'.$langs->trans("RUMWillBeGenerated").'</div></td></tr>'; |
|
1559 | 1559 | |
1560 | 1560 | print '<tr><td>'.$langs->trans("WithdrawMode").'</td><td>'; |
1561 | 1561 | $tblArraychoice = array("FRST" => $langs->trans("FRST"), "RECUR" => $langs->trans("RECUR")); |
1562 | - print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur'])?GETPOST('frstrecur'):'FRST'), 0); |
|
1562 | + print $form->selectarray("frstrecur", $tblArraychoice, (isset($_POST['frstrecur']) ?GETPOST('frstrecur') : 'FRST'), 0); |
|
1563 | 1563 | print '</td></tr>'; |
1564 | 1564 | |
1565 | 1565 | print '</table>'; |
@@ -1581,11 +1581,11 @@ discard block |
||
1581 | 1581 | // Create Card |
1582 | 1582 | if ($socid && $action == 'createcard' && $user->rights->societe->creer) |
1583 | 1583 | { |
1584 | - dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"),0,'company'); |
|
1584 | + dol_fiche_head($head, 'rib', $langs->trans("ThirdParty"), 0, 'company'); |
|
1585 | 1585 | |
1586 | 1586 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
1587 | 1587 | |
1588 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
1588 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
1589 | 1589 | |
1590 | 1590 | print '<div class="nofichecenter">'; |
1591 | 1591 | |
@@ -1593,25 +1593,25 @@ discard block |
||
1593 | 1593 | print '<table class="border centpercent">'; |
1594 | 1594 | |
1595 | 1595 | print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Label").'</td>'; |
1596 | - print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label','alpha').'"></td></tr>'; |
|
1596 | + print '<td><input class="minwidth200" type="text" id="label" name="label" value="'.GETPOST('label', 'alpha').'"></td></tr>'; |
|
1597 | 1597 | |
1598 | 1598 | print '<tr><td class="fieldrequired">'.$langs->trans("NameOnCard").'</td>'; |
1599 | - print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio','alpha').'"></td></tr>'; |
|
1599 | + print '<td><input class="minwidth200" type="text" name="proprio" value="'.GETPOST('proprio', 'alpha').'"></td></tr>'; |
|
1600 | 1600 | |
1601 | 1601 | print '<tr><td class="fieldrequired">'.$langs->trans("CardNumber").'</td>'; |
1602 | - print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber','alpha').'"></td></tr>'; |
|
1602 | + print '<td><input class="minwidth200" type="text" name="cardnumber" value="'.GETPOST('cardnumber', 'alpha').'"></td></tr>'; |
|
1603 | 1603 | |
1604 | 1604 | print '<tr><td class="fieldrequired">'.$langs->trans("ExpiryDate").'</td>'; |
1605 | 1605 | print '<td>'; |
1606 | - print $formother->select_month(GETPOST('exp_date_month','int'), 'exp_date_month', 1); |
|
1607 | - print $formother->select_year(GETPOST('exp_date_year','int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); |
|
1606 | + print $formother->select_month(GETPOST('exp_date_month', 'int'), 'exp_date_month', 1); |
|
1607 | + print $formother->select_year(GETPOST('exp_date_year', 'int'), 'exp_date_year', 1, 5, 10, 0, 0, '', 'marginleftonly'); |
|
1608 | 1608 | print '</td></tr>'; |
1609 | 1609 | |
1610 | 1610 | print '<tr><td class="fieldrequired">'.$langs->trans("CVN").'</td>'; |
1611 | - print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn','alpha').'"></td></tr>'; |
|
1611 | + print '<td><input size="8" type="text" name="cvn" value="'.GETPOST('cvn', 'alpha').'"></td></tr>'; |
|
1612 | 1612 | |
1613 | 1613 | print '<tr><td>'.$langs->trans("StripeID")." ('card_....')</td>"; |
1614 | - print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref','alpha').'"></td></tr>'; |
|
1614 | + print '<td><input class="minwidth300" type="text" name="stripe_card_ref" value="'.GETPOST('stripe_card_ref', 'alpha').'"></td></tr>'; |
|
1615 | 1615 | |
1616 | 1616 | print '</table>'; |
1617 | 1617 |
@@ -125,8 +125,8 @@ |
||
125 | 125 | } |
126 | 126 | else |
127 | 127 | { |
128 | - $langs->load("errors"); |
|
129 | - print $langs->trans("ErrorRecordNotFound"); |
|
128 | + $langs->load("errors"); |
|
129 | + print $langs->trans("ErrorRecordNotFound"); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | // End of page |
@@ -35,11 +35,15 @@ discard block |
||
35 | 35 | |
36 | 36 | // Security check |
37 | 37 | $id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int'); |
38 | -if ($user->societe_id) $id=$user->societe_id; |
|
38 | +if ($user->societe_id) { |
|
39 | + $id=$user->societe_id; |
|
40 | +} |
|
39 | 41 | $result = restrictedArea($user, 'societe', $id, '&societe'); |
40 | 42 | |
41 | 43 | $object = new Societe($db); |
42 | -if ($id > 0) $object->fetch($id); |
|
44 | +if ($id > 0) { |
|
45 | + $object->fetch($id); |
|
46 | +} |
|
43 | 47 | |
44 | 48 | $permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php |
45 | 49 | |
@@ -61,7 +65,9 @@ discard block |
||
61 | 65 | $form = new Form($db); |
62 | 66 | |
63 | 67 | $title=$langs->trans("ThirdParty").' - '.$langs->trans("Notes"); |
64 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notes"); |
|
68 | +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) { |
|
69 | + $title=$object->name.' - '.$langs->trans("Notes"); |
|
70 | +} |
|
65 | 71 | $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
66 | 72 | llxHeader('',$title,$help_url); |
67 | 73 | |
@@ -70,7 +76,9 @@ discard block |
||
70 | 76 | /* |
71 | 77 | * Affichage onglets |
72 | 78 | */ |
73 | - if (! empty($conf->notification->enabled)) $langs->load("mails"); |
|
79 | + if (! empty($conf->notification->enabled)) { |
|
80 | + $langs->load("mails"); |
|
81 | + } |
|
74 | 82 | |
75 | 83 | $head = societe_prepare_head($object); |
76 | 84 | |
@@ -89,17 +97,21 @@ discard block |
||
89 | 97 | print '<div class="underbanner clearboth"></div>'; |
90 | 98 | print '<table class="border centpercent">'; |
91 | 99 | |
92 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
100 | + if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
101 | + // Old not used prefix field |
|
93 | 102 | { |
94 | 103 | print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
95 | 104 | } |
105 | + } |
|
96 | 106 | |
97 | 107 | if ($object->client) |
98 | 108 | { |
99 | 109 | print '<tr><td class="'.$cssclass.'">'; |
100 | 110 | print $langs->trans('CustomerCode').'</td><td colspan="3">'; |
101 | 111 | print $object->code_client; |
102 | - if ($object->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
112 | + if ($object->check_codeclient() <> 0) { |
|
113 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
114 | + } |
|
103 | 115 | print '</td></tr>'; |
104 | 116 | } |
105 | 117 | |
@@ -108,7 +120,9 @@ discard block |
||
108 | 120 | print '<tr><td class="'.$cssclass.'">'; |
109 | 121 | print $langs->trans('SupplierCode').'</td><td colspan="3">'; |
110 | 122 | print $object->code_fournisseur; |
111 | - if ($object->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
123 | + if ($object->check_codefournisseur() <> 0) { |
|
124 | + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
125 | + } |
|
112 | 126 | print '</td></tr>'; |
113 | 127 | } |
114 | 128 | |
@@ -122,8 +136,7 @@ discard block |
||
122 | 136 | include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; |
123 | 137 | |
124 | 138 | dol_fiche_end(); |
125 | -} |
|
126 | -else |
|
139 | +} else |
|
127 | 140 | { |
128 | 141 | $langs->load("errors"); |
129 | 142 | print $langs->trans("ErrorRecordNotFound"); |
@@ -29,33 +29,33 @@ discard block |
||
29 | 29 | |
30 | 30 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
31 | 31 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
32 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
32 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
33 | 33 | |
34 | 34 | require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
35 | 35 | |
36 | -$action = GETPOST('action','aZ09'); |
|
36 | +$action = GETPOST('action', 'aZ09'); |
|
37 | 37 | |
38 | 38 | $langs->load("companies"); |
39 | 39 | |
40 | 40 | // Security check |
41 | -$id = GETPOST('id')?GETPOST('id','int'):GETPOST('socid','int'); |
|
42 | -if ($user->societe_id) $id=$user->societe_id; |
|
41 | +$id = GETPOST('id') ?GETPOST('id', 'int') : GETPOST('socid', 'int'); |
|
42 | +if ($user->societe_id) $id = $user->societe_id; |
|
43 | 43 | $result = restrictedArea($user, 'societe', $id, '&societe'); |
44 | 44 | |
45 | 45 | $object = new Societe($db); |
46 | 46 | if ($id > 0) $object->fetch($id); |
47 | 47 | |
48 | -$permissionnote=$user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php |
|
48 | +$permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php |
|
49 | 49 | |
50 | 50 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
51 | -$hookmanager->initHooks(array('thirdpartynote','globalcard')); |
|
51 | +$hookmanager->initHooks(array('thirdpartynote', 'globalcard')); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | /* |
55 | 55 | * Actions |
56 | 56 | */ |
57 | 57 | |
58 | -include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
|
58 | +include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once |
|
59 | 59 | |
60 | 60 | |
61 | 61 | /* |
@@ -64,17 +64,17 @@ discard block |
||
64 | 64 | |
65 | 65 | $form = new Form($db); |
66 | 66 | |
67 | -$title=$langs->trans("ThirdParty").' - '.$langs->trans("Notes"); |
|
68 | -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Notes"); |
|
69 | -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
|
70 | -llxHeader('',$title,$help_url); |
|
67 | +$title = $langs->trans("ThirdParty").' - '.$langs->trans("Notes"); |
|
68 | +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Notes"); |
|
69 | +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; |
|
70 | +llxHeader('', $title, $help_url); |
|
71 | 71 | |
72 | 72 | if ($object->id > 0) |
73 | 73 | { |
74 | 74 | /* |
75 | 75 | * Affichage onglets |
76 | 76 | */ |
77 | - if (! empty($conf->notification->enabled)) $langs->load("mails"); |
|
77 | + if (!empty($conf->notification->enabled)) $langs->load("mails"); |
|
78 | 78 | |
79 | 79 | $head = societe_prepare_head($object); |
80 | 80 | |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; |
84 | 84 | |
85 | - dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
85 | + dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
86 | 86 | |
87 | - $cssclass='titlefield'; |
|
87 | + $cssclass = 'titlefield'; |
|
88 | 88 | //if ($action == 'editnote_public') $cssclass='titlefieldcreate'; |
89 | 89 | //if ($action == 'editnote_private') $cssclass='titlefieldcreate'; |
90 | 90 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | print '<div class="underbanner clearboth"></div>'; |
94 | 94 | print '<table class="border centpercent">'; |
95 | 95 | |
96 | - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
96 | + if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
97 | 97 | { |
98 | 98 | print '<tr><td class="'.$cssclass.'">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
99 | 99 | } |
@@ -32,7 +32,9 @@ discard block |
||
32 | 32 | $langs->load("companies"); |
33 | 33 | |
34 | 34 | $socid = GETPOST('socid','int'); |
35 | -if ($user->societe_id) $socid=$user->societe_id; |
|
35 | +if ($user->societe_id) { |
|
36 | + $socid=$user->societe_id; |
|
37 | +} |
|
36 | 38 | |
37 | 39 | // Security check |
38 | 40 | $result=restrictedArea($user,'societe',0,'','','',''); |
@@ -57,12 +59,14 @@ discard block |
||
57 | 59 | print '<div class="fichecenter"><div class="fichethirdleft">'; |
58 | 60 | |
59 | 61 | |
60 | -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
62 | +if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { |
|
63 | + // This is useless due to the global search combo |
|
61 | 64 | { |
62 | 65 | // Search thirdparty |
63 | 66 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
64 | 67 | { |
65 | 68 | $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); |
69 | +} |
|
66 | 70 | } |
67 | 71 | // Search contact/address |
68 | 72 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
@@ -78,10 +82,14 @@ discard block |
||
78 | 82 | $i=0; |
79 | 83 | foreach($listofsearchfields as $key => $value) |
80 | 84 | { |
81 | - if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
|
85 | + if ($i == 0) { |
|
86 | + print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
|
87 | + } |
|
82 | 88 | print '<tr '.$bc[false].'>'; |
83 | 89 | print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; |
84 | - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; |
|
90 | + if ($i == 0) { |
|
91 | + print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; |
|
92 | + } |
|
85 | 93 | print '</tr>'; |
86 | 94 | $i++; |
87 | 95 | } |
@@ -106,11 +114,20 @@ discard block |
||
106 | 114 | |
107 | 115 | $sql = "SELECT s.rowid, s.client, s.fournisseur"; |
108 | 116 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
109 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
117 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
118 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
119 | +} |
|
110 | 120 | $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
111 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
112 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
113 | -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible |
|
121 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
122 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
123 | +} |
|
124 | +if ($socid) { |
|
125 | + $sql.= " AND s.rowid = ".$socid; |
|
126 | +} |
|
127 | +if (! $user->rights->fournisseur->lire) { |
|
128 | + $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; |
|
129 | +} |
|
130 | +// client=0, fournisseur=0 must be visible |
|
114 | 131 | //print $sql; |
115 | 132 | $result = $db->query($sql); |
116 | 133 | if ($result) |
@@ -122,10 +139,13 @@ discard block |
||
122 | 139 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } |
123 | 140 | if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } |
124 | 141 | if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } |
125 | - if ($found) $total++; |
|
142 | + if ($found) { |
|
143 | + $total++; |
|
144 | + } |
|
126 | 145 | } |
146 | +} else { |
|
147 | + dol_print_error($db); |
|
127 | 148 | } |
128 | -else dol_print_error($db); |
|
129 | 149 | |
130 | 150 | print '<div class="div-table-responsive-no-min">'; |
131 | 151 | print '<table class="noborder nohover" width="100%">'."\n"; |
@@ -134,10 +154,18 @@ discard block |
||
134 | 154 | { |
135 | 155 | print '<tr><td align="center" colspan="2">'; |
136 | 156 | $dataseries=array(); |
137 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); |
|
138 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); |
|
139 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); |
|
140 | - if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); |
|
157 | + if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { |
|
158 | + $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); |
|
159 | + } |
|
160 | + if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { |
|
161 | + $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); |
|
162 | + } |
|
163 | + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { |
|
164 | + $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); |
|
165 | + } |
|
166 | + if (! empty($conf->societe->enabled)) { |
|
167 | + $dataseries[]=array($langs->trans("Others"), round($third['other'])); |
|
168 | + } |
|
141 | 169 | include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
142 | 170 | $dolgraph = new DolGraph(); |
143 | 171 | $dolgraph->SetData($dataseries); |
@@ -148,8 +176,7 @@ discard block |
||
148 | 176 | $dolgraph->draw('idgraphthirdparties'); |
149 | 177 | print $dolgraph->show(); |
150 | 178 | print '</td></tr>'."\n"; |
151 | -} |
|
152 | -else |
|
179 | +} else |
|
153 | 180 | { |
154 | 181 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) |
155 | 182 | { |
@@ -193,7 +220,9 @@ discard block |
||
193 | 220 | $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; |
194 | 221 | $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; |
195 | 222 | $sql.= " WHERE c.type = 2"; |
196 | - if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
223 | + if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { |
|
224 | + $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
225 | + } |
|
197 | 226 | $sql.= " AND c.entity IN (".getEntity('category').")"; |
198 | 227 | $sql.= " GROUP BY c.label"; |
199 | 228 | $total=0; |
@@ -214,8 +243,7 @@ discard block |
||
214 | 243 | if ($i < $nbmax) |
215 | 244 | { |
216 | 245 | $dataseries[]=array($obj->label, round($obj->nb)); |
217 | - } |
|
218 | - else |
|
246 | + } else |
|
219 | 247 | { |
220 | 248 | $rest+=$obj->nb; |
221 | 249 | } |
@@ -235,8 +263,7 @@ discard block |
||
235 | 263 | $dolgraph->setWidth('100%'); |
236 | 264 | $dolgraph->draw('idgraphcateg'); |
237 | 265 | print $dolgraph->show(); |
238 | - } |
|
239 | - else |
|
266 | + } else |
|
240 | 267 | { |
241 | 268 | while ($i < $num) |
242 | 269 | { |
@@ -270,11 +297,19 @@ discard block |
||
270 | 297 | $sql.= ", s.logo"; |
271 | 298 | $sql.= ", s.canvas, s.tms as datem, s.status as status"; |
272 | 299 | $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
273 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
300 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
301 | + $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
302 | +} |
|
274 | 303 | $sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
275 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
276 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
277 | -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; |
|
304 | +if (! $user->rights->societe->client->voir && ! $socid) { |
|
305 | + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
306 | +} |
|
307 | +if ($socid) { |
|
308 | + $sql.= " AND s.rowid = ".$socid; |
|
309 | +} |
|
310 | +if (! $user->rights->fournisseur->lire) { |
|
311 | + $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; |
|
312 | +} |
|
278 | 313 | $sql.= $db->order("s.tms","DESC"); |
279 | 314 | $sql.= $db->plimit($max,0); |
280 | 315 | |
@@ -327,7 +362,9 @@ discard block |
||
327 | 362 | $thirdparty_static->name=$langs->trans("Customer"); |
328 | 363 | print $thirdparty_static->getNomUrl(0,'customer',0,1); |
329 | 364 | } |
330 | - if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; |
|
365 | + if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { |
|
366 | + print " / "; |
|
367 | + } |
|
331 | 368 | if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
332 | 369 | { |
333 | 370 | $thirdparty_static->name=$langs->trans("Prospect"); |
@@ -335,7 +372,9 @@ discard block |
||
335 | 372 | } |
336 | 373 | if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) |
337 | 374 | { |
338 | - if ($thirdparty_static->client) print " / "; |
|
375 | + if ($thirdparty_static->client) { |
|
376 | + print " / "; |
|
377 | + } |
|
339 | 378 | $thirdparty_static->name=$langs->trans("Supplier"); |
340 | 379 | print $thirdparty_static->getNomUrl(0,'supplier',0,1); |
341 | 380 | } |
@@ -357,8 +396,7 @@ discard block |
||
357 | 396 | print '</div>'; |
358 | 397 | print "<!-- End last thirdparties modified -->\n"; |
359 | 398 | } |
360 | -} |
|
361 | -else |
|
399 | +} else |
|
362 | 400 | { |
363 | 401 | dol_print_error($db); |
364 | 402 | } |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | // Search thirdparty |
68 | 68 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
69 | 69 | { |
70 | - $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); |
|
70 | + $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); |
|
71 | 71 | } |
72 | 72 | // Search contact/address |
73 | 73 | if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
74 | 74 | { |
75 | - $listofsearchfields['search_contact']=array('text'=>'Contact'); |
|
75 | + $listofsearchfields['search_contact']=array('text'=>'Contact'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if (count($listofsearchfields)) |
@@ -80,20 +80,20 @@ discard block |
||
80 | 80 | // print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; |
81 | 81 | print '<form method="post" action="' . BASE_URI . '?controller=core&method=search">'; |
82 | 82 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
83 | - print '<table class="noborder nohover centpercent">'; |
|
84 | - $i=0; |
|
85 | - foreach($listofsearchfields as $key => $value) |
|
86 | - { |
|
87 | - if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
|
88 | - print '<tr '.$bc[false].'>'; |
|
89 | - print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; |
|
90 | - if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; |
|
91 | - print '</tr>'; |
|
92 | - $i++; |
|
93 | - } |
|
94 | - print '</table>'; |
|
95 | - print '</form>'; |
|
96 | - print '<br>'; |
|
83 | + print '<table class="noborder nohover centpercent">'; |
|
84 | + $i=0; |
|
85 | + foreach($listofsearchfields as $key => $value) |
|
86 | + { |
|
87 | + if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
|
88 | + print '<tr '.$bc[false].'>'; |
|
89 | + print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; |
|
90 | + if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; |
|
91 | + print '</tr>'; |
|
92 | + $i++; |
|
93 | + } |
|
94 | + print '</table>'; |
|
95 | + print '</form>'; |
|
96 | + print '<br>'; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | */ |
104 | 104 | |
105 | 105 | $third = array( |
106 | - 'customer' => 0, |
|
107 | - 'prospect' => 0, |
|
108 | - 'supplier' => 0, |
|
109 | - 'other' =>0 |
|
106 | + 'customer' => 0, |
|
107 | + 'prospect' => 0, |
|
108 | + 'supplier' => 0, |
|
109 | + 'other' =>0 |
|
110 | 110 | ); |
111 | 111 | $total=0; |
112 | 112 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); |
147 | 147 | include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
148 | 148 | $dolgraph = new DolGraph(); |
149 | - $dolgraph->SetData($dataseries); |
|
150 | - $dolgraph->setShowLegend(1); |
|
151 | - $dolgraph->setShowPercent(1); |
|
152 | - $dolgraph->SetType(array('pie')); |
|
153 | - $dolgraph->setWidth('100%'); |
|
154 | - $dolgraph->draw('idgraphthirdparties'); |
|
155 | - print $dolgraph->show(); |
|
149 | + $dolgraph->SetData($dataseries); |
|
150 | + $dolgraph->setShowLegend(1); |
|
151 | + $dolgraph->setShowPercent(1); |
|
152 | + $dolgraph->SetType(array('pie')); |
|
153 | + $dolgraph->setWidth('100%'); |
|
154 | + $dolgraph->draw('idgraphthirdparties'); |
|
155 | + print $dolgraph->show(); |
|
156 | 156 | print '</td></tr>'."\n"; |
157 | 157 | } |
158 | 158 | else |
@@ -189,80 +189,80 @@ discard block |
||
189 | 189 | |
190 | 190 | if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) |
191 | 191 | { |
192 | - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
193 | - $elementtype = 'societe'; |
|
194 | - |
|
195 | - print '<br>'; |
|
196 | - |
|
197 | - print '<div class="div-table-responsive-no-min">'; |
|
198 | - print '<table class="noborder nohover" width="100%">'; |
|
199 | - print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>'; |
|
200 | - print '<tr '.$bc[0].'><td align="center" colspan="2">'; |
|
201 | - $sql = "SELECT c.label, count(*) as nb"; |
|
202 | - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; |
|
203 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; |
|
204 | - $sql.= " WHERE c.type = 2"; |
|
205 | - if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
206 | - $sql.= " AND c.entity IN (".getEntity('category').")"; |
|
207 | - $sql.= " GROUP BY c.label"; |
|
208 | - $total=0; |
|
209 | - $result = $db->query($sql); |
|
210 | - if ($result) |
|
211 | - { |
|
212 | - $num = $db->num_rows($result); |
|
213 | - $i=0; |
|
214 | - if (! empty($conf->use_javascript_ajax) ) |
|
215 | - { |
|
216 | - $dataseries=array(); |
|
217 | - $rest=0; |
|
218 | - $nbmax=10; |
|
219 | - |
|
220 | - while ($i < $num) |
|
221 | - { |
|
222 | - $obj = $db->fetch_object($result); |
|
223 | - if ($i < $nbmax) |
|
224 | - { |
|
225 | - $dataseries[]=array($obj->label, round($obj->nb)); |
|
226 | - } |
|
227 | - else |
|
228 | - { |
|
229 | - $rest+=$obj->nb; |
|
230 | - } |
|
231 | - $total+=$obj->nb; |
|
232 | - $i++; |
|
233 | - } |
|
234 | - if ($i > $nbmax) |
|
235 | - { |
|
236 | - $dataseries[]=array($langs->trans("Other"), round($rest)); |
|
237 | - } |
|
238 | - include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
|
239 | - $dolgraph = new DolGraph(); |
|
240 | - $dolgraph->SetData($dataseries); |
|
241 | - $dolgraph->setShowLegend(1); |
|
242 | - $dolgraph->setShowPercent(1); |
|
243 | - $dolgraph->SetType(array('pie')); |
|
244 | - $dolgraph->setWidth('100%'); |
|
245 | - $dolgraph->draw('idgraphcateg'); |
|
246 | - print $dolgraph->show(); |
|
247 | - } |
|
248 | - else |
|
249 | - { |
|
250 | - while ($i < $num) |
|
251 | - { |
|
252 | - $obj = $db->fetch_object($result); |
|
253 | - |
|
254 | - print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; |
|
255 | - $total+=$obj->nb; |
|
256 | - $i++; |
|
257 | - } |
|
258 | - } |
|
259 | - } |
|
260 | - print '</td></tr>'; |
|
261 | - print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'; |
|
262 | - print $total; |
|
263 | - print '</td></tr>'; |
|
264 | - print '</table>'; |
|
265 | - print '</div>'; |
|
192 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
193 | + $elementtype = 'societe'; |
|
194 | + |
|
195 | + print '<br>'; |
|
196 | + |
|
197 | + print '<div class="div-table-responsive-no-min">'; |
|
198 | + print '<table class="noborder nohover" width="100%">'; |
|
199 | + print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>'; |
|
200 | + print '<tr '.$bc[0].'><td align="center" colspan="2">'; |
|
201 | + $sql = "SELECT c.label, count(*) as nb"; |
|
202 | + $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; |
|
203 | + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; |
|
204 | + $sql.= " WHERE c.type = 2"; |
|
205 | + if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
206 | + $sql.= " AND c.entity IN (".getEntity('category').")"; |
|
207 | + $sql.= " GROUP BY c.label"; |
|
208 | + $total=0; |
|
209 | + $result = $db->query($sql); |
|
210 | + if ($result) |
|
211 | + { |
|
212 | + $num = $db->num_rows($result); |
|
213 | + $i=0; |
|
214 | + if (! empty($conf->use_javascript_ajax) ) |
|
215 | + { |
|
216 | + $dataseries=array(); |
|
217 | + $rest=0; |
|
218 | + $nbmax=10; |
|
219 | + |
|
220 | + while ($i < $num) |
|
221 | + { |
|
222 | + $obj = $db->fetch_object($result); |
|
223 | + if ($i < $nbmax) |
|
224 | + { |
|
225 | + $dataseries[]=array($obj->label, round($obj->nb)); |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
229 | + $rest+=$obj->nb; |
|
230 | + } |
|
231 | + $total+=$obj->nb; |
|
232 | + $i++; |
|
233 | + } |
|
234 | + if ($i > $nbmax) |
|
235 | + { |
|
236 | + $dataseries[]=array($langs->trans("Other"), round($rest)); |
|
237 | + } |
|
238 | + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
|
239 | + $dolgraph = new DolGraph(); |
|
240 | + $dolgraph->SetData($dataseries); |
|
241 | + $dolgraph->setShowLegend(1); |
|
242 | + $dolgraph->setShowPercent(1); |
|
243 | + $dolgraph->SetType(array('pie')); |
|
244 | + $dolgraph->setWidth('100%'); |
|
245 | + $dolgraph->draw('idgraphcateg'); |
|
246 | + print $dolgraph->show(); |
|
247 | + } |
|
248 | + else |
|
249 | + { |
|
250 | + while ($i < $num) |
|
251 | + { |
|
252 | + $obj = $db->fetch_object($result); |
|
253 | + |
|
254 | + print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; |
|
255 | + $total+=$obj->nb; |
|
256 | + $i++; |
|
257 | + } |
|
258 | + } |
|
259 | + } |
|
260 | + print '</td></tr>'; |
|
261 | + print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">'; |
|
262 | + print $total; |
|
263 | + print '</td></tr>'; |
|
264 | + print '</table>'; |
|
265 | + print '</div>'; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | //print '</td><td valign="top" width="70%" class="notopnoleftnoright">'; |
@@ -334,20 +334,20 @@ discard block |
||
334 | 334 | print '<td align="center">'; |
335 | 335 | if ($thirdparty_static->client==1 || $thirdparty_static->client==3) |
336 | 336 | { |
337 | - $thirdparty_static->name=$langs->trans("Customer"); |
|
338 | - print $thirdparty_static->getNomUrl(0,'customer',0,1); |
|
337 | + $thirdparty_static->name=$langs->trans("Customer"); |
|
338 | + print $thirdparty_static->getNomUrl(0,'customer',0,1); |
|
339 | 339 | } |
340 | 340 | if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; |
341 | 341 | if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
342 | 342 | { |
343 | - $thirdparty_static->name=$langs->trans("Prospect"); |
|
344 | - print $thirdparty_static->getNomUrl(0,'prospect',0,1); |
|
343 | + $thirdparty_static->name=$langs->trans("Prospect"); |
|
344 | + print $thirdparty_static->getNomUrl(0,'prospect',0,1); |
|
345 | 345 | } |
346 | 346 | if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) |
347 | 347 | { |
348 | 348 | if ($thirdparty_static->client) print " / "; |
349 | - $thirdparty_static->name=$langs->trans("Supplier"); |
|
350 | - print $thirdparty_static->getNomUrl(0,'supplier',0,1); |
|
349 | + $thirdparty_static->name=$langs->trans("Supplier"); |
|
350 | + print $thirdparty_static->getNomUrl(0,'supplier',0,1); |
|
351 | 351 | } |
352 | 352 | print '</td>'; |
353 | 353 | // Last modified date |
@@ -30,17 +30,17 @@ discard block |
||
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 | |
35 | 35 | require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
36 | 36 | |
37 | 37 | $langs->load("companies"); |
38 | 38 | |
39 | -$socid = GETPOST('socid','int'); |
|
40 | -if ($user->societe_id) $socid=$user->societe_id; |
|
39 | +$socid = GETPOST('socid', 'int'); |
|
40 | +if ($user->societe_id) $socid = $user->societe_id; |
|
41 | 41 | |
42 | 42 | // Security check |
43 | -$result=restrictedArea($user,'societe',0,'','','',''); |
|
43 | +$result = restrictedArea($user, 'societe', 0, '', '', '', ''); |
|
44 | 44 | |
45 | 45 | $thirdparty_static = new Societe($db); |
46 | 46 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | |
52 | 52 | $transAreaType = $langs->trans("ThirdPartiesArea"); |
53 | -$helpurl='EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros'; |
|
53 | +$helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros'; |
|
54 | 54 | |
55 | -llxHeader("",$langs->trans("ThirdParties"),$helpurl); |
|
56 | -$linkback=''; |
|
57 | -print load_fiche_titre($transAreaType,$linkback,'title_companies.png'); |
|
55 | +llxHeader("", $langs->trans("ThirdParties"), $helpurl); |
|
56 | +$linkback = ''; |
|
57 | +print load_fiche_titre($transAreaType, $linkback, 'title_companies.png'); |
|
58 | 58 | |
59 | 59 | |
60 | 60 | //print '<table border="0" width="100%" class="notopnoleftnoright">'; |
@@ -62,27 +62,27 @@ discard block |
||
62 | 62 | print '<div class="fichecenter"><div class="fichethirdleft">'; |
63 | 63 | |
64 | 64 | |
65 | -if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
65 | +if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo |
|
66 | 66 | { |
67 | 67 | // Search thirdparty |
68 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
|
68 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire) |
|
69 | 69 | { |
70 | - $listofsearchfields['search_thirdparty']=array('text'=>'ThirdParty'); |
|
70 | + $listofsearchfields['search_thirdparty'] = array('text'=>'ThirdParty'); |
|
71 | 71 | } |
72 | 72 | // Search contact/address |
73 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire) |
|
73 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire) |
|
74 | 74 | { |
75 | - $listofsearchfields['search_contact']=array('text'=>'Contact'); |
|
75 | + $listofsearchfields['search_contact'] = array('text'=>'Contact'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | if (count($listofsearchfields)) |
79 | 79 | { |
80 | 80 | // print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; |
81 | - print '<form method="post" action="' . BASE_URI . '?controller=core&method=search">'; |
|
81 | + print '<form method="post" action="'.BASE_URI.'?controller=core&method=search">'; |
|
82 | 82 | print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; |
83 | 83 | print '<table class="noborder nohover centpercent">'; |
84 | - $i=0; |
|
85 | - foreach($listofsearchfields as $key => $value) |
|
84 | + $i = 0; |
|
85 | + foreach ($listofsearchfields as $key => $value) |
|
86 | 86 | { |
87 | 87 | if ($i == 0) print '<tr class="liste_titre"><th colspan="3">'.$langs->trans("Search").'</th></tr>'; |
88 | 88 | print '<tr '.$bc[false].'>'; |
@@ -108,26 +108,26 @@ discard block |
||
108 | 108 | 'supplier' => 0, |
109 | 109 | 'other' =>0 |
110 | 110 | ); |
111 | -$total=0; |
|
111 | +$total = 0; |
|
112 | 112 | |
113 | 113 | $sql = "SELECT s.rowid, s.client, s.fournisseur"; |
114 | -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
115 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
116 | -$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
117 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
118 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
119 | -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible |
|
114 | +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
115 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
116 | +$sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
117 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
118 | +if ($socid) $sql .= " AND s.rowid = ".$socid; |
|
119 | +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur <> 1 OR s.client <> 0)"; // client=0, fournisseur=0 must be visible |
|
120 | 120 | //print $sql; |
121 | 121 | $result = $db->query($sql); |
122 | 122 | if ($result) |
123 | 123 | { |
124 | 124 | while ($objp = $db->fetch_object($result)) |
125 | 125 | { |
126 | - $found=0; |
|
127 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found=1; $third['prospect']++; } |
|
128 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found=1; $third['customer']++; } |
|
129 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found=1; $third['supplier']++; } |
|
130 | - if (! empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found=1; $third['other']++; } |
|
126 | + $found = 0; |
|
127 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third['prospect']++; } |
|
128 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third['customer']++; } |
|
129 | + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third['supplier']++; } |
|
130 | + if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third['other']++; } |
|
131 | 131 | if ($found) $total++; |
132 | 132 | } |
133 | 133 | } |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | print '<div class="div-table-responsive-no-min">'; |
137 | 137 | print '<table class="noborder nohover" width="100%">'."\n"; |
138 | 138 | print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; |
139 | -if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) |
|
139 | +if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) |
|
140 | 140 | { |
141 | 141 | print '<tr><td align="center" colspan="2">'; |
142 | - $dataseries=array(); |
|
143 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); |
|
144 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); |
|
145 | - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); |
|
146 | - if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); |
|
142 | + $dataseries = array(); |
|
143 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[] = array($langs->trans("Prospects"), round($third['prospect'])); |
|
144 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans("Customers"), round($third['customer'])); |
|
145 | + if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans("Suppliers"), round($third['supplier'])); |
|
146 | + if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans("Others"), round($third['other'])); |
|
147 | 147 | include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
148 | 148 | $dolgraph = new DolGraph(); |
149 | 149 | $dolgraph->SetData($dataseries); |
@@ -157,26 +157,26 @@ discard block |
||
157 | 157 | } |
158 | 158 | else |
159 | 159 | { |
160 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) |
|
160 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) |
|
161 | 161 | { |
162 | 162 | $statstring = "<tr>"; |
163 | 163 | //$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=p">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>'; |
164 | - $statstring .= '<td><a href="' . BASE_URI . '?controller=societe&method=list&type=p">' . $langs->trans("Prospects") . '</a></td><td align="right">' . round($third['prospect']) . '</td>'; |
|
165 | - $statstring.= "</tr>"; |
|
164 | + $statstring .= '<td><a href="'.BASE_URI.'?controller=societe&method=list&type=p">'.$langs->trans("Prospects").'</a></td><td align="right">'.round($third['prospect']).'</td>'; |
|
165 | + $statstring .= "</tr>"; |
|
166 | 166 | } |
167 | - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) |
|
167 | + if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) |
|
168 | 168 | { |
169 | - $statstring.= "<tr>"; |
|
169 | + $statstring .= "<tr>"; |
|
170 | 170 | //$statstring.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=c">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>'; |
171 | - $statstring .= '<td><a href="' . BASE_URI . '?controller=societe&method=list&type=c">' . $langs->trans("Customers") . '</a></td><td align="right">' . round($third['customer']) . '</td>'; |
|
172 | - $statstring.= "</tr>"; |
|
171 | + $statstring .= '<td><a href="'.BASE_URI.'?controller=societe&method=list&type=c">'.$langs->trans("Customers").'</a></td><td align="right">'.round($third['customer']).'</td>'; |
|
172 | + $statstring .= "</tr>"; |
|
173 | 173 | } |
174 | - if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) |
|
174 | + if (!empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) |
|
175 | 175 | { |
176 | 176 | $statstring2 = "<tr>"; |
177 | 177 | //$statstring2.= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>'; |
178 | - $statstring2 .= '<td><a href="' . BASE_URI . '?controller=societe&method=list&typef">' . $langs->trans("Suppliers") . '</a></td><td align="right">' . round($third['supplier']) . '</td>'; |
|
179 | - $statstring2.= "</tr>"; |
|
178 | + $statstring2 .= '<td><a href="'.BASE_URI.'?controller=societe&method=list&typef">'.$langs->trans("Suppliers").'</a></td><td align="right">'.round($third['supplier']).'</td>'; |
|
179 | + $statstring2 .= "</tr>"; |
|
180 | 180 | } |
181 | 181 | print $statstring; |
182 | 182 | print $statstring2; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | print '</table>'; |
188 | 188 | print '</div>'; |
189 | 189 | |
190 | -if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) |
|
190 | +if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) |
|
191 | 191 | { |
192 | 192 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
193 | 193 | $elementtype = 'societe'; |
@@ -199,41 +199,41 @@ discard block |
||
199 | 199 | print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>'; |
200 | 200 | print '<tr '.$bc[0].'><td align="center" colspan="2">'; |
201 | 201 | $sql = "SELECT c.label, count(*) as nb"; |
202 | - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; |
|
203 | - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; |
|
204 | - $sql.= " WHERE c.type = 2"; |
|
205 | - if (! is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql.= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
206 | - $sql.= " AND c.entity IN (".getEntity('category').")"; |
|
207 | - $sql.= " GROUP BY c.label"; |
|
208 | - $total=0; |
|
202 | + $sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; |
|
203 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; |
|
204 | + $sql .= " WHERE c.type = 2"; |
|
205 | + if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .= " AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)."'"; |
|
206 | + $sql .= " AND c.entity IN (".getEntity('category').")"; |
|
207 | + $sql .= " GROUP BY c.label"; |
|
208 | + $total = 0; |
|
209 | 209 | $result = $db->query($sql); |
210 | 210 | if ($result) |
211 | 211 | { |
212 | 212 | $num = $db->num_rows($result); |
213 | - $i=0; |
|
214 | - if (! empty($conf->use_javascript_ajax) ) |
|
213 | + $i = 0; |
|
214 | + if (!empty($conf->use_javascript_ajax)) |
|
215 | 215 | { |
216 | - $dataseries=array(); |
|
217 | - $rest=0; |
|
218 | - $nbmax=10; |
|
216 | + $dataseries = array(); |
|
217 | + $rest = 0; |
|
218 | + $nbmax = 10; |
|
219 | 219 | |
220 | 220 | while ($i < $num) |
221 | 221 | { |
222 | 222 | $obj = $db->fetch_object($result); |
223 | 223 | if ($i < $nbmax) |
224 | 224 | { |
225 | - $dataseries[]=array($obj->label, round($obj->nb)); |
|
225 | + $dataseries[] = array($obj->label, round($obj->nb)); |
|
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | - $rest+=$obj->nb; |
|
229 | + $rest += $obj->nb; |
|
230 | 230 | } |
231 | - $total+=$obj->nb; |
|
231 | + $total += $obj->nb; |
|
232 | 232 | $i++; |
233 | 233 | } |
234 | 234 | if ($i > $nbmax) |
235 | 235 | { |
236 | - $dataseries[]=array($langs->trans("Other"), round($rest)); |
|
236 | + $dataseries[] = array($langs->trans("Other"), round($rest)); |
|
237 | 237 | } |
238 | 238 | include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; |
239 | 239 | $dolgraph = new DolGraph(); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $obj = $db->fetch_object($result); |
253 | 253 | |
254 | 254 | print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>'; |
255 | - $total+=$obj->nb; |
|
255 | + $total += $obj->nb; |
|
256 | 256 | $i++; |
257 | 257 | } |
258 | 258 | } |
@@ -272,20 +272,20 @@ discard block |
||
272 | 272 | /* |
273 | 273 | * Last third parties modified |
274 | 274 | */ |
275 | -$max=15; |
|
275 | +$max = 15; |
|
276 | 276 | $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; |
277 | -$sql.= ", s.code_client"; |
|
278 | -$sql.= ", s.code_fournisseur"; |
|
279 | -$sql.= ", s.logo"; |
|
280 | -$sql.= ", s.canvas, s.tms as datem, s.status as status"; |
|
281 | -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
282 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
283 | -$sql.= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
284 | -if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; |
|
285 | -if ($socid) $sql.= " AND s.rowid = ".$socid; |
|
286 | -if (! $user->rights->fournisseur->lire) $sql.=" AND (s.fournisseur != 1 OR s.client != 0)"; |
|
287 | -$sql.= $db->order("s.tms","DESC"); |
|
288 | -$sql.= $db->plimit($max,0); |
|
277 | +$sql .= ", s.code_client"; |
|
278 | +$sql .= ", s.code_fournisseur"; |
|
279 | +$sql .= ", s.logo"; |
|
280 | +$sql .= ", s.canvas, s.tms as datem, s.status as status"; |
|
281 | +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; |
|
282 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; |
|
283 | +$sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; |
|
284 | +if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; |
|
285 | +if ($socid) $sql .= " AND s.rowid = ".$socid; |
|
286 | +if (!$user->rights->fournisseur->lire) $sql .= " AND (s.fournisseur != 1 OR s.client != 0)"; |
|
287 | +$sql .= $db->order("s.tms", "DESC"); |
|
288 | +$sql .= $db->plimit($max, 0); |
|
289 | 289 | |
290 | 290 | //print $sql; |
291 | 291 | $result = $db->query($sql); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | |
298 | 298 | if ($num > 0) |
299 | 299 | { |
300 | - $transRecordedType = $langs->trans("LastModifiedThirdParties",$max); |
|
300 | + $transRecordedType = $langs->trans("LastModifiedThirdParties", $max); |
|
301 | 301 | |
302 | 302 | print "\n<!-- last thirdparties modified -->\n"; |
303 | 303 | print '<div class="div-table-responsive-no-min">'; |
@@ -306,23 +306,23 @@ discard block |
||
306 | 306 | print '<tr class="liste_titre"><th colspan="2">'.$transRecordedType.'</th>'; |
307 | 307 | print '<th> </th>'; |
308 | 308 | //print '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; |
309 | - print '<th class="right"><a href="' . BASE_URI . '?controller=societe&method=list&sortfield=s.tms&sortorder=DESC">' . $langs->trans("FullList") . '</th>'; |
|
309 | + print '<th class="right"><a href="'.BASE_URI.'?controller=societe&method=list&sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; |
|
310 | 310 | print '</tr>'."\n"; |
311 | 311 | |
312 | 312 | while ($i < $num) |
313 | 313 | { |
314 | 314 | $objp = $db->fetch_object($result); |
315 | 315 | |
316 | - $thirdparty_static->id=$objp->rowid; |
|
317 | - $thirdparty_static->name=$objp->name; |
|
318 | - $thirdparty_static->client=$objp->client; |
|
319 | - $thirdparty_static->fournisseur=$objp->fournisseur; |
|
316 | + $thirdparty_static->id = $objp->rowid; |
|
317 | + $thirdparty_static->name = $objp->name; |
|
318 | + $thirdparty_static->client = $objp->client; |
|
319 | + $thirdparty_static->fournisseur = $objp->fournisseur; |
|
320 | 320 | $thirdparty_static->logo = $objp->logo; |
321 | - $thirdparty_static->datem=$db->jdate($objp->datem); |
|
322 | - $thirdparty_static->status=$objp->status; |
|
321 | + $thirdparty_static->datem = $db->jdate($objp->datem); |
|
322 | + $thirdparty_static->status = $objp->status; |
|
323 | 323 | $thirdparty_static->code_client = $objp->code_client; |
324 | 324 | $thirdparty_static->code_fournisseur = $objp->code_fournisseur; |
325 | - $thirdparty_static->canvas=$objp->canvas; |
|
325 | + $thirdparty_static->canvas = $objp->canvas; |
|
326 | 326 | $thirdparty_static->email = $objp->email; |
327 | 327 | |
328 | 328 | print '<tr class="oddeven">'; |
@@ -332,27 +332,27 @@ discard block |
||
332 | 332 | print "</td>\n"; |
333 | 333 | // Type |
334 | 334 | print '<td align="center">'; |
335 | - if ($thirdparty_static->client==1 || $thirdparty_static->client==3) |
|
335 | + if ($thirdparty_static->client == 1 || $thirdparty_static->client == 3) |
|
336 | 336 | { |
337 | - $thirdparty_static->name=$langs->trans("Customer"); |
|
338 | - print $thirdparty_static->getNomUrl(0,'customer',0,1); |
|
337 | + $thirdparty_static->name = $langs->trans("Customer"); |
|
338 | + print $thirdparty_static->getNomUrl(0, 'customer', 0, 1); |
|
339 | 339 | } |
340 | 340 | if ($thirdparty_static->client == 3 && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) print " / "; |
341 | - if (($thirdparty_static->client==2 || $thirdparty_static->client==3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
|
341 | + if (($thirdparty_static->client == 2 || $thirdparty_static->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) |
|
342 | 342 | { |
343 | - $thirdparty_static->name=$langs->trans("Prospect"); |
|
344 | - print $thirdparty_static->getNomUrl(0,'prospect',0,1); |
|
343 | + $thirdparty_static->name = $langs->trans("Prospect"); |
|
344 | + print $thirdparty_static->getNomUrl(0, 'prospect', 0, 1); |
|
345 | 345 | } |
346 | - if (! empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) |
|
346 | + if (!empty($conf->fournisseur->enabled) && $thirdparty_static->fournisseur) |
|
347 | 347 | { |
348 | 348 | if ($thirdparty_static->client) print " / "; |
349 | - $thirdparty_static->name=$langs->trans("Supplier"); |
|
350 | - print $thirdparty_static->getNomUrl(0,'supplier',0,1); |
|
349 | + $thirdparty_static->name = $langs->trans("Supplier"); |
|
350 | + print $thirdparty_static->getNomUrl(0, 'supplier', 0, 1); |
|
351 | 351 | } |
352 | 352 | print '</td>'; |
353 | 353 | // Last modified date |
354 | 354 | print '<td align="right">'; |
355 | - print dol_print_date($thirdparty_static->datem,'day'); |
|
355 | + print dol_print_date($thirdparty_static->datem, 'day'); |
|
356 | 356 | print "</td>"; |
357 | 357 | print '<td align="right" class="nowrap">'; |
358 | 358 | print $thirdparty_static->getLibStatut(3); |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
34 | 34 | |
35 | 35 | if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
36 | - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
36 | + require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
37 | 37 | |
38 | - $prodcustprice = new Productcustomerprice($db); |
|
38 | + $prodcustprice = new Productcustomerprice($db); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $langs->loadLangs(array("products", "companies", "bills")); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | // Security check |
48 | 48 | $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); |
49 | 49 | if ($user->societe_id) |
50 | - $socid = $user->societe_id; |
|
50 | + $socid = $user->societe_id; |
|
51 | 51 | $result = restrictedArea($user, 'societe', $socid, '&societe'); |
52 | 52 | |
53 | 53 | $object = new Societe($db); |
@@ -74,98 +74,98 @@ discard block |
||
74 | 74 | |
75 | 75 | if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { |
76 | 76 | |
77 | - $update_child_soc = GETPOST('updatechildprice'); |
|
78 | - |
|
79 | - // add price by customer |
|
80 | - $prodcustprice->fk_soc = $socid; |
|
81 | - $prodcustprice->fk_product = GETPOST('prodid', 'int'); |
|
82 | - $prodcustprice->price = price2num(GETPOST("price"), 'MU'); |
|
83 | - $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); |
|
84 | - $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); |
|
85 | - |
|
86 | - $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
87 | - |
|
88 | - // We must define tva_tx, npr and local taxes |
|
89 | - $vatratecode = ''; |
|
90 | - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
91 | - $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; |
|
92 | - $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; |
|
93 | - // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes |
|
94 | - if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) |
|
95 | - { |
|
96 | - // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. |
|
97 | - $vatratecode=$reg[1]; |
|
98 | - // Get record from code |
|
99 | - $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
|
100 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
101 | - $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
102 | - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
103 | - $sql.= " AND t.code ='".$vatratecode."'"; |
|
104 | - $resql=$db->query($sql); |
|
105 | - if ($resql) |
|
106 | - { |
|
107 | - $obj = $db->fetch_object($resql); |
|
108 | - $npr = $obj->recuperableonly; |
|
109 | - $localtax1 = $obj->localtax1; |
|
110 | - $localtax2 = $obj->localtax2; |
|
111 | - $localtax1_type = $obj->localtax1_type; |
|
112 | - $localtax2_type = $obj->localtax2_type; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - $prodcustprice->default_vat_code = $vatratecode; |
|
117 | - $prodcustprice->tva_tx = $tva_tx; |
|
118 | - $prodcustprice->recuperableonly = $npr; |
|
119 | - $prodcustprice->localtax1_tx = $localtax1; |
|
120 | - $prodcustprice->localtax2_tx = $localtax2; |
|
121 | - $prodcustprice->localtax1_type = $localtax1_type; |
|
122 | - $prodcustprice->localtax2_type = $localtax2_type; |
|
123 | - |
|
124 | - $result = $prodcustprice->create($user, 0, $update_child_soc); |
|
125 | - |
|
126 | - if ($result < 0) { |
|
127 | - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
128 | - } else { |
|
129 | - setEventMessages($langs->trans('Save'), null, 'mesgs'); |
|
130 | - } |
|
131 | - |
|
132 | - $action = ''; |
|
77 | + $update_child_soc = GETPOST('updatechildprice'); |
|
78 | + |
|
79 | + // add price by customer |
|
80 | + $prodcustprice->fk_soc = $socid; |
|
81 | + $prodcustprice->fk_product = GETPOST('prodid', 'int'); |
|
82 | + $prodcustprice->price = price2num(GETPOST("price"), 'MU'); |
|
83 | + $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); |
|
84 | + $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); |
|
85 | + |
|
86 | + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
87 | + |
|
88 | + // We must define tva_tx, npr and local taxes |
|
89 | + $vatratecode = ''; |
|
90 | + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
91 | + $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; |
|
92 | + $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; |
|
93 | + // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes |
|
94 | + if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) |
|
95 | + { |
|
96 | + // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. |
|
97 | + $vatratecode=$reg[1]; |
|
98 | + // Get record from code |
|
99 | + $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
|
100 | + $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
101 | + $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
102 | + $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
103 | + $sql.= " AND t.code ='".$vatratecode."'"; |
|
104 | + $resql=$db->query($sql); |
|
105 | + if ($resql) |
|
106 | + { |
|
107 | + $obj = $db->fetch_object($resql); |
|
108 | + $npr = $obj->recuperableonly; |
|
109 | + $localtax1 = $obj->localtax1; |
|
110 | + $localtax2 = $obj->localtax2; |
|
111 | + $localtax1_type = $obj->localtax1_type; |
|
112 | + $localtax2_type = $obj->localtax2_type; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + $prodcustprice->default_vat_code = $vatratecode; |
|
117 | + $prodcustprice->tva_tx = $tva_tx; |
|
118 | + $prodcustprice->recuperableonly = $npr; |
|
119 | + $prodcustprice->localtax1_tx = $localtax1; |
|
120 | + $prodcustprice->localtax2_tx = $localtax2; |
|
121 | + $prodcustprice->localtax1_type = $localtax1_type; |
|
122 | + $prodcustprice->localtax2_type = $localtax2_type; |
|
123 | + |
|
124 | + $result = $prodcustprice->create($user, 0, $update_child_soc); |
|
125 | + |
|
126 | + if ($result < 0) { |
|
127 | + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
128 | + } else { |
|
129 | + setEventMessages($langs->trans('Save'), null, 'mesgs'); |
|
130 | + } |
|
131 | + |
|
132 | + $action = ''; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $user->rights->service->creer)) { |
136 | - // Delete price by customer |
|
137 | - $prodcustprice->id = GETPOST('lineid'); |
|
138 | - $result = $prodcustprice->delete($user); |
|
139 | - |
|
140 | - if ($result < 0) { |
|
141 | - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); |
|
142 | - } else { |
|
143 | - setEventMessages($langs->trans('Delete'), null, 'errors'); |
|
144 | - } |
|
145 | - $action = ''; |
|
136 | + // Delete price by customer |
|
137 | + $prodcustprice->id = GETPOST('lineid'); |
|
138 | + $result = $prodcustprice->delete($user); |
|
139 | + |
|
140 | + if ($result < 0) { |
|
141 | + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); |
|
142 | + } else { |
|
143 | + setEventMessages($langs->trans('Delete'), null, 'errors'); |
|
144 | + } |
|
145 | + $action = ''; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { |
149 | 149 | |
150 | - $prodcustprice->fetch(GETPOST('lineid', 'int')); |
|
150 | + $prodcustprice->fetch(GETPOST('lineid', 'int')); |
|
151 | 151 | |
152 | - $update_child_soc = GETPOST('updatechildprice'); |
|
152 | + $update_child_soc = GETPOST('updatechildprice'); |
|
153 | 153 | |
154 | - // update price by customer |
|
155 | - $prodcustprice->price = price2num(GETPOST("price"), 'MU'); |
|
156 | - $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); |
|
157 | - $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); |
|
158 | - $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); |
|
159 | - $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); |
|
154 | + // update price by customer |
|
155 | + $prodcustprice->price = price2num(GETPOST("price"), 'MU'); |
|
156 | + $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); |
|
157 | + $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); |
|
158 | + $prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx")); |
|
159 | + $prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0); |
|
160 | 160 | |
161 | - $result = $prodcustprice->update($user, 0, $update_child_soc); |
|
162 | - if ($result < 0) { |
|
163 | - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
164 | - } else { |
|
165 | - setEventMessages($langs->trans('Save'), null, 'mesgs'); |
|
166 | - } |
|
161 | + $result = $prodcustprice->update($user, 0, $update_child_soc); |
|
162 | + if ($result < 0) { |
|
163 | + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
164 | + } else { |
|
165 | + setEventMessages($langs->trans('Save'), null, 'mesgs'); |
|
166 | + } |
|
167 | 167 | |
168 | - $action = ''; |
|
168 | + $action = ''; |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer')); |
183 | 183 | |
184 | 184 | if (! empty($conf->notification->enabled)) |
185 | - $langs->load("mails"); |
|
185 | + $langs->load("mails"); |
|
186 | 186 | $head = societe_prepare_head($object); |
187 | 187 | |
188 | 188 | dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); |
@@ -198,25 +198,25 @@ discard block |
||
198 | 198 | |
199 | 199 | if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
200 | 200 | { |
201 | - print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; |
|
201 | + print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | if ($object->client) { |
205 | - print '<tr><td class="titlefield">'; |
|
206 | - print $langs->trans('CustomerCode') . '</td><td colspan="3">'; |
|
207 | - print $object->code_client; |
|
208 | - if ($object->check_codeclient() != 0) |
|
209 | - print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
210 | - print '</td></tr>'; |
|
205 | + print '<tr><td class="titlefield">'; |
|
206 | + print $langs->trans('CustomerCode') . '</td><td colspan="3">'; |
|
207 | + print $object->code_client; |
|
208 | + if ($object->check_codeclient() != 0) |
|
209 | + print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
210 | + print '</td></tr>'; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | if ($object->fournisseur) { |
214 | - print '<tr><td class="titlefield">'; |
|
215 | - print $langs->trans('SupplierCode') . '</td><td colspan="3">'; |
|
216 | - print $object->code_fournisseur; |
|
217 | - if ($object->check_codefournisseur() != 0) |
|
218 | - print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
219 | - print '</td></tr>'; |
|
214 | + print '<tr><td class="titlefield">'; |
|
215 | + print $langs->trans('SupplierCode') . '</td><td colspan="3">'; |
|
216 | + print $object->code_fournisseur; |
|
217 | + if ($object->check_codefournisseur() != 0) |
|
218 | + print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
219 | + print '</td></tr>'; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | print '</table>'; |
@@ -229,277 +229,277 @@ discard block |
||
229 | 229 | |
230 | 230 | if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
231 | 231 | |
232 | - $prodcustprice = new Productcustomerprice($db); |
|
232 | + $prodcustprice = new Productcustomerprice($db); |
|
233 | 233 | |
234 | - $sortfield = GETPOST("sortfield", 'alpha'); |
|
235 | - $sortorder = GETPOST("sortorder", 'alpha'); |
|
234 | + $sortfield = GETPOST("sortfield", 'alpha'); |
|
235 | + $sortorder = GETPOST("sortorder", 'alpha'); |
|
236 | 236 | $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
237 | - $page = GETPOST("page", 'int'); |
|
238 | - if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
|
239 | - $offset = $limit * $page; |
|
240 | - $pageprev = $page - 1; |
|
241 | - $pagenext = $page + 1; |
|
242 | - if (! $sortorder) |
|
243 | - $sortorder = "ASC"; |
|
244 | - if (! $sortfield) |
|
245 | - $sortfield = "soc.nom"; |
|
246 | - |
|
247 | - // Build filter to diplay only concerned lines |
|
248 | - $filter = array ( |
|
249 | - 't.fk_soc' => $object->id |
|
250 | - ); |
|
251 | - |
|
252 | - if (! empty($search_prod)) { |
|
253 | - $filter ['prod.ref'] = $search_prod; |
|
254 | - } |
|
255 | - |
|
256 | - if ($action == 'add_customer_price') { |
|
257 | - |
|
258 | - // Create mode |
|
259 | - |
|
260 | - print load_fiche_titre($langs->trans('PriceByCustomer')); |
|
261 | - |
|
262 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
|
263 | - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
264 | - print '<input type="hidden" name="action" value="add_customer_price_confirm">'; |
|
265 | - print '<input type="hidden" name="socid" value="' . $object->id . '">'; |
|
266 | - print '<table class="border" width="100%">'; |
|
267 | - print '<tr>'; |
|
268 | - print '<td>' . $langs->trans('Product') . '</td>'; |
|
269 | - print '<td>'; |
|
270 | - print $form->select_produits('', 'prodid', '', 0); |
|
271 | - print '</td>'; |
|
272 | - print '</tr>'; |
|
273 | - |
|
274 | - // VAT |
|
275 | - print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; |
|
276 | - print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1); |
|
277 | - print '</td></tr>'; |
|
278 | - |
|
279 | - // Price base |
|
280 | - print '<tr><td width="15%">'; |
|
281 | - print $langs->trans('PriceBase'); |
|
282 | - print '</td>'; |
|
283 | - print '<td>'; |
|
284 | - print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); |
|
285 | - print '</td>'; |
|
286 | - print '</tr>'; |
|
287 | - |
|
288 | - // Price |
|
289 | - print '<tr><td width="20%">'; |
|
290 | - $text = $langs->trans('SellingPrice'); |
|
291 | - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
292 | - print '</td><td>'; |
|
293 | - if ($object->price_base_type == 'TTC') { |
|
294 | - print '<input name="price" size="10" value="' . price($object->price_ttc) . '">'; |
|
295 | - } else { |
|
296 | - print '<input name="price" size="10" value="' . price($object->price) . '">'; |
|
297 | - } |
|
298 | - print '</td></tr>'; |
|
299 | - |
|
300 | - // Price minimum |
|
301 | - print '<tr><td>'; |
|
302 | - $text = $langs->trans('MinPrice'); |
|
303 | - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
304 | - if ($object->price_base_type == 'TTC') { |
|
305 | - print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">'; |
|
306 | - } else { |
|
307 | - print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">'; |
|
308 | - } |
|
309 | - print '</td></tr>'; |
|
310 | - |
|
311 | - // Update all child soc |
|
312 | - print '<tr><td width="15%">'; |
|
313 | - print $langs->trans('ForceUpdateChildPriceSoc'); |
|
314 | - print '</td>'; |
|
315 | - print '<td>'; |
|
316 | - print '<input type="checkbox" name="updatechildprice" value="1"/>'; |
|
317 | - print '</td>'; |
|
318 | - print '</tr>'; |
|
319 | - |
|
320 | - print '</table>'; |
|
321 | - |
|
322 | - print '<br><div align="center">'; |
|
323 | - print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; |
|
324 | - print ' '; |
|
325 | - print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
326 | - print '</div>'; |
|
327 | - |
|
328 | - print '<br></form>'; |
|
329 | - } elseif ($action == 'edit_customer_price') { |
|
330 | - |
|
331 | - // Edit mode |
|
332 | - |
|
333 | - print load_fiche_titre($langs->trans('PriceByCustomer')); |
|
334 | - |
|
335 | - $result = $prodcustprice->fetch(GETPOST('lineid', 'int')); |
|
336 | - if ($result < 0) |
|
337 | - { |
|
338 | - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
339 | - } |
|
340 | - |
|
341 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
|
342 | - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
343 | - print '<input type="hidden" name="action" value="update_customer_price_confirm">'; |
|
344 | - print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">'; |
|
345 | - print '<table class="border" width="100%">'; |
|
346 | - print '<tr>'; |
|
347 | - print '<td>' . $langs->trans('Product') . '</td>'; |
|
348 | - $staticprod = new Product($db); |
|
349 | - $staticprod->fetch($prodcustprice->fk_product); |
|
350 | - print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
351 | - print '</tr>'; |
|
352 | - |
|
353 | - // VAT |
|
354 | - print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; |
|
355 | - print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); |
|
356 | - print '</td></tr>'; |
|
357 | - |
|
358 | - // Price base |
|
359 | - print '<tr><td width="15%">'; |
|
360 | - print $langs->trans('PriceBase'); |
|
361 | - print '</td>'; |
|
362 | - print '<td>'; |
|
363 | - print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type"); |
|
364 | - print '</td>'; |
|
365 | - print '</tr>'; |
|
366 | - |
|
367 | - // Price |
|
368 | - print '<tr><td width="20%">'; |
|
369 | - $text = $langs->trans('SellingPrice'); |
|
370 | - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
371 | - print '</td><td>'; |
|
372 | - if ($prodcustprice->price_base_type == 'TTC') { |
|
373 | - print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">'; |
|
374 | - } else { |
|
375 | - print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">'; |
|
376 | - } |
|
377 | - print '</td></tr>'; |
|
378 | - |
|
379 | - // Price minimum |
|
380 | - print '<tr><td>'; |
|
381 | - $text = $langs->trans('MinPrice'); |
|
382 | - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
383 | - print '</td><td>'; |
|
384 | - if ($prodcustprice->price_base_type == 'TTC') { |
|
385 | - print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">'; |
|
386 | - } else { |
|
387 | - print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">'; |
|
388 | - } |
|
389 | - print '</td></tr>'; |
|
390 | - |
|
391 | - // Update all child soc |
|
392 | - print '<tr><td width="15%">'; |
|
393 | - print $langs->trans('ForceUpdateChildPriceSoc'); |
|
394 | - print '</td>'; |
|
395 | - print '<td>'; |
|
396 | - print '<input type="checkbox" name="updatechildprice" value="1">'; |
|
397 | - print '</td>'; |
|
398 | - print '</tr>'; |
|
399 | - |
|
400 | - print '</table>'; |
|
401 | - |
|
402 | - print '<br><div class="center">'; |
|
403 | - print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; |
|
404 | - print ' '; |
|
405 | - print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
406 | - print '</div>'; |
|
407 | - |
|
408 | - print '<br></form>'; |
|
409 | - } elseif ($action == 'showlog_customer_price') { |
|
410 | - |
|
411 | - print '<!-- showlog_customer_price -->'."\n"; |
|
412 | - |
|
413 | - $filter = array ( |
|
414 | - 't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid |
|
415 | - ); |
|
416 | - |
|
417 | - // Count total nb of records |
|
418 | - $nbtotalofrecords = ''; |
|
419 | - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { |
|
420 | - $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); |
|
421 | - } |
|
422 | - |
|
423 | - $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); |
|
424 | - if ($result < 0) |
|
425 | - { |
|
426 | - setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
427 | - } |
|
428 | - |
|
429 | - $option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int'); |
|
430 | - |
|
431 | - print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); |
|
432 | - |
|
433 | - if (count($prodcustprice->lines) > 0) { |
|
434 | - |
|
435 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; |
|
436 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; |
|
437 | - |
|
438 | - print '<table class="noborder" width="100%">'; |
|
439 | - |
|
440 | - print '<tr class="liste_titre">'; |
|
441 | - print '<td>' . $langs->trans("Product") . '</td>'; |
|
442 | - print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>'; |
|
443 | - print '<td align="center">' . $langs->trans("PriceBase") . '</td>'; |
|
444 | - print '<td align="right">' . $langs->trans("VAT") . '</td>'; |
|
445 | - print '<td align="right">' . $langs->trans("HT") . '</td>'; |
|
446 | - print '<td align="right">' . $langs->trans("TTC") . '</td>'; |
|
447 | - print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>'; |
|
448 | - print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>'; |
|
449 | - print '<td align="right">' . $langs->trans("ChangedBy") . '</td>'; |
|
450 | - print '<td> </td>'; |
|
451 | - print '</tr>'; |
|
452 | - |
|
453 | - foreach ( $prodcustprice->lines as $line ) { |
|
454 | - |
|
455 | - print '<tr class="oddeven">'; |
|
456 | - $staticprod = new Product($db); |
|
457 | - $staticprod->fetch($line->fk_product); |
|
458 | - |
|
459 | - print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
460 | - print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>"; |
|
461 | - |
|
462 | - print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>"; |
|
463 | - print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>"; |
|
464 | - print '<td align="right">' . price($line->price) . "</td>"; |
|
465 | - print '<td align="right">' . price($line->price_ttc) . "</td>"; |
|
466 | - print '<td align="right">' . price($line->price_min) . '</td>'; |
|
467 | - print '<td align="right">' . price($line->price_min_ttc) . '</td>'; |
|
468 | - |
|
469 | - // User |
|
470 | - $userstatic = new User($db); |
|
471 | - $userstatic->fetch($line->fk_user); |
|
472 | - print '<td align="right">'; |
|
473 | - print $userstatic->getLoginUrl(1); |
|
474 | - print '</td>'; |
|
475 | - } |
|
476 | - print "</table>"; |
|
477 | - } |
|
478 | - else |
|
479 | - { |
|
480 | - print $langs->trans('None'); |
|
481 | - } |
|
482 | - |
|
483 | - print "\n" . '<div class="tabsAction">' . "\n"; |
|
484 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>'; |
|
485 | - print "\n</div><br>\n"; |
|
486 | - } |
|
487 | - else |
|
488 | - { |
|
237 | + $page = GETPOST("page", 'int'); |
|
238 | + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
|
239 | + $offset = $limit * $page; |
|
240 | + $pageprev = $page - 1; |
|
241 | + $pagenext = $page + 1; |
|
242 | + if (! $sortorder) |
|
243 | + $sortorder = "ASC"; |
|
244 | + if (! $sortfield) |
|
245 | + $sortfield = "soc.nom"; |
|
246 | + |
|
247 | + // Build filter to diplay only concerned lines |
|
248 | + $filter = array ( |
|
249 | + 't.fk_soc' => $object->id |
|
250 | + ); |
|
251 | + |
|
252 | + if (! empty($search_prod)) { |
|
253 | + $filter ['prod.ref'] = $search_prod; |
|
254 | + } |
|
255 | + |
|
256 | + if ($action == 'add_customer_price') { |
|
257 | + |
|
258 | + // Create mode |
|
259 | + |
|
260 | + print load_fiche_titre($langs->trans('PriceByCustomer')); |
|
261 | + |
|
262 | + print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
|
263 | + print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
264 | + print '<input type="hidden" name="action" value="add_customer_price_confirm">'; |
|
265 | + print '<input type="hidden" name="socid" value="' . $object->id . '">'; |
|
266 | + print '<table class="border" width="100%">'; |
|
267 | + print '<tr>'; |
|
268 | + print '<td>' . $langs->trans('Product') . '</td>'; |
|
269 | + print '<td>'; |
|
270 | + print $form->select_produits('', 'prodid', '', 0); |
|
271 | + print '</td>'; |
|
272 | + print '</tr>'; |
|
273 | + |
|
274 | + // VAT |
|
275 | + print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; |
|
276 | + print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1); |
|
277 | + print '</td></tr>'; |
|
278 | + |
|
279 | + // Price base |
|
280 | + print '<tr><td width="15%">'; |
|
281 | + print $langs->trans('PriceBase'); |
|
282 | + print '</td>'; |
|
283 | + print '<td>'; |
|
284 | + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); |
|
285 | + print '</td>'; |
|
286 | + print '</tr>'; |
|
287 | + |
|
288 | + // Price |
|
289 | + print '<tr><td width="20%">'; |
|
290 | + $text = $langs->trans('SellingPrice'); |
|
291 | + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
292 | + print '</td><td>'; |
|
293 | + if ($object->price_base_type == 'TTC') { |
|
294 | + print '<input name="price" size="10" value="' . price($object->price_ttc) . '">'; |
|
295 | + } else { |
|
296 | + print '<input name="price" size="10" value="' . price($object->price) . '">'; |
|
297 | + } |
|
298 | + print '</td></tr>'; |
|
299 | + |
|
300 | + // Price minimum |
|
301 | + print '<tr><td>'; |
|
302 | + $text = $langs->trans('MinPrice'); |
|
303 | + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
304 | + if ($object->price_base_type == 'TTC') { |
|
305 | + print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">'; |
|
306 | + } else { |
|
307 | + print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">'; |
|
308 | + } |
|
309 | + print '</td></tr>'; |
|
310 | + |
|
311 | + // Update all child soc |
|
312 | + print '<tr><td width="15%">'; |
|
313 | + print $langs->trans('ForceUpdateChildPriceSoc'); |
|
314 | + print '</td>'; |
|
315 | + print '<td>'; |
|
316 | + print '<input type="checkbox" name="updatechildprice" value="1"/>'; |
|
317 | + print '</td>'; |
|
318 | + print '</tr>'; |
|
319 | + |
|
320 | + print '</table>'; |
|
321 | + |
|
322 | + print '<br><div align="center">'; |
|
323 | + print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; |
|
324 | + print ' '; |
|
325 | + print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
326 | + print '</div>'; |
|
327 | + |
|
328 | + print '<br></form>'; |
|
329 | + } elseif ($action == 'edit_customer_price') { |
|
330 | + |
|
331 | + // Edit mode |
|
332 | + |
|
333 | + print load_fiche_titre($langs->trans('PriceByCustomer')); |
|
334 | + |
|
335 | + $result = $prodcustprice->fetch(GETPOST('lineid', 'int')); |
|
336 | + if ($result < 0) |
|
337 | + { |
|
338 | + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
339 | + } |
|
340 | + |
|
341 | + print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
|
342 | + print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
343 | + print '<input type="hidden" name="action" value="update_customer_price_confirm">'; |
|
344 | + print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">'; |
|
345 | + print '<table class="border" width="100%">'; |
|
346 | + print '<tr>'; |
|
347 | + print '<td>' . $langs->trans('Product') . '</td>'; |
|
348 | + $staticprod = new Product($db); |
|
349 | + $staticprod->fetch($prodcustprice->fk_product); |
|
350 | + print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
351 | + print '</tr>'; |
|
352 | + |
|
353 | + // VAT |
|
354 | + print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; |
|
355 | + print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); |
|
356 | + print '</td></tr>'; |
|
357 | + |
|
358 | + // Price base |
|
359 | + print '<tr><td width="15%">'; |
|
360 | + print $langs->trans('PriceBase'); |
|
361 | + print '</td>'; |
|
362 | + print '<td>'; |
|
363 | + print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type"); |
|
364 | + print '</td>'; |
|
365 | + print '</tr>'; |
|
366 | + |
|
367 | + // Price |
|
368 | + print '<tr><td width="20%">'; |
|
369 | + $text = $langs->trans('SellingPrice'); |
|
370 | + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
371 | + print '</td><td>'; |
|
372 | + if ($prodcustprice->price_base_type == 'TTC') { |
|
373 | + print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">'; |
|
374 | + } else { |
|
375 | + print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">'; |
|
376 | + } |
|
377 | + print '</td></tr>'; |
|
378 | + |
|
379 | + // Price minimum |
|
380 | + print '<tr><td>'; |
|
381 | + $text = $langs->trans('MinPrice'); |
|
382 | + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
|
383 | + print '</td><td>'; |
|
384 | + if ($prodcustprice->price_base_type == 'TTC') { |
|
385 | + print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">'; |
|
386 | + } else { |
|
387 | + print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">'; |
|
388 | + } |
|
389 | + print '</td></tr>'; |
|
390 | + |
|
391 | + // Update all child soc |
|
392 | + print '<tr><td width="15%">'; |
|
393 | + print $langs->trans('ForceUpdateChildPriceSoc'); |
|
394 | + print '</td>'; |
|
395 | + print '<td>'; |
|
396 | + print '<input type="checkbox" name="updatechildprice" value="1">'; |
|
397 | + print '</td>'; |
|
398 | + print '</tr>'; |
|
399 | + |
|
400 | + print '</table>'; |
|
401 | + |
|
402 | + print '<br><div class="center">'; |
|
403 | + print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; |
|
404 | + print ' '; |
|
405 | + print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
406 | + print '</div>'; |
|
407 | + |
|
408 | + print '<br></form>'; |
|
409 | + } elseif ($action == 'showlog_customer_price') { |
|
410 | + |
|
411 | + print '<!-- showlog_customer_price -->'."\n"; |
|
412 | + |
|
413 | + $filter = array ( |
|
414 | + 't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid |
|
415 | + ); |
|
416 | + |
|
417 | + // Count total nb of records |
|
418 | + $nbtotalofrecords = ''; |
|
419 | + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { |
|
420 | + $nbtotalofrecords = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); |
|
421 | + } |
|
422 | + |
|
423 | + $result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); |
|
424 | + if ($result < 0) |
|
425 | + { |
|
426 | + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
|
427 | + } |
|
428 | + |
|
429 | + $option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int'); |
|
430 | + |
|
431 | + print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); |
|
432 | + |
|
433 | + if (count($prodcustprice->lines) > 0) { |
|
434 | + |
|
435 | + print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; |
|
436 | + print '<input type="hidden" name="id" value="' . $object->id . '">'; |
|
437 | + |
|
438 | + print '<table class="noborder" width="100%">'; |
|
439 | + |
|
440 | + print '<tr class="liste_titre">'; |
|
441 | + print '<td>' . $langs->trans("Product") . '</td>'; |
|
442 | + print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>'; |
|
443 | + print '<td align="center">' . $langs->trans("PriceBase") . '</td>'; |
|
444 | + print '<td align="right">' . $langs->trans("VAT") . '</td>'; |
|
445 | + print '<td align="right">' . $langs->trans("HT") . '</td>'; |
|
446 | + print '<td align="right">' . $langs->trans("TTC") . '</td>'; |
|
447 | + print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>'; |
|
448 | + print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>'; |
|
449 | + print '<td align="right">' . $langs->trans("ChangedBy") . '</td>'; |
|
450 | + print '<td> </td>'; |
|
451 | + print '</tr>'; |
|
452 | + |
|
453 | + foreach ( $prodcustprice->lines as $line ) { |
|
454 | + |
|
455 | + print '<tr class="oddeven">'; |
|
456 | + $staticprod = new Product($db); |
|
457 | + $staticprod->fetch($line->fk_product); |
|
458 | + |
|
459 | + print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
460 | + print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>"; |
|
461 | + |
|
462 | + print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>"; |
|
463 | + print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>"; |
|
464 | + print '<td align="right">' . price($line->price) . "</td>"; |
|
465 | + print '<td align="right">' . price($line->price_ttc) . "</td>"; |
|
466 | + print '<td align="right">' . price($line->price_min) . '</td>'; |
|
467 | + print '<td align="right">' . price($line->price_min_ttc) . '</td>'; |
|
468 | + |
|
469 | + // User |
|
470 | + $userstatic = new User($db); |
|
471 | + $userstatic->fetch($line->fk_user); |
|
472 | + print '<td align="right">'; |
|
473 | + print $userstatic->getLoginUrl(1); |
|
474 | + print '</td>'; |
|
475 | + } |
|
476 | + print "</table>"; |
|
477 | + } |
|
478 | + else |
|
479 | + { |
|
480 | + print $langs->trans('None'); |
|
481 | + } |
|
482 | + |
|
483 | + print "\n" . '<div class="tabsAction">' . "\n"; |
|
484 | + print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>'; |
|
485 | + print "\n</div><br>\n"; |
|
486 | + } |
|
487 | + else |
|
488 | + { |
|
489 | 489 | // View mode |
490 | 490 | |
491 | - /* ************************************************************************** */ |
|
492 | - /* */ |
|
493 | - /* Barre d'action */ |
|
494 | - /* */ |
|
495 | - /* ************************************************************************** */ |
|
491 | + /* ************************************************************************** */ |
|
492 | + /* */ |
|
493 | + /* Barre d'action */ |
|
494 | + /* */ |
|
495 | + /* ************************************************************************** */ |
|
496 | 496 | |
497 | - print "\n" . '<div class="tabsAction">' . "\n"; |
|
497 | + print "\n" . '<div class="tabsAction">' . "\n"; |
|
498 | 498 | |
499 | - if ($user->rights->produit->creer || $user->rights->service->creer) { |
|
500 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>'; |
|
501 | - } |
|
502 | - print "\n</div>\n"; |
|
499 | + if ($user->rights->produit->creer || $user->rights->service->creer) { |
|
500 | + print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>'; |
|
501 | + } |
|
502 | + print "\n</div>\n"; |
|
503 | 503 | |
504 | 504 | |
505 | 505 | // Count total nb of records |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | |
518 | 518 | $option = '&search_prod=' . $search_prod . '&id=' . $object->id; |
519 | 519 | |
520 | - print '<!-- view specific price for each product -->'."\n"; |
|
520 | + print '<!-- view specific price for each product -->'."\n"; |
|
521 | 521 | |
522 | - print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); |
|
522 | + print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); |
|
523 | 523 | |
524 | 524 | print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; |
525 | 525 | print '<input type="hidden" name="id" value="' . $object->id . '">'; |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | if (count($prodcustprice->lines) > 0 || $search_prod) |
543 | 543 | { |
544 | 544 | print '<tr class="liste_titre">'; |
545 | - print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>'; |
|
545 | + print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>'; |
|
546 | 546 | print '<td class="liste_titre" colspan="8"> </td>'; |
547 | 547 | // Print the search button |
548 | 548 | print '<td class="liste_titre" align="right">'; |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | print "</table>"; |
610 | 610 | |
611 | 611 | print "</form>"; |
612 | - } |
|
612 | + } |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | // End of page |
@@ -46,8 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | // Security check |
48 | 48 | $socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); |
49 | -if ($user->societe_id) |
|
49 | +if ($user->societe_id) { |
|
50 | 50 | $socid = $user->societe_id; |
51 | +} |
|
51 | 52 | $result = restrictedArea($user, 'societe', $socid, '&societe'); |
52 | 53 | |
53 | 54 | $object = new Societe($db); |
@@ -63,14 +64,18 @@ discard block |
||
63 | 64 | |
64 | 65 | $parameters=array('id'=>$socid); |
65 | 66 | $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
66 | -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
67 | +if ($reshook < 0) { |
|
68 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
69 | +} |
|
67 | 70 | |
68 | 71 | if (empty($reshook)) |
69 | 72 | { |
70 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers |
|
73 | + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) { |
|
74 | + // Both test are required to be compatible with all browsers |
|
71 | 75 | { |
72 | 76 | $search_prod = ''; |
73 | 77 | } |
78 | + } |
|
74 | 79 | |
75 | 80 | if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { |
76 | 81 | |
@@ -181,8 +186,9 @@ discard block |
||
181 | 186 | $result = $object->fetch($socid); |
182 | 187 | llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer')); |
183 | 188 | |
184 | -if (! empty($conf->notification->enabled)) |
|
189 | +if (! empty($conf->notification->enabled)) { |
|
185 | 190 | $langs->load("mails"); |
191 | +} |
|
186 | 192 | $head = societe_prepare_head($object); |
187 | 193 | |
188 | 194 | dol_fiche_head($head, 'price', $langs->trans("ThirdParty"), -1, 'company'); |
@@ -196,17 +202,20 @@ discard block |
||
196 | 202 | print '<div class="underbanner clearboth"></div>'; |
197 | 203 | print '<table class="border centpercent">'; |
198 | 204 | |
199 | -if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
205 | +if (! empty($conf->global->SOCIETE_USEPREFIX)) { |
|
206 | + // Old not used prefix field |
|
200 | 207 | { |
201 | 208 | print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; |
202 | 209 | } |
210 | +} |
|
203 | 211 | |
204 | 212 | if ($object->client) { |
205 | 213 | print '<tr><td class="titlefield">'; |
206 | 214 | print $langs->trans('CustomerCode') . '</td><td colspan="3">'; |
207 | 215 | print $object->code_client; |
208 | - if ($object->check_codeclient() != 0) |
|
209 | - print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
216 | + if ($object->check_codeclient() != 0) { |
|
217 | + print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
218 | + } |
|
210 | 219 | print '</td></tr>'; |
211 | 220 | } |
212 | 221 | |
@@ -214,8 +223,9 @@ discard block |
||
214 | 223 | print '<tr><td class="titlefield">'; |
215 | 224 | print $langs->trans('SupplierCode') . '</td><td colspan="3">'; |
216 | 225 | print $object->code_fournisseur; |
217 | - if ($object->check_codefournisseur() != 0) |
|
218 | - print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
226 | + if ($object->check_codefournisseur() != 0) { |
|
227 | + print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
228 | + } |
|
219 | 229 | print '</td></tr>'; |
220 | 230 | } |
221 | 231 | |
@@ -239,10 +249,12 @@ discard block |
||
239 | 249 | $offset = $limit * $page; |
240 | 250 | $pageprev = $page - 1; |
241 | 251 | $pagenext = $page + 1; |
242 | - if (! $sortorder) |
|
243 | - $sortorder = "ASC"; |
|
244 | - if (! $sortfield) |
|
245 | - $sortfield = "soc.nom"; |
|
252 | + if (! $sortorder) { |
|
253 | + $sortorder = "ASC"; |
|
254 | + } |
|
255 | + if (! $sortfield) { |
|
256 | + $sortfield = "soc.nom"; |
|
257 | + } |
|
246 | 258 | |
247 | 259 | // Build filter to diplay only concerned lines |
248 | 260 | $filter = array ( |
@@ -474,8 +486,7 @@ discard block |
||
474 | 486 | print '</td>'; |
475 | 487 | } |
476 | 488 | print "</table>"; |
477 | - } |
|
478 | - else |
|
489 | + } else |
|
479 | 490 | { |
480 | 491 | print $langs->trans('None'); |
481 | 492 | } |
@@ -483,8 +494,7 @@ discard block |
||
483 | 494 | print "\n" . '<div class="tabsAction">' . "\n"; |
484 | 495 | print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>'; |
485 | 496 | print "\n</div><br>\n"; |
486 | - } |
|
487 | - else |
|
497 | + } else |
|
488 | 498 | { |
489 | 499 | // View mode |
490 | 500 | |
@@ -598,11 +608,12 @@ discard block |
||
598 | 608 | |
599 | 609 | print "</tr>\n"; |
600 | 610 | } |
601 | - } |
|
602 | - else |
|
611 | + } else |
|
603 | 612 | { |
604 | 613 | $colspan=9; |
605 | - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1; |
|
614 | + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) { |
|
615 | + $colspan+=1; |
|
616 | + } |
|
606 | 617 | print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>'; |
607 | 618 | } |
608 | 619 |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | // Copyright (C) 2018 Alxarafe/Alixar <[email protected]> |
31 | 31 | defined('BASE_PATH') or die('Single entry point through the index.php of the main folder'); |
32 | -require DOL_BASE_PATH . '/main.inc.php'; |
|
32 | +require DOL_BASE_PATH.'/main.inc.php'; |
|
33 | 33 | |
34 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/product.lib.php'; |
|
35 | -require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; |
|
36 | -require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; |
|
37 | -require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; |
|
34 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; |
|
35 | +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
36 | +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
37 | +require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; |
|
38 | 38 | |
39 | -if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
|
40 | - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; |
|
39 | +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
|
40 | + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; |
|
41 | 41 | |
42 | 42 | $prodcustprice = new Productcustomerprice($db); |
43 | 43 | } |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | $langs->loadLangs(array("products", "companies", "bills")); |
46 | 46 | |
47 | 47 | $action = GETPOST('action', 'alpha'); |
48 | -$search_prod = GETPOST('search_prod','alpha'); |
|
49 | -$cancel = GETPOST('cancel','alpha'); |
|
48 | +$search_prod = GETPOST('search_prod', 'alpha'); |
|
49 | +$cancel = GETPOST('cancel', 'alpha'); |
|
50 | 50 | |
51 | 51 | // Security check |
52 | -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); |
|
52 | +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); |
|
53 | 53 | if ($user->societe_id) |
54 | 54 | $socid = $user->societe_id; |
55 | 55 | $result = restrictedArea($user, 'societe', $socid, '&societe'); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $object = new Societe($db); |
58 | 58 | |
59 | 59 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
60 | -$hookmanager->initHooks(array('thirdpartycustomerprice','globalcard')); |
|
60 | +$hookmanager->initHooks(array('thirdpartycustomerprice', 'globalcard')); |
|
61 | 61 | |
62 | 62 | |
63 | 63 | |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | * Actions |
66 | 66 | */ |
67 | 67 | |
68 | -$parameters=array('id'=>$socid); |
|
69 | -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
68 | +$parameters = array('id'=>$socid); |
|
69 | +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
|
70 | 70 | if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
71 | 71 | |
72 | 72 | if (empty($reshook)) |
73 | 73 | { |
74 | - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers |
|
74 | + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers |
|
75 | 75 | { |
76 | 76 | $search_prod = ''; |
77 | 77 | } |
78 | 78 | |
79 | - if ($action == 'add_customer_price_confirm' && ! $cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { |
|
79 | + if ($action == 'add_customer_price_confirm' && !$cancel && ($user->rights->produit->creer || $user->rights->service->creer)) { |
|
80 | 80 | |
81 | 81 | $update_child_soc = GETPOST('updatechildprice'); |
82 | 82 | |
@@ -87,25 +87,25 @@ discard block |
||
87 | 87 | $prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU'); |
88 | 88 | $prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha'); |
89 | 89 | |
90 | - $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
90 | + $tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)' |
|
91 | 91 | |
92 | 92 | // We must define tva_tx, npr and local taxes |
93 | 93 | $vatratecode = ''; |
94 | - $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
94 | + $tva_tx = preg_replace('/[^0-9\.].*$/', '', $tva_tx_txt); // keep remove all after the numbers and dot |
|
95 | 95 | $npr = preg_match('/\*/', $tva_tx_txt) ? 1 : 0; |
96 | 96 | $localtax1 = 0; $localtax2 = 0; $localtax1_type = '0'; $localtax2_type = '0'; |
97 | 97 | // If value contains the unique code of vat line (new recommanded method), we use it to find npr and local taxes |
98 | 98 | if (preg_match('/\((.*)\)/', $tva_tx_txt, $reg)) |
99 | 99 | { |
100 | 100 | // We look into database using code (we can't use get_localtax() because it depends on buyer that is not known). Same in update price. |
101 | - $vatratecode=$reg[1]; |
|
101 | + $vatratecode = $reg[1]; |
|
102 | 102 | // Get record from code |
103 | 103 | $sql = "SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; |
104 | - $sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
105 | - $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
106 | - $sql.= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
107 | - $sql.= " AND t.code ='".$vatratecode."'"; |
|
108 | - $resql=$db->query($sql); |
|
104 | + $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c"; |
|
105 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$mysoc->country_code."'"; |
|
106 | + $sql .= " AND t.taux = ".((float) $tva_tx)." AND t.active = 1"; |
|
107 | + $sql .= " AND t.code ='".$vatratecode."'"; |
|
108 | + $resql = $db->query($sql); |
|
109 | 109 | if ($resql) |
110 | 110 | { |
111 | 111 | $obj = $db->fetch_object($resql); |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $action = ''; |
150 | 150 | } |
151 | 151 | |
152 | - if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { |
|
152 | + if ($action == 'update_customer_price_confirm' && !$_POST ["cancel"] && ($user->rights->produit->creer || $user->rights->service->creer)) { |
|
153 | 153 | |
154 | 154 | $prodcustprice->fetch(GETPOST('lineid', 'int')); |
155 | 155 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | $object = new Societe($db); |
184 | 184 | |
185 | 185 | $result = $object->fetch($socid); |
186 | -llxHeader("", $langs->trans("ThirdParty") . '-' . $langs->trans('PriceByCustomer')); |
|
186 | +llxHeader("", $langs->trans("ThirdParty").'-'.$langs->trans('PriceByCustomer')); |
|
187 | 187 | |
188 | -if (! empty($conf->notification->enabled)) |
|
188 | +if (!empty($conf->notification->enabled)) |
|
189 | 189 | $langs->load("mails"); |
190 | 190 | $head = societe_prepare_head($object); |
191 | 191 | |
@@ -193,33 +193,33 @@ discard block |
||
193 | 193 | |
194 | 194 | $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php">'.$langs->trans("BackToList").'</a>'; |
195 | 195 | |
196 | -dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); |
|
196 | +dol_banner_tab($object, 'socid', $linkback, ($user->societe_id ? 0 : 1), 'rowid', 'nom'); |
|
197 | 197 | |
198 | 198 | print '<div class="fichecenter">'; |
199 | 199 | |
200 | 200 | print '<div class="underbanner clearboth"></div>'; |
201 | 201 | print '<table class="border centpercent">'; |
202 | 202 | |
203 | -if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
203 | +if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field |
|
204 | 204 | { |
205 | - print '<tr><td class="titlefield">' . $langs->trans('Prefix') . '</td><td colspan="3">' . $object->prefix_comm . '</td></tr>'; |
|
205 | + print '<tr><td class="titlefield">'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>'; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | if ($object->client) { |
209 | 209 | print '<tr><td class="titlefield">'; |
210 | - print $langs->trans('CustomerCode') . '</td><td colspan="3">'; |
|
210 | + print $langs->trans('CustomerCode').'</td><td colspan="3">'; |
|
211 | 211 | print $object->code_client; |
212 | 212 | if ($object->check_codeclient() != 0) |
213 | - print ' <font class="error">(' . $langs->trans("WrongCustomerCode") . ')</font>'; |
|
213 | + print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; |
|
214 | 214 | print '</td></tr>'; |
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($object->fournisseur) { |
218 | 218 | print '<tr><td class="titlefield">'; |
219 | - print $langs->trans('SupplierCode') . '</td><td colspan="3">'; |
|
219 | + print $langs->trans('SupplierCode').'</td><td colspan="3">'; |
|
220 | 220 | print $object->code_fournisseur; |
221 | 221 | if ($object->check_codefournisseur() != 0) |
222 | - print ' <font class="error">(' . $langs->trans("WrongSupplierCode") . ')</font>'; |
|
222 | + print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; |
|
223 | 223 | print '</td></tr>'; |
224 | 224 | } |
225 | 225 | |
@@ -231,29 +231,29 @@ discard block |
||
231 | 231 | |
232 | 232 | |
233 | 233 | |
234 | -if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
|
234 | +if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { |
|
235 | 235 | |
236 | 236 | $prodcustprice = new Productcustomerprice($db); |
237 | 237 | |
238 | 238 | $sortfield = GETPOST("sortfield", 'alpha'); |
239 | 239 | $sortorder = GETPOST("sortorder", 'alpha'); |
240 | - $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; |
|
240 | + $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; |
|
241 | 241 | $page = GETPOST("page", 'int'); |
242 | 242 | if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 |
243 | 243 | $offset = $limit * $page; |
244 | 244 | $pageprev = $page - 1; |
245 | 245 | $pagenext = $page + 1; |
246 | - if (! $sortorder) |
|
246 | + if (!$sortorder) |
|
247 | 247 | $sortorder = "ASC"; |
248 | - if (! $sortfield) |
|
248 | + if (!$sortfield) |
|
249 | 249 | $sortfield = "soc.nom"; |
250 | 250 | |
251 | 251 | // Build filter to diplay only concerned lines |
252 | - $filter = array ( |
|
252 | + $filter = array( |
|
253 | 253 | 't.fk_soc' => $object->id |
254 | 254 | ); |
255 | 255 | |
256 | - if (! empty($search_prod)) { |
|
256 | + if (!empty($search_prod)) { |
|
257 | 257 | $filter ['prod.ref'] = $search_prod; |
258 | 258 | } |
259 | 259 | |
@@ -263,20 +263,20 @@ discard block |
||
263 | 263 | |
264 | 264 | print load_fiche_titre($langs->trans('PriceByCustomer')); |
265 | 265 | |
266 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
|
267 | - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
266 | + print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">'; |
|
267 | + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; |
|
268 | 268 | print '<input type="hidden" name="action" value="add_customer_price_confirm">'; |
269 | - print '<input type="hidden" name="socid" value="' . $object->id . '">'; |
|
269 | + print '<input type="hidden" name="socid" value="'.$object->id.'">'; |
|
270 | 270 | print '<table class="border" width="100%">'; |
271 | 271 | print '<tr>'; |
272 | - print '<td>' . $langs->trans('Product') . '</td>'; |
|
272 | + print '<td>'.$langs->trans('Product').'</td>'; |
|
273 | 273 | print '<td>'; |
274 | 274 | print $form->select_produits('', 'prodid', '', 0); |
275 | 275 | print '</td>'; |
276 | 276 | print '</tr>'; |
277 | 277 | |
278 | 278 | // VAT |
279 | - print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; |
|
279 | + print '<tr><td>'.$langs->trans("VATRate").'</td><td>'; |
|
280 | 280 | print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr, '', false, 1); |
281 | 281 | print '</td></tr>'; |
282 | 282 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
296 | 296 | print '</td><td>'; |
297 | 297 | if ($object->price_base_type == 'TTC') { |
298 | - print '<input name="price" size="10" value="' . price($object->price_ttc) . '">'; |
|
298 | + print '<input name="price" size="10" value="'.price($object->price_ttc).'">'; |
|
299 | 299 | } else { |
300 | - print '<input name="price" size="10" value="' . price($object->price) . '">'; |
|
300 | + print '<input name="price" size="10" value="'.price($object->price).'">'; |
|
301 | 301 | } |
302 | 302 | print '</td></tr>'; |
303 | 303 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | $text = $langs->trans('MinPrice'); |
307 | 307 | print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
308 | 308 | if ($object->price_base_type == 'TTC') { |
309 | - print '<td><input name="price_min" size="10" value="' . price($object->price_min_ttc) . '">'; |
|
309 | + print '<td><input name="price_min" size="10" value="'.price($object->price_min_ttc).'">'; |
|
310 | 310 | } else { |
311 | - print '<td><input name="price_min" size="10" value="' . price($object->price_min) . '">'; |
|
311 | + print '<td><input name="price_min" size="10" value="'.price($object->price_min).'">'; |
|
312 | 312 | } |
313 | 313 | print '</td></tr>'; |
314 | 314 | |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | print '</table>'; |
325 | 325 | |
326 | 326 | print '<br><div align="center">'; |
327 | - print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; |
|
327 | + print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; |
|
328 | 328 | print ' '; |
329 | - print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
329 | + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
330 | 330 | print '</div>'; |
331 | 331 | |
332 | 332 | print '<br></form>'; |
@@ -342,20 +342,20 @@ discard block |
||
342 | 342 | setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
343 | 343 | } |
344 | 344 | |
345 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">'; |
|
346 | - print '<input type="hidden" name="token" value="' . $_SESSION ['newtoken'] . '">'; |
|
345 | + print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">'; |
|
346 | + print '<input type="hidden" name="token" value="'.$_SESSION ['newtoken'].'">'; |
|
347 | 347 | print '<input type="hidden" name="action" value="update_customer_price_confirm">'; |
348 | - print '<input type="hidden" name="lineid" value="' . $prodcustprice->id . '">'; |
|
348 | + print '<input type="hidden" name="lineid" value="'.$prodcustprice->id.'">'; |
|
349 | 349 | print '<table class="border" width="100%">'; |
350 | 350 | print '<tr>'; |
351 | - print '<td>' . $langs->trans('Product') . '</td>'; |
|
351 | + print '<td>'.$langs->trans('Product').'</td>'; |
|
352 | 352 | $staticprod = new Product($db); |
353 | 353 | $staticprod->fetch($prodcustprice->fk_product); |
354 | - print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
354 | + print "<td>".$staticprod->getNomUrl(1)."</td>"; |
|
355 | 355 | print '</tr>'; |
356 | 356 | |
357 | 357 | // VAT |
358 | - print '<tr><td>' . $langs->trans("VATRate") . '</td><td>'; |
|
358 | + print '<tr><td>'.$langs->trans("VATRate").'</td><td>'; |
|
359 | 359 | print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, '', $staticprod->id, $prodcustprice->recuperableonly); |
360 | 360 | print '</td></tr>'; |
361 | 361 | |
@@ -374,9 +374,9 @@ discard block |
||
374 | 374 | print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
375 | 375 | print '</td><td>'; |
376 | 376 | if ($prodcustprice->price_base_type == 'TTC') { |
377 | - print '<input name="price" size="10" value="' . price($prodcustprice->price_ttc) . '">'; |
|
377 | + print '<input name="price" size="10" value="'.price($prodcustprice->price_ttc).'">'; |
|
378 | 378 | } else { |
379 | - print '<input name="price" size="10" value="' . price($prodcustprice->price) . '">'; |
|
379 | + print '<input name="price" size="10" value="'.price($prodcustprice->price).'">'; |
|
380 | 380 | } |
381 | 381 | print '</td></tr>'; |
382 | 382 | |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); |
387 | 387 | print '</td><td>'; |
388 | 388 | if ($prodcustprice->price_base_type == 'TTC') { |
389 | - print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min_ttc) . '">'; |
|
389 | + print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min_ttc).'">'; |
|
390 | 390 | } else { |
391 | - print '<input name="price_min" size="10" value="' . price($prodcustprice->price_min) . '">'; |
|
391 | + print '<input name="price_min" size="10" value="'.price($prodcustprice->price_min).'">'; |
|
392 | 392 | } |
393 | 393 | print '</td></tr>'; |
394 | 394 | |
@@ -404,9 +404,9 @@ discard block |
||
404 | 404 | print '</table>'; |
405 | 405 | |
406 | 406 | print '<br><div class="center">'; |
407 | - print '<input type="submit" class="button" value="' . $langs->trans("Save") . '">'; |
|
407 | + print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; |
|
408 | 408 | print ' '; |
409 | - print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; |
|
409 | + print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; |
|
410 | 410 | print '</div>'; |
411 | 411 | |
412 | 412 | print '<br></form>'; |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | |
415 | 415 | print '<!-- showlog_customer_price -->'."\n"; |
416 | 416 | |
417 | - $filter = array ( |
|
418 | - 't.fk_product' => GETPOST('prodid', 'int'),'t.fk_soc' => $socid |
|
417 | + $filter = array( |
|
418 | + 't.fk_product' => GETPOST('prodid', 'int'), 't.fk_soc' => $socid |
|
419 | 419 | ); |
420 | 420 | |
421 | 421 | // Count total nb of records |
@@ -430,45 +430,45 @@ discard block |
||
430 | 430 | setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
431 | 431 | } |
432 | 432 | |
433 | - $option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int'); |
|
433 | + $option = '&socid='.GETPOST('socid', 'int').'&prodid='.GETPOST('prodid', 'int'); |
|
434 | 434 | |
435 | 435 | print_barre_liste($langs->trans('PriceByCustomerLog'), $page, $_SERVEUR ['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords); |
436 | 436 | |
437 | 437 | if (count($prodcustprice->lines) > 0) { |
438 | 438 | |
439 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; |
|
440 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; |
|
439 | + print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; |
|
440 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
441 | 441 | |
442 | 442 | print '<table class="noborder" width="100%">'; |
443 | 443 | |
444 | 444 | print '<tr class="liste_titre">'; |
445 | - print '<td>' . $langs->trans("Product") . '</td>'; |
|
446 | - print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>'; |
|
447 | - print '<td align="center">' . $langs->trans("PriceBase") . '</td>'; |
|
448 | - print '<td align="right">' . $langs->trans("VAT") . '</td>'; |
|
449 | - print '<td align="right">' . $langs->trans("HT") . '</td>'; |
|
450 | - print '<td align="right">' . $langs->trans("TTC") . '</td>'; |
|
451 | - print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>'; |
|
452 | - print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>'; |
|
453 | - print '<td align="right">' . $langs->trans("ChangedBy") . '</td>'; |
|
445 | + print '<td>'.$langs->trans("Product").'</td>'; |
|
446 | + print '<td>'.$langs->trans("AppliedPricesFrom").'</td>'; |
|
447 | + print '<td align="center">'.$langs->trans("PriceBase").'</td>'; |
|
448 | + print '<td align="right">'.$langs->trans("VAT").'</td>'; |
|
449 | + print '<td align="right">'.$langs->trans("HT").'</td>'; |
|
450 | + print '<td align="right">'.$langs->trans("TTC").'</td>'; |
|
451 | + print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>'; |
|
452 | + print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>'; |
|
453 | + print '<td align="right">'.$langs->trans("ChangedBy").'</td>'; |
|
454 | 454 | print '<td> </td>'; |
455 | 455 | print '</tr>'; |
456 | 456 | |
457 | - foreach ( $prodcustprice->lines as $line ) { |
|
457 | + foreach ($prodcustprice->lines as $line) { |
|
458 | 458 | |
459 | 459 | print '<tr class="oddeven">'; |
460 | 460 | $staticprod = new Product($db); |
461 | 461 | $staticprod->fetch($line->fk_product); |
462 | 462 | |
463 | - print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
464 | - print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>"; |
|
463 | + print "<td>".$staticprod->getNomUrl(1)."</td>"; |
|
464 | + print "<td>".dol_print_date($line->datec, "dayhour")."</td>"; |
|
465 | 465 | |
466 | - print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>"; |
|
467 | - print '<td align="right">' . vatrate($line->tva_tx, true, $line->recuperableonly) . "</td>"; |
|
468 | - print '<td align="right">' . price($line->price) . "</td>"; |
|
469 | - print '<td align="right">' . price($line->price_ttc) . "</td>"; |
|
470 | - print '<td align="right">' . price($line->price_min) . '</td>'; |
|
471 | - print '<td align="right">' . price($line->price_min_ttc) . '</td>'; |
|
466 | + print '<td align="center">'.$langs->trans($line->price_base_type)."</td>"; |
|
467 | + print '<td align="right">'.vatrate($line->tva_tx, true, $line->recuperableonly)."</td>"; |
|
468 | + print '<td align="right">'.price($line->price)."</td>"; |
|
469 | + print '<td align="right">'.price($line->price_ttc)."</td>"; |
|
470 | + print '<td align="right">'.price($line->price_min).'</td>'; |
|
471 | + print '<td align="right">'.price($line->price_min_ttc).'</td>'; |
|
472 | 472 | |
473 | 473 | // User |
474 | 474 | $userstatic = new User($db); |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | print $langs->trans('None'); |
485 | 485 | } |
486 | 486 | |
487 | - print "\n" . '<div class="tabsAction">' . "\n"; |
|
488 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '">' . $langs->trans("Ok") . '</a></div>'; |
|
487 | + print "\n".'<div class="tabsAction">'."\n"; |
|
488 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">'.$langs->trans("Ok").'</a></div>'; |
|
489 | 489 | print "\n</div><br>\n"; |
490 | 490 | } |
491 | 491 | else |
@@ -498,10 +498,10 @@ discard block |
||
498 | 498 | /* */ |
499 | 499 | /* ************************************************************************** */ |
500 | 500 | |
501 | - print "\n" . '<div class="tabsAction">' . "\n"; |
|
501 | + print "\n".'<div class="tabsAction">'."\n"; |
|
502 | 502 | |
503 | 503 | if ($user->rights->produit->creer || $user->rights->service->creer) { |
504 | - print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=add_customer_price&socid=' . $object->id . '">' . $langs->trans("AddCustomerPrice") . '</a></div>'; |
|
504 | + print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=add_customer_price&socid='.$object->id.'">'.$langs->trans("AddCustomerPrice").'</a></div>'; |
|
505 | 505 | } |
506 | 506 | print "\n</div>\n"; |
507 | 507 | |
@@ -519,38 +519,38 @@ discard block |
||
519 | 519 | setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); |
520 | 520 | } |
521 | 521 | |
522 | - $option = '&search_prod=' . $search_prod . '&id=' . $object->id; |
|
522 | + $option = '&search_prod='.$search_prod.'&id='.$object->id; |
|
523 | 523 | |
524 | 524 | print '<!-- view specific price for each product -->'."\n"; |
525 | 525 | |
526 | 526 | print_barre_liste($langs->trans('PriceForEachProduct'), $page, $_SERVEUR['PHP_SELF'], $option, $sortfield, $sortorder, '', count($prodcustprice->lines), $nbtotalofrecords, ''); |
527 | 527 | |
528 | - print '<form action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '" method="POST">'; |
|
529 | - print '<input type="hidden" name="id" value="' . $object->id . '">'; |
|
528 | + print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">'; |
|
529 | + print '<input type="hidden" name="id" value="'.$object->id.'">'; |
|
530 | 530 | |
531 | 531 | print '<table class="noborder" width="100%">'; |
532 | 532 | |
533 | 533 | print '<tr class="liste_titre">'; |
534 | - print '<td>' . $langs->trans("Product") . '</td>'; |
|
535 | - print '<td>' . $langs->trans("AppliedPricesFrom") . '</td>'; |
|
536 | - print '<td align="center">' . $langs->trans("PriceBase") . '</td>'; |
|
537 | - print '<td align="right">' . $langs->trans("VAT") . '</td>'; |
|
538 | - print '<td align="right">' . $langs->trans("HT") . '</td>'; |
|
539 | - print '<td align="right">' . $langs->trans("TTC") . '</td>'; |
|
540 | - print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("HT") . '</td>'; |
|
541 | - print '<td align="right">' . $langs->trans("MinPrice") . ' ' . $langs->trans("TTC") . '</td>'; |
|
542 | - print '<td align="right">' . $langs->trans("ChangedBy") . '</td>'; |
|
534 | + print '<td>'.$langs->trans("Product").'</td>'; |
|
535 | + print '<td>'.$langs->trans("AppliedPricesFrom").'</td>'; |
|
536 | + print '<td align="center">'.$langs->trans("PriceBase").'</td>'; |
|
537 | + print '<td align="right">'.$langs->trans("VAT").'</td>'; |
|
538 | + print '<td align="right">'.$langs->trans("HT").'</td>'; |
|
539 | + print '<td align="right">'.$langs->trans("TTC").'</td>'; |
|
540 | + print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>'; |
|
541 | + print '<td align="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>'; |
|
542 | + print '<td align="right">'.$langs->trans("ChangedBy").'</td>'; |
|
543 | 543 | print '<td> </td>'; |
544 | 544 | print '</tr>'; |
545 | 545 | |
546 | 546 | if (count($prodcustprice->lines) > 0 || $search_prod) |
547 | 547 | { |
548 | 548 | print '<tr class="liste_titre">'; |
549 | - print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="' . $search_prod . '" size="20"></td>'; |
|
549 | + print '<td class="liste_titre"><input type="text" class="flat" name="search_prod" value="'.$search_prod.'" size="20"></td>'; |
|
550 | 550 | print '<td class="liste_titre" colspan="8"> </td>'; |
551 | 551 | // Print the search button |
552 | 552 | print '<td class="liste_titre" align="right">'; |
553 | - $searchpicto=$form->showFilterAndCheckAddButtons(0); |
|
553 | + $searchpicto = $form->showFilterAndCheckAddButtons(0); |
|
554 | 554 | print $searchpicto; |
555 | 555 | print '</td>'; |
556 | 556 | print '</tr>'; |
@@ -565,15 +565,15 @@ discard block |
||
565 | 565 | $staticprod = new Product($db); |
566 | 566 | $staticprod->fetch($line->fk_product); |
567 | 567 | |
568 | - print "<td>" . $staticprod->getNomUrl(1) . "</td>"; |
|
569 | - print "<td>" . dol_print_date($line->datec, "dayhour") . "</td>"; |
|
568 | + print "<td>".$staticprod->getNomUrl(1)."</td>"; |
|
569 | + print "<td>".dol_print_date($line->datec, "dayhour")."</td>"; |
|
570 | 570 | |
571 | - print '<td align="center">' . $langs->trans($line->price_base_type) . "</td>"; |
|
572 | - print '<td align="right">' . vatrate($line->tva_tx.($line->default_vat_code?' ('.$line->default_vat_code.')':''), true, $line->recuperableonly) . "</td>"; |
|
573 | - print '<td align="right">' . price($line->price) . "</td>"; |
|
574 | - print '<td align="right">' . price($line->price_ttc) . "</td>"; |
|
575 | - print '<td align="right">' . price($line->price_min) . '</td>'; |
|
576 | - print '<td align="right">' . price($line->price_min_ttc) . '</td>'; |
|
571 | + print '<td align="center">'.$langs->trans($line->price_base_type)."</td>"; |
|
572 | + print '<td align="right">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>"; |
|
573 | + print '<td align="right">'.price($line->price)."</td>"; |
|
574 | + print '<td align="right">'.price($line->price_ttc)."</td>"; |
|
575 | + print '<td align="right">'.price($line->price_min).'</td>'; |
|
576 | + print '<td align="right">'.price($line->price_min_ttc).'</td>'; |
|
577 | 577 | |
578 | 578 | // User |
579 | 579 | $userstatic = new User($db); |
@@ -586,15 +586,15 @@ discard block |
||
586 | 586 | if ($user->rights->produit->creer || $user->rights->service->creer) |
587 | 587 | { |
588 | 588 | print '<td align="right">'; |
589 | - print '<a href="' . $_SERVER["PHP_SELF"] . '?action=showlog_customer_price&socid=' . $object->id . '&prodid=' . $line->fk_product . '">'; |
|
589 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=showlog_customer_price&socid='.$object->id.'&prodid='.$line->fk_product.'">'; |
|
590 | 590 | print img_info(); |
591 | 591 | print '</a>'; |
592 | 592 | print ' '; |
593 | - print '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit_customer_price&socid=' . $object->id . '&lineid=' . $line->id . '">'; |
|
593 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=edit_customer_price&socid='.$object->id.'&lineid='.$line->id.'">'; |
|
594 | 594 | print img_edit('default', 0, 'style="vertical-align: middle;"'); |
595 | 595 | print '</a>'; |
596 | 596 | print ' '; |
597 | - print '<a href="' . $_SERVER["PHP_SELF"] . '?action=delete_customer_price&socid=' . $object->id . '&lineid=' . $line->id . '">'; |
|
597 | + print '<a href="'.$_SERVER["PHP_SELF"].'?action=delete_customer_price&socid='.$object->id.'&lineid='.$line->id.'">'; |
|
598 | 598 | print img_delete('default', 'style="vertical-align: middle;"'); |
599 | 599 | print '</a>'; |
600 | 600 | print '</td>'; |
@@ -605,9 +605,9 @@ discard block |
||
605 | 605 | } |
606 | 606 | else |
607 | 607 | { |
608 | - $colspan=9; |
|
609 | - if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan+=1; |
|
610 | - print '<tr ' . $bc[false] . '><td colspan="'.$colspan.'">' . $langs->trans('None') . '</td></tr>'; |
|
608 | + $colspan = 9; |
|
609 | + if ($user->rights->produit->supprimer || $user->rights->service->supprimer) $colspan += 1; |
|
610 | + print '<tr '.$bc[false].'><td colspan="'.$colspan.'">'.$langs->trans('None').'</td></tr>'; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | print "</table>"; |