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';
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");
56 $mesg =
''; $error = 0; $errors = array();
58 $action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
59 $cancel =
GETPOST(
'cancel',
'alpha');
60 $backtopage =
GETPOST(
'backtopage',
'alpha');
61 $confirm =
GETPOST(
'confirm',
'alpha');
64 if ($user->socid) $socid = $user->socid;
65 if (empty($socid) && $action ==
'view') $action =
'create';
71 $extrafields->fetch_name_optionals_label($object->table_element);
76 $hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
78 if ($socid > 0) $object->fetch($socid);
80 if (!($object->id > 0) && $action ==
'view')
82 $langs->load(
"errors");
83 print($langs->trans(
'ErrorRecordNotFound'));
88 $canvas = $object->canvas ? $object->canvas :
GETPOST(
"canvas");
92 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
93 $objcanvas =
new Canvas($db, $action);
94 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
98 $result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
110 $permissiontoread = $user->rights->societe->lire;
111 $permissiontoadd = $user->rights->societe->creer;
112 $permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0);
113 $permissionnote = $user->rights->societe->creer;
114 $permissiondellink = $user->rights->societe->creer;
115 $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
122 $parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
123 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
124 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
131 if (!empty($backtopage))
133 header(
"Location: ".$backtopage);
138 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->rights->societe->creer)
141 $soc_origin_id =
GETPOST(
'soc_origin',
'int');
142 $soc_origin =
new Societe($db);
144 if ($soc_origin_id <= 0)
146 $langs->load(
'errors');
147 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')), null,
'errors');
149 if (!$error && $soc_origin->fetch($soc_origin_id) < 1)
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'
172 foreach ($listofproperties as $property)
174 if (empty($object->$property)) $object->$property = $soc_origin->$property;
178 $listofproperties = array(
179 'note_public',
'note_private'
181 foreach ($listofproperties as $property)
183 $object->$property =
dol_concatdesc($object->$property, $soc_origin->$property);
187 if (is_array($soc_origin->array_options))
189 foreach ($soc_origin->array_options as $key => $val)
191 if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
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');
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');
209 if ($soc_origin->code_client == $object->code_client
210 || $soc_origin->code_fournisseur == $object->code_fournisseur
211 || $soc_origin->barcode == $object->barcode)
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');
221 $result = $object->update($object->id, $user, 0, 1, 1,
'merge');
234 'Adherent' =>
'/adherents/class/adherent.class.php',
235 'Don' =>
'/don/class/don.class.php',
236 'Societe' =>
'/societe/class/societe.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'
261 foreach ($objects as $object_name => $object_file)
263 require_once DOL_DOCUMENT_ROOT.$object_file;
265 if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id))
277 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', array(
278 'soc_origin' => $soc_origin->id,
279 'soc_dest' => $object->id
280 ), $object, $action);
292 $object->context = array(
'merge'=>1,
'mergefromid'=>$soc_origin->id);
295 $result = $object->call_trigger(
'COMPANY_MODIFY', $user);
307 if ($soc_origin->delete($soc_origin->id, $user) < 1)
318 $langs->load(
"errors");
326 if (
GETPOST(
'getcustomercode'))
329 $_POST[
"customer_code"] =
"Acompleter";
332 if (
GETPOST(
'getsuppliercode'))
335 $_POST[
"supplier_code"] =
"Acompleter";
338 if ($action ==
'set_localtax1')
342 $object->fetch($socid);
343 $res = $object->setValueFrom(
'localtax1_value', $value,
'', null,
'text',
'', $user,
'COMPANY_MODIFY');
345 if ($action ==
'set_localtax2')
349 $object->fetch($socid);
350 $res = $object->setValueFrom(
'localtax2_value', $value,
'', null,
'text',
'', $user,
'COMPANY_MODIFY');
353 if ($action ==
'update_extras') {
354 $object->fetch($socid);
359 $extrafields->fetch_name_optionals_label($object->table_element);
361 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
362 if ($ret < 0) $error++;
366 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
374 if ($error) $action =
'edit_extras';
379 && ($action ==
'add' || $action ==
'update') && $user->rights->societe->creer)
381 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
385 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")), null,
'errors');
390 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")), null,
'errors');
393 if (
GETPOST(
'fournisseur') < 0)
395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")), null,
'errors');
401 if ($action ==
'update')
403 $ret = $object->fetch($socid);
404 $object->oldcopy = clone $object;
405 }
else $object->canvas = $canvas;
407 if (
GETPOST(
"private",
'int') == 1)
409 $object->particulier =
GETPOST(
"private",
'int');
412 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
414 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
415 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
417 $object->name =
GETPOST(
'name',
'alphanohtml');
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');
430 $object->socialnetworks = array();
431 if (!empty($conf->socialnetworks->enabled)) {
432 foreach ($socialnetworks as $key => $value) {
434 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
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');
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');
454 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
455 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
456 $object->status =
GETPOST(
'status',
'alpha');
459 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
460 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
462 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
463 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
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');
469 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
471 $object->client =
GETPOST(
'client',
'int');
472 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
474 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
475 $object->default_lang =
GETPOST(
'default_lang');
478 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
479 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
482 if (!empty($conf->incoterm->enabled))
484 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
485 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
489 if (!empty($conf->multicurrency->enabled))
491 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
495 $ret = $extrafields->setOptionalsFromPost(null, $object);
502 $ret = $object->setValuesForExtraLanguages();
509 if (
GETPOST(
'deletephoto')) $object->logo =
'';
515 if (!empty($object->email) && !isValidEMail($object->email))
517 $langs->load(
"errors");
519 setEventMessages(
'', $langs->trans(
"ErrorBadEMail", $object->email),
'errors');
521 if (!empty($object->url) && !
isValidUrl($object->url))
523 $langs->load(
"errors");
526 if (!empty($object->webservices_url)) {
528 if (strpos($object->webservices_url,
"http") ===
false)
530 $object->webservices_url =
"http://".$object->webservices_url;
533 $langs->load(
"errors");
534 $error++; $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
539 $object->country_id =
GETPOST(
'country_id') !=
'' ?
GETPOST(
'country_id') : $mysoc->country_id;
540 if ($object->country_id)
542 $tmparray =
getCountry($object->country_id,
'all');
543 $object->country_code = $tmparray[
'code'];
544 $object->country = $tmparray[
'label'];
551 if ($action ==
'add')
557 if (empty($object->client)) $object->code_client =
'';
558 if (empty($object->fournisseur)) $object->code_fournisseur =
'';
560 $result = $object->create($user);
564 if ($object->particulier)
566 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
567 $result = $object->create_individual($user);
576 $salesreps =
GETPOST(
'commercial',
'array');
577 $result = $object->setSalesRep($salesreps,
true);
585 $custcats =
GETPOST(
'custcats',
'array');
586 $result = $object->setCategories($custcats,
'customer');
594 $suppcats =
GETPOST(
'suppcats',
'array');
595 $result = $object->setCategories($suppcats,
'supplier');
603 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
604 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
618 $errors[] =
"ErrorFailedToSaveFile";
621 $object->addThumbs($newfile);
626 switch ($_FILES[
'photo'][
'error'])
630 $errors[] =
"ErrorFileSizeTooLarge";
633 $errors[] =
"ErrorFilePartiallyUploaded";
638 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors))
640 $duplicate_code_error =
true;
641 $object->code_client = null;
644 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors))
646 $duplicate_code_error =
true;
647 $object->code_fournisseur = null;
650 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
651 $duplicate_code_error =
true;
658 if ($result >= 0 && !$error) {
661 if (!empty($backtopage)) {
662 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
663 if (preg_match(
'/\?/', $backtopage)) $backtopage .=
'&socid='.$object->id;
664 header(
"Location: ".$backtopage);
667 $url =
$_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
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;
671 header("Location: ".$url);
680 if ($action ==
'update')
684 if (
GETPOST(
'cancel',
'alpha'))
686 if (!empty($backtopage))
688 header(
"Location: ".$backtopage);
691 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
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 =
'';
701 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
710 $salesreps =
GETPOST(
'commercial',
'array');
711 $result = $object->setSalesRep($salesreps);
719 if (!$error && !empty($user->rights->categorie->lire))
722 $categories =
GETPOST(
'custcats',
'array');
723 $result = $object->setCategories($categories,
'customer');
731 $categories =
GETPOST(
'suppcats',
'array');
732 $result = $object->setCategories($categories,
'supplier');
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)
745 $fileimg = $dir.
'/'.$object->logo;
746 $dirthumbs = $dir.
'/thumbs';
763 $errors[] =
"ErrorFailedToSaveFile";
766 $object->addThumbs($newfile);
769 if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD))
771 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
780 $errors[] =
"ErrorBadImageFormat";
783 switch ($_FILES[
'photo'][
'error'])
787 $errors[] =
"ErrorFileSizeTooLarge";
790 $errors[] =
"ErrorFilePartiallyUploaded";
798 if (!$error && $object->fk_soc > 0)
800 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
801 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".$id;
802 if (!$object->db->query($sql))
805 $object->error .= $object->db->lasterror();
810 if (!$error && !count($errors))
812 if (!empty($backtopage))
814 header(
"Location: ".$backtopage);
817 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
821 $object->id = $socid;
826 $action = ($action ==
'add' ?
'create' :
'edit');
831 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->societe->supprimer)
833 $object->fetch($socid);
834 $object->oldcopy = clone $object;
835 $result = $object->delete($socid, $user);
839 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
842 $langs->load(
"errors");
850 if ($action ==
'set_thirdpartytype' && $user->rights->societe->creer)
852 $object->fetch($socid);
853 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
857 if ($action ==
'set_incoterms' && $user->rights->societe->creer && !empty($conf->incoterm->enabled))
859 $object->fetch($socid);
860 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
864 if ($action ==
'set_thirdparty' && $user->rights->societe->creer)
866 $object->fetch($socid);
867 $result = $object->set_parent(
GETPOST(
'parent_id',
'int'));
871 if ($action ==
'set_salesrepresentatives' && $user->rights->societe->creer)
873 $object->fetch($socid);
874 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
878 $object->fetch($socid);
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';
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';
894 $upload_dir = $conf->societe->dir_output;
895 $permissiontoadd = $user->rights->societe->creer;
896 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
904 $form =
new Form($db);
909 if ($socid > 0 && empty($object->id))
911 $result = $object->fetch($socid);
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';
920 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
922 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
927 $objcanvas->assign_values($action, $object->id, $object->ref);
928 $objcanvas->display_canvas($action);
933 if ($action ==
'create')
938 $private =
GETPOST(
"private",
"int");
939 if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !
GETPOSTISSET(
'private')) $private = 1;
940 if (empty($private)) $private = 0;
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')
946 $module = substr($module, 0,
dol_strlen($module) - 4);
948 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
949 foreach ($dirsociete as $dirroot)
954 $modCodeClient =
new $module;
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')
959 $module = substr($module, 0,
dol_strlen($module) - 4);
961 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
962 foreach ($dirsociete as $dirroot)
967 $modCodeFournisseur =
new $module;
972 $object->client = -1;
973 if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) { $object->client = 3; }
977 if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
978 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
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; }
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;
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');
998 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
'',
'warnings');
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');
1009 $object->socialnetworks = array();
1010 if (!empty($conf->socialnetworks->enabled)) {
1011 foreach ($socialnetworks as $key => $value) {
1013 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
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');
1033 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1034 $object->status =
GETPOST(
'status',
'int');
1037 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1038 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1040 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1041 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1043 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1045 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1046 $object->default_lang =
GETPOST(
'default_lang');
1048 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
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);
1066 $errors[] =
"ErrorFailedToSaveFile";
1069 $object->addThumbs($newfile);
1076 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1077 if ($object->country_id)
1079 $tmparray =
getCountry($object->country_id,
'all');
1080 $object->country_code = $tmparray[
'code'];
1081 $object->country = $tmparray[
'label'];
1083 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
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 () {
1095 is_private=' . $private.
';
1097 $(".individualline").show();
1099 $(".individualline").hide();
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;
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;
1120 init_customer_categ();
1121 $("#customerprospect").change(function() {
1122 init_customer_categ();
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').
'))
1128 jQuery(".visibleifcustomer").hide();
1132 jQuery(".visibleifcustomer").show();
1136 init_supplier_categ();
1137 $("#fournisseur").change(function() {
1138 init_supplier_categ();
1140 function init_supplier_categ() {
1141 console.log("is supplier = "+jQuery("#fournisseur").val());
1142 if (jQuery("#fournisseur").val() == 0)
1144 jQuery(".visibleifsupplier").hide();
1148 jQuery(".visibleifsupplier").show();
1152 $("#selectcountry_id").change(function() {
1153 document.formsoc.action.value="create";
1154 document.formsoc.submit();
1157 print '</script>'.
"\n";
1159 print '<div id="selectthirdpartytype">';
1160 print '<div class="hideonsmartphone float">';
1161 print $langs->trans(
"ThirdPartyType").
': ';
1163 print '<label for="radiocompany" class="radiocompany">';
1164 print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1166 print $langs->trans(
"CreateThirdPartyOnly");
1168 print
' ';
1169 print
'<label for="radioprivate" class="radioprivate">';
1170 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1172 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1173 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1174 print $form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
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();
1186 print
'</script>'.
"\n";
1192 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
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">';
1205 print
'<table class="border centpercent">';
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>';
1212 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
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');
1218 if (!empty($conf->global->SOCIETE_USEPREFIX))
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>';
1225 if ($conf->use_javascript_ajax)
1227 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION))
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>';
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>';
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>';
1246 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1247 print
'<td class="maxwidthonsmartphone">';
1249 print $formcompany->selectProspectCustomerType($selected);
1252 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
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">';
1260 $s = $modCodeClient->getToolTip($langs, $object, 0);
1261 print $form->textwithpicto(
'', $s, 1);
1262 print
'</td></tr></table>';
1265 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1266 || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire)))
1270 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
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);
1277 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
1280 if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1282 print $form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1285 if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
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">';
1292 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1293 print $form->textwithpicto(
'', $s, 1);
1294 print
'</td></tr></table>';
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);
1305 if (!empty($conf->barcode->enabled))
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).
'">';
1313 print
'<tr><td class="tdtop">';
1314 print $form->editfieldkey(
'Address',
'address',
'', $object, 0);
1316 print
'<td colspan="3">';
1317 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1319 print
'</textarea>';
1320 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
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');
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');
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);
1341 if (empty($conf->global->SOCIETE_DISABLE_STATE))
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))
1345 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1347 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1350 if ($object->country_id) print $formcompany->select_state($object->state_id, $object->country_code);
1351 else print $countrynotdefined;
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>';
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>';
1368 if (!empty($conf->socialnetworks->enabled)) {
1369 foreach ($socialnetworks as $key => $value) {
1370 if ($value[
'active']) {
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])).
'">';
1377 } elseif (!empty($object->socialnetworks[$key])) {
1378 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1384 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1386 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1387 if ($idprof !=
'-') {
1390 if (($j % $NBCOLS) == 0) print
'<tr>';
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>';
1395 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1397 if (($j % $NBCOLS) == ($NBCOLS - 1)) print
'</tr>';
1402 if ($NBCOLS > 1 && ($j % 2 == 1)) print
'<td colspan="2"></td></tr>';
1405 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1407 print $form->selectyesno(
'assujtva_value',
GETPOSTISSET(
'assujtva_value') ?
GETPOST(
'assujtva_value',
'int') : 1, 1);
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.
'">';
1414 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
1417 if (!empty($conf->use_javascript_ajax)) {
1419 if (!empty($conf->dol_use_jmobile)) $widthpopup = 350;
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";
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);
1431 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1440 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1")
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);
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);
1449 } elseif ($mysoc->localtax1_assuj ==
"1")
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);
1454 } elseif ($mysoc->localtax2_assuj ==
"1")
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);
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);
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);
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);
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)
1478 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1480 print $countrynotdefined;
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>';
1489 if (!empty($conf->global->MAIN_MULTILANGS))
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');
1498 if (!empty($conf->incoterm->enabled))
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 :
''));
1508 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
1510 $langs->load(
'categories');
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);
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);
1530 if (!empty($conf->multicurrency->enabled))
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);
1540 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1541 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
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);
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);
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" />';
1561 print
'</table>'.
"\n";
1565 print
'<div class="center">';
1566 print
'<input type="submit" class="button" name="create" value="'.$langs->trans(
'AddThirdParty').
'">';
1567 if (!empty($backtopage))
1569 print
' ';
1570 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1572 print
' ';
1573 print
'<input type="button" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" onClick="javascript:history.go(-1)">';
1575 print
'</div>'.
"\n";
1577 print
'</form>'.
"\n";
1578 } elseif ($action ==
'edit') {
1583 $res = $object->fetch_optionals();
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')
1592 $module = substr($module, 0,
dol_strlen($module) - 4);
1594 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1595 foreach ($dirsociete as $dirroot)
1600 $modCodeClient =
new $module($db);
1602 if ($modCodeClient->code_auto)
1604 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1606 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1607 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php')
1609 $module = substr($module, 0,
dol_strlen($module) - 4);
1611 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1612 foreach ($dirsociete as $dirroot)
1617 $modCodeFournisseur =
new $module($db);
1619 if ($modCodeFournisseur->code_auto)
1621 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1624 $object->oldcopy = clone $object;
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');
1644 $object->socialnetworks = array();
1645 if (!empty($conf->socialnetworks->enabled)) {
1646 foreach ($socialnetworks as $key => $value) {
1648 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
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');
1669 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1670 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1671 $object->status =
GETPOST(
'status',
'int');
1674 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
1675 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
1678 if (!empty($conf->incoterm->enabled))
1680 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
1681 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
1685 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value');
1686 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value');
1688 $object->localtax1_value =
GETPOST(
'lt1');
1689 $object->localtax2_value =
GETPOST(
'lt2');
1692 if ($object->country_id > 0)
1694 $tmparray =
getCountry($object->country_id,
'all');
1695 $object->country_code = $tmparray[
'code'];
1696 $object->country = $tmparray[
'label'];
1700 if ($object->localtax1_assuj == 0) {
1703 if ($object->localtax2_assuj == 0) {
1705 }
else {$sub2 = 1; }
1707 if ($conf->use_javascript_ajax)
1709 print
"\n".
'<script type="text/javascript">';
1710 print
'$(document).ready(function () {
1713 if("#localtax1assuj_value".value==undefined){
1720 if("#localtax2assuj_value".value==undefined){
1727 $("#localtax1assuj_value").change(function() {
1728 var value=document.getElementById("localtax1assuj_value").value;
1735 $("#localtax2assuj_value").change(function() {
1736 var value=document.getElementById("localtax2assuj_value").value;
1744 init_customer_categ();
1745 $("#customerprospect").change(function() {
1746 init_customer_categ();
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').
'))
1752 jQuery(".visibleifcustomer").hide();
1756 jQuery(".visibleifcustomer").show();
1760 init_supplier_categ();
1761 $("#fournisseur").change(function() {
1762 init_supplier_categ();
1764 function init_supplier_categ() {
1765 console.log("is supplier = "+jQuery("#fournisseur").val());
1766 if (jQuery("#fournisseur").val() == 0)
1768 jQuery(".visibleifsupplier").hide();
1772 jQuery(".visibleifsupplier").show();
1776 $("#selectcountry_id").change(function() {
1777 document.formsoc.action.value="edit";
1778 document.formsoc.submit();
1782 print
'</script>'.
"\n";
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">';
1795 print
'<div class="fichecenter2">';
1796 print
'<table class="border centpercent">';
1799 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
1801 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
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');
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>';
1817 if (!empty($conf->global->SOCIETE_USEPREFIX))
1819 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'', $object, 0).
'</td><td colspan="3">';
1821 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm)
1823 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
1824 print $object->prefix_comm;
1826 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
1832 print
'<tr><td>'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1833 print
'<td class="maxwidthonsmartphone">';
1834 print $formcompany->selectProspectCustomerType($object->client);
1836 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
1837 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1839 print
'<table class="nobordernopadding"><tr><td>';
1840 if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto)
1842 $tmpcode = $object->code_client;
1843 if (empty($tmpcode) && !empty($object->oldcopy->code_client)) $tmpcode = $object->oldcopy->code_client;
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())
1848 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).
'" maxlength="24">';
1850 print $object->code_client;
1851 print
'<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).
'">';
1854 $s = $modCodeClient->getToolTip($langs, $object, 0);
1855 print $form->textwithpicto(
'', $s, 1);
1856 print
'</td></tr></table>';
1861 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1862 || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire)))
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);
1869 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
1871 if (!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire))
1873 print $form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1877 print
'<table class="nobordernopadding"><tr><td>';
1878 if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto)
1880 $tmpcode = $object->code_fournisseur;
1881 if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) $tmpcode = $object->oldcopy->code_fournisseur;
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())
1886 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).
'" maxlength="24">';
1888 print $object->code_fournisseur;
1889 print
'<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.
'">';
1892 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1893 print $form->textwithpicto(
'', $s, 1);
1894 print
'</td></tr></table>';
1899 if (!empty($conf->barcode->enabled))
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).
'">';
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);
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">';
1915 print
'</textarea>';
1916 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
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');
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');
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);
1937 if (empty($conf->global->SOCIETE_DISABLE_STATE))
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))
1941 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
1943 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
1946 print $formcompany->select_state($object->state_id, $object->country_code);
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>';
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>';
1963 if (!empty($conf->socialnetworks->enabled)) {
1964 foreach ($socialnetworks as $key => $value) {
1965 if ($value[
'active']) {
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].
'">';
1972 } elseif (!empty($object->socialnetworks[$key])) {
1973 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1979 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1982 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1987 if (($j % $NBCOLS) == 0) print
'<tr>';
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);
1993 if (($j % $NBCOLS) == ($NBCOLS - 1)) print
'</tr>';
1998 if ($NBCOLS > 0 && $j % 2 == 1) print
'<td colspan="2"></td></tr>';
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);
2007 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1")
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);
2013 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2014 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
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);
2023 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2024 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2028 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1")
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);
2034 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2035 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2039 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1")
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);
2045 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2046 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
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.
'">';
2057 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object))
2061 if ($conf->use_javascript_ajax)
2064 if (!empty($conf->dol_use_jmobile)) $widthpopup = 350;
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";
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);
2076 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
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);
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);
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');
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="';
2103 print
'"> <font class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</font></td></tr>';
2106 if (!empty($conf->global->MAIN_MULTILANGS))
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);
2115 if (!empty($conf->incoterm->enabled))
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 :
''));
2125 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
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);
2132 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2133 $arrayselected = array();
2134 foreach ($cats as $cat) {
2135 $arrayselected[] = $cat->id;
2137 print
img_picto(
'',
'category').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
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);
2146 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2147 $arrayselected = array();
2148 foreach ($cats as $cat) {
2149 $arrayselected[] = $cat->id;
2151 print
img_picto(
'',
'category').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2157 if (!empty($conf->multicurrency->enabled))
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);
2167 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2168 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
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>';
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);
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>';
2190 print
'<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></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);
2211 print
'<div class="center">';
2212 print
'<input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
2213 print
' ';
2214 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
2224 if (!empty($object->id)) $res = $object->fetch_optionals();
2233 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)))
2235 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2238 if ($action ==
'merge')
2240 $formquestion = array(
2242 'name' =>
'soc_origin',
2243 'label' => $langs->trans(
'MergeOriginThirdparty'),
2245 'value' => $form->select_company(
'',
'soc_origin',
's.rowid <> '.$object->id,
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200')
2249 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2254 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2256 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2259 print
'<div class="fichecenter">';
2260 print
'<div class="fichehalfleft">';
2262 print
'<div class="underbanner clearboth"></div>';
2263 print
'<table class="border tableforfield" width="100%">';
2266 print
'<tr><td class="titlefield">'.$langs->trans(
'ProspectCustomer').
'</td><td>';
2267 print $object->getLibCustProspStatut();
2271 if (!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled))
2273 print
'<tr><td>'.$langs->trans(
'Supplier').
'</td><td>';
2274 print
yn($object->fournisseur);
2279 if (!empty($conf->global->SOCIETE_USEPREFIX))
2281 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.$object->prefix_comm.
'</td>';
2286 if ($object->client)
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>';
2300 if (!empty($conf->fournisseur->enabled) && $object->fournisseur && !empty($user->rights->fournisseur->lire))
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>';
2314 if (!empty($conf->barcode->enabled))
2326 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2331 print
'<td>'.$idprof.
'</td><td>';
2333 print $object->$key;
2336 if ($object->id_prof_check($i, $object) > 0) print
' '.$object->id_prof_url($i, $object);
2337 else print
' <font class="error">('.$langs->trans(
"ErrorWrongValue").
')</font>';
2353 if ($object->fournisseur)
2357 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2359 print
yn($object->tva_assuj);
2365 if ($object->fournisseur || $mysoc->country_code ==
'ES')
2367 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1")
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);
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&socid='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
2381 if ($action ==
'editRE')
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>';
2387 print
'<td>'.$object->localtax1_value.
'</td>';
2389 print
'</tr></form>';
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&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>';
2402 print
'<td>'.$object->localtax2_value.
'</td>';
2404 print
'</tr></form>';
2406 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1")
2408 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2409 print
yn($object->localtax1_assuj);
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&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>';
2422 print
'<td>'.$object->localtax1_value.
'</td>';
2424 print
'</tr></form>';
2426 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1")
2428 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2429 print
yn($object->localtax2_assuj);
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&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>';
2442 print
'<td>'.$object->localtax2_value.
'</td>';
2444 print
'</tr></form>';
2451 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
2452 if ($object->tva_intra)
2456 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2458 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object))
2462 if ($conf->use_javascript_ajax)
2465 if (!empty($conf->dol_use_jmobile)) $widthpopup = 350;
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";
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);
2477 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
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&socid='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a></td>';
2490 print
'</tr></table>';
2492 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
2493 $formcompany->formThirdpartyType(
$_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
2497 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
2502 print
'<div class="fichehalfright"><div class="ficheaddleft">';
2504 print
'<div class="underbanner clearboth"></div>';
2505 print
'<table class="border tableforfield" width="100%">';
2508 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire))
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>';
2514 print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
2519 if (!empty($conf->fournisseur->enabled) && $object->fournisseur) {
2520 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
2522 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
2528 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
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
' ';
2537 if (!empty($conf->global->MAIN_MULTILANGS))
2539 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2540 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
2543 $langs->load(
"languages");
2544 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
2550 if (!empty($conf->incoterm->enabled))
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')
2559 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
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);
2567 if (!empty($conf->multicurrency->enabled))
2570 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2572 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
2577 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2578 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2581 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY))
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&socid='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a></td>';
2586 print
'</tr></table>';
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);
2594 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
2597 if (!empty($conf->adherent->enabled))
2599 $langs->load(
"members");
2600 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
2603 $result = $adh->fetch(
'',
'', $object->id);
2606 $adh->ref = $adh->getFullName($langs);
2607 print $adh->getNomUrl(1);
2609 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
2611 print
"</td></tr>\n";
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>';
2623 print
'</div></div>';
2624 print
'<div style="clear:both"></div>';
2632 if ($action !=
'presend')
2634 print
'<div class="tabsAction">'.
"\n";
2636 $parameters = array();
2637 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2638 if (empty($reshook))
2640 $at_least_one_email_contact =
false;
2641 $TContact = $object->contact_array_objects();
2642 foreach ($TContact as &$contact)
2644 if (!empty($contact->email))
2646 $at_least_one_email_contact =
true;
2651 if (empty($user->socid)) {
2652 if (!empty($object->email) || $at_least_one_email_contact)
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>';
2657 $langs->load(
"mails");
2658 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a>';
2662 if ($user->rights->societe->creer)
2664 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit">'.$langs->trans(
"Modify").
'</a>'.
"\n";
2667 if (!empty($conf->adherent->enabled))
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))
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>';
2677 if ($user->rights->societe->supprimer)
2679 print
'<a class="butActionDelete" href="card.php?action=merge&socid='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeThirdparties")).
'">'.$langs->trans(
'Merge').
'</a>';
2682 if ($user->rights->societe->supprimer)
2684 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))
2686 print
'<span id="action-delete" class="butActionDelete">'.$langs->trans(
'Delete').
'</span>'.
"\n";
2688 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.
newToken().
'">'.$langs->trans(
'Delete').
'</a>'.
"\n";
2693 print
'</div>'.
"\n";
2697 if (
GETPOST(
'modelselected')) {
2698 $action =
'presend';
2701 if ($action !=
'presend')
2703 print
'<div class="fichecenter"><div class="fichehalfleft">';
2705 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC))
2707 print
'<a name="builddoc"></a>';
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;
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);
2721 if (empty($conf->global->SOCIETE_DISABLE_SUBSIDIARIES))
2726 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
2730 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
2733 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2735 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
2737 print
'</div></div></div>';
2739 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD))
2742 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
2748 if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
2750 $result = show_addresses($conf, $langs, $db, $object,
$_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
2756 $modelmail =
'thirdparty';
2757 $defaulttopic =
'Information';
2758 $diroutput = $conf->societe->dir_output;
2759 $trackid =
'thi'.$object->id;
2761 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
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.
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.
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 <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor]...
currency_name($code_iso, $withcode= '', $outputlangs=null)
Return label of currency or code+label.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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'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) ...
Class to manage members of a foundation.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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.
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.
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.
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.
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 'newtoken'.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig= '', $mode= 'uploaded', $setsharekey=0, $object=null)
Add a file into database index.
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.
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...