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