dolibarr 21.0.3
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Brian Fraval <brian@fraval.org>
4 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
6 * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2008 Patrick Raguin <patrick.raguin@auguria.net>
8 * Copyright (C) 2010-2020 Juanjo Menent <jmenent@2byte.es>
9 * Copyright (C) 2011-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
10 * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
11 * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
12 * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
13 * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
14 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es.com>
15 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
16 * Copyright (C) 2022-2023 George Gkantinas <info@geowv.eu>
17 * Copyright (C) 2023 Nick Fragoulis
18 * Copyright (C) 2023 Alexandre Janniaux <alexandre.janniaux@gmail.com>
19 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
20 * Copyright (C) 2024 Charlene Benke <charlene@patas-monkey.com>
21 *
22 * This program is free software; you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation; either version 3 of the License, or
25 * (at your option) any later version.
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program. If not, see <https://www.gnu.org/licenses/>.
34 */
35
43// Load Dolibarr environment
44require '../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
47require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
50require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
52require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
53require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
54require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
55if (isModEnabled('member')) {
56 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
57}
58if (isModEnabled('accounting')) {
59 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
60}
61if (isModEnabled('accounting')) {
62 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
63}
64if (isModEnabled('accounting')) {
65 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
66}
67if (isModEnabled('eventorganization')) {
68 require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php';
69}
79$u = '';
80$p = '';
81$myafm = '';
82
83if ($mysoc->country_code == 'GR') {
84 $u = getDolGlobalString('AADE_WEBSERVICE_USER');
85 $p = getDolGlobalString('AADE_WEBSERVICE_KEY');
86 $myafm = preg_replace('/\D/', '', getDolGlobalString('MAIN_INFO_TVAINTRA'));
87}
88
89
90// Load translation files required by the page
91
92$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
93
94if (isModEnabled('member')) {
95 $langs->load("members");
96}
97if (isModEnabled('category')) {
98 $langs->load("categories");
99}
100if (isModEnabled('incoterm')) {
101 $langs->load("incoterm");
102}
103if (isModEnabled('notification')) {
104 $langs->load("mails");
105}
106if (isModEnabled('accounting')) {
107 $langs->load("products");
108}
109
110$error = 0;
111$errors = array();
112
113
114// Get parameters
115$action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view');
116$cancel = GETPOST('cancel', 'alpha');
117$backtopage = GETPOST('backtopage', 'alpha');
118$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
119$backtopagejsfields = GETPOST('backtopagejsfields', 'alpha');
120$confirm = GETPOST('confirm', 'alpha');
121$canvas = GETPOST('canvas', 'alpha');
122
123$dol_openinpopup = '';
124if (!empty($backtopagejsfields)) {
125 $tmpbacktopagejsfields = explode(':', $backtopagejsfields);
126 $dol_openinpopup = preg_replace('/[^a-z0-9_]/i', '', $tmpbacktopagejsfields[0]);
127}
128
129$socid = GETPOSTINT('socid') ? GETPOSTINT('socid') : GETPOSTINT('id');
130if ($user->socid) {
131 if (in_array($action, ['add', 'create', 'merge', 'confirm_merge', 'delete', 'confirm_delete'])) {
133 }
134
135 $socid = $user->socid;
136}
137if (empty($socid) && $action == 'view') {
138 $action = 'create';
139}
140
141$id = $socid;
142
143$object = new Societe($db);
144$extrafields = new ExtraFields($db);
145
146// fetch optionals attributes and labels
147$extrafields->fetch_name_optionals_label($object->table_element);
148
149$socialnetworks = getArrayOfSocialNetworks();
150
151// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
152$hookmanager->initHooks(array('thirdpartycard', 'globalcard'));
153
154if ($socid > 0) {
155 $object->fetch($socid);
156}
157
158// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
159$canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
160$objcanvas = null;
161if (!empty($canvas)) {
162 require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
163 $objcanvas = new Canvas($db, $action);
164 $objcanvas->getCanvas('thirdparty', 'card', $canvas);
165}
166
167// Permissions
168$permissiontoread = $user->hasRight('societe', 'lire');
169$permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
170$permissiontodelete = $user->hasRight('societe', 'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0);
171$permissionnote = $user->hasRight('societe', 'creer'); // Used by the include of actions_setnotes.inc.php
172$permissiondellink = $user->hasRight('societe', 'creer'); // Used by the include of actions_dellink.inc.php
173$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
174
175// Security check
176$result = restrictedArea($user, 'societe', $object->id, '&societe', '', 'fk_soc', 'rowid', 0);
177
178if (!($object->id > 0) && $action == 'view') {
180}
181
182
183/*
184 * Actions
185 */
186
187$parameters = array('id' => $socid, 'objcanvas' => $objcanvas);
188$current_logo = '';
189$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
190if ($reshook < 0) {
191 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
192}
193
194if (empty($reshook)) {
195 $backurlforlist = DOL_URL_ROOT.'/societe/list.php';
196
197 if (empty($backtopage) || ($cancel && empty($id))) {
198 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
199 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
200 $backtopage = $backurlforlist;
201 } else {
202 $backtopage = DOL_URL_ROOT.'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__') . (!empty($canvas) ? "&canvas=" . $canvas : "");
203 }
204 }
205 }
206
207 if ($cancel) {
208 if (!empty($backtopageforcancel)) {
209 header("Location: ".$backtopageforcancel);
210 exit;
211 } elseif (!empty($backtopage)) {
212 header("Location: ".$backtopage);
213 exit;
214 }
215 $action = '';
216 }
217
218 if ($action == 'confirm_merge' && $confirm == 'yes' && $permissiontoadd) {
219 $soc_origin_id = GETPOSTINT('soc_origin');
220 $soc_origin = new Societe($db); // The thirdparty that we will delete
221
222 if ($soc_origin_id <= 0) {
223 $langs->load('errors');
224 setEventMessages($langs->trans('ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv('MergeOriginThirdparty')), null, 'errors');
225 } else {
226 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
227 setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
228 $error++;
229 }
230 if (!$error) {
231 $result = $object->mergeCompany($soc_origin_id);
232 if ($result < 0) {
233 $error++;
234 setEventMessages($object->error, $object->errors, 'errors');
235 } else {
236 setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs');
237 }
238 }
239 }
240 }
241
242 if (GETPOST('getcustomercode')) {
243 // We defined value code_client
244 $_POST["customer_code"] = "Acompleter";
245 }
246
247 if (GETPOST('getsuppliercode')) {
248 // We defined value code_fournisseur
249 $_POST["supplier_code"] = "Acompleter";
250 }
251
252 if ($action == 'set_localtax1' && $permissiontoadd) {
253 //get selected from combobox
254 $value = GETPOST('lt1');
255 $object->fetch($socid);
256 $res = $object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
257 }
258 if ($action == 'set_localtax2' && $permissiontoadd) {
259 //get selected from combobox
260 $value = GETPOST('lt2');
261 $object->fetch($socid);
262 $res = $object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
263 }
264
265 if ($action == 'update_extras' && $permissiontoadd) {
266 $object->fetch($socid);
267
268 $object->oldcopy = dol_clone($object, 2);
269
270 // Fill array 'array_options' with data from update form
271 $extrafields->fetch_name_optionals_label($object->table_element);
272
273 $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
274 if ($ret < 0) {
275 $error++;
276 }
277
278 if (!$error) {
279 $result = $object->insertExtraFields('COMPANY_MODIFY');
280 if ($result < 0) {
281 setEventMessages($object->error, $object->errors, 'errors');
282 $error++;
283 }
284 }
285
286 if ($error) {
287 $action = 'edit_extras';
288 }
289 }
290
291 // Add new or update third party
292 if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode')) && ($action == 'add' || $action == 'update') && $permissiontoadd) {
293 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
294
295 if (!GETPOST('name')) {
296 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors');
297 $error++;
298 }
299 if (GETPOSTINT('customer') && GETPOSTINT('customer') < 0) {
300 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), null, 'errors');
301 $error++;
302 }
303 if (GETPOSTINT('prospect') && GETPOSTINT('prospect') < 0) {
304 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Prospect")), null, 'errors');
305 $error++;
306 }
307 if (GETPOSTISSET('supplier') && GETPOSTINT('supplier') < 0) {
308 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors');
309 $error++;
310 }
311
312 if (isModEnabled('mailing') && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 && GETPOSTINT('contact_no_email') == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
313 $error++;
314 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors');
315 }
316
317 if (isModEnabled('mailing') && GETPOSTINT("private") == 1 && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 && GETPOSTINT('contact_no_email') == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) {
318 $error++;
319 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")), null, 'errors');
320 }
321
322 if (!$error) {
323 if ($action == 'update') { // Test on permission not required here
324 $ret = $object->fetch($socid);
325 $object->oldcopy = clone $object;
326 } else {
327 $object->canvas = $canvas;
328 }
329
330 if (GETPOSTINT("private") == 1) { // Ask to create a contact
331 $object->particulier = GETPOSTINT("private");
332
333 $object->name = dolGetFirstLastname(GETPOST('firstname', 'alphanohtml'), GETPOST('name', 'alphanohtml'));
334 $object->civility_id = GETPOST('civility_id', 'alphanohtml'); // Note: civility id is a code, not an int
335 // Add non official properties
336 $object->name_bis = GETPOST('name', 'alphanohtml');
337 $object->firstname = GETPOST('firstname', 'alphanohtml');
338 } else {
339 $object->name = GETPOST('name', 'alphanohtml');
340 }
341 $object->entity = ((GETPOSTISSET('entity') && GETPOST('entity') != '') ? GETPOSTINT('entity') : $conf->entity);
342 $object->name_alias = GETPOST('name_alias', 'alphanohtml');
343 $object->parent = GETPOSTISSET('parent_company_id') ? GETPOSTINT('parent_company_id') : $object->parent;
344 $object->address = GETPOST('address', 'alphanohtml');
345 $object->zip = GETPOST('zipcode', 'alphanohtml');
346 $object->town = GETPOST('town', 'alphanohtml');
347 $object->country_id = GETPOSTINT('country_id');
348 $object->state_id = GETPOSTINT('state_id');
349
350 $object->socialnetworks = array();
351 if (isModEnabled('socialnetworks')) {
352 foreach ($socialnetworks as $key => $value) {
353 if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
354 $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
355 }
356 }
357 }
358
359 $object->phone = GETPOST('phone', 'alpha');
360 $object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
361 $object->fax = GETPOST('fax', 'alpha');
362 $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
363 $object->no_email = GETPOSTINT("no_email");
364 $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
365 $object->idprof1 = trim(GETPOST('idprof1', 'alphanohtml'));
366 $object->idprof2 = trim(GETPOST('idprof2', 'alphanohtml'));
367 $object->idprof3 = trim(GETPOST('idprof3', 'alphanohtml'));
368 $object->idprof4 = trim(GETPOST('idprof4', 'alphanohtml'));
369 $object->idprof5 = trim(GETPOST('idprof5', 'alphanohtml'));
370 $object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml'));
371 $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
372 $object->code_client = GETPOSTISSET('customer_code') ? GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha');
373 $object->code_fournisseur = GETPOSTISSET('supplier_code') ? GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha');
374 $object->capital = GETPOSTFLOAT('capital');
375 $object->barcode = GETPOST('barcode', 'alphanohtml');
376
377 $object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
378 $object->tva_assuj = GETPOSTINT('assujtva_value');
379 $object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
380 $object->status = GETPOSTINT('status');
381
382 // Local Taxes
383 $object->localtax1_assuj = GETPOSTINT('localtax1assuj_value');
384 $object->localtax2_assuj = GETPOSTINT('localtax2assuj_value');
385
386 $object->localtax1_value = GETPOST('lt1', 'alpha');
387 $object->localtax2_value = GETPOST('lt2', 'alpha');
388
389 $object->forme_juridique_code = GETPOSTINT('forme_juridique_code');
390 $object->effectif_id = GETPOSTINT('effectif_id');
391 $object->typent_id = GETPOSTINT('typent_id');
392
393 $object->typent_code = dol_getIdFromCode($db, $object->typent_id, 'c_typent', 'id', 'code'); // Force typent_code too so check in verify() will be done on new type
394
395 // Calculate the type of the thirdparty
396 $customer = (GETPOSTINT('customer') > 0 ? 1 : 0);
397 $prospect = (GETPOSTINT('prospect') > 0 ? 2 : 0);
398 $prospectcustomer = $customer + $prospect;
399
400 $object->client = $prospectcustomer;
401 $object->fournisseur = (GETPOSTINT('supplier') > 0 ? 1 : 0);
402
403 if ($action == 'add') {
404 // for prospect, customer or supplier
405 if ($object->client > 0 || $object->fournisseur > 0) {
406 $form = new Form($db);
407 $form->load_cache_types_paiements();
408
409 $paymentTermId = GETPOSTINT('cond_reglement_id');
410 $paymentTypeId = GETPOSTINT('mode_reglement_id');
411 if ($object->client > 0) {
412 $object->cond_reglement_id = $paymentTermId;
413
414 $filterPaymentTypeIdArr = array(0, 2, 3); // allow payment type for customer (filter is "CRDT" in "Form::select_types_paiements()" method)
415 if (!empty($form->cache_types_paiements[$paymentTypeId]) && isset($form->cache_types_paiements[$paymentTypeId]['type']) && in_array($form->cache_types_paiements[$paymentTypeId]['type'], $filterPaymentTypeIdArr)) {
416 $object->mode_reglement_id = $paymentTypeId;
417 }
418 }
419
420 if ($object->fournisseur > 0) {
421 $object->cond_reglement_supplier_id = $paymentTermId;
422
423 $filterPaymentTypeIdArr = array(1, 2, 3); // allow payment type for supplier (filter is "DBIT" in "Form::select_types_paiements()" method)
424 if (!empty($form->cache_types_paiements[$paymentTypeId]) && isset($form->cache_types_paiements[$paymentTypeId]['type']) && in_array($form->cache_types_paiements[$paymentTypeId]['type'], $filterPaymentTypeIdArr)) {
425 $object->mode_reglement_supplier_id = $paymentTypeId;
426 }
427 }
428 }
429 }
430
431 $object->commercial_id = GETPOSTINT('commercial_id');
432 $object->default_lang = GETPOST('default_lang');
433
434 // Webservices url/key
435 $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
436 $object->webservices_key = GETPOST('webservices_key', 'san_alpha');
437
438 if (GETPOSTISSET('accountancy_code_sell')) {
439 $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
440
441 if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') {
442 $object->accountancy_code_sell = '';
443 } else {
444 $object->accountancy_code_sell = $accountancy_code_sell;
445 }
446 }
447 if (GETPOSTISSET('accountancy_code_buy')) {
448 $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
449
450 if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') {
451 $object->accountancy_code_buy = '';
452 } else {
453 $object->accountancy_code_buy = $accountancy_code_buy;
454 }
455 }
456
457 // Incoterms
458 if (isModEnabled('incoterm')) {
459 $object->fk_incoterms = GETPOSTINT('incoterm_id');
460 $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
461 }
462
463 // Multicurrency
464 if (isModEnabled("multicurrency")) {
465 $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
466 }
467
468 // Fill array 'array_options' with data from add form
469 $ret = $extrafields->setOptionalsFromPost(null, $object);
470 if ($ret < 0) {
471 $error++;
472 }
473
474 // Fill array 'array_languages' with data from add form
475 $ret = $object->setValuesForExtraLanguages();
476 if ($ret < 0) {
477 $error++;
478 }
479 //var_dump($object->array_languages);exit;
480
481 if (!empty($_FILES['photo']['name'])) {
482 $current_logo = $object->logo;
483 $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
484 }
485 if (GETPOST('deletephoto')) {
486 $current_logo = $object->logo;
487 $object->logo = '';
488 }
489
490
491 // Check parameters
492 if (!GETPOST('cancel', 'alpha')) {
493 if (!empty($object->email) && !isValidEmail($object->email)) {
494 $langs->load("errors");
495 $error++;
496 setEventMessages($langs->trans("ErrorBadEMail", $object->email), null, 'errors');
497 }
498 if (!empty($object->url) && !isValidUrl($object->url)) {
499 $langs->load("errors");
500 setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors');
501 }
502 if (!empty($object->webservices_url)) {
503 //Check if has transport, without any the soap client will give error
504 if (strpos($object->webservices_url, "http") === false) {
505 $object->webservices_url = "http://".$object->webservices_url;
506 }
507 if (!isValidUrl($object->webservices_url)) {
508 $langs->load("errors");
509 $error++;
510 $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url);
511 }
512 }
513
514 // We set country_id, country_code and country for the selected country
515 $object->country_id = GETPOSTINT('country_id') != '' ? GETPOSTINT('country_id') : $mysoc->country_id;
516 if ($object->country_id) {
517 $tmparray = getCountry($object->country_id, 'all');
518 $object->country_code = $tmparray['code'];
519 $object->country = $tmparray['label'];
520 }
521 }
522 }
523
524 if (!$error) {
525 if ($action == 'add' && $permissiontoadd) {
526 $error = 0;
527
528 $db->begin();
529
530 if (empty($object->client)) {
531 $object->code_client = '';
532 }
533 if (empty($object->fournisseur)) {
534 $object->code_fournisseur = '';
535 }
536
537 $result = $object->create($user);
538
539 if ($result >= 0 && isModEnabled('mailing') && !empty($object->email) && $object->no_email == 1) {
540 // Add mass emailing flag into table mailing_unsubscribe
541 $resultnoemail = $object->setNoEmail($object->no_email);
542 if ($resultnoemail < 0) {
543 $error++;
544 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
545 $action = 'create';
546 }
547 }
548
549 if ($result >= 0) {
550 if ($object->particulier) {
551 dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
552 $contcats = GETPOST('contcats', 'array');
553 $no_email = GETPOSTINT('contact_no_email');
554 $result = $object->create_individual($user, $no_email, $contcats);
555 if ($result < 0) {
556 setEventMessages($object->error, $object->errors, 'errors');
557 $error++;
558 }
559 }
560
561 // Links with users
562 $salesreps = GETPOST('commercial', 'array');
563 $result = $object->setSalesRep($salesreps, true);
564 if ($result < 0) {
565 $error++;
566 setEventMessages($object->error, $object->errors, 'errors');
567 }
568
569 // Customer categories association
570 $custcats = GETPOST('custcats', 'array');
571 $result = $object->setCategories($custcats, 'customer');
572 if ($result < 0) {
573 $error++;
574 setEventMessages($object->error, $object->errors, 'errors');
575 }
576
577 // Supplier categories association
578 $suppcats = GETPOST('suppcats', 'array');
579 $result = $object->setCategories($suppcats, 'supplier');
580 if ($result < 0) {
581 $error++;
582 setEventMessages($object->error, $object->errors, 'errors');
583 }
584
585 // Logo/Photo save
586 $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
587 $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
588 if ($file_OK) {
589 if (image_format_supported($_FILES['photo']['name'])) {
590 dol_mkdir($dir);
591
592 if (@is_dir($dir)) {
593 $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
594 $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
595
596 if (!($result > 0)) {
597 $errors[] = "ErrorFailedToSaveFile";
598 } else {
599 // Create thumbs
600 $object->addThumbs($newfile);
601 }
602 }
603 }
604 } else {
605 switch ($_FILES['photo']['error']) {
606 case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
607 case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
608 $errors[] = "ErrorFileSizeTooLarge";
609 break;
610 case 3: //uploaded file was only partially uploaded
611 $errors[] = "ErrorFilePartiallyUploaded";
612 break;
613 }
614 }
615 } else {
616 if ($result == -3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors)) {
617 $duplicate_code_error = true;
618 $object->code_client = '';
619 }
620
621 if ($result == -3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors)) {
622 $duplicate_code_error = true;
623 $object->code_fournisseur = '';
624 }
625
626 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { // TODO Sometime errors on duplicate on profid and not on code, so we must manage this case
627 $duplicate_code_error = true;
628 }
629
630 setEventMessages($object->error, $object->errors, 'errors');
631 $error++;
632 }
633
634 if ($result >= 0 && !$error) {
635 $db->commit();
636
637 if ($backtopagejsfields) {
638 llxHeader('', '', '');
639
640 $retstring = '<script>';
641 $retstring .= 'jQuery(document).ready(function() {
642 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.'\');
643 console.log(\'id = '.$object->id.'\');
644 $(\'#varforreturndialogid'.$dol_openinpopup.'\', window.parent.document).text(\''.$object->id.'\');
645 $(\'#varforreturndialoglabel'.$dol_openinpopup.'\', window.parent.document).text(\''.$object->name.'\');
646 window.parent.jQuery(\'#idfordialog'.$dol_openinpopup.'\').dialog(\'close\');
647 });';
648 $retstring .= '</script>';
649 print $retstring;
650
651 llxFooter();
652 exit;
653 }
654
655 if (!empty($backtopage)) {
656 $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', (string) $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
657 if (preg_match('/\?/', $backtopage)) {
658 $backtopage .= '&socid='.$object->id; // Old method
659 }
660 header("Location: ".$backtopage);
661 exit;
662 } else {
663 $url = $_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method
664 if (($object->client == 1 || $object->client == 3) && !getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
665 $url = DOL_URL_ROOT."/comm/card.php?socid=".$object->id;
666 } elseif ($object->fournisseur == 1) {
667 $url = DOL_URL_ROOT."/fourn/card.php?socid=".$object->id;
668 }
669
670 header("Location: ".$url);
671 exit;
672 }
673 } else {
674 $db->rollback();
675 $action = 'create';
676 }
677 }
678
679 if ($action == 'update' && $permissiontoadd) {
680 $error = 0;
681
682 if (GETPOST('cancel', 'alpha')) {
683 if (!empty($backtopage)) {
684 header("Location: ".$backtopage);
685 exit;
686 } else {
687 header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
688 exit;
689 }
690 }
691
692 // To not set code if third party is not concerned. But if it had values, we keep them.
693 if (empty($object->client) && empty($object->oldcopy->code_client)) {
694 $object->code_client = '';
695 }
696 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
697 $object->code_fournisseur = '';
698 }
699 //var_dump($object);exit;
700
701 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(), 'update', 0);
702
703 if ($result > 0) {
704 // Update mass emailing flag into table mailing_unsubscribe
705 if (GETPOSTISSET('no_email') && $object->email) {
706 $no_email = GETPOSTINT('no_email');
707 $result = $object->setNoEmail($no_email);
708 if ($result < 0) {
709 setEventMessages($object->error, $object->errors, 'errors');
710 $action = 'edit';
711 }
712 }
713
714 $action = 'view';
715 } else {
716 setEventMessages($object->error, $object->errors, 'errors');
717 $action = 'edit';
718 }
719
720 if ($result <= 0) {
721 setEventMessages($object->error, $object->errors, 'errors');
722 $error++;
723 }
724
725 // Links with users
726 $salesreps = GETPOST('commercial', 'array');
727 $result = $object->setSalesRep($salesreps);
728 if ($result < 0) {
729 $error++;
730 setEventMessages($object->error, $object->errors, 'errors');
731 }
732
733 // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined)
734 if (!$error && $user->hasRight('categorie', 'lire')) {
735 // Customer categories association
736 $categories = GETPOST('custcats', 'array');
737 $result = $object->setCategories($categories, 'customer');
738 if ($result < 0) {
739 $error++;
740 setEventMessages($object->error, $object->errors, 'errors');
741 }
742
743 // Supplier categories association
744 $categories = GETPOST('suppcats', 'array');
745 $result = $object->setCategories($categories, 'supplier');
746 if ($result < 0) {
747 $error++;
748 setEventMessages($object->error, $object->errors, 'errors');
749 }
750 }
751
752 // Logo/Photo save
753 $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
754 $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
755 if (GETPOST('deletephoto') && $object->logo) {
756 $fileimg = $dir.'/'.$object->logo;
757 $dirthumbs = $dir.'/thumbs';
758 dol_delete_file($fileimg);
759 dol_delete_dir_recursive($dirthumbs);
760 }
761 if ($file_OK) {
762 if (image_format_supported($_FILES['photo']['name']) > 0) {
763 if ($current_logo != $object->logo) {
764 $fileimg = $dir.'/'.$current_logo;
765 $dirthumbs = $dir.'/thumbs';
766 dol_delete_file($fileimg);
767 dol_delete_dir_recursive($dirthumbs);
768 }
769
770 dol_mkdir($dir);
771
772 if (@is_dir($dir)) {
773 $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
774 $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
775
776 if (!($result > 0)) {
777 $errors[] = "ErrorFailedToSaveFile";
778 } else {
779 // Create thumbs
780 $object->addThumbs($newfile);
781
782 // Index file in database
783 if (getDolGlobalString('THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD')) {
784 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
785 // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir
786 deleteFilesIntoDatabaseIndex(dirname($newfile), '', '');
787 // now we index the uploaded logo file
788 addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1);
789 }
790 }
791 }
792 } else {
793 $errors[] = "ErrorBadImageFormat";
794 }
795 } else {
796 switch ($_FILES['photo']['error']) {
797 case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
798 case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
799 $errors[] = "ErrorFileSizeTooLarge";
800 break;
801 case 3: //uploaded file was only partially uploaded
802 $errors[] = "ErrorFilePartiallyUploaded";
803 break;
804 }
805 }
806 // Company logo management
807
808
809 // Update linked member
810 if (!$error && isset($object->fk_soc) && $object->fk_soc > 0) {
811 $sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
812 $sql .= " SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
813 if (!$object->db->query($sql)) {
814 $error++;
815 $object->error .= $object->db->lasterror();
816 setEventMessages($object->error, $object->errors, 'errors');
817 }
818 }
819
820 if (!$error && !count($errors)) {
821 if (!empty($backtopage)) {
822 header("Location: ".$backtopage);
823 exit;
824 } else {
825 header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
826 exit;
827 }
828 } else {
829 $object->id = $socid;
830 $action = "edit";
831 }
832 }
833 } else {
834 $action = ($action == 'add' ? 'create' : 'edit');
835 }
836 }
837
838 // Delete third party
839 if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('societe', 'supprimer')) {
840 $object->fetch($socid);
841 $object->oldcopy = clone $object;
842 $result = $object->delete($socid, $user);
843
844 if ($result > 0) {
845 header("Location: ".DOL_URL_ROOT."/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
846 exit;
847 } else {
848 $langs->load("errors");
849 setEventMessages($object->error, $object->errors, 'errors');
850 $error++;
851 $action = '';
852 }
853 }
854
855 // Set third-party type
856 if ($action == 'set_thirdpartytype' && $permissiontoadd) {
857 $object->fetch($socid);
858 $result = $object->setThirdpartyType(GETPOSTINT('typent_id'));
859 }
860
861 // Set incoterm
862 if ($action == 'set_incoterms' && $permissiontoadd && isModEnabled('incoterm')) {
863 $object->fetch($socid);
864 $result = $object->setIncoterms(GETPOSTINT('incoterm_id'), GETPOST('location_incoterms'));
865 }
866
867 // Set parent company
868 if ($action == 'set_thirdparty' && $permissiontoadd) {
869 $object->fetch($socid);
870 $result = $object->setParent(GETPOSTINT('parent_id'));
871 }
872
873 // Set sales representatives
874 if ($action == 'set_salesrepresentatives' && $permissiontoadd) {
875 $object->fetch($socid);
876 $result = $object->setSalesRep(GETPOST('commercial', 'array'));
877 }
878
879 // warehouse
880 if ($action == 'setwarehouse' && $permissiontoadd) {
881 $result = $object->setWarehouse(GETPOSTINT('fk_warehouse'));
882 }
883
884 if ($action == 'confirm_clone' && $confirm != 'yes') {
885 $action = '';
886 }
887 //clone company essential info
888 if ($action == 'confirm_clone' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
889 if ($object->id > 0) {
890 $error = 0;
891
892 $clone = dol_clone($object, 1);
893
894 if (!empty(GETPOST('clone_name'))) {
895 $clone->id = 0;
896 $clone->name = GETPOST('clone_name', 'alphanohtml');
897 $clone->status = 1;
898 $clone->fournisseur = 0;
899 $clone->client = 0;
900
901 $db->begin();
902
903 $clone->context['createfromclone'] = 'createfromclone';
904 $id = $clone->create($user);
905 if ($id > 0) {
906 $clone->id = $id;
907 } else {
908 setEventMessages($clone->error, $clone->errors, 'errors');
909 $error++;
910 }
911
912 unset($clone->context['createfromclone']);
913
914 if ($error) {
915 $db->rollback();
916 } else {
917 $db->commit();
918 $db->close();
919 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
920 exit;
921 }
922 } else {
923 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewRefForClone")), null, 'errors');
924 }
925 } else {
926 dol_print_error($db, $object->error, $object->errors);
927 }
928 $action = 'clone';
929 }
930
931 $id = $socid;
932 $object->fetch($socid);
933
934 // Selection of new fields
935 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD') && (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS') || getDolGlobalString('SOCIETE_ADDRESSES_MANAGEMENT'))) {
936 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
937 }
938
939 // Actions to send emails
940 $triggersendname = 'COMPANY_SENTBYMAIL';
941 $paramname = 'socid';
942 $mode = 'emailfromthirdparty';
943 $trackid = 'thi'.$object->id;
944 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
945
946 // Actions to build doc
947 $id = $socid;
948 $upload_dir = !empty($conf->societe->multidir_output[$object->entity]) ? $conf->societe->multidir_output[$object->entity] : $conf->societe->dir_output;
949 $permissiontoadd = $user->hasRight('societe', 'creer');
950 include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
951}
952
953
954/*
955 * View
956 */
957
958$form = new Form($db);
959$formfile = new FormFile($db);
960$formadmin = new FormAdmin($db);
961$formcompany = new FormCompany($db);
962if (isModEnabled('accounting')) {
963 $formaccounting = new FormAccounting($db);
964}
965
966if ($socid > 0 && empty($object->id)) {
967 $result = $object->fetch($socid);
968 if ($result <= 0) {
969 dol_print_error(null, $object->error);
970 exit(-1);
971 }
972}
973
974$title = $langs->trans("ThirdParty");
975if ($action == 'create') {
976 $title = $langs->trans("NewThirdParty");
977}
978if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
979 $title = $object->name." - ".$langs->trans('Card');
980}
981$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
982
983llxHeader('', $title, $help_url);
984
985$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
986
987$canvasdisplayaction = $action;
988if (in_array($canvasdisplayaction, array('merge', 'confirm_merge'))) {
989 $canvasdisplayaction = 'view';
990}
991
992if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
993 // -----------------------------------------
994 // When used with CANVAS
995 // -----------------------------------------
996 $objcanvas->assign_values($canvasdisplayaction, $object->id, $object->ref); // Set value for templates
997 $objcanvas->display_canvas($canvasdisplayaction); // Show template
998} else {
999 // -----------------------------------------
1000 // When used in standard mode
1001 // -----------------------------------------
1002 if ($action == 'create') {
1003 /*
1004 * Creation
1005 */
1006 $private = GETPOSTINT("private");
1007 if (getDolGlobalString('THIRDPARTY_DEFAULT_CREATE_CONTACT') && !GETPOSTISSET('private')) {
1008 $private = 1;
1009 }
1010 if (empty($private)) {
1011 $private = 0;
1012 }
1013
1014 // Load object modCodeTiers
1015 $module = getDolGlobalString('SOCIETE_CODECLIENT_ADDON', 'mod_codeclient_leopard');
1016 if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
1017 $module = substr($module, 0, dol_strlen($module) - 4);
1018 }
1019 $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
1020 foreach ($dirsociete as $dirroot) {
1021 $res = dol_include_once($dirroot.$module.'.php');
1022 if ($res) {
1023 break;
1024 }
1025 }
1026 $modCodeClient = new $module($db);
1027 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
1028 // Load object modCodeFournisseur
1029 $module = getDolGlobalString('SOCIETE_CODECLIENT_ADDON', 'mod_codeclient_leopard');
1030 if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
1031 $module = substr($module, 0, dol_strlen($module) - 4);
1032 }
1033 $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
1034 foreach ($dirsociete as $dirroot) {
1035 $res = dol_include_once($dirroot.$module.'.php');
1036 if ($res) {
1037 break;
1038 }
1039 }
1040 $modCodeFournisseur = new $module($db);
1041 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
1042
1043 // Define if customer/prospect or supplier status is set or not
1044 if (GETPOST("type", 'aZ') != 'f') {
1045 $object->client = -1;
1046 if (getDolGlobalString('THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT')) {
1047 $object->client = 3;
1048 }
1049 }
1050 // Prospect / Customer
1051 if (GETPOST("type", 'aZ') == 'c') {
1052 if (getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT')) {
1053 $object->client = getDolGlobalInt('THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT');
1054 } else {
1055 $object->client = 3;
1056 }
1057 }
1058 if (GETPOST("type", 'aZ') == 'p') {
1059 $object->client = 2;
1060 }
1061
1062 if (getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') && $object->client == 3) {
1063 $object->client = 1;
1064 }
1065
1066 if ((isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && getDolGlobalString('THIRDPARTY_SUPPLIER_BY_DEFAULT')))) {
1067 $object->fournisseur = 1;
1068 }
1069
1070 $object->name = GETPOST('name', 'alphanohtml');
1071 $object->name_alias = GETPOST('name_alias', 'alphanohtml');
1072 $object->firstname = GETPOST('firstname', 'alphanohtml');
1073 $object->particulier = $private;
1074 $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
1075 //$object->client = GETPOSTINT('client') ? GETPOSTINT('client') : $object->client;
1076
1077 if (empty($duplicate_code_error)) {
1078 $object->code_client = GETPOST('customer_code', 'alpha');
1079 $object->fournisseur = GETPOST('fournisseur') ? GETPOSTINT('fournisseur') : $object->fournisseur;
1080 $object->code_fournisseur = GETPOST('supplier_code', 'alpha');
1081 } else {
1082 setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'), null, 'warnings');
1083 }
1084
1085 $object->address = GETPOST('address', 'alphanohtml');
1086 $object->zip = GETPOST('zipcode', 'alphanohtml');
1087 $object->town = GETPOST('town', 'alphanohtml');
1088 $object->state_id = GETPOSTINT('state_id');
1089
1090 $object->socialnetworks = array();
1091 if (isModEnabled('socialnetworks')) {
1092 foreach ($socialnetworks as $key => $value) {
1093 if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
1094 $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
1095 }
1096 }
1097 }
1098
1099 $object->phone = GETPOST('phone', 'alpha');
1100 $object->phone_mobile = (string) GETPOST("phone_mobile", 'alpha');
1101 $object->fax = GETPOST('fax', 'alpha');
1102 $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
1103 $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
1104 $object->capital = GETPOSTFLOAT('capital');
1105 $paymentTermId = GETPOSTINT('cond_reglement_id'); // can be set by default values on create page and not already in get or post variables
1106 if (empty($paymentTermId) && !GETPOSTISSET('cond_reglement_id')) {
1107 $paymentTermId = getDolGlobalString('MAIN_DEFAULT_PAYMENT_TERM_ID');
1108 }
1109 $object->cond_reglement_id = $paymentTermId;
1110 $paymentTypeId = GETPOSTINT('mode_reglement_id'); // can be set by default values on create page and not already in get or post variables
1111 if (empty($paymentTypeId) && !GETPOSTISSET('mode_reglement_id')) {
1112 $paymentTypeId = getDolGlobalString('MAIN_DEFAULT_PAYMENT_TYPE_ID');
1113 }
1114 $object->mode_reglement_id = $paymentTypeId;
1115 $object->barcode = GETPOST('barcode', 'alphanohtml');
1116 $object->idprof1 = GETPOST('idprof1', 'alphanohtml');
1117 $object->idprof2 = GETPOST('idprof2', 'alphanohtml');
1118 $object->idprof3 = GETPOST('idprof3', 'alphanohtml');
1119 $object->idprof4 = GETPOST('idprof4', 'alphanohtml');
1120 $object->idprof5 = GETPOST('idprof5', 'alphanohtml');
1121 $object->idprof6 = GETPOST('idprof6', 'alphanohtml');
1122 $object->typent_id = GETPOSTINT('typent_id');
1123 $object->effectif_id = GETPOSTINT('effectif_id');
1124 $object->civility_id = GETPOST('civility_id', 'alpha');
1125
1126 $object->tva_assuj = GETPOSTINT('assujtva_value');
1127 $object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
1128 $object->status = GETPOSTINT('status');
1129
1130 //Local Taxes
1131 $object->localtax1_assuj = GETPOSTINT('localtax1assuj_value');
1132 $object->localtax2_assuj = GETPOSTINT('localtax2assuj_value');
1133
1134 $object->localtax1_value = GETPOST('lt1', 'alpha');
1135 $object->localtax2_value = GETPOST('lt2', 'alpha');
1136
1137 $object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
1138
1139 $object->commercial_id = GETPOSTINT('commercial_id');
1140 $object->default_lang = GETPOST('default_lang');
1141
1142 if (GETPOSTISSET('accountancy_code_sell')) {
1143 $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
1144
1145 if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') {
1146 $object->accountancy_code_sell = '';
1147 } else {
1148 $object->accountancy_code_sell = $accountancy_code_sell;
1149 }
1150 }
1151 if (GETPOSTISSET('accountancy_code_buy')) {
1152 $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
1153
1154 if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') {
1155 $object->accountancy_code_buy = '';
1156 } else {
1157 $object->accountancy_code_buy = $accountancy_code_buy;
1158 }
1159 }
1160
1161 $object->logo = (isset($_FILES['photo']) ? dol_sanitizeFileName($_FILES['photo']['name']) : '');
1162
1163 // Company logo management
1164 $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos";
1165 $file_OK = (isset($_FILES['photo']) ? is_uploaded_file($_FILES['photo']['tmp_name']) : false);
1166 if ($file_OK) {
1167 if (image_format_supported($_FILES['photo']['name'])) {
1168 dol_mkdir($dir);
1169
1170 if (@is_dir($dir)) {
1171 $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
1172 $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
1173
1174 if (!($result > 0)) {
1175 $errors[] = "ErrorFailedToSaveFile";
1176 } else {
1177 // Create thumbs
1178 $object->addThumbs($newfile);
1179 }
1180 }
1181 }
1182 }
1183
1184 // We set country_id, country_code and country for the selected country
1185 $object->country_id = GETPOST('country_id') ? GETPOST('country_id') : $mysoc->country_id;
1186 if ($object->country_id) {
1187 $tmparray = getCountry($object->country_id, 'all');
1188 $object->country_code = $tmparray['code'];
1189 $object->country = $tmparray['label'];
1190 }
1191 $object->forme_juridique_code = GETPOSTINT('forme_juridique_code');
1192
1193 // We set multicurrency_code if enabled
1194 if (isModEnabled("multicurrency")) {
1195 $object->multicurrency_code = GETPOST('multicurrency_code') ? GETPOST('multicurrency_code') : $conf->currency;
1196 }
1197 /* Show create form */
1198
1199 $linkback = "";
1200 print load_fiche_titre($langs->trans("NewThirdParty"), $linkback, 'building');
1201
1202 if (!empty($conf->use_javascript_ajax)) {
1203 if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
1204 print "\n".'<script type="text/javascript">';
1205 print '$(document).ready(function () {
1206 id_te_private=8;
1207 id_ef15=1;
1208 is_private=' . $private.';
1209 if (is_private) {
1210 $(".individualline").show();
1211 } else {
1212 $(".individualline").hide();
1213 }
1214 $("#radiocompany").click(function() {
1215 $(".individualline").hide();
1216 $("#typent_id").val(0);
1217 $("#typent_id").change();
1218 $("#effectif_id").val(0);
1219 $("#effectif_id").change();
1220 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1221 document.formsoc.private.value=0;
1222 });
1223 $("#radioprivate").click(function() {
1224 $(".individualline").show();
1225 $("#typent_id").val(id_te_private);
1226 $("#typent_id").change();
1227 $("#effectif_id").val(id_ef15);
1228 $("#effectif_id").change();
1229 /* Force to recompute the width of a select2 field when it was hidden and then shown programmatically */
1230 if ($("#civility_id").data("select2")) {
1231 $("#civility_id").select2({width: "resolve"});
1232 }
1233 $("#TypeName").html(document.formsoc.LastName.value);
1234 document.formsoc.private.value=1;
1235 });';
1236
1237 if (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1238 print '
1239 function init_check_no_email(input) {
1240 if (input.val()!="") {
1241 $(".noemail").addClass("fieldrequired");
1242 } else {
1243 $(".noemail").removeClass("fieldrequired");
1244 }
1245 }
1246 $("#email").keyup(function() {
1247 init_check_no_email($(this));
1248 });
1249 init_check_no_email($("#email"));';
1250 }
1251 print '});';
1252 print '</script>'."\n";
1253
1254 print '<div id="selectthirdpartytype">';
1255 print '<div class="hideonsmartphone float">';
1256 print $langs->trans("ThirdPartyType").': &nbsp; &nbsp; ';
1257 print '</div>';
1258 print '<label for="radiocompany" class="radiocompany">';
1259 print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ? '' : ' checked').'>';
1260 print '&nbsp;';
1261 print $langs->trans("CreateThirdPartyOnly");
1262 print '</label>';
1263 print ' &nbsp; &nbsp; ';
1264 print '<label for="radioprivate" class="radioprivate">';
1265 $text = '<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ? ' checked' : '').'>';
1266 $text .= '&nbsp;';
1267 $text .= $langs->trans("CreateThirdPartyAndContact");
1268 $htmltext = $langs->trans("ToCreateContactWithSameName");
1269 print $form->textwithpicto($text, $htmltext, 1, 'help', '', 0, 3);
1270 print '</label>';
1271 print '</div>';
1272 print "<br>\n";
1273 }
1274
1275 print '<script type="text/javascript">';
1276 print '$(document).ready(function () {
1277 var canHaveCustomerCategoryIfNotCustomerProspectSupplier = ' . (!getDolGlobalString('THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ? '0' : '1') . ';
1278
1279 init_customer_categ();
1280 $("#customerprospect").change(function() {
1281 init_customer_categ();
1282 });
1283 function init_customer_categ() {
1284 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1285 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspectSupplier) {
1286 jQuery(".visibleifcustomer").hide();
1287 } else {
1288 jQuery(".visibleifcustomer").show();
1289 }
1290 }
1291
1292 init_supplier_categ();
1293 $("#fournisseur").change(function() {
1294 init_supplier_categ();
1295 });
1296 function init_supplier_categ() {
1297 console.log("is supplier = "+jQuery("#fournisseur").val());
1298 if (jQuery("#fournisseur").val() == 0) {
1299 jQuery(".visibleifsupplier").hide();
1300 } else {
1301 jQuery(".visibleifsupplier").show();
1302 }
1303 }
1304
1305 $("#selectcountry_id").change(function() {
1306 console.log("selectcountry_id change");
1307 document.formsoc.action.value="create";
1308 document.formsoc.submit();
1309 });
1310 });';
1311 print '</script>'."\n";
1312 }
1313
1314 dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
1315
1316 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">'; // Chrome ignores autocomplete
1317
1318 print '<input type="hidden" name="action" value="add">';
1319 print '<input type="hidden" name="token" value="'.newToken().'">';
1320 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1321 print '<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.'">';
1322 print '<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.'">';
1323 print '<input type="hidden" name="private" value='.$object->particulier.'>';
1324 print '<input type="hidden" name="type" value='.GETPOST("type", 'alpha').'>';
1325 print '<input type="hidden" name="LastName" value="'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName').'">';
1326 print '<input type="hidden" name="ThirdPartyName" value="'.$langs->trans('ThirdPartyName').'">';
1327 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1328 print '<input type="hidden" name="code_auto" value="1">';
1329 }
1330
1331 print dol_get_fiche_head(array(), 'card', '', 0, '');
1332
1333 // Call Hook tabContentCreateThirdparty
1334 $parameters = array();
1335 // Note that $action and $object may be modified by hook
1336 $reshook = $hookmanager->executeHooks('tabContentCreateThirdparty', $parameters, $object, $action);
1337 if (empty($reshook)) {
1338 print '<table class="border centpercent">';
1339
1340 // Name, firstname
1341 print '<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1342 if ($object->particulier || $private) {
1343 print '<span id="TypeName" class="fieldrequired">'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName', 'name').'</span>';
1344 } else {
1345 print '<span id="TypeName" class="fieldrequired">'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0).'</span>';
1346 }
1347 print '</td><td'.(getDolGlobalString('SOCIETE_USEPREFIX') ? '' : ' colspan="3"').'>';
1348
1349 print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus">';
1350 print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300'); // For some countries that need the company name in 2 languages
1351 // This implementation of the feature to search already existing company has been disabled. It must be implemented by keeping the "input text" and we must call the search ajax societe/ajax/ajaxcompanies.php
1352 // on a keydown of the input. We should show data about a duplicate found if we found less than 5 answers into a div under the input.
1353 /*
1354 print '<select class="name" name="name" id="name" style="min-width:500px"></select>';
1355 print "\n".'<script type="text/javascript">';
1356 print '$(document).ready(function () {
1357 $("#name").select2({
1358 ajax: {
1359 url: "' . DOL_URL_ROOT . '/core/ajax/ajaxcompanies.php",
1360 dataType: "json",
1361 delay: 250,
1362 data: function (params) {
1363 return {
1364 newcompany: params.term // search term
1365 }
1366 },
1367 processResults: function (data, params) {
1368 return {
1369 results: data
1370 }
1371 },
1372 cache: true
1373 },
1374
1375 placeholder: "' . $langs->trans('Name of the new third party. In the meantime we check if it already exists...') . '",
1376 allowClear: true,
1377 minimumInputLength: 3,
1378 language: (typeof select2arrayoflanguage === \'undefined\') ? \'en\' : select2arrayoflanguage,
1379 containerCssClass: ":all:",
1380 selectionCssClass: ":all:",
1381 tags: true,
1382 templateResult: formatCustomer,
1383 templateSelection: formatCustomerSelection
1384 });
1385
1386 function formatCustomer (Customer) {
1387 if(Customer.label === undefined) {
1388 return Customer.text;
1389 }
1390
1391 if(Customer.logo !== null ) {
1392 logo = \'<img src="\';
1393 logo += \'' . DOL_URL_ROOT . '/viewimage.php?modulepart=societe&amp;entity=1&amp;file=\' + Customer.key + "%2Flogos%2Fthumbs%2F" + Customer.logo.replace(".", "_mini.") + "&amp;cache=0";
1394 logo += \'" /></div>\';
1395 } else {
1396 logo = \'<div class="floatleft inline-block valigntop photowithmargin" style="padding:0 10px"><div class="photosociete photoref" alt="No photo"><span class="fas fa-building" style="color: #6c6aa8;"></span></div></div>\';
1397 }
1398
1399 var $container = $("<div class=\'select2-result-repository clearfix\'>" +
1400 "<div class=\'select2-result-repository__avatar floatleft inline-block valigntop\'>" + logo +
1401 "<div class=\'select2-result-repository__meta floatleft inline-block valigntop\'>" +
1402 "<div class=\'select2-result-repository__title\'></div>" +
1403 "<div class=\'select2-result-repository__name_alias\'></div>" +
1404 "<div class=\'select2-result-repository__code_client\'></div>" +
1405 "<div class=\'select2-result-repository__code_fournisseur\'></div>" +
1406 "<div class=\'select2-result-repository__companies_info\'>" +
1407 "<div class=\'select2-result-repository__email\'><i class=\'fa fa-at\'></i> </div>" +
1408 "<div class=\'select2-result-repository__address\'><i class=\'fa fa-flag\'></i> </div>" +
1409 "<div class=\'select2-result-repository__zip\'><i class=\'fa fa-circle-o\'></i> </div>" +
1410 "<div class=\'select2-result-repository__country\'><i class=\'fa fa-globe-americas\'></i> </div>" +
1411 "<div class=\'select2-result-repository__departement\'><i class=\'fa fa-circle-o\'></i> </div>" +
1412 "<div class=\'select2-result-repository__town\'><i class=\'fa fa-circle-o\'></i> </div>" +
1413 "<div class=\'select2-result-repository__siren\'><i class=\'fa fa-circle-o\'></i> </div>" +
1414 "<div class=\'select2-result-repository__datec\'><i class=\'fa fa-calendar\'></i> </div>" +
1415 "</div>" +
1416 "</div>" +
1417 "</div>"
1418 );
1419
1420 $container.find(".select2-result-repository__title").text(Customer.label);
1421 $container.find(".select2-result-repository__name_alias").text(Customer.name_alias ? Customer.name_alias : "");
1422 $container.find(".select2-result-repository__code_client").text(Customer.code_client ? Customer.code_client : "");
1423 $container.find(".select2-result-repository__code_fournisseur").text((Customer.code_fournisseur!==null) ? Customer.code_fournisseur : "");
1424 $container.find(".select2-result-repository__email").append("' . $langs->trans('EMail') . ': " + (Customer.email !== null ? Customer.email : ""));
1425 $container.find(".select2-result-repository__address").append("' . $langs->trans('Address') . ': " + (Customer.address !== null ? Customer.address : ""));
1426 $container.find(".select2-result-repository__country").append("' . $langs->trans('Country') . ': " + (Customer.country !== null ? Customer.country : ""));
1427 $container.find(".select2-result-repository__departement").append("' . $langs->trans('Region-State') . ': " + (Customer.departement !== null ? Customer.departement : ""));
1428 $container.find(".select2-result-repository__zip").append("' . $langs->trans('Zip') . ': " + (Customer.zip !== null ? Customer.zip : ""));
1429 $container.find(".select2-result-repository__town").append("' . $langs->trans('Town') . ': " + (Customer.town !== null ? Customer.town : ""));
1430 $container.find(".select2-result-repository__siren").append("' . $langs->trans('Siren') . ': " + (Customer.siren !== null ? Customer.siren : ""));
1431 $container.find(".select2-result-repository__datec").append("' . $langs->trans('Created') . ': " + (Customer.datec !== null ? Customer.datec : ""));
1432
1433 return $container;
1434 }
1435
1436 function formatCustomerSelection (selection) {
1437 return selection.label || selection.text;
1438 }
1439 });
1440 </script>
1441 ';
1442 */
1443 print '</td>';
1444 if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
1445 print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'"></td>';
1446 }
1447 print '</tr>';
1448
1449 // If javascript on, we show option individual
1450 if ($conf->use_javascript_ajax) {
1451 if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
1452 // Firstname
1453 print '<tr class="individualline"><td>'.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).'</td>';
1454 print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).'"></td>';
1455 print '</tr>';
1456
1457 // Title
1458 print '<tr class="individualline"><td>'.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1459 print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'</td>';
1460 print '</tr>';
1461 }
1462 }
1463
1464 // Alias names (commercial, trademark or alias names)
1465 print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1466 print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag($object->name_alias).'"></td></tr>';
1467
1468 // Prospect/Customer/Supplier
1469 $selected = $object->client;
1470 $selectedcustomer = 0;
1471 $selectedprospect = 0;
1472 switch ($selected) {
1473 case 1:
1474 $selectedcustomer = 1;
1475 break;
1476 case 2:
1477 $selectedprospect = 1;
1478 break;
1479 case 3:
1480 $selectedprospect = 1;
1481 $selectedcustomer = 1;
1482 break;
1483 default:
1484 break;
1485 }
1486
1487 $selectedprospect = ((GETPOSTISSET('prospect') && $action == 'create') ? GETPOSTINT('prospect') : $selectedprospect);
1488 $selectedcustomer = ((GETPOSTISSET('customer') && $action == 'create') ? GETPOSTINT('customer') : $selectedcustomer);
1489 $selectedsupplier = ((GETPOSTISSET('supplier') && $action == 'create') ? GETPOSTINT('supplier') : $object->fournisseur);
1490
1491 print '<tr class="marginbottomlarge height50">';
1492 if ($conf->browser->layout != 'phone') {
1493 print '<td class="titlefieldcreate">'.$form->editfieldkey('', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
1494 }
1495 print '<td class="maxwidthonsmartphone"'.($conf->browser->layout != 'phone' ? 'colspan="3"' : 'colspan="2"').'>';
1496
1497 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
1498 print '<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans("Prospect").'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'></label></span>';
1499 }
1500
1501 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
1502 print '<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans("Customer").'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'></label></span>';
1503 }
1504
1505 if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))
1506 || (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
1507 // Supplier
1508 print '<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans("Vendor").'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selectedsupplier ? ' checked="checked"' : '').'></label></span>';
1509 }
1510 // Add js to manage the background of nature
1511 if ($conf->use_javascript_ajax) {
1512 print '<script>
1513 function refreshNatureCss() {
1514 jQuery(".spannature").each(function( index ) {
1515 id = $(this).attr("id").split("spannature")[1];
1516 console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
1517 if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
1518 if (id == 1) {
1519 jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
1520 }
1521 if (id == 2) {
1522 jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
1523 }
1524 if (id == 3) {
1525 jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
1526 }
1527 } else {
1528 jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
1529 }
1530 });
1531 }
1532
1533 function manageprospectcustomer(element) {
1534 console.log("We uncheck unwanted values on a nature");
1535 id = $(element).attr("id").split("spannature")[1];
1536 if ( id == 1){
1537 $("#spannature2 .checkforselect").prop("checked", false);
1538 }
1539 if ( id == 2){
1540 $("#spannature1 .checkforselect").prop("checked", false);
1541 }
1542 }
1543
1544 jQuery(".spannature").click(function(){
1545 console.log("We click on a nature");
1546 '.(getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ? 'manageprospectcustomer($(this));' : '').'
1547 refreshNatureCss();
1548 });
1549 refreshNatureCss();
1550 </script>';
1551 }
1552 print '</td>';
1553 print '</tr>';
1554
1555 // Customer code
1556 print '<tr>';
1557 print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
1558 print '<table class="nobordernopadding"><tr><td>';
1559 $tmpcode = $object->code_client;
1560 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1561 $tmpcode = $modCodeClient->getNextValue($object, 0);
1562 }
1563 print '<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
1564 print '</td><td>';
1565 $s = $modCodeClient->getToolTip($langs, $object, 0);
1566 print $form->textwithpicto('', $s, 1);
1567 print '</td></tr></table>';
1568 print '</td>';
1569
1570 if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))
1571 || (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
1572 if ($conf->browser->layout == 'phone') {
1573 print '<td colspan="2"></td>';
1574 print '</tr><tr>';
1575 }
1576 print '<td>'.$form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0).'</td><td>';
1577 print '<table class="nobordernopadding"><tr><td>';
1578 $tmpcode = $object->code_fournisseur;
1579 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1580 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1581 }
1582 print '<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
1583 print '</td><td>';
1584 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1585 print $form->textwithpicto('', $s, 1);
1586 print '</td></tr></table>';
1587 print '</td>';
1588 } else {
1589 print '<td colspan="2"></td>';
1590 }
1591 print '</tr>';
1592
1593 // Status
1594 print '<tr><td>'.$form->editfieldkey('Status', 'status', '', $object, 0).'</td><td colspan="3">';
1595 print $form->selectarray('status', array('1' => $langs->trans('InActivity'), '0' => $langs->trans('ActivityCeased')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
1596 print '</td></tr>';
1597
1598 // Barcode
1599 if (isModEnabled('barcode')) {
1600 print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
1601 print '<td colspan="3">';
1602 print img_picto('', 'barcode', 'class="pictofixedwidth"');
1603 print '<input type="text" class="minwidth200 maxwidth300 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">';
1604 print '</td></tr>';
1605 }
1606
1607 $colspan = ($conf->browser->layout == 'phone' ? 2 : 4);
1608 print '<tr><td'.($colspan ? ' colspan="'.$colspan.'"' : '').'>&nbsp;</td></tr>';
1609
1610 // Address
1611 print '<tr><td class="tdtop">';
1612 print $form->editfieldkey('Address', 'address', '', $object, 0);
1613 print '</td>';
1614 print '<td colspan="3">';
1615 print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.'" wrap="soft">';
1616 print dol_escape_htmltag($object->address, 0, 1);
1617 print '</textarea>';
1618 print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
1619 print '</td></tr>';
1620
1621 // Zip / Town
1622 print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
1623 print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
1624 print '</td>';
1625 if ($conf->browser->layout == 'phone') {
1626 print '</tr><tr>';
1627 }
1628 print '<td class="tdtop">'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
1629 print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth150 quatrevingtpercent');
1630 print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
1631 print '</td></tr>';
1632
1633 // Country
1634 print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1635 print img_picto('', 'country', 'class="pictofixedwidth"');
1636 print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth200 maxwidth300 widthcentpercentminusx');
1637 if ($user->admin) {
1638 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1639 }
1640 print '</td></tr>';
1641
1642 // State
1643 if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
1644 if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) {
1645 print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1646 } else {
1647 print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1648 }
1649
1650 if ($object->country_id) {
1651 print img_picto('', 'state', 'class="pictofixedwidth"');
1652 print $formcompany->select_state($object->state_id, $object->country_code, 'state_id', 'minwidth200 maxwidth300 widthcentpercentminusx');
1653 } else {
1654 print $countrynotdefined;
1655 }
1656 print '</td></tr>';
1657 }
1658
1659 // Phone / Fax
1660 print '<tr><td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
1661 print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $object->phone).'"></td>';
1662
1663 if ($conf->browser->layout == 'phone') {
1664 print '</tr><tr>';
1665 }
1666
1667 // Phone mobile
1668 print '<td>'.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).'</td>';
1669 print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').' <input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
1670
1671 // Fax
1672 print '<tr>';
1673 print '<td>'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>';
1674 print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('fax') ? GETPOST('fax', 'alpha') : $object->fax).'"></td></tr>';
1675
1676 // URL
1677 print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
1678 print '<td colspan="3">'.img_picto('', 'globe', 'class="pictofixedwidth"').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.'"></td></tr>';
1679
1680 // Email
1681 print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', getDolGlobalString('SOCIETE_EMAIL_MANDATORY')).'</td>';
1682 print '<td'.(($conf->browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.img_picto('', 'object_email', 'class="pictofixedwidth"').' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td>';
1683
1684 // Unsubscribe
1685 if (isModEnabled('mailing')) {
1686 if ($conf->browser->layout == 'phone') {
1687 print '</tr><tr>';
1688 }
1689 if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1690 print "\n".'<script type="text/javascript">'."\n";
1691 print '$(document).ready(function () {
1692 $("#email").keyup(function() {
1693 console.log("We change email content");
1694 if ($(this).val()!="") {
1695 $(".noemail").addClass("fieldrequired");
1696 } else {
1697 $(".noemail").removeClass("fieldrequired");
1698 }
1699 });
1700 })'."\n";
1701 print '</script>'."\n";
1702 }
1703 if (!GETPOSTISSET("no_email") && !empty($object->email)) {
1704 $result = $object->getNoEmail();
1705 if ($result < 0) {
1706 setEventMessages($object->error, $object->errors, 'errors');
1707 }
1708 }
1709 print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
1710 print '<td>';
1711 print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 ? 1 : 0), 1);
1712 print '</td>';
1713 }
1714 print '</tr>';
1715
1716 // Refuse emailing of all contacts
1717 if (isModEnabled('mailing') && getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
1718 print '<tr>';
1719 if ($conf->browser->layout != 'phone') {
1720 print '<td></td>';
1721 print '<td></td>';
1722 }
1723 print '<td class="individualline noemail">'.$form->editfieldkey($langs->trans('No_Email') .' ('.$langs->trans('Contact').')', 'contact_no_email', '', $object, 0).'</td>';
1724 print '<td class="individualline" '.(($conf->browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>'.$form->selectyesno('contact_no_email', (GETPOSTISSET("contact_no_email") ? GETPOST("contact_no_email", 'alpha') : (empty($object->no_email) ? 0 : 1)), 1, false, 1).'</td>';
1725 print '</tr>';
1726 }
1727
1728 // Social networks
1729 if (isModEnabled('socialnetworks')) {
1730 $colspan = ($conf->browser->layout == 'phone' ? 2 : 4);
1731
1732 $object->showSocialNetwork($socialnetworks, $colspan);
1733
1734 print '<tr><td'.($colspan ? ' colspan="'.$colspan.'"' : '').'><hr></td></tr>';
1735 }
1736
1737 // Prof ids
1738 $i = 1;
1739 $j = 0;
1740 $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2);
1741 $NBPROFIDMIN = getDolGlobalInt('THIRDPARTY_MIN_NB_PROF_ID', 2);
1742 $NBPROFIDMAX = getDolGlobalInt('THIRDPARTY_MAX_NB_PROF_ID', 6);
1743 while ($i <= $NBPROFIDMAX) {
1744 $idprof = $langs->transcountry('ProfId'.$i, $object->country_code);
1745 if ($idprof != '-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate['ProfId'.$i.$object->country_code]))) {
1746 $key = 'idprof'.$i;
1747
1748 if (($j % $NBCOLS) == 0) {
1749 print '<tr>';
1750 }
1751
1752 $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY';
1753 print '<td>'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).'</td><td>';
1754
1755 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1756 print '</td>';
1757 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1758 print '</tr>';
1759 }
1760 $j++;
1761 }
1762 $i++;
1763 }
1764 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1765 print '<td colspan="2"></td></tr>';
1766 }
1767
1768 // Vat is used
1769 print '<tr><td><label for="assujtva_value">'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).'</label></td>';
1770 print '<td>';
1771 print '<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (GETPOSTISSET('assujtva_value') ? (GETPOST('assujtva_value', 'alpha') != '' ? ' checked="checked"' : '') : 'checked="checked"') . ' value="1">'; // Assujeti par default en creation
1772 print '</td>';
1773 if ($conf->browser->layout == 'phone') {
1774 print '</tr><tr>';
1775 }
1776 print '<td class="nowrap">'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).'</td>';
1777 print '<td class="nowrap">';
1778 $s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
1779
1780 if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) {
1781 $s .= ' ';
1782
1783 if (!empty($conf->use_javascript_ajax)) {
1784 $widthpopup = 600;
1785 if (!empty($conf->dol_use_jmobile)) {
1786 $widthpopup = 350;
1787 }
1788 $heightpopup = 400;
1789 print "\n";
1790 print '<script type="text/javascript">';
1791 print "function CheckVAT(a) {\n";
1792 if ($mysoc->country_code == 'GR' && $object->country_code == 'GR' && !empty($u)) {
1793 print "GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
1794 } else {
1795 print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n";
1796 }
1797 print "}\n";
1798 print '</script>';
1799 print "\n";
1800 $s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
1801 $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
1802 } else {
1803 $s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
1804 }
1805 }
1806 print $s;
1807 print '</td>';
1808 print '</tr>';
1809
1810 // VAT reverse charge by default
1811 if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
1812 print '<tr><td><label for="vat_reverse_charge">' . $form->editfieldkey('VATReverseChargeByDefault', 'vat_reverse_charge', '', $object, 0) . '</label></td><td colspan="3">';
1813 print '<input type="checkbox" name="vat_reverse_charge" id="vat_reverse_charge" '.($object->vat_reverse_charge == '1' ? ' checked' : '').'>';
1814 print '</td></tr>';
1815 }
1816
1817 // Local Taxes
1818 //TODO: Place into a function to control showing by country or study better option
1819 if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
1820 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
1821 print '<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? 'checked="checked"' : '') . ' value="1">';
1822 print '</td>';
1823 if ($conf->browser->layout == 'phone') {
1824 print '</tr><tr>';
1825 }
1826 print '<td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
1827 print '<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? 'checked="checked"' : '') . ' value="1">';
1828 print '</td></tr>';
1829 } elseif ($mysoc->localtax1_assuj == "1") {
1830 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td colspan="3">';
1831 print '<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? 'checked="checked"' : '') . ' value="1">';
1832 print '</td></tr>';
1833 } elseif ($mysoc->localtax2_assuj == "1") {
1834 print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td colspan="3">';
1835 print '<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? 'checked="checked"' : '') . ' value="1">';
1836 print '</td></tr>';
1837 }
1838
1839 // Type - Workforce/Staff
1840 print '<tr><td>'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'</td><td class="maxwidthonsmartphone"'.(($conf->browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>'."\n";
1841 $sortparam = (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
1842 print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1843 if ($user->admin) {
1844 print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1845 }
1846 if (!getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) {
1847 print '</td>';
1848 if ($conf->browser->layout == 'phone') {
1849 print '</tr><tr>';
1850 }
1851 print '<td>'.$form->editfieldkey('Workforce', 'effectif_id', '', $object, 0).'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>';
1852 print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0, '', 0, 0, 0, '', '', 1);
1853 if ($user->admin) {
1854 print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1855 }
1856 } else {
1857 print '<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.'">';
1858 }
1859 print '</td></tr>';
1860
1861 // Legal Form
1862 print '<tr><td>'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).'</td>';
1863 print '<td colspan="3" class="maxwidthonsmartphone">';
1864 if ($object->country_id) {
1865 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
1866 } else {
1867 print $countrynotdefined;
1868 }
1869 print '</td></tr>';
1870
1871 // Capital
1872 print '<tr><td>'.$form->editfieldkey('Capital', 'capital', '', $object, 0).'</td>';
1873 print '<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.'"> ';
1874 if (isModEnabled("multicurrency")) {
1875 print '<span class="hideonsmartphone">';
1876 //print $langs->trans("Currency".$object->multicurrency_code);
1877 print $langs->getCurrencySymbol($object->multicurrency_code);
1878 print '</span></td></tr>';
1879 } else {
1880 print '<span class="hideonsmartphone">';
1881 print $langs->getCurrencySymbol($conf->currency);
1882 //print $langs->trans("Currency".$conf->currency);
1883 print '</span></td></tr>';
1884 }
1885 if (getDolGlobalInt('MAIN_MULTILANGS')) {
1886 print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
1887 print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, array(), 1, 0, 0, 'maxwidth200onsmartphone');
1888 print '</td>';
1889 print '</tr>';
1890 }
1891
1892 // Payment terms of the settlement
1893 print '<tr>';
1894 print '<td>'.$form->editfieldkey('PaymentConditions', 'cond_reglement_id', '', $object, 0).'</td>';
1895 print '<td colspan="3" class="maxwidthonsmartphone">';
1896 print $form->getSelectConditionsPaiements($object->cond_reglement_id, 'cond_reglement_id', 1, 1, 1, '', $object->deposit_percent);
1897 print '</td></tr>';
1898
1899 // Payment mode
1900 print '<tr>';
1901 print '<td>'.$form->editfieldkey('PaymentMode', 'mode_reglement_id', '', $object, 0).'</td>';
1902 print '<td colspan="3" class="maxwidthonsmartphone">';
1903 print $form->select_types_paiements($object->mode_reglement_id, 'mode_reglement_id', '', 0, 1, 1, 0, 1);
1904 print '</td></tr>';
1905
1906 // Incoterms
1907 if (isModEnabled('incoterm')) {
1908 print '<tr>';
1909 print '<td>'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).'</td>';
1910 print '<td colspan="3" class="maxwidthonsmartphone">';
1911 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
1912 print '</td></tr>';
1913 }
1914
1915 // Categories
1916 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
1917 $langs->load('categories');
1918
1919 // Customer
1920 print '<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).'</td><td colspan="3">';
1921 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', 'parent', 64, 0, 3);
1922 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1923 print "</td></tr>";
1924
1925 if (getDolGlobalString('THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
1926 print '<tr class="individualline"><td class="toptd">'.$form->editfieldkey('ContactCategoriesShort', 'contcats', '', $object, 0).'</td><td colspan="3">';
1927 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, '', 'parent', 64, 0, 3);
1928 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('contcats', $cate_arbo, GETPOST('contcats', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1929 print "</td></tr>";
1930 }
1931
1932 // Supplier
1933 if (isModEnabled("supplier_proposal") || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) {
1934 print '<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).'</td><td colspan="3">';
1935 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, '', 'parent', 64, 0, 3);
1936 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1937 print "</td></tr>";
1938 }
1939 }
1940
1941 // Multicurrency
1942 if (isModEnabled("multicurrency")) {
1943 print '<tr>';
1944 print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
1945 print '<td colspan="3" class="maxwidthonsmartphone">';
1946 print img_picto('', 'currency', 'class="pictofixedwidth"');
1947 print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)), 'multicurrency_code', 1, '', false, 'maxwidth150 widthcentpercentminusx');
1948 print '</td></tr>';
1949 }
1950
1951 // Other attributes
1952 $parameters = array('socid' => $socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
1953 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1954
1955 // Parent company
1956 if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY')) {
1957 print '<tr>';
1958 print '<td>'.$langs->trans('ParentCompany').'</td>';
1959 print '<td colspan="3" class="maxwidthonsmartphone">';
1960 print img_picto('', 'company', 'class="paddingrightonly"');
1961 print $form->select_company(GETPOST('parent_company_id'), 'parent_company_id', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
1962 print '</td></tr>';
1963 }
1964
1965 // Assign a sale representative
1966 print '<tr>';
1967 print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
1968 print '<td colspan="3" class="maxwidthonsmartphone">';
1969 // TODO Use select_doluser in multiselect mode
1970 $userlist = $form->select_dolusers($selected, '', 0, null, 0, '', '', '0', 0, 0, 'u.statut:=:1', 0, '', '', 0, 2);
1971 // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record.
1972 $selected = (GETPOSTISARRAY('commercial') ? GETPOST('commercial', 'array:int') : (GETPOSTINT('commercial') > 0 ? array(GETPOSTINT('commercial')) : array($user->id)));
1973 print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1974 print '</td></tr>';
1975
1976 // Add logo
1977 print '<tr class="hideonsmartphone">';
1978 print '<td>'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).'</td>';
1979 print '<td colspan="3">';
1980 print '<input class="flat" type="file" name="photo" id="photoinput" />';
1981 print '</td>';
1982 print '</tr>';
1983
1984 print '</table>'."\n";
1985
1986 // Accountancy codes
1987 if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {
1988 print '<table class="border centpercent">';
1989
1990 if (isModEnabled('accounting')) {
1992 // Accountancy_code_sell
1993 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
1994 print '<td>';
1995 $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
1996 print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, array(), 1, 1, '');
1997 print '</td></tr>';
1998
1999 // Accountancy_code_buy
2000 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
2001 print '<td>';
2002 $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
2003 print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, array(), 1, 1, '');
2004 print '</td></tr>';
2005 } else { // For external software
2006 // Accountancy_code_sell
2007 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
2008 print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.'">';
2009 print '</td></tr>';
2010
2011 // Accountancy_code_buy
2012 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
2013 print '<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.'">';
2014 print '</td></tr>';
2015 }
2016
2017 print '</table>';
2018 }
2019 }
2020
2021 print dol_get_fiche_end();
2022
2023 print $form->buttonsSaveCancel('AddThirdParty', 'Cancel', array(), 0, '', $dol_openinpopup);
2024
2025 print '</form>'."\n";
2026 } elseif ($action == 'edit') {
2027 //print load_fiche_titre($langs->trans("EditCompany"));
2028
2029 if ($socid) {
2030 $res = $object->fetch_optionals();
2031 //if ($res < 0) { dol_print_error($db); exit; }
2032
2034
2035 // Load object modCodeTiers
2036 $module = getDolGlobalString('SOCIETE_CODECLIENT_ADDON', 'mod_codeclient_leopard');
2037 if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
2038 $module = substr($module, 0, dol_strlen($module) - 4);
2039 }
2040 $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2041 foreach ($dirsociete as $dirroot) {
2042 $res = dol_include_once($dirroot.$module.'.php');
2043 if ($res) {
2044 break;
2045 }
2046 }
2047 $modCodeClient = new $module($db);
2048 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
2049 // We check if the prefix tag is used
2050 if ($modCodeClient->code_auto) {
2051 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
2052 } else {
2053 $prefixCustomerIsUsed = false;
2054 }
2055 $module = getDolGlobalString('SOCIETE_CODECLIENT_ADDON');
2056 if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') {
2057 $module = substr($module, 0, dol_strlen($module) - 4);
2058 }
2059 $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
2060 foreach ($dirsociete as $dirroot) {
2061 $res = dol_include_once($dirroot.$module.'.php');
2062 if ($res) {
2063 break;
2064 }
2065 }
2066 $modCodeFournisseur = new $module($db);
2067 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
2068 // We check if the prefix tag is used
2069 if ($modCodeFournisseur->code_auto) {
2070 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
2071 } else {
2072 $prefixSupplierIsUsed = false;
2073 }
2074
2075 $object->oldcopy = clone $object;
2076
2077 if (GETPOSTISSET('name')) {
2078 // We overwrite with values if posted
2079 $object->name = GETPOST('name', 'alphanohtml');
2080 $object->name_alias = GETPOST('name_alias', 'alphanohtml');
2081 $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
2082 $object->client = GETPOSTINT('client');
2083 $object->code_client = GETPOST('customer_code', 'alpha');
2084 $object->fournisseur = GETPOSTINT('fournisseur');
2085 $object->code_fournisseur = GETPOST('supplier_code', 'alpha');
2086 $object->address = GETPOST('address', 'alphanohtml');
2087 $object->zip = GETPOST('zipcode', 'alphanohtml');
2088 $object->town = GETPOST('town', 'alphanohtml');
2089 $object->country_id = GETPOST('country_id') ? GETPOSTINT('country_id') : $mysoc->country_id;
2090 $object->state_id = GETPOSTINT('state_id');
2091 $object->parent = GETPOSTINT('parent_company_id');
2092
2093 $object->socialnetworks = array();
2094 if (isModEnabled('socialnetworks')) {
2095 foreach ($socialnetworks as $key => $value) {
2096 if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
2097 $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
2098 }
2099 }
2100 }
2101
2102 $object->phone = GETPOST('phone', 'alpha');
2103 $object->phone_mobile = (string) GETPOST('phone_mobile', 'alpha');
2104 $object->fax = GETPOST('fax', 'alpha');
2105 $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
2106 $object->no_email = GETPOSTINT("no_email");
2107 $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
2108 $object->capital = GETPOSTFLOAT('capital');
2109 $object->idprof1 = GETPOST('idprof1', 'alphanohtml');
2110 $object->idprof2 = GETPOST('idprof2', 'alphanohtml');
2111 $object->idprof3 = GETPOST('idprof3', 'alphanohtml');
2112 $object->idprof4 = GETPOST('idprof4', 'alphanohtml');
2113 $object->idprof5 = GETPOST('idprof5', 'alphanohtml');
2114 $object->idprof6 = GETPOST('idprof6', 'alphanohtml');
2115 $object->typent_id = GETPOSTINT('typent_id');
2116 $object->effectif_id = GETPOSTINT('effectif_id');
2117 $object->barcode = GETPOST('barcode', 'alphanohtml');
2118 $object->forme_juridique_code = GETPOSTINT('forme_juridique_code');
2119 $object->default_lang = GETPOST('default_lang', 'alpha');
2120
2121 $object->tva_assuj = GETPOSTINT('assujtva_value');
2122 $object->vat_reverse_charge = GETPOST('vat_reverse_charge') == 'on' ? 1 : 0;
2123 $object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
2124 $object->status = GETPOSTINT('status');
2125
2126 // Webservices url/key
2127 $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
2128 $object->webservices_key = GETPOST('webservices_key', 'san_alpha');
2129
2130 if (GETPOSTISSET('accountancy_code_sell')) {
2131 $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
2132
2133 if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') {
2134 $object->accountancy_code_sell = '';
2135 } else {
2136 $object->accountancy_code_sell = $accountancy_code_sell;
2137 }
2138 }
2139 if (GETPOSTISSET('accountancy_code_buy')) {
2140 $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
2141
2142 if (empty($accountancy_code_buy) || $accountancy_code_buy == '-1') {
2143 $object->accountancy_code_buy = '';
2144 } else {
2145 $object->accountancy_code_buy = $accountancy_code_buy;
2146 }
2147 }
2148
2149 //Incoterms
2150 if (isModEnabled('incoterm')) {
2151 $object->fk_incoterms = GETPOSTINT('incoterm_id');
2152 $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha');
2153 }
2154
2155 //Local Taxes
2156 $object->localtax1_assuj = GETPOSTINT('localtax1assuj_value');
2157 $object->localtax2_assuj = GETPOSTINT('localtax2assuj_value');
2158
2159 $object->localtax1_value = GETPOST('lt1');
2160 $object->localtax2_value = GETPOST('lt2');
2161
2162 // We set country_id, and country_code label of the chosen country
2163 if ($object->country_id > 0) {
2164 $tmparray = getCountry($object->country_id, 'all');
2165 $object->country_code = $tmparray['code'];
2166 $object->country = $tmparray['label'];
2167 }
2168
2169 // We set multicurrency_code if enabled
2170 if (isModEnabled("multicurrency")) {
2171 $object->multicurrency_code = GETPOST('multicurrency_code') ? GETPOST('multicurrency_code') : $object->multicurrency_code;
2172 }
2173 }
2174
2175 if ($object->localtax1_assuj == 0) {
2176 $sub = 0;
2177 } else {
2178 $sub = 1;
2179 }
2180 if ($object->localtax2_assuj == 0) {
2181 $sub2 = 0;
2182 } else {
2183 $sub2 = 1;
2184 }
2185
2186 if (!empty($conf->use_javascript_ajax)) {
2187 print "\n".'<script type="text/javascript">';
2188 print '$(document).ready(function () {
2189 var val='.$sub.';
2190 var val2='.$sub2.';
2191 if("#localtax1assuj_value".value==undefined){
2192 if(val==1){
2193 $(".cblt1").show();
2194 }else{
2195 $(".cblt1").hide();
2196 }
2197 }
2198 if("#localtax2assuj_value".value==undefined){
2199 if(val2==1){
2200 $(".cblt2").show();
2201 }else{
2202 $(".cblt2").hide();
2203 }
2204 }
2205 $("#localtax1assuj_value").change(function() {
2206 var value=document.getElementById("localtax1assuj_value").value;
2207 if(value==1){
2208 $(".cblt1").show();
2209 }else{
2210 $(".cblt1").hide();
2211 }
2212 });
2213 $("#localtax2assuj_value").change(function() {
2214 var value=document.getElementById("localtax2assuj_value").value;
2215 if(value==1){
2216 $(".cblt2").show();
2217 }else{
2218 $(".cblt2").hide();
2219 }
2220 });
2221
2222 var canHaveCustomerCategoryIfNotCustomerProspect = ' . (getDolGlobalInt('THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ? '1' : '0') . ';
2223
2224 init_customer_categ();
2225 $("#customerprospect").change(function() {
2226 init_customer_categ();
2227 });
2228 function init_customer_categ() {
2229 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
2230 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspect)
2231 {
2232 jQuery(".visibleifcustomer").hide();
2233 }
2234 else
2235 {
2236 jQuery(".visibleifcustomer").show();
2237 }
2238 }
2239
2240 init_supplier_categ();
2241 $("#fournisseur").change(function() {
2242 init_supplier_categ();
2243 });
2244 function init_supplier_categ() {
2245 console.log("is supplier = "+jQuery("#fournisseur").val());
2246 if (jQuery("#fournisseur").val() == 0)
2247 {
2248 jQuery(".visibleifsupplier").hide();
2249 }
2250 else
2251 {
2252 jQuery(".visibleifsupplier").show();
2253 }
2254 }
2255
2256 $("#selectcountry_id").change(function() {
2257 console.log("selectcountry_id change");
2258 document.formsoc.action.value="edit";
2259 document.formsoc.submit();
2260 });
2261
2262 })';
2263 print '</script>'."\n";
2264 }
2265
2266 print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post" name="formsoc">';
2267 print '<input type="hidden" name="action" value="update">';
2268 print '<input type="hidden" name="token" value="'.newToken().'">';
2269 print '<input type="hidden" name="socid" value="'.$object->id.'">';
2270 print '<input type="hidden" name="entity" value="'.$object->entity.'">';
2271 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2272 print '<input type="hidden" name="code_auto" value="1">';
2273 }
2274
2275
2276 print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
2277
2278 print '<div class="fichecenter2">';
2279 // Call Hook tabContentEditThirdparty
2280 $parameters = array();
2281 // Note that $action and $object may be modified by hook
2282 $reshook = $hookmanager->executeHooks('tabContentEditThirdparty', $parameters, $object, $action);
2283 if (empty($reshook)) {
2284 print '<table class="border centpercent">';
2285
2286 // Ref/ID
2287 if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID')) {
2288 print '<tr><td class="titlefieldcreate">'.$langs->trans("ID").'</td><td colspan="3">';
2289 print $object->id;
2290 print '</td></tr>';
2291 }
2292
2293 // Name
2294 print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).'</td>';
2295 print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus">';
2296 print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alphanohtml', 'minwidth300');
2297 print '</td></tr>';
2298
2299 // Alias names (commercial, trademark or alias names)
2300 print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
2301 print '<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag($object->name_alias).'"></td></tr>';
2302
2303 // Prefix
2304 if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
2305 print '<tr><td>'.$form->editfieldkey('Prefix', 'prefix', '', $object, 0).'</td><td colspan="3">';
2306 // It does not change the prefix mode using the auto numbering prefix
2307 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
2308 print '<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">';
2309 print $object->prefix_comm;
2310 } else {
2311 print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).'">';
2312 }
2313 print '</td>';
2314 }
2315
2316 // Prospect/Customer/Supplier
2317 $selected = $object->client;
2318 $selectedcustomer = 0;
2319 $selectedprospect = 0;
2320 switch ($selected) {
2321 case 1:
2322 $selectedcustomer = 1;
2323 break;
2324 case 2:
2325 $selectedprospect = 1;
2326 break;
2327 case 3:
2328 $selectedprospect = 1;
2329 $selectedcustomer = 1;
2330 break;
2331 default:
2332 break;
2333 }
2334
2335 // Nature of thirdparty
2336 $selectedprospect = (GETPOSTISSET('prospect') ? GETPOSTINT('prospect') : $selectedprospect);
2337 $selectedcustomer = (GETPOSTISSET('customer') ? GETPOSTINT('customer') : $selectedcustomer);
2338 print '<tr class="marginbottomlarge height50">';
2339 if ($conf->browser->layout != 'phone') {
2340 print '<td class="titlefieldcreate">'.$form->editfieldkey('', 'customerprospect', '', $object, 0, 'string', '', 0).'</td>';
2341 }
2342 print '<td class="maxwidthonsmartphone"'.($conf->browser->layout != 'phone' ? 'colspan="3"' : 'colspan="2"').'>';
2343
2344 if (!getDolGlobalString('SOCIETE_DISABLE_PROSPECTS')) {
2345 print '<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans("Prospect").'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ? ' checked="checked"' : '').'></label></span>';
2346 }
2347
2348 if (!getDolGlobalString('SOCIETE_DISABLE_CUSTOMERS')) {
2349 print '<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans("Customer").'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ? ' checked="checked"' : '').'></label></span>';
2350 }
2351 if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))
2352 || (isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire'))) {
2353 // Supplier
2354 $selected = (GETPOSTISSET('supplier') ? GETPOSTINT('supplier') : $object->fournisseur);
2355 print '<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans("Vendor").'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selected ? ' checked="checked"' : '').'></label></span>';
2356 }
2357
2358 // Add js to manage the background of nature
2359 if ($conf->use_javascript_ajax) {
2360 print '<script>
2361 function refreshNatureCss() {
2362 jQuery(".spannature").each(function( index ) {
2363 id = $(this).attr("id").split("spannature")[1];
2364 console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
2365 if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
2366 if (id == 1) {
2367 jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
2368 }
2369 if (id == 2) {
2370 jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
2371 }
2372 if (id == 3) {
2373 jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
2374 }
2375 } else {
2376 jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
2377 }
2378 })
2379 }
2380
2381 function manageprospectcustomer(element) {
2382 console.log("We uncheck unwanted values on a nature");
2383 id = $(element).attr("id").split("spannature")[1];
2384 if ( id == 1){
2385 $("#spannature2 .checkforselect").prop("checked", false);
2386 }
2387 if ( id == 2){
2388 $("#spannature1 .checkforselect").prop("checked", false);
2389 }
2390 }
2391
2392 jQuery(".spannature").click(function(){
2393 console.log("We click on a nature");
2394 '.(getDolGlobalString('SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ? 'manageprospectcustomer($(this));' : '').'
2395 refreshNatureCss();
2396 });
2397 refreshNatureCss();
2398 </script>';
2399 }
2400 print '</td>';
2401 print '</tr>';
2402
2403 print '<tr><td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td colspan="3">';
2404 print '<table class="nobordernopadding"><tr><td>';
2405 $tmpcode = $object->code_client;
2406 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2407 $tmpcode = $modCodeClient->getNextValue($object, 0);
2408 }
2409 print '<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
2410 print '</td><td>';
2411 $s = $modCodeClient->getToolTip($langs, $object, 0);
2412 print $form->textwithpicto('', $s, 1);
2413 print '</td></tr></table>';
2414 print '</td>';
2415
2416 if ($conf->browser->layout == 'phone') {
2417 print '</tr><tr>';
2418 }
2419
2420 print '<td>'.$form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0).'</td><td colspan="3">';
2421
2422 if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
2423 print '<table class="nobordernopadding"><tr><td>';
2424 $tmpcode = $object->code_fournisseur;
2425 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2426 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2427 }
2428 print '<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
2429 print '</td><td>';
2430 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2431 print $form->textwithpicto('', $s, 1);
2432 print '</td></tr></table>';
2433 }
2434 print '</td></tr>';
2435
2436
2437 // Barcode
2438 if (isModEnabled('barcode')) {
2439 print '<tr><td class="tdtop">'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
2440 print '<td colspan="3">';
2441 print img_picto('', 'barcode', 'class="pictofixedwidth"');
2442 print '<input type="text" class="minwidth100 maxwidth200 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">';
2443 print '</td></tr>';
2444 }
2445
2446 // Status
2447 print '<tr><td>'.$form->editfieldkey('Status', 'status', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? '' : ' colspan="3"').'>';
2448 print $form->selectarray('status', array('0' => $langs->trans('ActivityCeased'), '1' => $langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
2449 print '</td></tr>';
2450
2451 //$colspan = ($conf->browser->layout == 'phone' ? 2 : 4);
2452 $colspan = 4;
2453 print '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>';
2454
2455 // Address
2456 print '<tr><td class="tdtop">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
2457 print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2458 print dol_escape_htmltag($object->address, 0, 1);
2459 print '</textarea>';
2460 print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
2461 print '</td></tr>';
2462
2463 // Zip / Town
2464 print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>';
2465 print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
2466 print '</td>';
2467 if ($conf->browser->layout == 'phone') {
2468 print '</tr><tr>';
2469 }
2470 print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>';
2471 print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
2472 print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
2473 print '</td></tr>';
2474
2475 // Country
2476 print '<tr><td>'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).'</td><td colspan="3">';
2477 print img_picto('', 'globe-americas', 'class="pictofixedwidth"');
2478 print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth200 maxwidth400 widthcentpercentminusx');
2479 if ($user->admin) {
2480 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2481 }
2482 print '</td></tr>';
2483
2484 // State
2485 if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) {
2486 if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) {
2487 print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td colspan="3">';
2488 } else {
2489 print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td colspan="3">';
2490 }
2491
2492 print img_picto('', 'state', 'class="pictofixedwidth"');
2493 print $formcompany->select_state($object->state_id, $object->country_code, 'state_id', 'minwidth200 maxwidth400 widthcentpercentminusx');
2494 print '</td></tr>';
2495 }
2496
2497 // Phone / Fax
2498 print '<tr><td>'.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).'</td>';
2499 print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning', 'class="pictofixedwidth"').' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $object->phone).'"></td>';
2500 if ($conf->browser->layout == 'phone') {
2501 print '</tr><tr>';
2502 }
2503 print '<td>'.$form->editfieldkey('PhoneMobile', 'phone_mobile', GETPOST('phone_mobile', 'alpha'), $object, 0).'</td>';
2504 print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_mobile', 'class="pictofixedwidth"').' <input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
2505
2506 print '<td>'.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'</td>';
2507 print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax', 'class="pictofixedwidth"').' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('fax') ? GETPOST('fax', 'alpha') : $object->fax).'"></td>';
2508 print '</tr>';
2509
2510 // Web
2511 print '<tr><td>'.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).'</td>';
2512 print '<td colspan="3">'.img_picto('', 'globe', 'class="pictofixedwidth"').' <input type="text" name="url" id="url" class="maxwidth200onsmartphone maxwidth300 widthcentpercentminusx " value="'.(GETPOSTISSET('url') ? GETPOST('url', 'alpha') : $object->url).'"></td></tr>';
2513
2514 // EMail
2515 print '<tr><td>'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (getDolGlobalString('SOCIETE_EMAIL_MANDATORY'))).'</td>';
2516 print '<td'.(($conf->browser->layout == 'phone') || !isModEnabled('mailing') ? ' colspan="3"' : '').'>';
2517 print img_picto('', 'object_email', 'class="pictofixedwidth"');
2518 print '<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'">';
2519 print '</td>';
2520
2521 // Unsubscribe
2522 if (isModEnabled('mailing')) {
2523 if ($conf->browser->layout == 'phone') {
2524 print '</tr><tr>';
2525 }
2526 if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
2527 print "\n".'<script type="text/javascript">'."\n";
2528
2529 print '
2530 jQuery(document).ready(function () {
2531 function init_check_no_email(input) {
2532 if (input.val()!="") {
2533 $(".noemail").addClass("fieldrequired");
2534 } else {
2535 $(".noemail").removeClass("fieldrequired");
2536 }
2537 }
2538 $("#email").keyup(function() {
2539 init_check_no_email($(this));
2540 });
2541 init_check_no_email($("#email"));
2542 })'."\n";
2543 print '</script>'."\n";
2544 }
2545 if (!GETPOSTISSET("no_email") && !empty($object->email)) {
2546 $result = $object->getNoEmail();
2547 if ($result < 0) {
2548 setEventMessages($object->error, $object->errors, 'errors');
2549 }
2550 }
2551 print '<td class="noemail"><label for="no_email">'.$langs->trans("No_Email").'</label></td>';
2552 print '<td>';
2553 $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
2554 print $form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, false, $useempty);
2555 print '</td>';
2556 }
2557 print '</tr>';
2558
2559 // Social network
2560 if (isModEnabled('socialnetworks')) {
2561 //$colspan = ($conf->browser->layout == 'phone' ? 2 : 4);
2562 $colspan = 4;
2563
2564 $object->showSocialNetwork($socialnetworks, $colspan);
2565
2566 print '<tr><td'.($colspan ? ' colspan="'.$colspan.'"' : '').'><hr></td></tr>';
2567 }
2568
2569 // Prof ids
2570 $i = 1;
2571 $j = 0;
2572 $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2);
2573 $NBPROFIDMIN = getDolGlobalInt('THIRDPARTY_MIN_NB_PROF_ID', 2);
2574 $NBPROFIDMAX = getDolGlobalInt('THIRDPARTY_MAX_NB_PROF_ID', 6);
2575 while ($i <= $NBPROFIDMAX) {
2576 $idprof = $langs->transcountry('ProfId'.$i, $object->country_code);
2577 if ($idprof != '-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate['ProfId'.$i.$object->country_code]))) {
2578 $key = 'idprof'.$i;
2579
2580 if (($j % $NBCOLS) == 0) {
2581 print '<tr>';
2582 }
2583
2584 $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY';
2585 print '<td>'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).'</td><td>';
2586 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2587 print '</td>';
2588 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2589 print '</tr>';
2590 }
2591 $j++;
2592 }
2593 $i++;
2594 }
2595 if ($NBCOLS > 0 && ($j % 2) == 1) {
2596 print '<td colspan="2"></td></tr>';
2597 }
2598
2599 // VAT is used
2600 print '<tr><td>'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).'</td><td colspan="3">';
2601 print '<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . ($object->tva_assuj ? 'checked="checked"' : '') . ' value="1">';
2602 print '</td></tr>';
2603
2604 // Local Taxes
2605 //TODO: Place into a function to control showing by country or study better option
2606 if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
2607 print '<tr><td>'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).'</td><td>';
2608 print '<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . ($object->localtax1_assuj ? 'checked="checked"' : '') . ' value="1">';
2609 if (!isOnlyOneLocalTax(1)) {
2610 print '<span class="cblt1"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2611 $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
2612 print '</span>';
2613 }
2614 print '</td>';
2615 print '</tr><tr>';
2616 print '<td>'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).'</td><td>';
2617 print '<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . ($object->localtax2_assuj ? 'checked="checked"' : '') . ' value="1"></td></tr>';
2618 if (!isOnlyOneLocalTax(2)) {
2619 print '<span class="cblt2"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2620 $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
2621 print '</span>';
2622 }
2623 print '</td></tr>';
2624 } elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") {
2625 print '<tr><td>'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).'</td><td colspan="3">';
2626 print '<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . ($object->localtax1_assuj ? 'checked="checked"' : '') . ' value="1">';
2627 if (!isOnlyOneLocalTax(1)) {
2628 print '<span class="cblt1"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2629 $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
2630 print '</span>';
2631 }
2632 print '</td></tr>';
2633 } elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") {
2634 print '<tr><td>'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).'</td><td colspan="3">';
2635 print '<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . ($object->localtax2_assuj ? 'checked="checked"' : '') . ' value="1">';
2636 if (!isOnlyOneLocalTax(2)) {
2637 print '<span class="cblt2"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2638 $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
2639 print '</span>';
2640 }
2641 print '</td></tr>';
2642 }
2643
2644 // VAT reverse charge by default
2645 if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
2646 print '<tr><td>' . $form->editfieldkey('VATReverseChargeByDefault', 'vat_reverse_charge', '', $object, 0) . '</td><td colspan="3">';
2647 print '<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge == '1' ? ' checked' : '').'>';
2648 print '</td></tr>';
2649 }
2650
2651 // VAT Code
2652 print '<tr><td>'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).'</td>';
2653 print '<td colspan="3">';
2654 $s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
2655
2656 if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) {
2657 $s .= ' &nbsp; ';
2658
2659 if ($conf->use_javascript_ajax) {
2660 $widthpopup = 600;
2661 if (!empty($conf->dol_use_jmobile)) {
2662 $widthpopup = 350;
2663 }
2664 $heightpopup = 400;
2665 print "\n";
2666 print '<script type="text/javascript">';
2667 print "function CheckVAT(a) {\n";
2668 if ($mysoc->country_code == 'GR' && $object->country_code == 'GR' && !empty($u)) {
2669 print "GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
2670 } else {
2671 print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n";
2672 }
2673 print "}\n";
2674 print '</script>';
2675 print "\n";
2676 $s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
2677 $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
2678 } else {
2679 $s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
2680 }
2681 }
2682 print $s;
2683 print '</td>';
2684 print '</tr>';
2685
2686 // Type - Workforce/Staff
2687 print '<tr><td>'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'</td><td class="maxwidthonsmartphone"'.(($conf->browser->layout == 'phone' || getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) ? ' colspan="3"' : '').'>';
2688 print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0, '', 0, 0, 0, (!getDolGlobalString('SOCIETE_SORT_ON_TYPEENT') ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
2689 if ($user->admin) {
2690 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2691 }
2692 if (!getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) {
2693 print '</td>';
2694 if ($conf->browser->layout == 'phone') {
2695 print '</tr><tr>';
2696 }
2697 print '<td>'.$form->editfieldkey('Workforce', 'effectif_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
2698 print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0, '', 0, 0, 0, '', '', 1);
2699 if ($user->admin) {
2700 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2701 }
2702 } else {
2703 print '<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.'">';
2704 }
2705 print '</td></tr>';
2706
2707 // Juridical type
2708 print '<tr><td>'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).'</td><td class="maxwidthonsmartphone" colspan="3">';
2709 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
2710 print '</td></tr>';
2711
2712 // Capital
2713 print '<tr><td>'.$form->editfieldkey('Capital', 'capital', '', $object, 0).'</td>';
2714 print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2715 print $object->capital != '' && $object->capital != 0 ? dol_escape_htmltag(price($object->capital)) : '';
2716 if (isModEnabled("multicurrency")) {
2717 print '"> <span class="hideonsmartphone">'.$langs->trans("Currency".$object->multicurrency_code).'</span></td></tr>';
2718 } else {
2719 print '"> <span class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
2720 }
2721
2722 // Default language
2723 if (getDolGlobalInt('MAIN_MULTILANGS')) {
2724 print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n";
2725 print img_picto('', 'language', 'class="pictofixedwidth"').$formadmin->select_language($object->default_lang, 'default_lang', 0, array(), '1', 0, 0, 'maxwidth300 widthcentpercentminusx');
2726 print '</td>';
2727 print '</tr>';
2728 }
2729
2730 // Incoterms
2731 if (isModEnabled('incoterm')) {
2732 print '<tr>';
2733 print '<td>'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).'</td>';
2734 print '<td colspan="3" class="maxwidthonsmartphone">';
2735 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
2736 print '</td></tr>';
2737 }
2738
2739 // Categories
2740 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
2741 // Customer
2742 print '<tr class="visibleifcustomer"><td>'.$form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0).'</td>';
2743 print '<td colspan="3">';
2744 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', '', 64, 0, 3);
2745 $c = new Categorie($db);
2746 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2747 $arrayselected = array();
2748 foreach ($cats as $cat) {
2749 $arrayselected[] = $cat->id;
2750 }
2751 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
2752 print "</td></tr>";
2753
2754 // Supplier
2755 if ((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) {
2756 print '<tr class="visibleifsupplier"><td>'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).'</td>';
2757 print '<td colspan="3">';
2758 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, '', '', 64, 0, 3);
2759 $c = new Categorie($db);
2760 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2761 $arrayselected = array();
2762 foreach ($cats as $cat) {
2763 $arrayselected[] = $cat->id;
2764 }
2765 print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
2766 print "</td></tr>";
2767 }
2768 }
2769
2770 // Multicurrency
2771 if (isModEnabled("multicurrency")) {
2772 print '<tr>';
2773 print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
2774 print '<td colspan="3" class="maxwidthonsmartphone">';
2775 print img_picto('', 'currency', 'class="pictofixedwidth"');
2776 print $form->selectMultiCurrency((GETPOSTISSET('multicurrency_code') ? GETPOST('multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)), 'multicurrency_code', 1, '', false, 'maxwidth150 widthcentpercentminusx');
2777 print '</td></tr>';
2778 }
2779
2780 // Other attributes
2781 $parameters = array('socid' => $socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
2782 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
2783
2784 // Parent company
2785 if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY')) {
2786 print '<tr>';
2787 print '<td>'.$langs->trans('ParentCompany').'</td>';
2788 print '<td colspan="3" class="maxwidthonsmartphone">';
2789 print img_picto('', 'company', 'class="pictofixedwidth"');
2790 print $form->select_company(GETPOST('parent_company_id') ? GETPOST('parent_company_id') : $object->parent, 'parent_company_id', '', 'SelectThirdParty', 0, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx');
2791 print '</td></tr>';
2792 }
2793
2794 // Logo
2795 print '<tr class="hideonsmartphone">';
2796 print '<td>'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).'</td>';
2797 print '<td colspan="3">';
2798 if ($object->logo) {
2799 print $form->showphoto('societe', $object, 100, 0, 0, 'inline-block');
2800 }
2801 $caneditfield = 1;
2802 if ($caneditfield) {
2803 if ($object->logo) {
2804 print "<br>\n";
2805 }
2806 print '<table class="nobordernopadding">';
2807 if ($object->logo) {
2808 print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans("Delete").'</photo><br></td></tr>';
2809 }
2810 //print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
2811 print '<tr><td>';
2812 $maxfilesizearray = getMaxFileSizeArray();
2813 $maxmin = $maxfilesizearray['maxmin'];
2814 if ($maxmin > 0) {
2815 print '<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).'">'; // MAX_FILE_SIZE must precede the field type=file
2816 }
2817 print '<input type="file" class="flat" name="photo" id="photoinput">';
2818 print '</td></tr>';
2819 print '</table>';
2820 }
2821 print '</td>';
2822 print '</tr>';
2823
2824 // Assign sale representative
2825 print '<tr>';
2826 print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
2827 print '<td colspan="3" class="maxwidthonsmartphone">';
2828 $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'u.statut:=:1', 0, '', '', 0, 1);
2829 $arrayselected = GETPOST('commercial', 'array');
2830 if (empty($arrayselected)) {
2831 $arrayselected = $object->getSalesRepresentatives($user, 1);
2832 }
2833 print img_picto('', 'user', 'class="pictofixedwidth"').$form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1);
2834 print '</td></tr>';
2835
2836 print '</table>';
2837
2838 if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {
2839 print '<br>';
2840 print '<table class="border centpercent">';
2841
2842 if (isModEnabled('accounting')) {
2844 // Accountancy_code_sell
2845 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
2846 print '<td>';
2847 print $formaccounting->select_account($object->accountancy_code_sell, 'accountancy_code_sell', 1, array(), 1, 1);
2848 print '</td></tr>';
2849
2850 // Accountancy_code_buy
2851 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
2852 print '<td>';
2853 print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, array(), 1, 1);
2854 print '</td></tr>';
2855 } else { // For external software
2856 // Accountancy_code_sell
2857 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancySellCode").'</td>';
2858 print '<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.'">';
2859 print '</td></tr>';
2860
2861 // Accountancy_code_buy
2862 print '<tr><td class="titlefieldcreate">'.$langs->trans("ProductAccountancyBuyCode").'</td>';
2863 print '<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.'">';
2864 print '</td></tr>';
2865 }
2866 print '</table>';
2867 }
2868 }
2869
2870 print '</div>';
2871
2872 print dol_get_fiche_end();
2873
2874 print $form->buttonsSaveCancel();
2875
2876 print '</form>';
2877 }
2878 } else {
2879 // View
2880 if (!empty($object->id)) {
2881 $res = $object->fetch_optionals();
2882 }
2883 //if ($res < 0) { dol_print_error($db); exit; }
2884
2885
2887
2888 print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company', 0, '', '', 0, '', 1);
2889
2890 $formconfirm = '';
2891
2892 // Confirm delete third party
2893 if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2894 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
2895 }
2896
2897 if ($action == 'merge') {
2898 $formquestion = array(
2899 array(
2900 'name' => 'soc_origin',
2901 'label' => $langs->trans('MergeOriginThirdparty'),
2902 'type' => 'other',
2903 'value' => $form->select_company('', 'soc_origin', '', 'SelectThirdParty', 1, 0, array(), 0, 'minwidth200', '', '', 1, array(), false, array($object->id))
2904 )
2905 );
2906
2907 $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250);
2908 }
2909
2910 // Clone confirmation
2911 if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js
2912 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) { // Always output when not jmobile nor js
2913 // Define confirmation messages
2914 $formquestionclone = array(
2915 'text' => $langs->trans("ConfirmClone"),
2916 0 => array('type' => 'text', 'name' => 'clone_name', 'label' => $langs->trans("NewSocNameForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->nom : $tmpcode, 'morecss' => 'width250'),
2917 );
2918 $formconfirm .= $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneThirdparties', $object->name), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 350, 600);
2919 }
2920
2921 // Call Hook formConfirm
2922 $parameters = array('formConfirm' => $formconfirm);
2923 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2924 if (empty($reshook)) {
2925 $formconfirm .= $hookmanager->resPrint;
2926 } elseif ($reshook > 0) {
2927 $formconfirm = $hookmanager->resPrint;
2928 }
2929
2930 // Print form confirm
2931 print $formconfirm;
2932
2933 dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
2934
2935 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2936
2937 dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
2938
2939 // Call Hook tabContentViewThirdparty
2940 $parameters = array();
2941 // Note that $action and $object may be modified by hook
2942 $reshook = $hookmanager->executeHooks('tabContentViewThirdparty', $parameters, $object, $action);
2943 if (empty($reshook)) {
2944 print '<div class="fichecenter">';
2945 print '<div class="fichehalfleft">';
2946
2947 print '<div class="underbanner clearboth"></div>';
2948 print '<table class="border tableforfield centpercent">';
2949
2950 // Type Prospect/Customer/Supplier
2951 print '<tr><td class="titlefieldmiddle">'.$langs->trans('NatureOfThirdParty').'</td><td>';
2952 print $object->getTypeUrl(1);
2953 print '</td></tr>';
2954
2955 // Prefix
2956 if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
2957 print '<tr><td>'.$langs->trans('Prefix').'</td><td>'.dol_escape_htmltag($object->prefix_comm).'</td>';
2958 print '</tr>';
2959 }
2960
2961 // Customer code
2962 if ($object->client) {
2963 print '<tr><td>';
2964 print $langs->trans('CustomerCode');
2965 print '</td>';
2966 print '<td>';
2968 $tmpcheck = $object->check_codeclient();
2969 if ($tmpcheck != 0 && $tmpcheck != -5) {
2970 print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
2971 }
2972 print '</td>';
2973 print '</tr>';
2974 }
2975
2976 // Supplier code
2977 if (((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) && $object->fournisseur) {
2978 print '<tr><td>';
2979 print $langs->trans('SupplierCode').'</td><td>';
2981 $tmpcheck = $object->check_codefournisseur();
2982 if ($tmpcheck != 0 && $tmpcheck != -5) {
2983 print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
2984 }
2985 print '</td>';
2986 print '</tr>';
2987 }
2988
2989 // Barcode
2990 if (isModEnabled('barcode')) {
2991 print '<tr><td>';
2992 print $langs->trans('Gencod').'</td><td>'.showValueWithClipboardCPButton(dol_escape_htmltag($object->barcode));
2993 print '</td>';
2994 print '</tr>';
2995 }
2996
2997 // Prof ids
2998 $i = 1;
2999 $j = 0;
3000 $NBPROFIDMIN = getDolGlobalInt('THIRDPARTY_MIN_NB_PROF_ID', 2);
3001 $NBPROFIDMAX = getDolGlobalInt('THIRDPARTY_MAX_NB_PROF_ID', 6);
3002 while ($i <= $NBPROFIDMAX) {
3003 $idprof = $langs->transcountry('ProfId'.$i, $object->country_code);
3004 if (!empty($conf->dol_optimize_smallscreen)) {
3005 $idprof = $langs->transcountry('ProfId'.$i.'Short', $object->country_code);
3006 }
3007 if ($idprof != '-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate['ProfId'.$i.$object->country_code]))) {
3008 print '<tr>';
3009 print '<td>'.$idprof.'</td><td>';
3010 $key = 'idprof'.$i;
3011 print dol_print_profids($object->$key, 'ProfId'.$i, $object->country_code, 1);
3012 if ($object->$key) {
3013 if ($object->id_prof_check($i, $object) > 0) {
3014 if (!empty($object->id_prof_url($i, $object))) {
3015 print ' &nbsp; '.$object->id_prof_url($i, $object);
3016 }
3017 } else {
3018 print ' <span class="error">('.$langs->trans("ErrorWrongValue").')</span>';
3019 }
3020 }
3021 print '</td>';
3022 print '</tr>';
3023 $j++;
3024 }
3025 $i++;
3026 }
3027
3028
3029 // This fields are used to know VAT to include in an invoice when the thirdparty is making a sale, so when it is a supplier.
3030 // We don't need them into customer profile.
3031 // Except for spain and localtax where localtax depends on buyer and not seller
3032
3033 if ($object->fournisseur) {
3034 // VAT is used
3035 print '<tr><td>';
3036 print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling'));
3037 print '</td><td>';
3038 print yn($object->tva_assuj);
3039 print '</td>';
3040 print '</tr>';
3041
3042 if (getDolGlobalString('ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
3043 // VAT reverse charge by default
3044 print '<tr><td>';
3045 print $form->textwithpicto($langs->trans('VATReverseChargeByDefault'), $langs->trans('VATReverseChargeByDefaultDesc'));
3046 print '</td><td>';
3047 print '<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge == '1' ? ' checked' : '') . ' disabled>';
3048 print '</td>';
3049 print '</tr>';
3050 }
3051 }
3052
3053 // Local Taxes
3054 if ($object->fournisseur || $mysoc->country_code == 'ES') {
3055 if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") {
3056 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
3057 print yn($object->localtax1_assuj);
3058 print '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
3059 print yn($object->localtax2_assuj);
3060 print '</td></tr>';
3061
3062 if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) {
3063 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
3064 print '<input type="hidden" name="action" value="set_localtax1">';
3065 print '<input type="hidden" name="token" value="'.newToken().'">';
3066 print '<tr><td>'.$langs->transcountry("Localtax1", $mysoc->country_code).' <a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editRE&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
3067 if ($action == 'editRE') {
3068 print '<td class="left">';
3069 $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
3070 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
3071 } else {
3072 print '<td>'.$object->localtax1_value.'</td>';
3073 }
3074 print '</tr></form>';
3075 }
3076 if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) {
3077 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
3078 print '<input type="hidden" name="action" value="set_localtax2">';
3079 print '<input type="hidden" name="token" value="'.newToken().'">';
3080 print '<tr><td>'.$langs->transcountry("Localtax2", $mysoc->country_code).'<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
3081 if ($action == 'editIRPF') {
3082 print '<td class="left">';
3083 $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
3084 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
3085 } else {
3086 print '<td>'.$object->localtax2_value.'</td>';
3087 }
3088 print '</tr></form>';
3089 }
3090 } elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1") {
3091 print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
3092 print yn($object->localtax1_assuj);
3093 print '</td></tr>';
3094 if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1))) {
3095 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
3096 print '<input type="hidden" name="action" value="set_localtax1">';
3097 print '<input type="hidden" name="token" value="'.newToken().'">';
3098 print '<tr><td> '.$langs->transcountry("Localtax1", $mysoc->country_code).'<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editRE&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
3099 if ($action == 'editRE') {
3100 print '<td class="left">';
3101 $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
3102 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
3103 } else {
3104 print '<td>'.$object->localtax1_value.'</td>';
3105 }
3106 print '</tr></form>';
3107 }
3108 } elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1") {
3109 print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
3110 print yn($object->localtax2_assuj);
3111 print '</td></tr>';
3112 if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2))) {
3113 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
3114 print '<input type="hidden" name="action" value="set_localtax2">';
3115 print '<input type="hidden" name="token" value="'.newToken().'">';
3116 print '<tr><td> '.$langs->transcountry("Localtax2", $mysoc->country_code).' <a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
3117 if ($action == 'editIRPF') {
3118 print '<td class="left">';
3119 $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
3120 print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'"></td>';
3121 } else {
3122 print '<td>'.$object->localtax2_value.'</td>';
3123 }
3124 print '</tr></form>';
3125 }
3126 }
3127 }
3128
3129 // Sale tax code (VAT code)
3130 print '<tr>';
3131 print '<td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
3132 if ($object->tva_intra) {
3133 $s = '';
3134 $s .= dol_print_profids($object->tva_intra, 'VAT', $object->country_code, 1);
3135 $s .= '<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.'">';
3136
3137 if (!getDolGlobalString('MAIN_DISABLEVATCHECK') && isInEEC($object)) {
3138 $s .= ' &nbsp; ';
3139
3140 if ($conf->use_javascript_ajax) {
3141 $widthpopup = 600;
3142 if (!empty($conf->dol_use_jmobile)) {
3143 $widthpopup = 350;
3144 }
3145 $heightpopup = 400;
3146 print "\n";
3147 print '<script type="text/javascript">';
3148 print "function CheckVAT(a) {\n";
3149 if ($mysoc->country_code == 'GR' && $object->country_code == 'GR' && !empty($u)) {
3150 print "GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
3151 } else {
3152 print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n";
3153 }
3154 print "}\n";
3155 print '</script>';
3156 print "\n";
3157 $s .= '<a href="#" class="hideonsmartphone" onclick="CheckVAT(jQuery(\'#tva_intra\').val());">'.$langs->trans("VATIntraCheck").'</a>';
3158 $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
3159 } else {
3160 $s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
3161 }
3162 }
3163 print $s;
3164 } else {
3165 print '&nbsp;';
3166 }
3167 print '</td></tr>';
3168
3169 // Warehouse
3170 if (isModEnabled('stock') && getDolGlobalString('SOCIETE_ASK_FOR_WAREHOUSE')) {
3171 $langs->load('stocks');
3172 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
3173 $formproduct = new FormProduct($db);
3174 print '<tr class="nowrap">';
3175 print '<td>';
3176 print $form->editfieldkey("Warehouse", 'warehouse', '', $object, $user->hasRight('societe', 'creer'));
3177 print '</td><td>';
3178 if ($action == 'editwarehouse') {
3179 $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'fk_warehouse', 1);
3180 } else {
3181 if ($object->fk_warehouse > 0) {
3182 print img_picto('', 'stock', 'class="paddingrightonly"');
3183 }
3184 $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_warehouse, 'none');
3185 }
3186 print '</td>';
3187 print '</tr>';
3188 }
3189
3190 print '</table>';
3191 print '</div>';
3192
3193 print '<div class="fichehalfright">';
3194
3195 print '<div class="underbanner clearboth"></div>';
3196 print '<table class="border tableforfield centpercent">';
3197
3198 // Tags / categories
3199 if (isModEnabled('category') && $user->hasRight('categorie', 'lire')) {
3200 // Customer
3201 if ($object->prospect || $object->client || getDolGlobalString('THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT')) {
3202 print '<tr><td class="titlefieldmiddle">'.$langs->trans("CustomersCategoriesShort").'</td>';
3203 print '<td>';
3204 print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
3205 print "</td></tr>";
3206 }
3207
3208 // Supplier
3209 if (((isModEnabled("fournisseur") && $user->hasRight('fournisseur', 'lire') && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire'))) && $object->fournisseur) {
3210 print '<tr><td class="titlefieldmiddle">'.$langs->trans("SuppliersCategoriesShort").'</td>';
3211 print '<td>';
3212 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
3213 print "</td></tr>";
3214 }
3215 }
3216
3217
3218 // Third-Party Type
3219 print '<tr><td class="titlefieldmiddle">';
3220 print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('ThirdPartyType').'</td>';
3221 if ($action != 'editthirdpartytype' && $user->hasRight('societe', 'creer')) {
3222 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editthirdpartytype&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
3223 }
3224 print '</tr></table>';
3225 print '</td><td>';
3226 $html_name = ($action == 'editthirdpartytype') ? 'typent_id' : 'none';
3227 $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->typent_id, $html_name, '');
3228 print '</td></tr>';
3229
3230 // Workforce/Staff
3231 if (!getDolGlobalString('SOCIETE_DISABLE_WORKFORCE')) {
3232 print '<tr><td>'.$langs->trans("Workforce").'</td><td>'.$object->effectif.'</td></tr>';
3233 }
3234
3235 // Legal
3236 print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td>'.dolPrintHTML($object->forme_juridique).'</td></tr>';
3237
3238 // Capital
3239 print '<tr><td>'.$langs->trans('Capital').'</td><td>';
3240 if ($object->capital) {
3241 if (isModEnabled("multicurrency") && !empty($object->multicurrency_code)) {
3242 print price($object->capital, 0, $langs, 0, -1, -1, $object->multicurrency_code);
3243 } else {
3244 print price($object->capital, 0, $langs, 0, -1, -1, $conf->currency);
3245 }
3246 } else {
3247 print '&nbsp;';
3248 }
3249 print '</td></tr>';
3250
3251 // Unsubscribe opt-out
3252 if (isModEnabled('mailing')) {
3253 $result = $object->getNoEmail();
3254 if ($result < 0) {
3255 setEventMessages($object->error, $object->errors, 'errors');
3256 }
3257 print '<tr><td>'.$langs->trans("No_Email").'</td><td>';
3258 if ($object->email) {
3259 print yn($object->no_email);
3260 } else {
3261 $langs->load("mails");
3262 print '<span class="opacitymedium">'.$langs->trans("EMailNotDefined").'</span>';
3263 }
3264
3265 $langs->load("mails");
3266 print ' &nbsp; <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans("NbOfEMailingsSend")).'">'.$object->getNbOfEMailings().'</span>';
3267
3268 print '</td></tr>';
3269 }
3270
3271 // Default language
3272 if (getDolGlobalInt('MAIN_MULTILANGS')) {
3273 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
3274 print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
3275 //$s=picto_from_langcode($object->default_lang);
3276 //print ($s?$s.' ':'');
3277 $langs->load("languages");
3278 $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
3279 print picto_from_langcode($object->default_lang, 'class="paddingrightonly saturatemedium opacitylow"');
3280 print $labellang;
3281 print '</td></tr>';
3282 }
3283
3284 // Incoterms
3285 if (isModEnabled('incoterm')) {
3286 print '<tr><td>';
3287 print '<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans('IncotermLabel').'</td>';
3288 if ($action != 'editincoterm' && $user->hasRight('societe', 'creer')) {
3289 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=editincoterm&token='.newToken().'">'.img_edit('', 1).'</a></td>';
3290 }
3291 print '</tr></table>';
3292 print '</td><td colspan="3">';
3293 if ($action != 'editincoterm') {
3294 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
3295 } else {
3296 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?socid='.$object->id);
3297 }
3298 print '</td></tr>';
3299 }
3300
3301 // Multicurrency
3302 if (isModEnabled("multicurrency")) {
3303 print '<tr>';
3304 print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
3305 print '<td>';
3306 print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code, 1) : '';
3307 print '</td></tr>';
3308 }
3309
3310 if (getDolGlobalString('ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY')) {
3311 // Accountancy sell code
3312 print '<tr><td class="nowrap">';
3313 print $langs->trans("ProductAccountancySellCode");
3314 print '</td><td colspan="2">';
3315 if (isModEnabled('accounting')) {
3316 if (!empty($object->accountancy_code_sell)) {
3317 $accountingaccount = new AccountingAccount($db);
3318 $accountingaccount->fetch(0, $object->accountancy_code_sell, 1);
3319
3320 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
3321 }
3322 } else {
3323 print $object->accountancy_code_sell;
3324 }
3325 print '</td></tr>';
3326
3327 // Accountancy buy code
3328 print '<tr><td class="nowrap">';
3329 print $langs->trans("ProductAccountancyBuyCode");
3330 print '</td><td colspan="2">';
3331 if (isModEnabled('accounting')) {
3332 if (!empty($object->accountancy_code_buy)) {
3333 $accountingaccount2 = new AccountingAccount($db);
3334 $accountingaccount2->fetch(0, $object->accountancy_code_buy, 1);
3335
3336 print $accountingaccount2->getNomUrl(0, 1, 1, '', 1);
3337 }
3338 } else {
3339 print $object->accountancy_code_buy;
3340 }
3341 print '</td></tr>';
3342 }
3343
3344 // Other attributes
3345 $parameters = array('socid' => $socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
3346 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
3347
3348 // Parent company
3349 if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY')) {
3350 print '<tr><td>';
3351 print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('ParentCompany').'</td>';
3352 if ($action != 'editparentcompany' && $user->hasRight('societe', 'creer')) {
3353 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editparentcompany&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
3354 }
3355 print '</tr></table>';
3356 print '</td><td>';
3357 $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none';
3358 $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, '', 1, 0, 0, array(), 0, array($object->id));
3359 print '</td></tr>';
3360 }
3361
3362 // Sales representative
3363 include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
3364
3365 // Module Adherent
3366 if (isModEnabled('member')) {
3367 $langs->load("members");
3368 print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
3369 print '<td>';
3370 $adh = new Adherent($db);
3371 $result = $adh->fetch(0, '', $object->id);
3372 if ($result > 0) {
3373 $adh->ref = $adh->getFullName($langs);
3374 print $adh->getNomUrl(-1);
3375 } else {
3376 print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
3377 }
3378 print "</td></tr>\n";
3379 }
3380
3381 // Link user (you must create a contact to get a user)
3382 /*
3383 print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
3384 if ($object->user_id) {
3385 $dolibarr_user = new User($db);
3386 $result = $dolibarr_user->fetch($object->user_id);
3387 print $dolibarr_user->getLoginUrl(-1);
3388 } else {
3389 //print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
3390 if (!$object->user_id && $user->hasRight('user', 'user', 'creer')) {
3391 print '<a class="aaa" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=create_user&token='.newToken().'">'.img_picto($langs->trans("CreateDolibarrLogin"), 'add').' '.$langs->trans("CreateDolibarrLogin").'</a>';
3392 }
3393 }
3394 print '</td></tr>';
3395 */
3396
3397 print '</table>';
3398 print '</div>';
3399
3400 print '</div>';
3401 print '<div class="clearboth"></div>';
3402 }
3403
3404 print dol_get_fiche_end();
3405
3406
3407 /*
3408 * Actions
3409 */
3410 if ($action != 'presend') {
3411 print '<div class="tabsAction">'."\n";
3412
3413 $parameters = array();
3414 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3415 if (empty($reshook)) {
3416 $at_least_one_email_contact = false;
3417 $TContact = $object->contact_array_objects();
3418 foreach ($TContact as &$contact) {
3419 if (!empty($contact->email)) {
3420 $at_least_one_email_contact = true;
3421 break;
3422 }
3423 }
3424
3425 if (empty($user->socid)) {
3426 $langs->load("mails");
3427 $title = '';
3428 if (empty($object->email) && !$at_least_one_email_contact) {
3429 $title = $langs->trans('NoEMail');
3430 }
3431 print dolGetButtonAction($title, $langs->trans('SendMail'), 'default', $_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle', 'btn-send-mail', !empty($object->email) || $at_least_one_email_contact);
3432 }
3433
3434 print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd);
3435
3436 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
3437 $cloneSocietetUrl = '';
3438 $cloneButtonId = 'action-clone';
3439 } else {
3440 $cloneSocietetUrl = '';
3441 $cloneButtonId = '';
3442 }
3443 print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $cloneSocietetUrl, $cloneButtonId, $user->hasRight('societe', 'creer'));
3444
3445 if (isModEnabled('member')) {
3446 $adh = new Adherent($db);
3447 $result = $adh->fetch(0, '', $object->id);
3448 if ($result == 0 && ($object->client == 1 || $object->client == 3) && getDolGlobalString('MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS')) {
3449 print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/card.php?&action=create&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("NewMember")).'">'.$langs->trans("NewMember").'</a>'."\n";
3450 }
3451 }
3452
3453 print dolGetButtonAction($langs->trans('MergeThirdparties'), $langs->trans('Merge'), 'danger', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=merge&token='.newToken(), '', $permissiontodelete);
3454
3455 $deleteUrl = $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=delete&token='.newToken();
3456 $buttonId = 'action-delete-no-ajax';
3457 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile
3458 $deleteUrl = '';
3459 $buttonId = 'action-delete';
3460 }
3461 print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $deleteUrl, $buttonId, $permissiontodelete);
3462 }
3463
3464 print '</div>'."\n";
3465 }
3466
3467 //Select mail models is same action as presend
3468 if (GETPOST('modelselected')) {
3469 $action = 'presend';
3470 }
3471
3472 if ($action != 'presend') {
3473 print '<div class="fichecenter"><div class="fichehalfleft">';
3474
3475 if (!getDolGlobalString('SOCIETE_DISABLE_BUILDDOC')) {
3476 print '<a name="builddoc"></a>'; // ancre
3477
3478 /*
3479 * Generated documents
3480 */
3481 $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id;
3482 $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id;
3483 $genallowed = $user->hasRight('societe', 'lire');
3484 $delallowed = $user->hasRight('societe', 'creer');
3485
3486 print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang);
3487 }
3488
3489 // Subsidiaries list
3490 if (!getDolGlobalString('SOCIETE_DISABLE_PARENTCOMPANY') && !getDolGlobalString('SOCIETE_DISABLE_SHOW_SUBSIDIARIES')) {
3491 print '<br>';
3492 $result = show_subsidiaries($conf, $langs, $db, $object);
3493 }
3494
3495 print '</div><div class="fichehalfright">';
3496
3497 $MAXEVENT = 10;
3498
3499 $morehtmlcenter = '<div class="nowraponall">';
3500 $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id);
3501 $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id);
3502 $morehtmlcenter .= '</div>';
3503
3504 // List of actions on element
3505 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
3506 $formactions = new FormActions($db);
3507 $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlcenter); // Show all action for thirdparty
3508
3509 print '</div></div>';
3510
3511 if (getDolGlobalString('MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD')) {
3512 // Contacts list
3513 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS')) {
3514 $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
3515 }
3516 }
3517 }
3518
3519 // Presend form
3520 $modelmail = 'thirdparty';
3521 $defaulttopic = 'Information';
3522 $diroutput = $conf->societe->multidir_output[$object->entity];
3523 $trackid = 'thi'.$object->id;
3524
3525 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
3526 }
3527}
3528
3529
3530// End of page
3531llxFooter();
3532$db->close();
3533
3534?>
3535
3536<script>
3537// Function to retrieve VAT details from the Greek Ministry of Finance GSIS SOAP web service
3538function GRVAT(a, u, p, myafm) {
3539 var afm = a.replace(/\D/g, ""); // Remove non-digit characters from 'a'
3540
3541 $.ajax({
3542 type: "GET",
3543 url: '<?php echo DOL_URL_ROOT ?>/societe/checkvat/checkVatGr.php',
3544 data: { afm }, // Set request parameters
3545 success: function(data) {
3546 var obj = data; // Parse response data as JSON
3547
3548 // Update form fields based on retrieved data
3549 if (obj.RgWsPublicBasicRt_out.afm === null) {
3550 alert(obj.pErrorRec_out.errorDescr); // Display error message if AFM is null
3551 } else {
3552 $("#name").val(obj.RgWsPublicBasicRt_out.onomasia); // Set 'name' field value
3553 $("#address").val(obj.RgWsPublicBasicRt_out.postalAddress + " " + obj.RgWsPublicBasicRt_out.postalAddressNo); // Set 'address' field value
3554 $("#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode); // Set 'zipcode' field value
3555 $("#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription); // Set 'town' field value
3556 $("#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr); // Set 'idprof2' field value
3557 $("#name_alias_input").val(obj.RgWsPublicBasicRt_out.commerTitle); // Set 'name_alias' field value
3558
3559 if (obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser) {
3560 var firmActUser = obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser;
3561
3562 if (Array.isArray(firmActUser)) {
3563 var primaryFirmAct = firmActUser.find(item => item.firmActKindDescr === "ΚΥΡΙΑ"); // Find primary client activity
3564 if (primaryFirmAct) {
3565 $("#idprof1").val(primaryFirmAct.firmActDescr); // Set 'idprof1' field value
3566 }
3567 } else {
3568 $("#idprof1").val(firmActUser.firmActDescr); // Set 'idprof1' field value
3569 }
3570 }
3571 }
3572 }
3573 });
3574}
3575
3576</script>
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:87
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
$c
Definition line.php:327
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage canvas.
Class to manage categories.
Class to manage standard extra fields.
Class to manage generation of HTML components for accounting management.
Class to manage building of HTML components.
Class to generate html code for admin pages.
Class to build HTML component for third parties management Only common components are here.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
Class to manage third parties objects (customers, suppliers, prospects...)
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
currency_name($code_iso, $withcode=0, $outputlangs=null)
Return label of currency or code+label.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Check validity of a file upload from an GUI page, and move it to its final destination.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null, $forceFullTextIndexation='')
Add a file into database index.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded')
Delete files into database index using search criteria.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:150
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.