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