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