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