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