dolibarr  13.0.2
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-2013 Alexandre Spangaro <aspangaro@open-dsi.fr>
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 Frédéric France <frederic.france@netlogic.fr>
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation; either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <https://www.gnu.org/licenses/>.
29  */
30 
37 require '../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
40 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
46 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
47 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
48 if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
49 
50 $langs->loadLangs(array("companies", "commercial", "bills", "banks", "users"));
51 if (!empty($conf->adherent->enabled)) $langs->load("members");
52 if (!empty($conf->categorie->enabled)) $langs->load("categories");
53 if (!empty($conf->incoterm->enabled)) $langs->load("incoterm");
54 if (!empty($conf->notification->enabled)) $langs->load("mails");
55 
56 $mesg = ''; $error = 0; $errors = array();
57 
58 $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view');
59 $cancel = GETPOST('cancel', 'alpha');
60 $backtopage = GETPOST('backtopage', 'alpha');
61 $confirm = GETPOST('confirm', 'alpha');
62 
63 $socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int');
64 if ($user->socid) $socid = $user->socid;
65 if (empty($socid) && $action == 'view') $action = 'create';
66 
67 $object = new Societe($db);
68 $extrafields = new ExtraFields($db);
69 
70 // fetch optionals attributes and labels
71 $extrafields->fetch_name_optionals_label($object->table_element);
72 
73 $socialnetworks = getArrayOfSocialNetworks();
74 
75 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
76 $hookmanager->initHooks(array('thirdpartycard', 'globalcard'));
77 
78 if ($socid > 0) $object->fetch($socid);
79 
80 if (!($object->id > 0) && $action == 'view')
81 {
82  $langs->load("errors");
83  print($langs->trans('ErrorRecordNotFound'));
84  exit;
85 }
86 
87 // Get object canvas (By default, this is not defined, so standard usage of dolibarr)
88 $canvas = $object->canvas ? $object->canvas : GETPOST("canvas");
89 $objcanvas = null;
90 if (!empty($canvas))
91 {
92  require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php';
93  $objcanvas = new Canvas($db, $action);
94  $objcanvas->getCanvas('thirdparty', 'card', $canvas);
95 }
96 
97 // Security check
98 $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
99 
100 /*
101 if ($object->id > 0) {
102  if ($object->client == 0 && $object->fournisseur > 0) {
103  if (!empty($user->rights->fournisseur->lire)) {
104  accessforbidden();
105  }
106  }
107 }
108 */
109 
110 $permissiontoread = $user->rights->societe->lire;
111 $permissiontoadd = $user->rights->societe->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
112 $permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0);
113 $permissionnote = $user->rights->societe->creer; // Used by the include of actions_setnotes.inc.php
114 $permissiondellink = $user->rights->societe->creer; // Used by the include of actions_dellink.inc.php
115 $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
116 
117 
118 /*
119  * Actions
120  */
121 
122 $parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
123 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
124 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
125 
126 if (empty($reshook))
127 {
128  if ($cancel)
129  {
130  $action = '';
131  if (!empty($backtopage))
132  {
133  header("Location: ".$backtopage);
134  exit;
135  }
136  }
137 
138  if ($action == 'confirm_merge' && $confirm == 'yes' && $user->rights->societe->creer)
139  {
140  $error = 0;
141  $soc_origin_id = GETPOST('soc_origin', 'int');
142  $soc_origin = new Societe($db);
143 
144  if ($soc_origin_id <= 0)
145  {
146  $langs->load('errors');
147  setEventMessages($langs->trans('ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv('MergeOriginThirdparty')), null, 'errors');
148  } else {
149  if (!$error && $soc_origin->fetch($soc_origin_id) < 1)
150  {
151  setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
152  $error++;
153  }
154 
155  if (!$error)
156  {
157  // TODO Move the merge function into class of object.
158 
159  $db->begin();
160 
161  // Recopy some data
162  $object->client = $object->client | $soc_origin->client;
163  $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
164  $listofproperties = array(
165  'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'linkedin', 'socialnetworks', 'url', 'barcode',
166  'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
167  'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
168  'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
169  'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
170  'model_pdf', 'fk_projet'
171  );
172  foreach ($listofproperties as $property)
173  {
174  if (empty($object->$property)) $object->$property = $soc_origin->$property;
175  }
176 
177  // Concat some data
178  $listofproperties = array(
179  'note_public', 'note_private'
180  );
181  foreach ($listofproperties as $property)
182  {
183  $object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
184  }
185 
186  // Merge extrafields
187  if (is_array($soc_origin->array_options))
188  {
189  foreach ($soc_origin->array_options as $key => $val)
190  {
191  if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
192  }
193  }
194 
195  // Merge categories
196  $static_cat = new Categorie($db);
197 
198  $custcats_ori = $static_cat->containing($soc_origin->id, 'customer', 'id');
199  $custcats = $static_cat->containing($object->id, 'customer', 'id');
200  $custcats = array_merge($custcats, $custcats_ori);
201  $object->setCategories($custcats, 'customer');
202 
203  $suppcats_ori = $static_cat->containing($soc_origin->id, 'supplier', 'id');
204  $suppcats = $static_cat->containing($object->id, 'supplier', 'id');
205  $suppcats = array_merge($suppcats, $suppcats_ori);
206  $object->setCategories($suppcats, 'supplier');
207 
208  // If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys.
209  if ($soc_origin->code_client == $object->code_client
210  || $soc_origin->code_fournisseur == $object->code_fournisseur
211  || $soc_origin->barcode == $object->barcode)
212  {
213  dol_syslog("We clean customer and supplier code so we will be able to make the update of target");
214  $soc_origin->code_client = '';
215  $soc_origin->code_fournisseur = '';
216  $soc_origin->barcode = '';
217  $soc_origin->update($soc_origin->id, $user, 0, 1, 1, 'merge');
218  }
219 
220  // Update
221  $result = $object->update($object->id, $user, 0, 1, 1, 'merge');
222  if ($result < 0)
223  {
224  setEventMessages($object->error, $object->errors, 'errors');
225  $error++;
226  }
227 
228  // Move links
229  if (!$error)
230  {
231  // This list is also into the api_thirdparties.class.php
232  // TODO Mutualise the list into object societe.class.php
233  $objects = array(
234  'Adherent' => '/adherents/class/adherent.class.php',
235  'Don' => '/don/class/don.class.php',
236  'Societe' => '/societe/class/societe.class.php',
237  //'Categorie' => '/categories/class/categorie.class.php',
238  'ActionComm' => '/comm/action/class/actioncomm.class.php',
239  'Propal' => '/comm/propal/class/propal.class.php',
240  'Commande' => '/commande/class/commande.class.php',
241  'Facture' => '/compta/facture/class/facture.class.php',
242  'FactureRec' => '/compta/facture/class/facture-rec.class.php',
243  'LignePrelevement' => '/compta/prelevement/class/ligneprelevement.class.php',
244  'Mo' => '/mrp/class/mo.class.php',
245  'Contact' => '/contact/class/contact.class.php',
246  'Contrat' => '/contrat/class/contrat.class.php',
247  'Expedition' => '/expedition/class/expedition.class.php',
248  'Fichinter' => '/fichinter/class/fichinter.class.php',
249  'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php',
250  'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php',
251  'SupplierProposal' => '/supplier_proposal/class/supplier_proposal.class.php',
252  'ProductFournisseur' => '/fourn/class/fournisseur.product.class.php',
253  'Delivery' => '/delivery/class/delivery.class.php',
254  'Product' => '/product/class/product.class.php',
255  'Project' => '/projet/class/project.class.php',
256  'Ticket' => '/ticket/class/ticket.class.php',
257  'User' => '/user/class/user.class.php'
258  );
259 
260  //First, all core objects must update their tables
261  foreach ($objects as $object_name => $object_file)
262  {
263  require_once DOL_DOCUMENT_ROOT.$object_file;
264 
265  if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id))
266  {
267  $error++;
268  setEventMessages($db->lasterror(), null, 'errors');
269  break;
270  }
271  }
272  }
273 
274  // External modules should update their ones too
275  if (!$error)
276  {
277  $reshook = $hookmanager->executeHooks('replaceThirdparty', array(
278  'soc_origin' => $soc_origin->id,
279  'soc_dest' => $object->id
280  ), $object, $action);
281 
282  if ($reshook < 0)
283  {
284  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
285  $error++;
286  }
287  }
288 
289 
290  if (!$error)
291  {
292  $object->context = array('merge'=>1, 'mergefromid'=>$soc_origin->id);
293 
294  // Call trigger
295  $result = $object->call_trigger('COMPANY_MODIFY', $user);
296  if ($result < 0)
297  {
298  setEventMessages($object->error, $object->errors, 'errors');
299  $error++;
300  }
301  // End call triggers
302  }
303 
304  if (!$error)
305  {
306  //We finally remove the old thirdparty
307  if ($soc_origin->delete($soc_origin->id, $user) < 1)
308  {
309  $error++;
310  }
311  }
312 
313  if (!$error)
314  {
315  setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs');
316  $db->commit();
317  } else {
318  $langs->load("errors");
319  setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors');
320  $db->rollback();
321  }
322  }
323  }
324  }
325 
326  if (GETPOST('getcustomercode'))
327  {
328  // We defined value code_client
329  $_POST["customer_code"] = "Acompleter";
330  }
331 
332  if (GETPOST('getsuppliercode'))
333  {
334  // We defined value code_fournisseur
335  $_POST["supplier_code"] = "Acompleter";
336  }
337 
338  if ($action == 'set_localtax1')
339  {
340  //obtidre selected del combobox
341  $value = GETPOST('lt1');
342  $object->fetch($socid);
343  $res = $object->setValueFrom('localtax1_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
344  }
345  if ($action == 'set_localtax2')
346  {
347  //obtidre selected del combobox
348  $value = GETPOST('lt2');
349  $object->fetch($socid);
350  $res = $object->setValueFrom('localtax2_value', $value, '', null, 'text', '', $user, 'COMPANY_MODIFY');
351  }
352 
353  if ($action == 'update_extras') {
354  $object->fetch($socid);
355 
356  $object->oldcopy = dol_clone($object);
357 
358  // Fill array 'array_options' with data from update form
359  $extrafields->fetch_name_optionals_label($object->table_element);
360 
361  $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
362  if ($ret < 0) $error++;
363 
364  if (!$error)
365  {
366  $result = $object->insertExtraFields('COMPANY_MODIFY');
367  if ($result < 0)
368  {
369  setEventMessages($object->error, $object->errors, 'errors');
370  $error++;
371  }
372  }
373 
374  if ($error) $action = 'edit_extras';
375  }
376 
377  // Add new or update third party
378  if ((!GETPOST('getcustomercode') && !GETPOST('getsuppliercode'))
379  && ($action == 'add' || $action == 'update') && $user->rights->societe->creer)
380  {
381  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
382 
383  if (!GETPOST('name'))
384  {
385  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdPartyName")), null, 'errors');
386  $error++;
387  }
388  if (GETPOST('client') < 0)
389  {
390  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ProspectCustomer")), null, 'errors');
391  $error++;
392  }
393  if (GETPOST('fournisseur') < 0)
394  {
395  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Supplier")), null, 'errors');
396  $error++;
397  }
398 
399  if (!$error)
400  {
401  if ($action == 'update')
402  {
403  $ret = $object->fetch($socid);
404  $object->oldcopy = clone $object;
405  } else $object->canvas = $canvas;
406 
407  if (GETPOST("private", 'int') == 1) // Ask to create a contact
408  {
409  $object->particulier = GETPOST("private", 'int');
410 
411  $object->name = dolGetFirstLastname(GETPOST('firstname', 'alphanohtml'), GETPOST('name', 'alphanohtml'));
412  $object->civility_id = GETPOST('civility_id', 'alphanohtml'); // Note: civility id is a code, not an int
413  // Add non official properties
414  $object->name_bis = GETPOST('name', 'alphanohtml');
415  $object->firstname = GETPOST('firstname', 'alphanohtml');
416  } else {
417  $object->name = GETPOST('name', 'alphanohtml');
418  }
419  $object->entity = (GETPOSTISSET('entity') ? GETPOST('entity', 'int') : $conf->entity);
420  $object->name_alias = GETPOST('name_alias', 'alphanohtml');
421  $object->address = GETPOST('address', 'alphanohtml');
422  $object->zip = GETPOST('zipcode', 'alphanohtml');
423  $object->town = GETPOST('town', 'alphanohtml');
424  $object->country_id = GETPOST('country_id', 'int');
425  $object->state_id = GETPOST('state_id', 'int');
426  //$object->skype = GETPOST('skype', 'alpha');
427  //$object->twitter = GETPOST('twitter', 'alpha');
428  //$object->facebook = GETPOST('facebook', 'alpha');
429  //$object->linkedin = GETPOST('linkedin', 'alpha');
430  $object->socialnetworks = array();
431  if (!empty($conf->socialnetworks->enabled)) {
432  foreach ($socialnetworks as $key => $value) {
433  if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
434  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
435  }
436  }
437  }
438  $object->phone = GETPOST('phone', 'alpha');
439  $object->fax = GETPOST('fax', 'alpha');
440  $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
441  $object->url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL));
442  $object->idprof1 = trim(GETPOST('idprof1', 'alphanohtml'));
443  $object->idprof2 = trim(GETPOST('idprof2', 'alphanohtml'));
444  $object->idprof3 = trim(GETPOST('idprof3', 'alphanohtml'));
445  $object->idprof4 = trim(GETPOST('idprof4', 'alphanohtml'));
446  $object->idprof5 = trim(GETPOST('idprof5', 'alphanohtml'));
447  $object->idprof6 = trim(GETPOST('idprof6', 'alphanohtml'));
448  $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
449  $object->code_client = GETPOSTISSET('customer_code') ?GETPOST('customer_code', 'alpha') : GETPOST('code_client', 'alpha');
450  $object->code_fournisseur = GETPOSTISSET('supplier_code') ?GETPOST('supplier_code', 'alpha') : GETPOST('code_fournisseur', 'alpha');
451  $object->capital = GETPOST('capital', 'alphanohtml');
452  $object->barcode = GETPOST('barcode', 'alphanohtml');
453 
454  $object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
455  $object->tva_assuj = GETPOST('assujtva_value', 'alpha');
456  $object->status = GETPOST('status', 'alpha');
457 
458  // Local Taxes
459  $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'alpha');
460  $object->localtax2_assuj = GETPOST('localtax2assuj_value', 'alpha');
461 
462  $object->localtax1_value = GETPOST('lt1', 'alpha');
463  $object->localtax2_value = GETPOST('lt2', 'alpha');
464 
465  $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int');
466  $object->effectif_id = GETPOST('effectif_id', 'int');
467  $object->typent_id = GETPOST('typent_id', 'int');
468 
469  $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
470 
471  $object->client = GETPOST('client', 'int');
472  $object->fournisseur = GETPOST('fournisseur', 'int');
473 
474  $object->commercial_id = GETPOST('commercial_id', 'int');
475  $object->default_lang = GETPOST('default_lang');
476 
477  // Webservices url/key
478  $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
479  $object->webservices_key = GETPOST('webservices_key', 'san_alpha');
480 
481  // Incoterms
482  if (!empty($conf->incoterm->enabled))
483  {
484  $object->fk_incoterms = GETPOST('incoterm_id', 'int');
485  $object->location_incoterms = GETPOST('location_incoterms', 'alpha');
486  }
487 
488  // Multicurrency
489  if (!empty($conf->multicurrency->enabled))
490  {
491  $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha');
492  }
493 
494  // Fill array 'array_options' with data from add form
495  $ret = $extrafields->setOptionalsFromPost(null, $object);
496  if ($ret < 0)
497  {
498  $error++;
499  }
500 
501  // Fill array 'array_languages' with data from add form
502  $ret = $object->setValuesForExtraLanguages();
503  if ($ret < 0)
504  {
505  $error++;
506  }
507  //var_dump($object->array_languages);exit;
508 
509  if (GETPOST('deletephoto')) $object->logo = '';
510  elseif (!empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
511 
512  // Check parameters
513  if (!GETPOST('cancel', 'alpha'))
514  {
515  if (!empty($object->email) && !isValidEMail($object->email))
516  {
517  $langs->load("errors");
518  $error++;
519  setEventMessages('', $langs->trans("ErrorBadEMail", $object->email), 'errors');
520  }
521  if (!empty($object->url) && !isValidUrl($object->url))
522  {
523  $langs->load("errors");
524  setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors');
525  }
526  if (!empty($object->webservices_url)) {
527  //Check if has transport, without any the soap client will give error
528  if (strpos($object->webservices_url, "http") === false)
529  {
530  $object->webservices_url = "http://".$object->webservices_url;
531  }
532  if (!isValidUrl($object->webservices_url)) {
533  $langs->load("errors");
534  $error++; $errors[] = $langs->trans("ErrorBadUrl", $object->webservices_url);
535  }
536  }
537 
538  // We set country_id, country_code and country for the selected country
539  $object->country_id = GETPOST('country_id') != '' ?GETPOST('country_id') : $mysoc->country_id;
540  if ($object->country_id)
541  {
542  $tmparray = getCountry($object->country_id, 'all');
543  $object->country_code = $tmparray['code'];
544  $object->country = $tmparray['label'];
545  }
546  }
547  }
548 
549  if (!$error)
550  {
551  if ($action == 'add')
552  {
553  $error = 0;
554 
555  $db->begin();
556 
557  if (empty($object->client)) $object->code_client = '';
558  if (empty($object->fournisseur)) $object->code_fournisseur = '';
559 
560  $result = $object->create($user);
561 
562  if ($result >= 0)
563  {
564  if ($object->particulier)
565  {
566  dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
567  $result = $object->create_individual($user);
568  if ($result < 0)
569  {
570  setEventMessages($object->error, $object->errors, 'errors');
571  $error++;
572  }
573  }
574 
575  // Links with users
576  $salesreps = GETPOST('commercial', 'array');
577  $result = $object->setSalesRep($salesreps, true);
578  if ($result < 0)
579  {
580  $error++;
581  setEventMessages($object->error, $object->errors, 'errors');
582  }
583 
584  // Customer categories association
585  $custcats = GETPOST('custcats', 'array');
586  $result = $object->setCategories($custcats, 'customer');
587  if ($result < 0)
588  {
589  $error++;
590  setEventMessages($object->error, $object->errors, 'errors');
591  }
592 
593  // Supplier categories association
594  $suppcats = GETPOST('suppcats', 'array');
595  $result = $object->setCategories($suppcats, 'supplier');
596  if ($result < 0)
597  {
598  $error++;
599  setEventMessages($object->error, $object->errors, 'errors');
600  }
601 
602  // Logo/Photo save
603  $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/";
604  $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
605  if ($file_OK)
606  {
607  if (image_format_supported($_FILES['photo']['name']))
608  {
609  dol_mkdir($dir);
610 
611  if (@is_dir($dir))
612  {
613  $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
614  $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
615 
616  if (!$result > 0)
617  {
618  $errors[] = "ErrorFailedToSaveFile";
619  } else {
620  // Create thumbs
621  $object->addThumbs($newfile);
622  }
623  }
624  }
625  } else {
626  switch ($_FILES['photo']['error'])
627  {
628  case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
629  case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
630  $errors[] = "ErrorFileSizeTooLarge";
631  break;
632  case 3: //uploaded file was only partially uploaded
633  $errors[] = "ErrorFilePartiallyUploaded";
634  break;
635  }
636  }
637  } else {
638  if ($result == -3 && in_array('ErrorCustomerCodeAlreadyUsed', $object->errors))
639  {
640  $duplicate_code_error = true;
641  $object->code_client = null;
642  }
643 
644  if ($result == -3 && in_array('ErrorSupplierCodeAlreadyUsed', $object->errors))
645  {
646  $duplicate_code_error = true;
647  $object->code_fournisseur = null;
648  }
649 
650  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
651  $duplicate_code_error = true;
652  }
653 
654  setEventMessages($object->error, $object->errors, 'errors');
655  $error++;
656  }
657 
658  if ($result >= 0 && !$error) {
659  $db->commit();
660 
661  if (!empty($backtopage)) {
662  $backtopage = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $backtopage); // New method to autoselect project after a New on another form object creation
663  if (preg_match('/\?/', $backtopage)) $backtopage .= '&socid='.$object->id; // Old method
664  header("Location: ".$backtopage);
665  exit;
666  } else {
667  $url = $_SERVER["PHP_SELF"]."?socid=".$object->id; // Old method
668  if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) $url = DOL_URL_ROOT."/comm/card.php?socid=".$object->id;
669  elseif ($object->fournisseur == 1) $url = DOL_URL_ROOT."/fourn/card.php?socid=".$object->id;
670 
671  header("Location: ".$url);
672  exit;
673  }
674  } else {
675  $db->rollback();
676  $action = 'create';
677  }
678  }
679 
680  if ($action == 'update')
681  {
682  $error = 0;
683 
684  if (GETPOST('cancel', 'alpha'))
685  {
686  if (!empty($backtopage))
687  {
688  header("Location: ".$backtopage);
689  exit;
690  } else {
691  header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
692  exit;
693  }
694  }
695 
696  // To not set code if third party is not concerned. But if it had values, we keep them.
697  if (empty($object->client) && empty($object->oldcopy->code_client)) $object->code_client = '';
698  if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) $object->code_fournisseur = '';
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  {
705  setEventMessages($object->error, $object->errors, 'errors');
706  $error++;
707  }
708 
709  // Links with users
710  $salesreps = GETPOST('commercial', 'array');
711  $result = $object->setSalesRep($salesreps);
712  if ($result < 0)
713  {
714  $error++;
715  setEventMessages($object->error, $object->errors, 'errors');
716  }
717 
718  // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined)
719  if (!$error && !empty($user->rights->categorie->lire))
720  {
721  // Customer categories association
722  $categories = GETPOST('custcats', 'array');
723  $result = $object->setCategories($categories, 'customer');
724  if ($result < 0)
725  {
726  $error++;
727  setEventMessages($object->error, $object->errors, 'errors');
728  }
729 
730  // Supplier categories association
731  $categories = GETPOST('suppcats', 'array');
732  $result = $object->setCategories($categories, 'supplier');
733  if ($result < 0)
734  {
735  $error++;
736  setEventMessages($object->error, $object->errors, 'errors');
737  }
738  }
739 
740  // Logo/Photo save
741  $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
742  $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
743  if (GETPOST('deletephoto') && $object->logo)
744  {
745  $fileimg = $dir.'/'.$object->logo;
746  $dirthumbs = $dir.'/thumbs';
747  dol_delete_file($fileimg);
748  dol_delete_dir_recursive($dirthumbs);
749  }
750  if ($file_OK)
751  {
752  if (image_format_supported($_FILES['photo']['name']) > 0)
753  {
754  dol_mkdir($dir);
755 
756  if (@is_dir($dir))
757  {
758  $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
759  $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
760 
761  if (!$result > 0)
762  {
763  $errors[] = "ErrorFailedToSaveFile";
764  } else {
765  // Create thumbs
766  $object->addThumbs($newfile);
767 
768  // Index file in database
769  if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD))
770  {
771  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
772  // 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
773  deleteFilesIntoDatabaseIndex(dirname($newfile), '', '');
774  // now we index the uploaded logo file
775  addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1);
776  }
777  }
778  }
779  } else {
780  $errors[] = "ErrorBadImageFormat";
781  }
782  } else {
783  switch ($_FILES['photo']['error'])
784  {
785  case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
786  case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
787  $errors[] = "ErrorFileSizeTooLarge";
788  break;
789  case 3: //uploaded file was only partially uploaded
790  $errors[] = "ErrorFilePartiallyUploaded";
791  break;
792  }
793  }
794  // Gestion du logo de la société
795 
796 
797  // Update linked member
798  if (!$error && $object->fk_soc > 0)
799  {
800  $sql = "UPDATE ".MAIN_DB_PREFIX."adherent";
801  $sql .= " SET fk_soc = NULL WHERE fk_soc = ".$id;
802  if (!$object->db->query($sql))
803  {
804  $error++;
805  $object->error .= $object->db->lasterror();
806  setEventMessages($object->error, $object->errors, 'errors');
807  }
808  }
809 
810  if (!$error && !count($errors))
811  {
812  if (!empty($backtopage))
813  {
814  header("Location: ".$backtopage);
815  exit;
816  } else {
817  header("Location: ".$_SERVER["PHP_SELF"]."?socid=".$socid);
818  exit;
819  }
820  } else {
821  $object->id = $socid;
822  $action = "edit";
823  }
824  }
825  } else {
826  $action = ($action == 'add' ? 'create' : 'edit');
827  }
828  }
829 
830  // Delete third party
831  if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
832  {
833  $object->fetch($socid);
834  $object->oldcopy = clone $object;
835  $result = $object->delete($socid, $user);
836 
837  if ($result > 0)
838  {
839  header("Location: ".DOL_URL_ROOT."/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
840  exit;
841  } else {
842  $langs->load("errors");
843  setEventMessages($object->error, $object->errors, 'errors');
844  $error++;
845  $action = '';
846  }
847  }
848 
849  // Set third-party type
850  if ($action == 'set_thirdpartytype' && $user->rights->societe->creer)
851  {
852  $object->fetch($socid);
853  $result = $object->setThirdpartyType(GETPOST('typent_id', 'int'));
854  }
855 
856  // Set incoterm
857  if ($action == 'set_incoterms' && $user->rights->societe->creer && !empty($conf->incoterm->enabled))
858  {
859  $object->fetch($socid);
860  $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha'));
861  }
862 
863  // Set parent company
864  if ($action == 'set_thirdparty' && $user->rights->societe->creer)
865  {
866  $object->fetch($socid);
867  $result = $object->set_parent(GETPOST('parent_id', 'int'));
868  }
869 
870  // Set sales representatives
871  if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer)
872  {
873  $object->fetch($socid);
874  $result = $object->setSalesRep(GETPOST('commercial', 'array'));
875  }
876 
877  $id = $socid;
878  $object->fetch($socid);
879 
880  // Selection of new fields
881  if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
882  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
883  }
884 
885  // Actions to send emails
886  $triggersendname = 'COMPANY_SENTBYMAIL';
887  $paramname = 'socid';
888  $mode = 'emailfromthirdparty';
889  $trackid = 'thi'.$object->id;
890  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
891 
892  // Actions to build doc
893  $id = $socid;
894  $upload_dir = $conf->societe->dir_output;
895  $permissiontoadd = $user->rights->societe->creer;
896  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
897 }
898 
899 
900 /*
901  * View
902  */
903 
904 $form = new Form($db);
905 $formfile = new FormFile($db);
906 $formadmin = new FormAdmin($db);
907 $formcompany = new FormCompany($db);
908 
909 if ($socid > 0 && empty($object->id))
910 {
911  $result = $object->fetch($socid);
912  if ($result <= 0) dol_print_error('', $object->error);
913 }
914 
915 $title = $langs->trans("ThirdParty");
916 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$langs->trans('Card');
917 $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
918 llxHeader('', $title, $help_url);
919 
920 $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
921 
922 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
923 {
924  // -----------------------------------------
925  // When used with CANVAS
926  // -----------------------------------------
927  $objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
928  $objcanvas->display_canvas($action); // Show template
929 } else {
930  // -----------------------------------------
931  // When used in standard mode
932  // -----------------------------------------
933  if ($action == 'create')
934  {
935  /*
936  * Creation
937  */
938  $private = GETPOST("private", "int");
939  if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !GETPOSTISSET('private')) $private = 1;
940  if (empty($private)) $private = 0;
941 
942  // Load object modCodeTiers
943  $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
944  if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
945  {
946  $module = substr($module, 0, dol_strlen($module) - 4);
947  }
948  $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
949  foreach ($dirsociete as $dirroot)
950  {
951  $res = dol_include_once($dirroot.$module.'.php');
952  if ($res) break;
953  }
954  $modCodeClient = new $module;
955  // Load object modCodeFournisseur
956  $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
957  if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
958  {
959  $module = substr($module, 0, dol_strlen($module) - 4);
960  }
961  $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
962  foreach ($dirsociete as $dirroot)
963  {
964  $res = dol_include_once($dirroot.$module.'.php');
965  if ($res) break;
966  }
967  $modCodeFournisseur = new $module;
968 
969  // Define if customer/prospect or supplier status is set or not
970  if (GETPOST("type") != 'f')
971  {
972  $object->client = -1;
973  if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client = 3; }
974  }
975  // Prospect / Customer
976  if (GETPOST("type") == 'c') {
977  if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
978  $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
979  } else {
980  $object->client = 3;
981  }
982  }
983  if (GETPOST("type") == 'p') { $object->client = 2; }
984  if (!empty($conf->fournisseur->enabled) && (GETPOST("type") == 'f' || (GETPOST("type") == '' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) { $object->fournisseur = 1; }
985 
986  $object->name = GETPOST('name', 'alphanohtml');
987  $object->name_alias = GETPOST('name_alias', 'alphanohtml');
988  $object->firstname = GETPOST('firstname', 'alphanohtml');
989  $object->particulier = $private;
990  $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
991  $object->client = GETPOST('client', 'int') ?GETPOST('client', 'int') : $object->client;
992 
993  if (empty($duplicate_code_error)) {
994  $object->code_client = GETPOST('customer_code', 'alpha');
995  $object->fournisseur = GETPOST('fournisseur') ? GETPOST('fournisseur', 'int') : $object->fournisseur;
996  $object->code_fournisseur = GETPOST('supplier_code', 'alpha');
997  } else {
998  setEventMessages($langs->trans('NewCustomerSupplierCodeProposed'), '', 'warnings');
999  }
1000 
1001  $object->address = GETPOST('address', 'alphanohtml');
1002  $object->zip = GETPOST('zipcode', 'alphanohtml');
1003  $object->town = GETPOST('town', 'alphanohtml');
1004  $object->state_id = GETPOST('state_id', 'int');
1005  //$object->skype = GETPOST('skype', 'alpha');
1006  //$object->twitter = GETPOST('twitter', 'alpha');
1007  //$object->facebook = GETPOST('facebook', 'alpha');
1008  //$object->linkedin = GETPOST('linkedin', 'alpha');
1009  $object->socialnetworks = array();
1010  if (!empty($conf->socialnetworks->enabled)) {
1011  foreach ($socialnetworks as $key => $value) {
1012  if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
1013  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
1014  }
1015  }
1016  }
1017  $object->phone = GETPOST('phone', 'alpha');
1018  $object->fax = GETPOST('fax', 'alpha');
1019  $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
1020  $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
1021  $object->capital = GETPOST('capital', 'alphanohtml');
1022  $object->barcode = GETPOST('barcode', 'alphanohtml');
1023  $object->idprof1 = GETPOST('idprof1', 'alphanohtml');
1024  $object->idprof2 = GETPOST('idprof2', 'alphanohtml');
1025  $object->idprof3 = GETPOST('idprof3', 'alphanohtml');
1026  $object->idprof4 = GETPOST('idprof4', 'alphanohtml');
1027  $object->idprof5 = GETPOST('idprof5', 'alphanohtml');
1028  $object->idprof6 = GETPOST('idprof6', 'alphanohtml');
1029  $object->typent_id = GETPOST('typent_id', 'int');
1030  $object->effectif_id = GETPOST('effectif_id', 'int');
1031  $object->civility_id = GETPOST('civility_id', 'alpha');
1032 
1033  $object->tva_assuj = GETPOST('assujtva_value', 'int');
1034  $object->status = GETPOST('status', 'int');
1035 
1036  //Local Taxes
1037  $object->localtax1_assuj = GETPOST('localtax1assuj_value', 'int');
1038  $object->localtax2_assuj = GETPOST('localtax2assuj_value', 'int');
1039 
1040  $object->localtax1_value = GETPOST('lt1', 'int');
1041  $object->localtax2_value = GETPOST('lt2', 'int');
1042 
1043  $object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
1044 
1045  $object->commercial_id = GETPOST('commercial_id', 'int');
1046  $object->default_lang = GETPOST('default_lang');
1047 
1048  $object->logo = (isset($_FILES['photo']) ?dol_sanitizeFileName($_FILES['photo']['name']) : '');
1049 
1050  // Gestion du logo de la société
1051  $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos";
1052  $file_OK = (isset($_FILES['photo']) ?is_uploaded_file($_FILES['photo']['tmp_name']) : false);
1053  if ($file_OK)
1054  {
1055  if (image_format_supported($_FILES['photo']['name']))
1056  {
1057  dol_mkdir($dir);
1058 
1059  if (@is_dir($dir))
1060  {
1061  $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
1062  $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1);
1063 
1064  if (!$result > 0)
1065  {
1066  $errors[] = "ErrorFailedToSaveFile";
1067  } else {
1068  // Create thumbs
1069  $object->addThumbs($newfile);
1070  }
1071  }
1072  }
1073  }
1074 
1075  // We set country_id, country_code and country for the selected country
1076  $object->country_id = GETPOST('country_id') ?GETPOST('country_id') : $mysoc->country_id;
1077  if ($object->country_id)
1078  {
1079  $tmparray = getCountry($object->country_id, 'all');
1080  $object->country_code = $tmparray['code'];
1081  $object->country = $tmparray['label'];
1082  }
1083  $object->forme_juridique_code = GETPOST('forme_juridique_code');
1084  /* Show create form */
1085 
1086  $linkback = "";
1087  print load_fiche_titre($langs->trans("NewThirdParty"), $linkback, 'building');
1088 
1089  if (!empty($conf->use_javascript_ajax)) {
1090  if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1091  print "\n".'<script type="text/javascript">';
1092  print '$(document).ready(function () {
1093  id_te_private=8;
1094  id_ef15=1;
1095  is_private=' . $private.';
1096  if (is_private) {
1097  $(".individualline").show();
1098  } else {
1099  $(".individualline").hide();
1100  }
1101  $("#radiocompany").click(function() {
1102  $(".individualline").hide();
1103  $("#typent_id").val(0);
1104  $("#typent_id").change();
1105  $("#effectif_id").val(0);
1106  $("#effectif_id").change();
1107  $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1108  document.formsoc.private.value=0;
1109  });
1110  $("#radioprivate").click(function() {
1111  $(".individualline").show();
1112  $("#typent_id").val(id_te_private);
1113  $("#typent_id").change();
1114  $("#effectif_id").val(id_ef15);
1115  $("#effectif_id").change();
1116  $("#TypeName").html(document.formsoc.LastName.value);
1117  document.formsoc.private.value=1;
1118  });
1119 
1120  init_customer_categ();
1121  $("#customerprospect").change(function() {
1122  init_customer_categ();
1123  });
1124  function init_customer_categ() {
1125  console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1126  if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').'))
1127  {
1128  jQuery(".visibleifcustomer").hide();
1129  }
1130  else
1131  {
1132  jQuery(".visibleifcustomer").show();
1133  }
1134  }
1135 
1136  init_supplier_categ();
1137  $("#fournisseur").change(function() {
1138  init_supplier_categ();
1139  });
1140  function init_supplier_categ() {
1141  console.log("is supplier = "+jQuery("#fournisseur").val());
1142  if (jQuery("#fournisseur").val() == 0)
1143  {
1144  jQuery(".visibleifsupplier").hide();
1145  }
1146  else
1147  {
1148  jQuery(".visibleifsupplier").show();
1149  }
1150  }
1151 
1152  $("#selectcountry_id").change(function() {
1153  document.formsoc.action.value="create";
1154  document.formsoc.submit();
1155  });
1156  });';
1157  print '</script>'."\n";
1158 
1159  print '<div id="selectthirdpartytype">';
1160  print '<div class="hideonsmartphone float">';
1161  print $langs->trans("ThirdPartyType").': &nbsp; &nbsp; ';
1162  print '</div>';
1163  print '<label for="radiocompany" class="radiocompany">';
1164  print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ? '' : ' checked').'>';
1165  print '&nbsp;';
1166  print $langs->trans("CreateThirdPartyOnly");
1167  print '</label>';
1168  print ' &nbsp; &nbsp; ';
1169  print '<label for="radioprivate" class="radioprivate">';
1170  $text = '<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ? ' checked' : '').'>';
1171  $text .= '&nbsp;';
1172  $text .= $langs->trans("CreateThirdPartyAndContact");
1173  $htmltext = $langs->trans("ToCreateContactWithSameName");
1174  print $form->textwithpicto($text, $htmltext, 1, 'help', '', 0, 3);
1175  print '</label>';
1176  print '</div>';
1177  print "<br>\n";
1178  } else {
1179  print '<script type="text/javascript">';
1180  print '$(document).ready(function () {
1181  $("#selectcountry_id").change(function() {
1182  document.formsoc.action.value="create";
1183  document.formsoc.submit();
1184  });
1185  });';
1186  print '</script>'."\n";
1187  }
1188  }
1189 
1190  dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
1191 
1192  print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" method="post" name="formsoc" autocomplete="off">'; // Chrome ignor autocomplete
1193 
1194  print '<input type="hidden" name="action" value="add">';
1195  print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
1196  print '<input type="hidden" name="token" value="'.newToken().'">';
1197  print '<input type="hidden" name="private" value='.$object->particulier.'>';
1198  print '<input type="hidden" name="type" value='.GETPOST("type", 'alpha').'>';
1199  print '<input type="hidden" name="LastName" value="'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName').'">';
1200  print '<input type="hidden" name="ThirdPartyName" value="'.$langs->trans('ThirdPartyName').'">';
1201  if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
1202 
1203  print dol_get_fiche_head(null, 'card', '', 0, '');
1204 
1205  print '<table class="border centpercent">';
1206 
1207  // Name, firstname
1208  print '<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1209  if ($object->particulier || $private) {
1210  print '<span id="TypeName" class="fieldrequired">'.$langs->trans('ThirdPartyName').' / '.$langs->trans('LastName', 'name').'</span>';
1211  } else {
1212  print '<span id="TypeName" class="fieldrequired">'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0).'</span>';
1213  }
1214  print '</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ? ' colspan="3"' : '').'>';
1215  print '<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus">';
1216  print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300');
1217  print '</td>';
1218  if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
1219  {
1220  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>';
1221  }
1222  print '</tr>';
1223 
1224  // If javascript on, we show option individual
1225  if ($conf->use_javascript_ajax)
1226  {
1227  if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION))
1228  {
1229  // Firstname
1230  print '<tr class="individualline"><td>'.$form->editfieldkey('FirstName', 'firstname', '', $object, 0).'</td>';
1231  print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).'"></td>';
1232  print '</tr>';
1233 
1234  // Title
1235  print '<tr class="individualline"><td>'.$form->editfieldkey('UserTitle', 'civility_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1236  print $formcompany->select_civility($object->civility_id, 'civility_id', 'maxwidth100').'</td>';
1237  print '</tr>';
1238  }
1239  }
1240 
1241  // Alias names (commercial, trademark or alias names)
1242  print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1243  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>';
1244 
1245  // Prospect/Customer
1246  print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).'</td>';
1247  print '<td class="maxwidthonsmartphone">';
1248  $selected = (GETPOSTISSET('client') ?GETPOST('client', 'int') : $object->client);
1249  print $formcompany->selectProspectCustomerType($selected);
1250  print '</td>';
1251 
1252  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1253 
1254  print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
1255  print '<table class="nobordernopadding"><tr><td>';
1256  $tmpcode = $object->code_client;
1257  if (empty($tmpcode) && !empty($modCodeClient->code_auto)) $tmpcode = $modCodeClient->getNextValue($object, 0);
1258  print '<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
1259  print '</td><td>';
1260  $s = $modCodeClient->getToolTip($langs, $object, 0);
1261  print $form->textwithpicto('', $s, 1);
1262  print '</td></tr></table>';
1263  print '</td></tr>';
1264 
1265  if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1266  || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire)))
1267  {
1268  // Supplier
1269  print '<tr>';
1270  print '<td>'.$form->editfieldkey('Vendor', 'fournisseur', '', $object, 0, 'string', '', 1).'</td><td>';
1271  $default = -1;
1272  if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) $default = 1;
1273  print $form->selectyesno("fournisseur", (GETPOST('fournisseur', 'int') != '' ? GETPOST('fournisseur', 'int') : (GETPOST("type", 'alpha') == '' ? $default : $object->fournisseur)), 1, 0, (GETPOST("type", 'alpha') == '' ? 1 : 0), 1);
1274  print '</td>';
1275 
1276 
1277  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1278 
1279  print '<td>';
1280  if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1281  {
1282  print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0);
1283  }
1284  print '</td><td>';
1285  if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1286  {
1287  print '<table class="nobordernopadding"><tr><td>';
1288  $tmpcode = $object->code_fournisseur;
1289  if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1290  print '<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
1291  print '</td><td>';
1292  $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1293  print $form->textwithpicto('', $s, 1);
1294  print '</td></tr></table>';
1295  }
1296  print '</td></tr>';
1297  }
1298 
1299  // Status
1300  print '<tr><td>'.$form->editfieldkey('Status', 'status', '', $object, 0).'</td><td colspan="3">';
1301  print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
1302  print '</td></tr>';
1303 
1304  // Barcode
1305  if (!empty($conf->barcode->enabled))
1306  {
1307  print '<tr><td>'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
1308  print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">';
1309  print '</td></tr>';
1310  }
1311 
1312  // Address
1313  print '<tr><td class="tdtop">';
1314  print $form->editfieldkey('Address', 'address', '', $object, 0);
1315  print '</td>';
1316  print '<td colspan="3">';
1317  print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.'" wrap="soft">';
1318  print dol_escape_htmltag($object->address, 0, 1);
1319  print '</textarea>';
1320  print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
1321  print '</td></tr>';
1322 
1323  // Zip / Town
1324  print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
1325  print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
1326  print '</td>';
1327  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1328  print '<td class="tdtop">'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
1329  print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100 quatrevingtpercent');
1330  print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
1331  print '</td></tr>';
1332 
1333  // Country
1334  print '<tr><td>'.$form->editfieldkey('Country', 'selectcountry_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1335  print img_picto('', 'globe-americas', 'class="paddingrightonly"');
1336  print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 maxwidth500 widthcentpercentminusx');
1337  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1338  print '</td></tr>';
1339 
1340  // State
1341  if (empty($conf->global->SOCIETE_DISABLE_STATE))
1342  {
1343  if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1344  {
1345  print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1346  } else {
1347  print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">';
1348  }
1349 
1350  if ($object->country_id) print $formcompany->select_state($object->state_id, $object->country_code);
1351  else print $countrynotdefined;
1352  print '</td></tr>';
1353  }
1354 
1355  // Phone / Fax
1356  print '<tr><td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
1357  print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning').' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone') ?GETPOST('phone', 'alpha') : $object->phone).'"></td>';
1358  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1359  print '<td>'.$form->editfieldkey('Fax', 'fax', '', $object, 0).'</td>';
1360  print '<td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'.img_picto('', 'object_phoning_fax').' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('fax') ?GETPOST('fax', 'alpha') : $object->fax).'"></td></tr>';
1361 
1362  // Email / Web
1363  print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ? '' : $conf->global->SOCIETE_EMAIL_MANDATORY).'</td>';
1364  print '<td colspan="3">'.img_picto('', 'object_email').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="email" id="email" value="'.$object->email.'"></td></tr>';
1365  print '<tr><td>'.$form->editfieldkey('Web', 'url', '', $object, 0).'</td>';
1366  print '<td colspan="3">'.img_picto('', 'globe').' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.'"></td></tr>';
1367 
1368  if (!empty($conf->socialnetworks->enabled)) {
1369  foreach ($socialnetworks as $key => $value) {
1370  if ($value['active']) {
1371  print '<tr>';
1372  print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>';
1373  print '<td colspan="3">';
1374  print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : (empty($object->socialnetworks[$key]) ? '' : $object->socialnetworks[$key])).'">';
1375  print '</td>';
1376  print '</tr>';
1377  } elseif (!empty($object->socialnetworks[$key])) {
1378  print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">';
1379  }
1380  }
1381  }
1382 
1383  // Prof ids
1384  $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2);
1385  while ($i <= 6) {
1386  $idprof = $langs->transcountry('ProfId'.$i, $object->country_code);
1387  if ($idprof != '-') {
1388  $key = 'idprof'.$i;
1389 
1390  if (($j % $NBCOLS) == 0) print '<tr>';
1391 
1392  $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY';
1393  print '<td>'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).'</td><td>';
1394 
1395  print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1396  print '</td>';
1397  if (($j % $NBCOLS) == ($NBCOLS - 1)) print '</tr>';
1398  $j++;
1399  }
1400  $i++;
1401  }
1402  if ($NBCOLS > 1 && ($j % 2 == 1)) print '<td colspan="2"></td></tr>';
1403 
1404  // Vat is used
1405  print '<tr><td>'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).'</td>';
1406  print '<td>';
1407  print $form->selectyesno('assujtva_value', GETPOSTISSET('assujtva_value') ?GETPOST('assujtva_value', 'int') : 1, 1); // Assujeti par defaut en creation
1408  print '</td>';
1409  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1410  print '<td class="nowrap">'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).'</td>';
1411  print '<td class="nowrap">';
1412  $s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
1413 
1414  if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object)) {
1415  $s .= ' ';
1416 
1417  if (!empty($conf->use_javascript_ajax)) {
1418  $widthpopup = 600;
1419  if (!empty($conf->dol_use_jmobile)) $widthpopup = 350;
1420  $heightpopup = 400;
1421  print "\n";
1422  print '<script language="JavaScript" type="text/javascript">';
1423  print "function CheckVAT(a) {\n";
1424  print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n";
1425  print "}\n";
1426  print '</script>';
1427  print "\n";
1428  $s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
1429  $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
1430  } else {
1431  $s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
1432  }
1433  }
1434  print $s;
1435  print '</td>';
1436  print '</tr>';
1437 
1438  // Local Taxes
1439  //TODO: Place into a function to control showing by country or study better option
1440  if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
1441  {
1442  print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
1443  print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1444  print '</td>';
1445  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1446  print '<td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
1447  print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1448  print '</td></tr>';
1449  } elseif ($mysoc->localtax1_assuj == "1")
1450  {
1451  print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td colspan="3">';
1452  print $form->selectyesno('localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1453  print '</td></tr>';
1454  } elseif ($mysoc->localtax2_assuj == "1")
1455  {
1456  print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td colspan="3">';
1457  print $form->selectyesno('localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1458  print '</td></tr>';
1459  }
1460 
1461  // Type - Workforce/Staff
1462  print '<tr><td>'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>'."\n";
1463  $sortparam = (empty($conf->global->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.
1464  print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam, '', 1);
1465  if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1466  print '</td>';
1467  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1468  print '<td>'.$form->editfieldkey('Workforce', 'effectif_id', '', $object, 0).'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>';
1469  print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0, '', 0, 0, 0, '', '', 1);
1470  if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1471  print '</td></tr>';
1472 
1473  // Legal Form
1474  print '<tr><td>'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).'</td>';
1475  print '<td colspan="3" class="maxwidthonsmartphone">';
1476  if ($object->country_id)
1477  {
1478  print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
1479  } else {
1480  print $countrynotdefined;
1481  }
1482  print '</td></tr>';
1483 
1484  // Capital
1485  print '<tr><td>'.$form->editfieldkey('Capital', 'capital', '', $object, 0).'</td>';
1486  print '<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.'"> ';
1487  print '<span class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</span></td></tr>';
1488 
1489  if (!empty($conf->global->MAIN_MULTILANGS))
1490  {
1491  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
1492  print $formadmin->select_language(GETPOST('default_lang', 'alpha') ? GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
1493  print '</td>';
1494  print '</tr>';
1495  }
1496 
1497  // Incoterms
1498  if (!empty($conf->incoterm->enabled))
1499  {
1500  print '<tr>';
1501  print '<td>'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).'</td>';
1502  print '<td colspan="3" class="maxwidthonsmartphone">';
1503  print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
1504  print '</td></tr>';
1505  }
1506 
1507  // Categories
1508  if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
1509  {
1510  $langs->load('categories');
1511 
1512  // Customer
1513  //if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) {
1514  print '<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey('CustomersProspectsCategoriesShort', 'custcats', '', $object, 0).'</td><td colspan="3">';
1515  $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1);
1516  print img_picto('', 'category').$form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1517  print "</td></tr>";
1518  //}
1519 
1520  // Supplier
1521  if (!empty($conf->fournisseur->enabled)) {
1522  print '<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).'</td><td colspan="3">';
1523  $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1);
1524  print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1525  print "</td></tr>";
1526  }
1527  }
1528 
1529  // Multicurrency
1530  if (!empty($conf->multicurrency->enabled))
1531  {
1532  print '<tr>';
1533  print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
1534  print '<td colspan="3" class="maxwidthonsmartphone">';
1535  print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
1536  print '</td></tr>';
1537  }
1538 
1539  // Other attributes
1540  $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
1541  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
1542 
1543  // Assign a sale representative
1544  print '<tr>';
1545  print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
1546  print '<td colspan="3" class="maxwidthonsmartphone">';
1547  $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1);
1548  // 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.
1549  $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array())));
1550  print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1551  print '</td></tr>';
1552 
1553  // Ajout du logo
1554  print '<tr class="hideonsmartphone">';
1555  print '<td>'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).'</td>';
1556  print '<td colspan="3">';
1557  print '<input class="flat" type="file" name="photo" id="photoinput" />';
1558  print '</td>';
1559  print '</tr>';
1560 
1561  print '</table>'."\n";
1562 
1563  print dol_get_fiche_end();
1564 
1565  print '<div class="center">';
1566  print '<input type="submit" class="button" name="create" value="'.$langs->trans('AddThirdParty').'">';
1567  if (!empty($backtopage))
1568  {
1569  print ' &nbsp; &nbsp; ';
1570  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
1571  } else {
1572  print ' &nbsp; &nbsp; ';
1573  print '<input type="button" class="button button-cancel" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
1574  }
1575  print '</div>'."\n";
1576 
1577  print '</form>'."\n";
1578  } elseif ($action == 'edit') {
1579  //print load_fiche_titre($langs->trans("EditCompany"));
1580 
1581  if ($socid)
1582  {
1583  $res = $object->fetch_optionals();
1584  //if ($res < 0) { dol_print_error($db); exit; }
1585 
1586  $head = societe_prepare_head($object);
1587 
1588  // Load object modCodeTiers
1589  $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
1590  if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
1591  {
1592  $module = substr($module, 0, dol_strlen($module) - 4);
1593  }
1594  $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
1595  foreach ($dirsociete as $dirroot)
1596  {
1597  $res = dol_include_once($dirroot.$module.'.php');
1598  if ($res) break;
1599  }
1600  $modCodeClient = new $module($db);
1601  // We verified if the tag prefix is used
1602  if ($modCodeClient->code_auto)
1603  {
1604  $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1605  }
1606  $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1607  if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php')
1608  {
1609  $module = substr($module, 0, dol_strlen($module) - 4);
1610  }
1611  $dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']);
1612  foreach ($dirsociete as $dirroot)
1613  {
1614  $res = dol_include_once($dirroot.$module.'.php');
1615  if ($res) break;
1616  }
1617  $modCodeFournisseur = new $module($db);
1618  // On verifie si la balise prefix est utilisee
1619  if ($modCodeFournisseur->code_auto)
1620  {
1621  $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1622  }
1623 
1624  $object->oldcopy = clone $object;
1625 
1626  if (GETPOSTISSET('name'))
1627  {
1628  // We overwrite with values if posted
1629  $object->name = GETPOST('name', 'alphanohtml');
1630  $object->prefix_comm = GETPOST('prefix_comm', 'alphanohtml');
1631  $object->client = GETPOST('client', 'int');
1632  $object->code_client = GETPOST('customer_code', 'alpha');
1633  $object->fournisseur = GETPOST('fournisseur', 'int');
1634  $object->code_fournisseur = GETPOST('supplier_code', 'alpha');
1635  $object->address = GETPOST('address', 'alphanohtml');
1636  $object->zip = GETPOST('zipcode', 'alphanohtml');
1637  $object->town = GETPOST('town', 'alphanohtml');
1638  $object->country_id = GETPOST('country_id') ?GETPOST('country_id', 'int') : $mysoc->country_id;
1639  $object->state_id = GETPOST('state_id', 'int');
1640  //$object->skype = GETPOST('skype', 'alpha');
1641  //$object->twitter = GETPOST('twitter', 'alpha');
1642  //$object->facebook = GETPOST('facebook', 'alpha');
1643  //$object->linkedin = GETPOST('linkedin', 'alpha');
1644  $object->socialnetworks = array();
1645  if (!empty($conf->socialnetworks->enabled)) {
1646  foreach ($socialnetworks as $key => $value) {
1647  if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') {
1648  $object->socialnetworks[$key] = GETPOST($key, 'alphanohtml');
1649  }
1650  }
1651  }
1652  $object->phone = GETPOST('phone', 'alpha');
1653  $object->fax = GETPOST('fax', 'alpha');
1654  $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
1655  $object->url = GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL);
1656  $object->capital = GETPOST('capital', 'alphanohtml');
1657  $object->idprof1 = GETPOST('idprof1', 'alphanohtml');
1658  $object->idprof2 = GETPOST('idprof2', 'alphanohtml');
1659  $object->idprof3 = GETPOST('idprof3', 'alphanohtml');
1660  $object->idprof4 = GETPOST('idprof4', 'alphanohtml');
1661  $object->idprof5 = GETPOST('idprof5', 'alphanohtml');
1662  $object->idprof6 = GETPOST('idprof6', 'alphanohtml');
1663  $object->typent_id = GETPOST('typent_id', 'int');
1664  $object->effectif_id = GETPOST('effectif_id', 'int');
1665  $object->barcode = GETPOST('barcode', 'alphanohtml');
1666  $object->forme_juridique_code = GETPOST('forme_juridique_code', 'int');
1667  $object->default_lang = GETPOST('default_lang', 'alpha');
1668 
1669  $object->tva_assuj = GETPOST('assujtva_value', 'int');
1670  $object->tva_intra = GETPOST('tva_intra', 'alphanohtml');
1671  $object->status = GETPOST('status', 'int');
1672 
1673  // Webservices url/key
1674  $object->webservices_url = GETPOST('webservices_url', 'custom', 0, FILTER_SANITIZE_URL);
1675  $object->webservices_key = GETPOST('webservices_key', 'san_alpha');
1676 
1677  //Incoterms
1678  if (!empty($conf->incoterm->enabled))
1679  {
1680  $object->fk_incoterms = GETPOST('incoterm_id', 'int');
1681  $object->location_incoterms = GETPOST('lcoation_incoterms', 'alpha');
1682  }
1683 
1684  //Local Taxes
1685  $object->localtax1_assuj = GETPOST('localtax1assuj_value');
1686  $object->localtax2_assuj = GETPOST('localtax2assuj_value');
1687 
1688  $object->localtax1_value = GETPOST('lt1');
1689  $object->localtax2_value = GETPOST('lt2');
1690 
1691  // We set country_id, and country_code label of the chosen country
1692  if ($object->country_id > 0)
1693  {
1694  $tmparray = getCountry($object->country_id, 'all');
1695  $object->country_code = $tmparray['code'];
1696  $object->country = $tmparray['label'];
1697  }
1698  }
1699 
1700  if ($object->localtax1_assuj == 0) {
1701  $sub = 0;
1702  } else {$sub = 1; }
1703  if ($object->localtax2_assuj == 0) {
1704  $sub2 = 0;
1705  } else {$sub2 = 1; }
1706 
1707  if ($conf->use_javascript_ajax)
1708  {
1709  print "\n".'<script type="text/javascript">';
1710  print '$(document).ready(function () {
1711  var val='.$sub.';
1712  var val2='.$sub2.';
1713  if("#localtax1assuj_value".value==undefined){
1714  if(val==1){
1715  $(".cblt1").show();
1716  }else{
1717  $(".cblt1").hide();
1718  }
1719  }
1720  if("#localtax2assuj_value".value==undefined){
1721  if(val2==1){
1722  $(".cblt2").show();
1723  }else{
1724  $(".cblt2").hide();
1725  }
1726  }
1727  $("#localtax1assuj_value").change(function() {
1728  var value=document.getElementById("localtax1assuj_value").value;
1729  if(value==1){
1730  $(".cblt1").show();
1731  }else{
1732  $(".cblt1").hide();
1733  }
1734  });
1735  $("#localtax2assuj_value").change(function() {
1736  var value=document.getElementById("localtax2assuj_value").value;
1737  if(value==1){
1738  $(".cblt2").show();
1739  }else{
1740  $(".cblt2").hide();
1741  }
1742  });
1743 
1744  init_customer_categ();
1745  $("#customerprospect").change(function() {
1746  init_customer_categ();
1747  });
1748  function init_customer_categ() {
1749  console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1750  if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER) ? '1' : '0').'))
1751  {
1752  jQuery(".visibleifcustomer").hide();
1753  }
1754  else
1755  {
1756  jQuery(".visibleifcustomer").show();
1757  }
1758  }
1759 
1760  init_supplier_categ();
1761  $("#fournisseur").change(function() {
1762  init_supplier_categ();
1763  });
1764  function init_supplier_categ() {
1765  console.log("is supplier = "+jQuery("#fournisseur").val());
1766  if (jQuery("#fournisseur").val() == 0)
1767  {
1768  jQuery(".visibleifsupplier").hide();
1769  }
1770  else
1771  {
1772  jQuery(".visibleifsupplier").show();
1773  }
1774  };
1775 
1776  $("#selectcountry_id").change(function() {
1777  document.formsoc.action.value="edit";
1778  document.formsoc.submit();
1779  });
1780 
1781  })';
1782  print '</script>'."\n";
1783  }
1784 
1785  print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="post" name="formsoc">';
1786  print '<input type="hidden" name="action" value="update">';
1787  print '<input type="hidden" name="token" value="'.newToken().'">';
1788  print '<input type="hidden" name="socid" value="'.$object->id.'">';
1789  print '<input type="hidden" name="entity" value="'.$object->entity.'">';
1790  if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) print '<input type="hidden" name="code_auto" value="1">';
1791 
1792 
1793  print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), 0, 'company');
1794 
1795  print '<div class="fichecenter2">';
1796  print '<table class="border centpercent">';
1797 
1798  // Ref/ID
1799  if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
1800  {
1801  print '<tr><td class="titlefieldcreate">'.$langs->trans("ID").'</td><td colspan="3">';
1802  print $object->ref;
1803  print '</td></tr>';
1804  }
1805 
1806  // Name
1807  print '<tr><td class="titlefieldcreate">'.$form->editfieldkey('ThirdPartyName', 'name', '', $object, 0, 'string', '', 1).'</td>';
1808  print '<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).'" autofocus="autofocus">';
1809  print $form->widgetForTranslation("name", $object, $permissiontoadd, 'string', 'alpahnohtml', 'minwidth300');
1810  print '</td></tr>';
1811 
1812  // Alias names (commercial, trademark or alias names)
1813  print '<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans('AliasNames').'</label></td>';
1814  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>';
1815 
1816  // Prefix
1817  if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
1818  {
1819  print '<tr><td>'.$form->editfieldkey('Prefix', 'prefix', '', $object, 0).'</td><td colspan="3">';
1820  // It does not change the prefix mode using the auto numbering prefix
1821  if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm)
1822  {
1823  print '<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).'">';
1824  print $object->prefix_comm;
1825  } else {
1826  print '<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).'">';
1827  }
1828  print '</td>';
1829  }
1830 
1831  // Prospect/Customer
1832  print '<tr><td>'.$form->editfieldkey('ProspectCustomer', 'customerprospect', '', $object, 0, 'string', '', 1).'</td>';
1833  print '<td class="maxwidthonsmartphone">';
1834  print $formcompany->selectProspectCustomerType($object->client);
1835  print '</td>';
1836  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1837  print '<td>'.$form->editfieldkey('CustomerCode', 'customer_code', '', $object, 0).'</td><td>';
1838 
1839  print '<table class="nobordernopadding"><tr><td>';
1840  if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto)
1841  {
1842  $tmpcode = $object->code_client;
1843  if (empty($tmpcode) && !empty($object->oldcopy->code_client)) $tmpcode = $object->oldcopy->code_client; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
1844  if (empty($tmpcode) && !empty($modCodeClient->code_auto)) $tmpcode = $modCodeClient->getNextValue($object, 0);
1845  print '<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
1846  } elseif ($object->codeclient_modifiable())
1847  {
1848  print '<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).'" maxlength="24">';
1849  } else {
1850  print $object->code_client;
1851  print '<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).'">';
1852  }
1853  print '</td><td>';
1854  $s = $modCodeClient->getToolTip($langs, $object, 0);
1855  print $form->textwithpicto('', $s, 1);
1856  print '</td></tr></table>';
1857 
1858  print '</td></tr>';
1859 
1860  // Supplier
1861  if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1862  || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire)))
1863  {
1864  print '<tr>';
1865  print '<td>'.$form->editfieldkey('Supplier', 'fournisseur', '', $object, 0, 'string', '', 1).'</td>';
1866  print '<td class="maxwidthonsmartphone">';
1867  print $form->selectyesno("fournisseur", $object->fournisseur, 1, false, 0, 1);
1868  print '</td>';
1869  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1870  print '<td>';
1871  if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1872  {
1873  print $form->editfieldkey('SupplierCode', 'supplier_code', '', $object, 0);
1874  }
1875  print '</td>';
1876  print '<td>';
1877  print '<table class="nobordernopadding"><tr><td>';
1878  if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto)
1879  {
1880  $tmpcode = $object->code_fournisseur;
1881  if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) $tmpcode = $object->oldcopy->code_fournisseur; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
1882  if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1883  print '<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).'" maxlength="24">';
1884  } elseif ($object->codefournisseur_modifiable())
1885  {
1886  print '<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).'" maxlength="24">';
1887  } else {
1888  print $object->code_fournisseur;
1889  print '<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.'">';
1890  }
1891  print '</td><td>';
1892  $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1893  print $form->textwithpicto('', $s, 1);
1894  print '</td></tr></table>';
1895  print '</td></tr>';
1896  }
1897 
1898  // Barcode
1899  if (!empty($conf->barcode->enabled))
1900  {
1901  print '<tr><td class="tdtop">'.$form->editfieldkey('Gencod', 'barcode', '', $object, 0).'</td>';
1902  print '<td colspan="3"><input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).'">';
1903  print '</td></tr>';
1904  }
1905 
1906  // Status
1907  print '<tr><td>'.$form->editfieldkey('Status', 'status', '', $object, 0).'</td><td colspan="3">';
1908  print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
1909  print '</td></tr>';
1910 
1911  // Address
1912  print '<tr><td class="tdtop">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
1913  print '<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
1914  print dol_escape_htmltag($object->address, 0, 1);
1915  print '</textarea>';
1916  print $form->widgetForTranslation("address", $object, $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
1917  print '</td></tr>';
1918 
1919  // Zip / Town
1920  print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
1921  print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
1922  print '</td>';
1923  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1924  print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
1925  print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
1926  print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
1927  print '</td></tr>';
1928 
1929  // Country
1930  print '<tr><td>'.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).'</td><td colspan="3">';
1931  print img_picto('', 'globe-americas', 'class="paddingrightonly"');
1932  print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth300 maxwidth500 widthcentpercentminusx');
1933  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1934  print '</td></tr>';
1935 
1936  // State
1937  if (empty($conf->global->SOCIETE_DISABLE_STATE))
1938  {
1939  if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1940  {
1941  print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td colspan="3">';
1942  } else {
1943  print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td colspan="3">';
1944  }
1945 
1946  print $formcompany->select_state($object->state_id, $object->country_code);
1947  print '</td></tr>';
1948  }
1949 
1950  // Phone / Fax
1951  print '<tr><td>'.$form->editfieldkey('Phone', 'phone', GETPOST('phone', 'alpha'), $object, 0).'</td>';
1952  print '<td>'.img_picto('', 'object_phoning').' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('phone') ?GETPOST('phone', 'alpha') : $object->phone).'"></td>';
1953  if ($conf->browser->layout == 'phone') print '</tr><tr>';
1954  print '<td>'.$form->editfieldkey('Fax', 'fax', GETPOST('fax', 'alpha'), $object, 0).'</td>';
1955  print '<td>'.img_picto('', 'object_phoning_fax').' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET('fax') ?GETPOST('fax', 'alpha') : $object->fax).'"></td></tr>';
1956 
1957  // EMail / Web
1958  print '<tr><td>'.$form->editfieldkey('EMail', 'email', GETPOST('email', 'alpha'), $object, 0, 'string', '', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).'</td>';
1959  print '<td colspan="3">'.img_picto('', 'object_email').' <input type="text" name="email" id="email" class="maxwidth200onsmartphone widthcentpercentminusx" value="'.(GETPOSTISSET('email') ?GETPOST('email', 'alpha') : $object->email).'"></td></tr>';
1960  print '<tr><td>'.$form->editfieldkey('Web', 'url', GETPOST('url', 'alpha'), $object, 0).'</td>';
1961  print '<td colspan="3">'.img_picto('', 'globe').' <input type="text" name="url" id="url" class="maxwidth200onsmartphone widthcentpercentminusx " value="'.(GETPOSTISSET('url') ?GETPOST('url', 'alpha') : $object->url).'"></td></tr>';
1962 
1963  if (!empty($conf->socialnetworks->enabled)) {
1964  foreach ($socialnetworks as $key => $value) {
1965  if ($value['active']) {
1966  print '<tr>';
1967  print '<td><label for="'.$value['label'].'">'.$form->editfieldkey($value['label'], $key, '', $object, 0).'</label></td>';
1968  print '<td colspan="3">';
1969  print '<input type="text" name="'.$key.'" id="'.$key.'" class="minwidth100" maxlength="80" value="'.$object->socialnetworks[$key].'">';
1970  print '</td>';
1971  print '</tr>';
1972  } elseif (!empty($object->socialnetworks[$key])) {
1973  print '<input type="hidden" name="'.$key.'" value="'.$object->socialnetworks[$key].'">';
1974  }
1975  }
1976  }
1977 
1978  // Prof ids
1979  $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout == 'phone' ? 1 : 2);
1980  while ($i <= 6)
1981  {
1982  $idprof = $langs->transcountry('ProfId'.$i, $object->country_code);
1983  if ($idprof != '-')
1984  {
1985  $key = 'idprof'.$i;
1986 
1987  if (($j % $NBCOLS) == 0) print '<tr>';
1988 
1989  $idprof_mandatory = 'SOCIETE_IDPROF'.($i).'_MANDATORY';
1990  print '<td>'.$form->editfieldkey($idprof, $key, '', $object, 0, 'string', '', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).'</td><td>';
1991  print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1992  print '</td>';
1993  if (($j % $NBCOLS) == ($NBCOLS - 1)) print '</tr>';
1994  $j++;
1995  }
1996  $i++;
1997  }
1998  if ($NBCOLS > 0 && $j % 2 == 1) print '<td colspan="2"></td></tr>';
1999 
2000  // VAT is used
2001  print '<tr><td>'.$form->editfieldkey('VATIsUsed', 'assujtva_value', '', $object, 0).'</td><td colspan="3">';
2002  print $form->selectyesno('assujtva_value', $object->tva_assuj, 1);
2003  print '</td></tr>';
2004 
2005  // Local Taxes
2006  //TODO: Place into a function to control showing by country or study better option
2007  if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
2008  {
2009  print '<tr><td>'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).'</td><td>';
2010  print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1);
2011  if (!isOnlyOneLocalTax(1))
2012  {
2013  print '<span class="cblt1"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2014  $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
2015  print '</span>';
2016  }
2017  print '</td>';
2018  print '</tr><tr>';
2019  print '<td>'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).'</td><td>';
2020  print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1);
2021  if (!isOnlyOneLocalTax(2))
2022  {
2023  print '<span class="cblt2"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2024  $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
2025  print '</span>';
2026  }
2027  print '</td></tr>';
2028  } elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1")
2029  {
2030  print '<tr><td>'.$form->editfieldkey($langs->transcountry("LocalTax1IsUsed", $mysoc->country_code), 'localtax1assuj_value', '', $object, 0).'</td><td colspan="3">';
2031  print $form->selectyesno('localtax1assuj_value', $object->localtax1_assuj, 1);
2032  if (!isOnlyOneLocalTax(1))
2033  {
2034  print '<span class="cblt1"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2035  $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
2036  print '</span>';
2037  }
2038  print '</td></tr>';
2039  } elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1")
2040  {
2041  print '<tr><td>'.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).'</td><td colspan="3">';
2042  print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1);
2043  if (!isOnlyOneLocalTax(2))
2044  {
2045  print '<span class="cblt2"> '.$langs->transcountry("Type", $mysoc->country_code).': ';
2046  $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
2047  print '</span>';
2048  }
2049  print '</td></tr>';
2050  }
2051 
2052  // VAT Code
2053  print '<tr><td>'.$form->editfieldkey('VATIntra', 'intra_vat', '', $object, 0).'</td>';
2054  print '<td colspan="3">';
2055  $s = '<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.'">';
2056 
2057  if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object))
2058  {
2059  $s .= ' &nbsp; ';
2060 
2061  if ($conf->use_javascript_ajax)
2062  {
2063  $widthpopup = 600;
2064  if (!empty($conf->dol_use_jmobile)) $widthpopup = 350;
2065  $heightpopup = 400;
2066  print "\n";
2067  print '<script language="JavaScript" type="text/javascript">';
2068  print "function CheckVAT(a) {\n";
2069  print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n";
2070  print "}\n";
2071  print '</script>';
2072  print "\n";
2073  $s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
2074  $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
2075  } else {
2076  $s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
2077  }
2078  }
2079  print $s;
2080  print '</td>';
2081  print '</tr>';
2082 
2083  // Type - Workforce/Staff
2084  print '<tr><td>'.$form->editfieldkey('ThirdPartyType', 'typent_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
2085  print $form->selectarray("typent_id", $formcompany->typent_array(0), $object->typent_id, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1);
2086  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2087  print '</td>';
2088  if ($conf->browser->layout == 'phone') print '</tr><tr>';
2089  print '<td>'.$form->editfieldkey('Workforce', 'effectif_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
2090  print $form->selectarray("effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0, '', 0, 0, 0, '', '', 1);
2091  if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2092  print '</td></tr>';
2093 
2094  // Juridical type
2095  print '<tr><td>'.$form->editfieldkey('JuridicalStatus', 'forme_juridique_code', '', $object, 0).'</td><td class="maxwidthonsmartphone" colspan="3">';
2096  print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code, '', 'forme_juridique_code');
2097  print '</td></tr>';
2098 
2099  // Capital
2100  print '<tr><td>'.$form->editfieldkey('Capital', 'capital', '', $object, 0).'</td>';
2101  print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2102  print $object->capital != '' ? dol_escape_htmltag(price($object->capital)) : '';
2103  print '"> <font class="hideonsmartphone">'.$langs->trans("Currency".$conf->currency).'</font></td></tr>';
2104 
2105  // Default language
2106  if (!empty($conf->global->MAIN_MULTILANGS))
2107  {
2108  print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).'</td><td colspan="3">'."\n";
2109  print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1);
2110  print '</td>';
2111  print '</tr>';
2112  }
2113 
2114  // Incoterms
2115  if (!empty($conf->incoterm->enabled))
2116  {
2117  print '<tr>';
2118  print '<td>'.$form->editfieldkey('IncotermLabel', 'incoterm_id', '', $object, 0).'</td>';
2119  print '<td colspan="3" class="maxwidthonsmartphone">';
2120  print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''));
2121  print '</td></tr>';
2122  }
2123 
2124  // Categories
2125  if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
2126  {
2127  // Customer
2128  print '<tr class="visibleifcustomer"><td>'.$form->editfieldkey('CustomersCategoriesShort', 'custcats', '', $object, 0).'</td>';
2129  print '<td colspan="3">';
2130  $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1);
2131  $c = new Categorie($db);
2132  $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2133  $arrayselected = array();
2134  foreach ($cats as $cat) {
2135  $arrayselected[] = $cat->id;
2136  }
2137  print img_picto('', 'category').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
2138  print "</td></tr>";
2139 
2140  // Supplier
2141  if (!empty($conf->fournisseur->enabled)) {
2142  print '<tr class="visibleifsupplier"><td>'.$form->editfieldkey('SuppliersCategoriesShort', 'suppcats', '', $object, 0).'</td>';
2143  print '<td colspan="3">';
2144  $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1);
2145  $c = new Categorie($db);
2146  $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2147  $arrayselected = array();
2148  foreach ($cats as $cat) {
2149  $arrayselected[] = $cat->id;
2150  }
2151  print img_picto('', 'category').$form->multiselectarray('suppcats', $cate_arbo, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
2152  print "</td></tr>";
2153  }
2154  }
2155 
2156  // Multicurrency
2157  if (!empty($conf->multicurrency->enabled))
2158  {
2159  print '<tr>';
2160  print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
2161  print '<td colspan="3" class="maxwidthonsmartphone">';
2162  print $form->selectMultiCurrency(($object->multicurrency_code ? $object->multicurrency_code : $conf->currency), 'multicurrency_code', 1);
2163  print '</td></tr>';
2164  }
2165 
2166  // Other attributes
2167  $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
2168  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php';
2169 
2170  // Webservices url/key
2171  if (!empty($conf->syncsupplierwebservices->enabled)) {
2172  print '<tr><td>'.$form->editfieldkey('WebServiceURL', 'webservices_url', '', $object, 0).'</td>';
2173  print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.'"></td>';
2174  print '<td>'.$form->editfieldkey('WebServiceKey', 'webservices_key', '', $object, 0).'</td>';
2175  print '<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.'"></td></tr>';
2176  }
2177 
2178  // Logo
2179  print '<tr class="hideonsmartphone">';
2180  print '<td>'.$form->editfieldkey('Logo', 'photoinput', '', $object, 0).'</td>';
2181  print '<td colspan="3">';
2182  if ($object->logo) print $form->showphoto('societe', $object);
2183  $caneditfield = 1;
2184  if ($caneditfield)
2185  {
2186  if ($object->logo) print "<br>\n";
2187  print '<table class="nobordernopadding">';
2188  if ($object->logo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
2189  //print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
2190  print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
2191  print '</table>';
2192  }
2193  print '</td>';
2194  print '</tr>';
2195 
2196  // Assign sale representative
2197  print '<tr>';
2198  print '<td>'.$form->editfieldkey('AllocateCommercial', 'commercial_id', '', $object, 0).'</td>';
2199  print '<td colspan="3" class="maxwidthonsmartphone">';
2200  $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, 'AND u.statut = 1', 0, '', '', 0, 1);
2201  $arrayselected = GETPOST('commercial', 'array');
2202  if (empty($arrayselected)) $arrayselected = $object->getSalesRepresentatives($user, 1);
2203  print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0, '', '', '', 1);
2204  print '</td></tr>';
2205 
2206  print '</table>';
2207  print '</div>';
2208 
2209  print dol_get_fiche_end();
2210 
2211  print '<div class="center">';
2212  print '<input type="submit" class="button button-save" name="save" value="'.$langs->trans("Save").'">';
2213  print ' &nbsp; &nbsp; ';
2214  print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'">';
2215  print '</div>';
2216 
2217  print '</form>';
2218  }
2219  } else {
2220  /*
2221  * View
2222  */
2223 
2224  if (!empty($object->id)) $res = $object->fetch_optionals();
2225  //if ($res < 0) { dol_print_error($db); exit; }
2226 
2227 
2228  $head = societe_prepare_head($object);
2229 
2230  print dol_get_fiche_head($head, 'card', $langs->trans("ThirdParty"), -1, 'company');
2231 
2232  // Confirm delete third party
2233  if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)))
2234  {
2235  print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("DeleteACompany"), $langs->trans("ConfirmDeleteCompany"), "confirm_delete", '', 0, "action-delete");
2236  }
2237 
2238  if ($action == 'merge')
2239  {
2240  $formquestion = array(
2241  array(
2242  'name' => 'soc_origin',
2243  'label' => $langs->trans('MergeOriginThirdparty'),
2244  'type' => 'other',
2245  'value' => $form->select_company('', 'soc_origin', 's.rowid <> '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200')
2246  )
2247  );
2248 
2249  print $form->formconfirm($_SERVER["PHP_SELF"]."?socid=".$object->id, $langs->trans("MergeThirdparties"), $langs->trans("ConfirmMergeThirdparties"), "confirm_merge", $formquestion, 'no', 1, 250);
2250  }
2251 
2252  dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
2253 
2254  $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2255 
2256  dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
2257 
2258 
2259  print '<div class="fichecenter">';
2260  print '<div class="fichehalfleft">';
2261 
2262  print '<div class="underbanner clearboth"></div>';
2263  print '<table class="border tableforfield" width="100%">';
2264 
2265  // Prospect/Customer
2266  print '<tr><td class="titlefield">'.$langs->trans('ProspectCustomer').'</td><td>';
2267  print $object->getLibCustProspStatut();
2268  print '</td></tr>';
2269 
2270  // Supplier
2271  if (!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled))
2272  {
2273  print '<tr><td>'.$langs->trans('Supplier').'</td><td>';
2274  print yn($object->fournisseur);
2275  print '</td></tr>';
2276  }
2277 
2278  // Prefix
2279  if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
2280  {
2281  print '<tr><td>'.$langs->trans('Prefix').'</td><td>'.$object->prefix_comm.'</td>';
2282  print '</tr>';
2283  }
2284 
2285  // Customer code
2286  if ($object->client)
2287  {
2288  print '<tr><td>';
2289  print $langs->trans('CustomerCode').'</td><td>';
2290  print $object->code_client;
2291  $tmpcheck = $object->check_codeclient();
2292  if ($tmpcheck != 0 && $tmpcheck != -5) {
2293  print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
2294  }
2295  print '</td>';
2296  print '</tr>';
2297  }
2298 
2299  // Supplier code
2300  if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire))
2301  {
2302  print '<tr><td>';
2303  print $langs->trans('SupplierCode').'</td><td>';
2304  print $object->code_fournisseur;
2305  $tmpcheck = $object->check_codefournisseur();
2306  if ($tmpcheck != 0 && $tmpcheck != -5) {
2307  print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
2308  }
2309  print '</td>';
2310  print '</tr>';
2311  }
2312 
2313  // Barcode
2314  if (!empty($conf->barcode->enabled))
2315  {
2316  print '<tr><td>';
2317  print $langs->trans('Gencod').'</td><td>'.dol_escape_htmltag($object->barcode);
2318  print '</td>';
2319  print '</tr>';
2320  }
2321 
2322  // Prof ids
2323  $i = 1; $j = 0;
2324  while ($i <= 6)
2325  {
2326  $idprof = $langs->transcountry('ProfId'.$i, $object->country_code);
2327  if ($idprof != '-')
2328  {
2329  //if (($j % 2) == 0) print '<tr>';
2330  print '<tr>';
2331  print '<td>'.$idprof.'</td><td>';
2332  $key = 'idprof'.$i;
2333  print $object->$key;
2334  if ($object->$key)
2335  {
2336  if ($object->id_prof_check($i, $object) > 0) print ' &nbsp; '.$object->id_prof_url($i, $object);
2337  else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
2338  }
2339  print '</td>';
2340  //if (($j % 2) == 1) print '</tr>';
2341  print '</tr>';
2342  $j++;
2343  }
2344  $i++;
2345  }
2346  //if ($j % 2 == 1) print '<td colspan="2"></td></tr>';
2347 
2348 
2349  // 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.
2350  // We don't need them into customer profile.
2351  // Except for spain and localtax where localtax depends on buyer and not seller
2352 
2353  if ($object->fournisseur)
2354  {
2355  // VAT is used
2356  print '<tr><td>';
2357  print $form->textwithpicto($langs->trans('VATIsUsed'), $langs->trans('VATIsUsedWhenSelling'));
2358  print '</td><td>';
2359  print yn($object->tva_assuj);
2360  print '</td>';
2361  print '</tr>';
2362  }
2363 
2364  // Local Taxes
2365  if ($object->fournisseur || $mysoc->country_code == 'ES')
2366  {
2367  if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1")
2368  {
2369  print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
2370  print yn($object->localtax1_assuj);
2371  print '</td></tr><tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
2372  print yn($object->localtax2_assuj);
2373  print '</td></tr>';
2374 
2375  if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1)))
2376  {
2377  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2378  print '<input type="hidden" name="action" value="set_localtax1">';
2379  print '<input type="hidden" name="token" value="'.newToken().'">';
2380  print '<tr><td>'.$langs->transcountry("Localtax1", $mysoc->country_code).' <a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
2381  if ($action == 'editRE')
2382  {
2383  print '<td class="left">';
2384  $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
2385  print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2386  } else {
2387  print '<td>'.$object->localtax1_value.'</td>';
2388  }
2389  print '</tr></form>';
2390  }
2391  if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2)))
2392  {
2393  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2394  print '<input type="hidden" name="action" value="set_localtax2">';
2395  print '<input type="hidden" name="token" value="'.newToken().'">';
2396  print '<tr><td>'.$langs->transcountry("Localtax2", $mysoc->country_code).'<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
2397  if ($action == 'editIRPF') {
2398  print '<td class="left">';
2399  $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
2400  print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2401  } else {
2402  print '<td>'.$object->localtax2_value.'</td>';
2403  }
2404  print '</tr></form>';
2405  }
2406  } elseif ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj != "1")
2407  {
2408  print '<tr><td>'.$langs->transcountry("LocalTax1IsUsed", $mysoc->country_code).'</td><td>';
2409  print yn($object->localtax1_assuj);
2410  print '</td></tr>';
2411  if ($object->localtax1_assuj == "1" && (!isOnlyOneLocalTax(1)))
2412  {
2413  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2414  print '<input type="hidden" name="action" value="set_localtax1">';
2415  print '<input type="hidden" name="token" value="'.newToken().'">';
2416  print '<tr><td> '.$langs->transcountry("Localtax1", $mysoc->country_code).'<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editRE&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
2417  if ($action == 'editRE') {
2418  print '<td class="left">';
2419  $formcompany->select_localtax(1, $object->localtax1_value, "lt1");
2420  print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2421  } else {
2422  print '<td>'.$object->localtax1_value.'</td>';
2423  }
2424  print '</tr></form>';
2425  }
2426  } elseif ($mysoc->localtax2_assuj == "1" && $mysoc->localtax1_assuj != "1")
2427  {
2428  print '<tr><td>'.$langs->transcountry("LocalTax2IsUsed", $mysoc->country_code).'</td><td>';
2429  print yn($object->localtax2_assuj);
2430  print '</td></tr>';
2431  if ($object->localtax2_assuj == "1" && (!isOnlyOneLocalTax(2)))
2432  {
2433  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'">';
2434  print '<input type="hidden" name="action" value="set_localtax2">';
2435  print '<input type="hidden" name="token" value="'.newToken().'">';
2436  print '<tr><td> '.$langs->transcountry("Localtax2", $mysoc->country_code).' <a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editIRPF&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</td>';
2437  if ($action == 'editIRPF') {
2438  print '<td class="left">';
2439  $formcompany->select_localtax(2, $object->localtax2_value, "lt2");
2440  print '<input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
2441  } else {
2442  print '<td>'.$object->localtax2_value.'</td>';
2443  }
2444  print '</tr></form>';
2445  }
2446  }
2447  }
2448 
2449  // Sale tax code (VAT code)
2450  print '<tr>';
2451  print '<td class="nowrap">'.$langs->trans('VATIntra').'</td><td>';
2452  if ($object->tva_intra)
2453  {
2454  $s = '';
2455  $s .= dol_escape_htmltag($object->tva_intra);
2456  $s .= '<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.'">';
2457 
2458  if (empty($conf->global->MAIN_DISABLEVATCHECK) && isInEEC($object))
2459  {
2460  $s .= ' &nbsp; ';
2461 
2462  if ($conf->use_javascript_ajax)
2463  {
2464  $widthpopup = 600;
2465  if (!empty($conf->dol_use_jmobile)) $widthpopup = 350;
2466  $heightpopup = 400;
2467  print "\n";
2468  print '<script language="JavaScript" type="text/javascript">';
2469  print "function CheckVAT(a) {\n";
2470  print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."', ".$widthpopup.", ".$heightpopup.");\n";
2471  print "}\n";
2472  print '</script>';
2473  print "\n";
2474  $s .= '<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans("VATIntraCheck").'</a>';
2475  $s = $form->textwithpicto($s, $langs->trans("VATIntraCheckDesc", $langs->transnoentitiesnoconv("VATIntraCheck")), 1);
2476  } else {
2477  $s .= '<a href="'.$langs->transcountry("VATIntraCheckURL", $object->country_id).'" class="hideonsmartphone" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"), 'help').'</a>';
2478  }
2479  }
2480  print $s;
2481  } else {
2482  print '&nbsp;';
2483  }
2484  print '</td></tr>';
2485 
2486  // Third-Party Type
2487  print '<tr><td>';
2488  print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('ThirdPartyType').'</td>';
2489  if ($action != 'editthirdpartytype' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editthirdpartytype&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
2490  print '</tr></table>';
2491  print '</td><td>';
2492  $html_name = ($action == 'editthirdpartytype') ? 'typent_id' : 'none';
2493  $formcompany->formThirdpartyType($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->typent_id, $html_name, '');
2494  print '</td></tr>';
2495 
2496  // Workforce/Staff
2497  print '<tr><td>'.$langs->trans("Workforce").'</td><td>'.$object->effectif.'</td></tr>';
2498 
2499  print '</table>';
2500  print '</div>';
2501 
2502  print '<div class="fichehalfright"><div class="ficheaddleft">';
2503 
2504  print '<div class="underbanner clearboth"></div>';
2505  print '<table class="border tableforfield" width="100%">';
2506 
2507  // Tags / categories
2508  if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
2509  {
2510  // Customer
2511  if ($object->prospect || $object->client || (!$object->fournisseur && !empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) {
2512  print '<tr><td>'.$langs->trans("CustomersCategoriesShort").'</td>';
2513  print '<td>';
2514  print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
2515  print "</td></tr>";
2516  }
2517 
2518  // Supplier
2519  if (!empty($conf->fournisseur->enabled) && $object->fournisseur) {
2520  print '<tr><td>'.$langs->trans("SuppliersCategoriesShort").'</td>';
2521  print '<td>';
2522  print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
2523  print "</td></tr>";
2524  }
2525  }
2526 
2527  // Legal
2528  print '<tr><td class="titlefield">'.$langs->trans('JuridicalStatus').'</td><td>'.$object->forme_juridique.'</td></tr>';
2529 
2530  // Capital
2531  print '<tr><td>'.$langs->trans('Capital').'</td><td>';
2532  if ($object->capital) print price($object->capital, '', $langs, 0, -1, -1, $conf->currency);
2533  else print '&nbsp;';
2534  print '</td></tr>';
2535 
2536  // Default language
2537  if (!empty($conf->global->MAIN_MULTILANGS))
2538  {
2539  require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2540  print '<tr><td>'.$langs->trans("DefaultLang").'</td><td>';
2541  //$s=picto_from_langcode($object->default_lang);
2542  //print ($s?$s.' ':'');
2543  $langs->load("languages");
2544  $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang) : '');
2545  print $labellang;
2546  print '</td></tr>';
2547  }
2548 
2549  // Incoterms
2550  if (!empty($conf->incoterm->enabled))
2551  {
2552  print '<tr><td>';
2553  print '<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans('IncotermLabel').'</td>';
2554  if ($action != 'editincoterm' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=editincoterm">'.img_edit('', 1).'</a></td>';
2555  print '</tr></table>';
2556  print '</td><td colspan="3">';
2557  if ($action != 'editincoterm')
2558  {
2559  print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2560  } else {
2561  print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?socid='.$object->id);
2562  }
2563  print '</td></tr>';
2564  }
2565 
2566  // Multicurrency
2567  if (!empty($conf->multicurrency->enabled))
2568  {
2569  print '<tr>';
2570  print '<td>'.$form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0).'</td>';
2571  print '<td>';
2572  print !empty($object->multicurrency_code) ? currency_name($object->multicurrency_code, 1) : '';
2573  print '</td></tr>';
2574  }
2575 
2576  // Other attributes
2577  $parameters = array('socid'=>$socid, 'colspan' => ' colspan="3"', 'colspanvalue' => '3');
2578  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
2579 
2580  // Parent company
2581  if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY))
2582  {
2583  print '<tr><td>';
2584  print '<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans('ParentCompany').'</td>';
2585  if ($action != 'editparentcompany' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editparentcompany&amp;socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
2586  print '</tr></table>';
2587  print '</td><td>';
2588  $html_name = ($action == 'editparentcompany') ? 'parent_id' : 'none';
2589  $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->parent, $html_name, 's.rowid <> '.$object->id, 1);
2590  print '</td></tr>';
2591  }
2592 
2593  // Sales representative
2594  include DOL_DOCUMENT_ROOT.'/societe/tpl/linesalesrepresentative.tpl.php';
2595 
2596  // Module Adherent
2597  if (!empty($conf->adherent->enabled))
2598  {
2599  $langs->load("members");
2600  print '<tr><td>'.$langs->trans("LinkedToDolibarrMember").'</td>';
2601  print '<td>';
2602  $adh = new Adherent($db);
2603  $result = $adh->fetch('', '', $object->id);
2604  if ($result > 0)
2605  {
2606  $adh->ref = $adh->getFullName($langs);
2607  print $adh->getNomUrl(1);
2608  } else {
2609  print '<span class="opacitymedium">'.$langs->trans("ThirdpartyNotLinkedToMember").'</span>';
2610  }
2611  print "</td></tr>\n";
2612  }
2613 
2614  // Webservices url/key
2615  if (!empty($conf->syncsupplierwebservices->enabled)) {
2616  print '<tr><td>'.$langs->trans("WebServiceURL").'</td><td>'.dol_print_url($object->webservices_url).'</td>';
2617  print '<td class="nowrap">'.$langs->trans('WebServiceKey').'</td><td>'.$object->webservices_key.'</td></tr>';
2618  }
2619 
2620  print '</table>';
2621  print '</div>';
2622 
2623  print '</div></div>';
2624  print '<div style="clear:both"></div>';
2625 
2626  print dol_get_fiche_end();
2627 
2628 
2629  /*
2630  * Actions
2631  */
2632  if ($action != 'presend')
2633  {
2634  print '<div class="tabsAction">'."\n";
2635 
2636  $parameters = array();
2637  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2638  if (empty($reshook))
2639  {
2640  $at_least_one_email_contact = false;
2641  $TContact = $object->contact_array_objects();
2642  foreach ($TContact as &$contact)
2643  {
2644  if (!empty($contact->email))
2645  {
2646  $at_least_one_email_contact = true;
2647  break;
2648  }
2649  }
2650 
2651  if (empty($user->socid)) {
2652  if (!empty($object->email) || $at_least_one_email_contact)
2653  {
2654  $langs->load("mails");
2655  print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?socid='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>';
2656  } else {
2657  $langs->load("mails");
2658  print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoEMail")).'">'.$langs->trans('SendMail').'</a>';
2659  }
2660  }
2661 
2662  if ($user->rights->societe->creer)
2663  {
2664  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
2665  }
2666 
2667  if (!empty($conf->adherent->enabled))
2668  {
2669  $adh = new Adherent($db);
2670  $result = $adh->fetch('', '', $object->id);
2671  if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS))
2672  {
2673  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>';
2674  }
2675  }
2676 
2677  if ($user->rights->societe->supprimer)
2678  {
2679  print '<a class="butActionDelete" href="card.php?action=merge&socid='.$object->id.'" title="'.dol_escape_htmltag($langs->trans("MergeThirdparties")).'">'.$langs->trans('Merge').'</a>';
2680  }
2681 
2682  if ($user->rights->societe->supprimer)
2683  {
2684  if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) // We can't use preloaded confirm form with jmobile
2685  {
2686  print '<span id="action-delete" class="butActionDelete">'.$langs->trans('Delete').'</span>'."\n";
2687  } else {
2688  print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&amp;action=delete&amp;token='.newToken().'">'.$langs->trans('Delete').'</a>'."\n";
2689  }
2690  }
2691  }
2692 
2693  print '</div>'."\n";
2694  }
2695 
2696  //Select mail models is same action as presend
2697  if (GETPOST('modelselected')) {
2698  $action = 'presend';
2699  }
2700 
2701  if ($action != 'presend')
2702  {
2703  print '<div class="fichecenter"><div class="fichehalfleft">';
2704 
2705  if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
2706  {
2707  print '<a name="builddoc"></a>'; // ancre
2708 
2709  /*
2710  * Documents generes
2711  */
2712  $filedir = $conf->societe->multidir_output[$object->entity].'/'.$object->id;
2713  $urlsource = $_SERVER["PHP_SELF"]."?socid=".$object->id;
2714  $genallowed = $user->rights->societe->lire;
2715  $delallowed = $user->rights->societe->creer;
2716 
2717  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);
2718  }
2719 
2720  // Subsidiaries list
2721  if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES))
2722  {
2723  $result = show_subsidiaries($conf, $langs, $db, $object);
2724  }
2725 
2726  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
2727 
2728  $MAXEVENT = 10;
2729 
2730  $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id);
2731 
2732  // List of actions on element
2733  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
2734  $formactions = new FormActions($db);
2735  $somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty
2736 
2737  print '</div></div></div>';
2738 
2739  if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD))
2740  {
2741  // Contacts list
2742  if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
2743  {
2744  $result = show_contacts($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
2745  }
2746 
2747  // Addresses list
2748  if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
2749  {
2750  $result = show_addresses($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id);
2751  }
2752  }
2753  }
2754 
2755  // Presend form
2756  $modelmail = 'thirdparty';
2757  $defaulttopic = 'Information';
2758  $diroutput = $conf->societe->dir_output;
2759  $trackid = 'thi'.$object->id;
2760 
2761  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
2762  }
2763 }
2764 
2765 // End of page
2766 llxFooter();
2767 $db->close();
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
deleteFilesIntoDatabaseIndex($dir, $file, $mode= 'uploaded')
Delete files into database index using search criterias.
Definition: files.lib.php:1795
Class to manage building of HTML components.
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
Class to manage canvas.
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.
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
show_contacts($conf, $langs, $db, $object, $backtopage= '')
Show html area for list of contacts.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
Definition: images.lib.php:39
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...
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation &lt;http[s]&gt; :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor]...
currency_name($code_iso, $withcode= '', $outputlangs=null)
Return label of currency or code+label.
Class to generate html code for admin pages.
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to build HTML component for third parties management Only common components are here...
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
Definition: files.lib.php:1286
Class to manage members of a foundation.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
Definition: notice.php:44
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
Definition: files.lib.php:1144
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
Definition: company.lib.php:42
Class to offer components to list and upload files.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles= 'addedfile', $upload_dir= '')
Make control on an uploaded file from an GUI page and move it to final destination.
Definition: files.lib.php:999
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_htmloutput_mesg($mesgstring= '', $mesgarray=array(), $style= 'ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig= '', $mode= 'uploaded', $setsharekey=0, $object=null)
Add a file into database index.
Definition: files.lib.php:1742
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...