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