44require
'../main.inc.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
70 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
73 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
76 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
83if (
$mysoc->country_code ==
'GR') {
92$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
95 $langs->load(
"members");
98 $langs->load(
"categories");
101 $langs->load(
"incoterm");
104 $langs->load(
"mails");
107 $langs->load(
"products");
113$refalreadyexists = 0;
116$action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
117$cancel =
GETPOST(
'cancel',
'alpha');
118$backtopage =
GETPOST(
'backtopage',
'alpha');
119$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
120$confirm =
GETPOST(
'confirm',
'alpha');
121$canvas =
GETPOST(
'canvas',
'alpha');
123$dol_openinpopup =
'';
127 if (in_array($action, [
'add',
'create',
'merge',
'confirm_merge',
'delete',
'confirm_delete'])) {
131 $socid = $user->socid;
133if (empty($socid) && $action ==
'view') {
143$extrafields->fetch_name_optionals_label(
$object->table_element);
148$hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
157if (!empty($canvas)) {
158 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
159 $objcanvas =
new Canvas($db, $action);
160 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
164$permissiontoread = $user->hasRight(
'societe',
'lire');
165$permissiontoadd = $user->hasRight(
'societe',
'creer');
166$permissiontodelete = $user->hasRight(
'societe',
'supprimer') || ($permissiontoadd && isset(
$object->status) &&
$object->status == 0);
167$permissionnote = $user->hasRight(
'societe',
'creer');
168$permissiondellink = $user->hasRight(
'societe',
'creer');
169$permissiontoeditextra = $permissiontoadd;
170if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
172 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
175$upload_dir = $conf->societe->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
180if (!(
$object->id > 0) && $action ==
'view') {
189$parameters = array(
'id' => $socid,
'objcanvas' => $objcanvas);
191$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
196if (empty($reshook)) {
197 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
199 if (empty($backtopage) || ($cancel && empty($id))) {
200 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
201 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
202 $backtopage = $backurlforlist;
204 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__') . (!empty($canvas) ?
"&canvas=" . $canvas :
"");
210 if (!empty($backtopageforcancel)) {
211 header(
"Location: ".$backtopageforcancel);
213 } elseif (!empty($backtopage)) {
214 header(
"Location: ".$backtopage);
220 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $permissiontoadd) {
222 $soc_origin =
new Societe($db);
224 if ($soc_origin_id <= 0) {
225 $langs->load(
'errors');
226 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
228 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
233 $result =
$object->mergeCompany($soc_origin_id);
244 if (
GETPOST(
'getcustomercode')) {
246 $_POST[
"customer_code"] =
"Acompleter";
249 if (
GETPOST(
'getsuppliercode')) {
251 $_POST[
"supplier_code"] =
"Acompleter";
254 if ($action ==
'set_localtax1' && $permissiontoadd) {
258 $res =
$object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
260 if ($action ==
'set_localtax2' && $permissiontoadd) {
264 $res =
$object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
267 if ($action ==
'update_extras' && $permissiontoeditextra) {
272 $attribute_name =
GETPOST(
'attribute',
'aZ09');
274 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
280 $result =
$object->updateExtraField($attribute_name,
'COMPANY_MODIFY');
288 $action =
'edit_extras';
293 if ((!
GETPOST(
'getcustomercode') && !
GETPOST(
'getsuppliercode')) && ($action ==
'add' || $action ==
'update') && $permissiontoadd) {
294 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
297 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
301 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
305 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Prospect")),
null,
'errors');
308 if (GETPOSTISSET(
'supplier') &&
GETPOSTINT(
'supplier') < 0) {
309 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
315 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
320 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
324 if ($action ==
'update') {
352 $object->socialnetworks = array();
354 foreach ($socialnetworks as $key => $value) {
355 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
362 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
374 $object->code_client = GETPOSTISSET(
'customer_code') ?
GETPOST(
'customer_code',
'alpha') :
GETPOST(
'code_client',
'alpha');
375 $object->code_fournisseur = GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
381 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
400 $customer = (
GETPOSTINT(
'customer') > 0 ? 1 : 0);
401 $prospect = (
GETPOSTINT(
'prospect') > 0 ? 2 : 0);
402 $prospectcustomer = $customer + $prospect;
404 $object->client = $prospectcustomer;
407 if ($action ==
'add') {
410 $form =
new Form($db);
411 $form->load_cache_types_paiements();
413 $paymentTermId =
GETPOSTINT(
'cond_reglement_id');
414 $paymentTypeId =
GETPOSTINT(
'mode_reglement_id');
416 $object->cond_reglement_id = $paymentTermId;
418 $filterPaymentTypeIdArr = array(0, 2, 3);
419 if (!empty($form->cache_types_paiements[$paymentTypeId]) && isset($form->cache_types_paiements[$paymentTypeId][
'type']) && in_array($form->cache_types_paiements[$paymentTypeId][
'type'], $filterPaymentTypeIdArr)) {
420 $object->mode_reglement_id = $paymentTypeId;
424 if (
$object->fournisseur > 0) {
425 $object->cond_reglement_supplier_id = $paymentTermId;
427 $filterPaymentTypeIdArr = array(1, 2, 3);
428 if (!empty($form->cache_types_paiements[$paymentTypeId]) && isset($form->cache_types_paiements[$paymentTypeId][
'type']) && in_array($form->cache_types_paiements[$paymentTypeId][
'type'], $filterPaymentTypeIdArr)) {
429 $object->mode_reglement_supplier_id = $paymentTypeId;
440 $object->webservices_key =
GETPOST(
'webservices_key',
'password');
442 if (GETPOSTISSET(
'accountancy_code_sell')) {
443 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
445 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
446 $object->accountancy_code_sell =
'';
448 $object->accountancy_code_sell = $accountancy_code_sell;
451 if (GETPOSTISSET(
'accountancy_code_buy')) {
452 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
454 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
455 $object->accountancy_code_buy =
'';
457 $object->accountancy_code_buy = $accountancy_code_buy;
464 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
469 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
473 $ret = $extrafields->setOptionalsFromPost(
null, $object);
479 $ret =
$object->setValuesForExtraLanguages();
485 if (!empty($_FILES[
'photo'][
'name'])) {
496 if (!
GETPOST(
'cancel',
'alpha')) {
498 $langs->load(
"errors");
503 $langs->load(
"errors");
506 if (!empty(
$object->webservices_url)) {
508 if (strpos(
$object->webservices_url,
"http") ===
false) {
509 $object->webservices_url =
"http://".$object->webservices_url;
512 $langs->load(
"errors");
514 $errors[] = $langs->trans(
"ErrorBadUrl",
$object->webservices_url);
522 $object->country_code = $tmparray[
'code'];
523 $object->country = $tmparray[
'label'];
529 if ($action ==
'add' && $permissiontoadd) {
537 if (empty(
$object->fournisseur)) {
538 $object->code_fournisseur =
'';
541 $result =
$object->create($user);
546 if ($resultnoemail < 0) {
555 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
556 $contcats =
GETPOST(
'contcats',
'array');
558 $result =
$object->create_individual($user, $no_email, $contcats);
566 $salesreps =
GETPOST(
'commercial',
'array');
567 $result =
$object->setSalesRep($salesreps,
true);
574 $custcats =
GETPOST(
'custcats',
'array');
575 $result =
$object->setCategories($custcats,
'customer');
582 $suppcats =
GETPOST(
'suppcats',
'array');
583 $result =
$object->setCategories($suppcats,
'supplier');
590 $dir = $conf->societe->multidir_output[$conf->entity].
"/".
$object->id.
"/logos/";
591 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
600 if (!($result > 0)) {
601 $errors[] =
"ErrorFailedToSaveFile";
608 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
618 switch ($_FILES[
'photo'][
'error']) {
621 $errors[] =
"ErrorFileSizeTooLarge";
624 $errors[] =
"ErrorFilePartiallyUploaded";
629 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed',
$object->errors)) {
630 $duplicate_code_error =
true;
634 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed',
$object->errors)) {
635 $duplicate_code_error =
true;
636 $object->code_fournisseur =
'';
639 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
640 $duplicate_code_error =
true;
647 if ($result >= 0 && !$error) {
650 if (!empty($backtopage)) {
651 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
652 if (preg_match(
'/\?/', $backtopage)) {
653 $backtopage .=
'&socid='.$object->id;
655 header(
"Location: ".$backtopage);
658 $url = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
660 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".
$object->id;
661 } elseif (
$object->fournisseur == 1) {
662 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".
$object->id;
665 header(
"Location: ".$url);
674 if ($action ==
'update' && $permissiontoadd) {
677 if (
GETPOST(
'cancel',
'alpha')) {
678 if (!empty($backtopage)) {
679 header(
"Location: ".$backtopage);
682 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
688 if (empty(
$object->client) && empty(
$object->oldcopy->code_client)) {
691 if (empty(
$object->fournisseur) && empty(
$object->oldcopy->code_fournisseur)) {
692 $object->code_fournisseur =
'';
698 $result =
$object->update($socid, $user, 1,
$object->oldcopy->codeclient_modifiable(),
$object->oldcopy->codefournisseur_modifiable(),
'update', $nosyncmember);
702 if (GETPOSTISSET(
'no_email') &&
$object->email) {
704 $result =
$object->setNoEmail($no_email);
723 $salesreps =
GETPOST(
'commercial',
'array');
724 $result =
$object->setSalesRep($salesreps);
731 if (!$error && $user->hasRight(
'categorie',
'lire')) {
733 $categories =
GETPOST(
'custcats',
'array');
734 $result =
$object->setCategories($categories,
'customer');
741 $categories =
GETPOST(
'suppcats',
'array');
742 $result =
$object->setCategories($categories,
'supplier');
750 $dir = $conf->societe->multidir_output[
$object->entity ?? $conf->entity].
"/".
$object->id.
"/logos";
751 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
752 if (
GETPOST(
'deletephoto') && $current_logo) {
753 $fileimg = $dir.
'/'.$current_logo;
754 $dirthumbs = $dir.
'/thumbs';
760 if ($current_logo !=
$object->logo) {
761 $fileimg = $dir.
'/'.$current_logo;
762 $dirthumbs = $dir.
'/thumbs';
773 if (!($result > 0)) {
774 $errors[] =
"ErrorFailedToSaveFile";
781 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
790 $errors[] =
"ErrorBadImageFormat";
793 switch ($_FILES[
'photo'][
'error']) {
796 $errors[] =
"ErrorFileSizeTooLarge";
799 $errors[] =
"ErrorFilePartiallyUploaded";
808 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
809 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
810 if (!
$object->db->query($sql)) {
817 if (!$error && !count($errors)) {
818 if (!empty($backtopage)) {
819 header(
"Location: ".$backtopage);
822 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
831 $action = ($action ==
'add' ?
'create' :
'edit');
836 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'supprimer')) {
839 $result =
$object->delete($socid, $user);
842 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode(
$object->name));
845 $langs->load(
"errors");
853 if ($action ==
'set_thirdpartytype' && $permissiontoadd) {
859 if ($action ==
'set_incoterms' && $permissiontoadd &&
isModEnabled(
'incoterm')) {
865 if ($action ==
'set_thirdparty' && $permissiontoadd) {
871 if ($action ==
'set_salesrepresentatives' && $permissiontoadd) {
877 if ($action ==
'setwarehouse' && $permissiontoadd) {
881 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
885 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
891 if (!empty(
GETPOST(
'clone_name'))) {
893 $clone->name =
GETPOST(
'clone_name',
'alphanohtml');
895 $clone->fournisseur = 0;
900 $clone->context[
'createfromclone'] =
'createfromclone';
901 $id = $clone->create($user);
909 unset($clone->context[
'createfromclone']);
916 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
920 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
933 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
937 $triggersendname =
'COMPANY_SENTBYMAIL';
938 $paramname =
'socid';
939 $mode =
'emailfromthirdparty';
940 $trackid =
'thi'.$object->id;
941 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
945 $upload_dir = !empty($conf->societe->multidir_output[
$object->entity ?? $conf->entity]) ? $conf->societe->multidir_output[
$object->entity ?? $conf->entity] : $conf->societe->dir_output;
946 $permissiontoadd = $user->hasRight(
'societe',
'creer');
947 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
950 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
958$form =
new Form($db);
966if ($socid > 0 && empty(
$object->id)) {
967 $result =
$object->fetch($socid);
974$title = $langs->trans(
"ThirdParty");
975if ($action ==
'create') {
976 $title = $langs->trans(
"NewThirdParty");
979 $title =
$object->name.
" - ".$langs->trans(
'Card');
981$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
985$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
987$canvasdisplayaction = $action;
988if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
989 $canvasdisplayaction =
'view';
992if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
996 $objcanvas->assign_values($canvasdisplayaction,
$object->id,
$object->ref);
997 $objcanvas->display_canvas($canvasdisplayaction);
1002 if ($action ==
'create') {
1007 if (
getDolGlobalString(
'THIRDPARTY_DEFAULT_CREATE_CONTACT') && !GETPOSTISSET(
'private') &&
GETPOST(
"type",
'aZ') !=
'f') {
1010 if (empty($private)) {
1016 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1017 $module = substr($module, 0,
dol_strlen($module) - 4);
1019 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1020 foreach ($dirsociete as $dirroot) {
1026 $modCodeClient =
new $module($db);
1027 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
1031 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1032 $module = substr($module, 0,
dol_strlen($module) - 4);
1034 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1035 foreach ($dirsociete as $dirroot) {
1041 $modCodeFournisseur =
new $module($db);
1042 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
1045 if (
GETPOST(
"type",
'aZ') !=
'f') {
1052 if (
GETPOST(
"type",
'aZ') ==
'c') {
1059 if (
GETPOST(
"type",
'aZ') ==
'p') {
1074 $object->particulier = $private;
1078 if (empty($duplicate_code_error)) {
1083 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
null,
'warnings');
1091 $object->socialnetworks = array();
1093 foreach ($socialnetworks as $key => $value) {
1094 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
1101 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
1106 $paymentTermId =
GETPOSTINT(
'cond_reglement_id');
1107 if (empty($paymentTermId) && !GETPOSTISSET(
'cond_reglement_id')) {
1110 $object->cond_reglement_id = $paymentTermId;
1111 $paymentTypeId =
GETPOSTINT(
'mode_reglement_id');
1112 if (empty($paymentTypeId) && !GETPOSTISSET(
'mode_reglement_id')) {
1115 $object->mode_reglement_id = $paymentTypeId;
1128 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1143 if (GETPOSTISSET(
'accountancy_code_sell')) {
1144 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1146 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1147 $object->accountancy_code_sell =
'';
1149 $object->accountancy_code_sell = $accountancy_code_sell;
1152 if (GETPOSTISSET(
'accountancy_code_buy')) {
1153 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1155 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1156 $object->accountancy_code_buy =
'';
1158 $object->accountancy_code_buy = $accountancy_code_buy;
1165 $dir = $conf->societe->multidir_output[$conf->entity].
"/".
$object->id.
"/logos";
1166 $file_OK = (isset($_FILES[
'photo']) ? is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1171 if (@is_dir($dir)) {
1175 if (!($result > 0)) {
1176 $errors[] =
"ErrorFailedToSaveFile";
1189 $object->country_code = $tmparray[
'code'];
1190 $object->country = $tmparray[
'label'];
1196 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1201 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1203 if (!empty($conf->use_javascript_ajax)) {
1206 print
"\n".
'<script type="text/javascript">';
1207 print
'$(document).ready(function () {
1210 is_private=' . $private.
';
1212 $(".individualline").show();
1214 $(".individualline").hide();
1216 $("#radiocompany").click(function() {
1217 $(".individualline").hide();
1218 $("#typent_id").val(0);
1219 $("#typent_id").change();
1220 $("#effectif_id").val(0);
1221 $("#effectif_id").change();
1222 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1223 document.formsoc.private.value=0;
1225 $("#radioprivate").click(function() {
1226 $(".individualline").show();
1227 $("#typent_id").val(id_te_private);
1228 $("#typent_id").change();
1229 $("#effectif_id").val(id_ef15);
1230 $("#effectif_id").change();
1231 /* Force to recompute the width of a select2 field when it was hidden and then shown programmatically */
1232 if ($("#civility_id").data("select2")) {
1233 $("#civility_id").select2({width: "resolve"});
1235 $("#TypeName").html(document.formsoc.LastName.value);
1236 document.formsoc.private.value=1;
1241 function init_check_no_email(input) {
1242 if (input.val()!="") {
1243 $(".noemail").addClass("fieldrequired");
1245 $(".noemail").removeClass("fieldrequired");
1248 $("#email").keyup(function() {
1249 init_check_no_email($(this));
1251 init_check_no_email($("#email"));';
1254 print
'</script>'.
"\n";
1256 print
'<div id="selectthirdpartytype">';
1257 print
'<div class="hideonsmartphone float">';
1258 print $langs->trans(
"ThirdPartyType").
': ';
1260 print
'<label for="radiocompany" class="radiocompany">';
1261 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1263 print $langs->trans(
"CreateThirdPartyOnly");
1265 print
' ';
1266 print
'<label for="radioprivate" class="radioprivate">';
1267 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1269 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1270 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1271 print $form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1277 print
'<script type="text/javascript">';
1278 print
'$(document).ready(function () {
1279 var canHaveCustomerCategoryIfNotCustomerProspectSupplier = ' . (!
getDolGlobalString(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'0' :
'1') .
';
1281 init_customer_categ();
1282 $("#prospectinput, #customerinput").change(function() {
1283 init_customer_categ();
1285 function init_customer_categ() {
1286 var iscustomerorprospect = jQuery("#prospectinput").is(":checked") + jQuery("#customerinput").is(":checked");
1287 console.log("is customer or prospect = "+iscustomerorprospect);
1288 if (iscustomerorprospect == 0 && !canHaveCustomerCategoryIfNotCustomerProspectSupplier) {
1289 jQuery(".visibleifcustomer").hide();
1291 jQuery(".visibleifcustomer").show();
1295 init_supplier_categ();
1296 $("#supplierinput").change(function() {
1297 init_supplier_categ();
1299 function init_supplier_categ() {
1300 var issupplier = jQuery("#supplierinput").is(":checked");
1301 console.log("is supplier = "+issupplier);
1302 if (issupplier == 0) {
1303 jQuery(".visibleifsupplier").hide();
1305 jQuery(".visibleifsupplier").show();
1309 $("#selectcountry_id").change(function() {
1310 console.log("selectcountry_id change");
1311 document.formsoc.action.value="create";
1312 document.formsoc.submit();
1315 print
'</script>'.
"\n";
1320 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1322 print
'<input type="hidden" name="action" value="add">';
1323 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1324 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1325 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
1326 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1327 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1328 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1329 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1330 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1331 print
'<input type="hidden" name="code_auto" value="1">';
1337 $parameters = array();
1339 $reshook = $hookmanager->executeHooks(
'tabContentCreateThirdparty', $parameters, $object, $action);
1340 if (empty($reshook)) {
1341 print
'<table class="border centpercent">';
1344 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1345 if (
$object->particulier || $private) {
1346 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1348 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1350 print
'</td><td colspan="3">';
1352 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag(
$object->name).
'" autofocus="autofocus" spellcheck="false">';
1353 print $form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alphanohtml',
'minwidth300');
1450 if ($conf->use_javascript_ajax) {
1453 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1454 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag(
$object->firstname).
'" spellcheck="false"></td>';
1458 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1459 print $formcompany->select_civility(
$object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1465 print
'<tr id="name_alias"><td>';
1466 print
'<input type="hidden" name="status" value="1">';
1468 print
'<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag(
$object->name_alias).
'" spellcheck="false" placeholder="'.
dolPrintHTMLForAttribute($langs->trans(
'AliasNames')).
'"></td></tr>';
1474 switch ($selected) {
1476 $selectedcustomer = 1;
1479 $selectedprospect = 1;
1482 $selectedprospect = 1;
1483 $selectedcustomer = 1;
1489 $selectedprospect = ((GETPOSTISSET(
'prospect') && $action ==
'create') ?
GETPOSTINT(
'prospect') : $selectedprospect);
1490 $selectedcustomer = ((GETPOSTISSET(
'customer') && $action ==
'create') ?
GETPOSTINT(
'customer') : $selectedcustomer);
1491 $selectedsupplier = ((GETPOSTISSET(
'supplier') && $action ==
'create') ?
GETPOSTINT(
'supplier') :
$object->fournisseur);
1493 if ($selectedprospect && $selectedcustomer &&
getDolGlobalString(
"SOCIETE_DISABLE_PROSPECTSCUSTOMERS")) {
1495 $selectedcustomer = 0;
1498 print
'<tr class="marginbottomlarge height50">';
1499 if ($conf->browser->layout !=
'phone') {
1500 print
'<td class="titlefieldcreate">'.$form->editfieldkey(
'',
'customerprospect',
'', $object, 0,
'string',
'', 0).
'</td>';
1502 print
'<td class="maxwidthonsmartphone"'.($conf->browser->layout !=
'phone' ?
'colspan="3"' :
'colspan="2"').
'>';
1505 print
'<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="spanlabel">'.$langs->trans(
"Prospect").
'</label><input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ?
' checked="checked"' :
'').
'></span>';
1509 print
'<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="spanlabel">'.$langs->trans(
"Customer").
'</label><input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ?
' checked="checked"' :
'').
'></span>';
1512 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))
1513 || (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
1515 print
'<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="spanlabel">'.$langs->trans(
"Vendor").
'</label><input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selectedsupplier ?
' checked="checked"' :
'').
'></span>';
1518 if ($conf->use_javascript_ajax) {
1520 function refreshNatureCss() {
1521 jQuery(".spannature").each(function( index ) {
1522 id = $(this).attr("id").split("spannature")[1];
1523 console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
1524 if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
1526 jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
1529 jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
1532 jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
1535 jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
1540 function manageprospectcustomer(element) {
1541 console.log("We uncheck unwanted values on a nature");
1542 id = $(element).attr("id").split("spannature")[1];
1544 $("#spannature2 .checkforselect").prop("checked", false);
1547 $("#spannature1 .checkforselect").prop("checked", false);
1551 jQuery(".spannature").click(function(){
1552 console.log("We click on a nature");
1553 '.(getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ?
'manageprospectcustomer($(this));' :
'').
'
1564 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1565 print
'<table class="nobordernopadding"><tr><td>';
1566 $tmpcode =
$object->code_client ??
'';
1567 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1568 $tmpcode = $modCodeClient->getNextValue($object, 0);
1570 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1572 $s = $modCodeClient->getToolTip($langs, $object, 0);
1573 print $form->textwithpicto(
'', $s, 1);
1574 print
'</td></tr></table>';
1577 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))
1578 || (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
1579 if ($conf->browser->layout ==
'phone') {
1580 print
'<td colspan="2"></td>';
1583 print
'<td>'.$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0).
'</td><td>';
1584 print
'<table class="nobordernopadding"><tr><td>';
1585 $tmpcode =
$object->code_fournisseur ??
'';
1586 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1587 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1589 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1591 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1592 print $form->textwithpicto(
'', $s, 1);
1593 print
'</td></tr></table>';
1596 print
'<td colspan="2"></td>';
1609 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1610 print
'<td colspan="3">';
1611 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1612 print
'<input type="text" class="minwidth200 maxwidth300 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag(
$object->barcode).
'">';
1616 print
'<tr class="tdsmallheight"><td colspan="4"></td></tr>';
1619 print
'<tr><td class="tdtop">';
1620 print $form->editfieldkey(
'Address',
'address',
'', $object, 0);
1622 print
'<td colspan="3">';
1623 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1625 print
'</textarea>';
1626 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1630 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1631 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1633 if ($conf->browser->layout ==
'phone') {
1636 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1637 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1638 print $form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1642 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1643 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1644 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth200 maxwidth300 widthcentpercentminusx');
1646 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1653 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1655 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1659 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1660 print $formcompany->select_state(
$object->state_id,
$object->country_code,
'state_id',
'minwidth200 maxwidth300 widthcentpercentminusx');
1662 print $countrynotdefined;
1668 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1669 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
'<input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone') ?
GETPOST(
'phone',
'alpha') :
$object->phone).
'" spellcheck="false"></td>';
1671 if ($conf->browser->layout ==
'phone') {
1676 print
'<td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'', $object, 0).
'</td>';
1677 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"').
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'" spellcheck="false"></td></tr>';
1681 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1682 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"').
'<input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') :
$object->fax).
'" spellcheck="false"></td></tr>';
1685 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1686 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
'<input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.
$object->url.
'" spellcheck="false"></td></tr>';
1689 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'',
getDolGlobalInt(
'SOCIETE_EMAIL_MANDATORY')).
'</td>';
1690 print
'<td'.(($conf->browser->layout ==
'phone') || !
isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_email',
'class="pictofixedwidth"').
'<input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.
$object->email.
'" spellcheck="false"></td>';
1694 if ($conf->browser->layout ==
'phone') {
1697 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1698 print
"\n".
'<script type="text/javascript">'.
"\n";
1699 print
'$(document).ready(function () {
1700 $("#email").keyup(function() {
1701 console.log("We change email content");
1702 if ($(this).val()!="") {
1703 $(".noemail").addClass("fieldrequired");
1705 $(".noemail").removeClass("fieldrequired");
1709 print
'</script>'.
"\n";
1711 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
1712 $result =
$object->getNoEmail();
1717 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1719 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 ? 1 : 0), 1);
1727 if ($conf->browser->layout !=
'phone') {
1731 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1732 print
'<td class="individualline" '.(($conf->browser->layout ==
'phone') || !
isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>'.$form->selectyesno(
'contact_no_email', (GETPOSTISSET(
"contact_no_email") ?
GETPOST(
"contact_no_email",
'alpha') : (empty(
$object->no_email) ? 0 : 1)), 1, false, 1).
'</td>';
1736 $colspan = ($conf->browser->layout ==
'phone' ? 2 : 4);
1740 $object->showSocialNetwork($socialnetworks, $colspan);
1742 print
'<tr><td colspan="'.$colspan.
'"><hr></td></tr>';
1748 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1751 while ($i <= $NBPROFIDMAX) {
1752 $idprof = $langs->transcountry(
'ProfId'.$i, (
string)
$object->country_code);
1753 if ($idprof !=
'-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate[
'ProfId'.$i.$object->country_code]))) {
1756 if (($j % $NBCOLS) == 0) {
1760 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1761 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (
getDolGlobalString($idprof_mandatory) ? 1 : 0)).
'</td><td>';
1763 print $formcompany->get_input_id_prof($i, $key,
$object->$key,
$object->country_code);
1765 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1772 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1773 print
'<td colspan="2"></td></tr>';
1777 print
'<tr><td><label for="assujtva_value">'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</label></td>';
1779 print
'<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (GETPOSTISSET(
'assujtva_value') ? (
GETPOST(
'assujtva_value',
'alpha') !=
'' ?
' checked="checked"' :
'') :
'checked="checked"') .
' value="1">';
1781 if ($conf->browser->layout ==
'phone') {
1784 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1785 print
'<td class="nowrap">';
1786 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1791 if (!empty($conf->use_javascript_ajax)) {
1793 if (!empty($conf->dol_use_jmobile)) {
1798 print
'<script type="text/javascript">';
1799 print
"function CheckVAT(a) {\n";
1800 if (
$mysoc->country_code ==
'GR' &&
$object->country_code ==
'GR' && !empty($u)) {
1801 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
1803 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1808 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1809 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1811 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", (
string)
$object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1820 print
'<tr><td><label for="vat_reverse_charge">' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'', $object, 0) .
'</label></td><td colspan="3">';
1821 print
'<input type="checkbox" name="vat_reverse_charge" id="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
1827 if (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj ==
"1") {
1828 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
1829 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (
getDolGlobalString(
'THIRDPARTY_DEFAULT_USELOCALTAX1') ?
'checked="checked"' :
'') .
' value="1">';
1831 if ($conf->browser->layout ==
'phone') {
1834 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
1835 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (
getDolGlobalString(
'THIRDPARTY_DEFAULT_USELOCALTAX2') ?
'checked="checked"' :
'') .
' value="1">';
1837 } elseif (
$mysoc->localtax1_assuj ==
"1") {
1838 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td colspan="3">';
1839 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (
getDolGlobalString(
'THIRDPARTY_DEFAULT_USELOCALTAX1') ?
'checked="checked"' :
'') .
' value="1">';
1841 } elseif (
$mysoc->localtax2_assuj ==
"1") {
1842 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td colspan="3">';
1843 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (
getDolGlobalString(
'THIRDPARTY_DEFAULT_USELOCALTAX2') ?
'checked="checked"' :
'') .
' value="1">';
1848 print
'<tr><td colspan="'.$colspan.
'"><hr></td></tr>';
1851 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
1852 $langs->load(
'categories');
1855 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1856 print $form->selectCategories(Categorie::TYPE_CUSTOMER,
'custcats', $object);
1860 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1861 print $form->selectCategories(Categorie::TYPE_CONTACT,
'contcats', $object);
1867 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1868 print $form->selectCategories(Categorie::TYPE_SUPPLIER,
'suppcats', $object);
1873 print
'<tr><td colspan="'.$colspan.
'"><a class="paddingtop paddingbottom morefieldslnk onreposition" id="morefieldslnk" href="#">'.$langs->trans(
"More").
'';
1875 print
'<span class="badge badge-secondary socialnetworklnk marginleftonly">'.$nbactive.
'</span></a>';
1880 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.(($conf->browser->layout ==
'phone' ||
getDolGlobalString(
'SOCIETE_DISABLE_WORKFORCE')) ?
' colspan="3"' :
'').
'>'.
"\n";
1882 print $form->selectarray(
"typent_id", $formcompany->typent_array(0),
$object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1884 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1888 if ($conf->browser->layout ==
'phone') {
1889 print
'</tr><tr class="morefields">';
1891 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1892 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0),
$object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1894 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1897 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1902 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1903 print
'<td colspan="3" class="maxwidthonsmartphone">';
1905 print $formcompany->select_juridicalstatus(
$object->forme_juridique_code,
$object->country_code,
'',
'forme_juridique_code');
1907 print $countrynotdefined;
1912 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'CompnanyBirthDate',
'birth',
'', $object, 0).
'</td>';
1913 print
'<td colspan="3" class="maxwidthonsmartphone">';
1914 print $form->selectDate(
$object->birth,
'birth', 0, 0, 1,
"", 1);
1918 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1919 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.((string)
$object->capital).
'"> ';
1921 print
'<span class="hideonsmartphone">';
1923 print $langs->getCurrencySymbol(
$object->multicurrency_code);
1924 print
'</span></td></tr>';
1926 print
'<span class="hideonsmartphone">';
1927 print $langs->getCurrencySymbol($conf->currency);
1929 print
'</span></td></tr>';
1932 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1933 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : (
$object->default_lang ?
$object->default_lang :
''),
'default_lang', 0, array(), 1, 0, 0,
'maxwidth200onsmartphone');
1939 print
'<tr class="morefields">';
1940 print
'<td>'.$form->editfieldkey(
'PaymentConditions',
'cond_reglement_id',
'', $object, 0).
'</td>';
1941 print
'<td colspan="3" class="maxwidthonsmartphone">';
1942 print $form->getSelectConditionsPaiements((
int)
$object->cond_reglement_id,
'cond_reglement_id', 1, 1, 1,
'', (
float)
$object->deposit_percent);
1946 print
'<tr class="morefields">';
1947 print
'<td>'.$form->editfieldkey(
'PaymentMode',
'mode_reglement_id',
'', $object, 0).
'</td>';
1948 print
'<td colspan="3" class="maxwidthonsmartphone">';
1949 print $form->select_types_paiements((
string)
$object->mode_reglement_id,
'mode_reglement_id',
'', 0, 1, 1, 0, 1);
1954 print
'<tr class="morefields">';
1955 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1956 print
'<td colspan="3" class="maxwidthonsmartphone">';
1957 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1963 print
'<tr class="morefields">';
1964 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1965 print
'<td colspan="3" class="maxwidthonsmartphone">';
1966 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1967 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (
$object->multicurrency_code ?
$object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
1972 $parameters = array(
'socid' => $socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1973 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1977 print
'<tr class="morefields">';
1978 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1979 print
'<td colspan="3" class="maxwidthonsmartphone">';
1980 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1981 print $form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1986 print
'<tr class="morefields">';
1987 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1988 print
'<td colspan="3" class="maxwidthonsmartphone">';
1990 $userlist = $form->select_dolusers($selected,
'', 0,
null, 0,
'',
'',
'0', 0, 0,
'u.statut:=:1', 0,
'',
'', 0, 2);
1993 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1997 print
'<tr class="hideonsmartphone morefields"">';
1998 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1999 print
'<td colspan="3">';
2000 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
2004 print
'</table>'.
"\n";
2006 print
'<script nonce="'.getNonce().
'" type="text/javascript">
2007 $("document").ready(function() { toogleMoreFields(false); });
2009 jQuery(".morefieldslnk").click(function() {
2010 console.log("Click on link .morefieldslnk (create)");
2011 toogleMoreFields(true);
2015 function toogleMoreFields(chgCookieState) {
2016 const lnk = $("#morefieldslnk");
2017 const items = $(".morefields, .trextrafields:not(.trextrafieldsgroup)");
2018 var cookieState = document.cookie.split(";").some((item) => item.trim().startsWith("DOLUSER_MOREFIELDS_SHOW=true")) == true;
2020 if (!chgCookieState) cookieState = !cookieState ;
2024 if (chgCookieState) { document.cookie = "DOLUSER_MOREFIELDS_SHOW=false; SameSite=Strict"};
2027 if (chgCookieState) { document.cookie = "DOLUSER_MOREFIELDS_SHOW=true; SameSite=Strict";}
2035 print
'<table class="border centpercent">';
2040 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2042 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
2043 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1,
'');
2047 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2049 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
2050 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1,
'');
2054 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2055 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
2059 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2060 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
2070 print $form->buttonsSaveCancel(
'AddThirdParty',
'Cancel', array(), 0,
'', $dol_openinpopup);
2072 print
'</form>'.
"\n";
2073 } elseif ($action ==
'edit') {
2077 $res =
$object->fetch_optionals();
2084 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
2085 $module = substr($module, 0,
dol_strlen($module) - 4);
2087 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
2088 foreach ($dirsociete as $dirroot) {
2094 $modCodeClient =
new $module($db);
2095 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
2097 if ($modCodeClient->code_auto) {
2098 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
2100 $prefixCustomerIsUsed =
false;
2103 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
2104 $module = substr($module, 0,
dol_strlen($module) - 4);
2106 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
2107 foreach ($dirsociete as $dirroot) {
2113 $modCodeFournisseur =
new $module($db);
2114 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
2116 if ($modCodeFournisseur->code_auto) {
2117 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
2119 $prefixSupplierIsUsed =
false;
2124 if (GETPOSTISSET(
'name')) {
2140 $object->socialnetworks = array();
2142 foreach ($socialnetworks as $key => $value) {
2143 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
2150 $object->phone_mobile = (string)
GETPOST(
'phone_mobile',
'alpha');
2169 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
2175 $object->webservices_key =
GETPOST(
'webservices_key',
'password');
2177 if (GETPOSTISSET(
'accountancy_code_sell')) {
2178 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
2180 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
2181 $object->accountancy_code_sell =
'';
2183 $object->accountancy_code_sell = $accountancy_code_sell;
2186 if (GETPOSTISSET(
'accountancy_code_buy')) {
2187 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
2189 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
2190 $object->accountancy_code_buy =
'';
2192 $object->accountancy_code_buy = $accountancy_code_buy;
2199 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
2210 if (
$object->country_id > 0) {
2212 $object->country_code = $tmparray[
'code'];
2213 $object->country = $tmparray[
'label'];
2222 if (
$object->localtax1_assuj == 0) {
2227 if (
$object->localtax2_assuj == 0) {
2233 if (!empty($conf->use_javascript_ajax)) {
2234 print
"\n".
'<script type="text/javascript">';
2235 print
'$(document).ready(function () {
2238 if("#localtax1assuj_value".value==undefined){
2245 if("#localtax2assuj_value".value==undefined){
2252 $("#localtax1assuj_value").change(function() {
2253 var value=document.getElementById("localtax1assuj_value").value;
2260 $("#localtax2assuj_value").change(function() {
2261 var value=document.getElementById("localtax2assuj_value").value;
2269 var canHaveCustomerCategoryIfNotCustomerProspect = ' . (
getDolGlobalInt(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'1' :
'0') .
';
2271 init_customer_categ();
2272 $("#prospectinput, #customerinput").change(function() {
2273 init_customer_categ();
2275 function init_customer_categ() {
2276 var iscustomerorprospect = jQuery("#prospectinput").is(":checked") + jQuery("#customerinput").is(":checked");
2277 console.log("is customer or prospect = "+iscustomerorprospect);
2278 if (iscustomerorprospect == 0 && !canHaveCustomerCategoryIfNotCustomerProspect) {
2279 jQuery(".visibleifcustomer").hide();
2281 jQuery(".visibleifcustomer").show();
2285 init_supplier_categ();
2286 $("#supplierinput").change(function() {
2287 init_supplier_categ();
2289 function init_supplier_categ() {
2290 var issupplier = jQuery("#supplierinput").is(":checked");
2291 console.log("is supplier = "+issupplier);
2292 if (issupplier == 0) {
2293 jQuery(".visibleifsupplier").hide();
2295 jQuery(".visibleifsupplier").show();
2299 $("#selectcountry_id").change(function() {
2300 console.log("selectcountry_id change");
2301 document.formsoc.action.value="edit";
2302 document.formsoc.submit();
2306 print
'</script>'.
"\n";
2309 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post" name="formsoc">';
2310 print
'<input type="hidden" name="action" value="update">';
2311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2312 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2313 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2314 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2315 print
'<input type="hidden" name="code_auto" value="1">';
2321 print
'<div class="fichecenter2">';
2324 $parameters = array();
2326 $reshook = $hookmanager->executeHooks(
'tabContentEditThirdparty', $parameters, $object, $action);
2327 if (empty($reshook)) {
2328 print
'<table class="border centpercent">';
2332 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2338 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0,
'string',
'', 1).
'</td>';
2339 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag(
$object->name).
'" autofocus="autofocus" spellcheck="false">';
2340 print $form->widgetForTranslation(
"name", $object, (
int) $permissiontoadd,
'string',
'alphanohtml',
'minwidth300');
2344 print
'<tr id="name_alias"><td>';
2347 print
'<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag(
$object->name_alias).
'" placeholder="'.
dolPrintHTMLForAttribute($langs->trans(
'AliasNames')).
'" spellcheck="false"></td></tr>';
2351 $selectedcustomer = 0;
2352 $selectedprospect = 0;
2353 switch ($selected) {
2355 $selectedcustomer = 1;
2358 $selectedprospect = 1;
2361 $selectedprospect = 1;
2362 $selectedcustomer = 1;
2369 $selectedprospect = (GETPOSTISSET(
'prospect') ?
GETPOSTINT(
'prospect') : $selectedprospect);
2370 $selectedcustomer = (GETPOSTISSET(
'customer') ?
GETPOSTINT(
'customer') : $selectedcustomer);
2371 print
'<tr class="marginbottomlarge height50">';
2372 if ($conf->browser->layout !=
'phone') {
2373 print
'<td class="titlefieldcreate">'.$form->editfieldkey(
'',
'customerprospect',
'', $object, 0,
'string',
'', 0).
'</td>';
2375 print
'<td class="maxwidthonsmartphone"'.($conf->browser->layout !=
'phone' ?
'colspan="3"' :
'colspan="2"').
'>';
2378 print
'<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans(
"Prospect").
'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ?
' checked="checked"' :
'').
'></label></span>';
2382 print
'<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans(
"Customer").
'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ?
' checked="checked"' :
'').
'></label></span>';
2384 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))
2385 || (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
2387 $selected = (GETPOSTISSET(
'supplier') ?
GETPOSTINT(
'supplier') :
$object->fournisseur);
2388 print
'<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans(
"Vendor").
'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selected ?
' checked="checked"' :
'').
'></label></span>';
2392 if ($conf->use_javascript_ajax) {
2394 function refreshNatureCss() {
2395 jQuery(".spannature").each(function( index ) {
2396 id = $(this).attr("id").split("spannature")[1];
2397 console.log("id="+id+" "+jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
2398 if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
2400 jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
2403 jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
2406 jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
2409 jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
2414 function manageprospectcustomer(element) {
2415 console.log("We uncheck unwanted values on a nature");
2416 id = $(element).attr("id").split("spannature")[1];
2418 $("#spannature2 .checkforselect").prop("checked", false);
2421 $("#spannature1 .checkforselect").prop("checked", false);
2425 jQuery(".spannature").click(function(){
2426 console.log("We click on a nature");
2427 '.(getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ?
'manageprospectcustomer($(this));' :
'').
'
2437 if ($conf->browser->layout ==
'phone') {
2441 print
'<tr><td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td'.($colspan ?
' colspan="'.$colspan.
'"':
'').
'>';
2442 print
'<table class="nobordernopadding"><tr><td>';
2443 $tmpcode =
$object->code_client ??
'';
2444 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2445 $tmpcode = $modCodeClient->getNextValue($object, 0);
2447 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2449 $s = $modCodeClient->getToolTip($langs, $object, 0);
2450 print $form->textwithpicto(
'', $s, 1);
2451 print
'</td></tr></table>';
2454 if ($conf->browser->layout ==
'phone') {
2458 print
'<td>'.$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0).
'</td><td'.($colspan ?
' colspan="'.$colspan.
'"':
'').
'>';
2460 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
2461 print
'<table class="nobordernopadding"><tr><td>';
2462 $tmpcode =
$object->code_fournisseur ??
'';
2463 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2464 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2466 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2468 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2469 print $form->textwithpicto(
'', $s, 1);
2470 print
'</td></tr></table>';
2477 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
2478 print
'<td colspan="3">';
2479 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
2480 print
'<input type="text" class="minwidth100 maxwidth200 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag(
$object->barcode).
'" spellcheck="false">';
2485 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
'' :
' colspan="3"').
'>';
2486 print $form->selectarray(
'status', array(
'0' => $langs->trans(
'ActivityCeased'),
'1' => $langs->trans(
'InActivity')),
$object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2491 print
'<tr class="tdsmallheight"><td colspan="'.$colspan.
'"></td></tr>';
2494 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2495 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft" spellcheck="false">';
2497 print
'</textarea>';
2498 print $form->widgetForTranslation(
"address", $object, (
int) $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2502 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
2503 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2505 if ($conf->browser->layout ==
'phone') {
2508 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
2509 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2510 print $form->widgetForTranslation(
"town", $object, (
int) $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2514 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td colspan="3">';
2515 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
2516 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth200 maxwidth400 widthcentpercentminusx');
2518 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2525 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2527 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2530 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2531 print $formcompany->select_state(
$object->state_id,
$object->country_code,
'state_id',
'minwidth200 maxwidth400 widthcentpercentminusx');
2536 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'), $object, 0).
'</td>';
2537 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
'<input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone') ?
GETPOST(
'phone',
'alpha') :
$object->phone).
'" spellcheck="false"></td>';
2538 if ($conf->browser->layout ==
'phone') {
2541 print
'<td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'), $object, 0).
'</td>';
2542 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"').
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'" spellcheck="false"></td></tr>';
2544 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
2545 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"').
'<input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') :
$object->fax).
'" spellcheck="false"></td>';
2549 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'), $object, 0).
'</td>';
2550 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
'<input type="text" name="url" id="url" class="maxwidth200onsmartphone maxwidth300 widthcentpercentminusx " value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url',
'alpha') :
$object->url).
'" spellcheck="false"></td></tr>';
2553 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (
getDolGlobalInt(
'SOCIETE_EMAIL_MANDATORY'))).
'</td>';
2554 print
'<td'.(($conf->browser->layout ==
'phone') || !
isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>';
2555 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2556 print
'<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->
email).
'" spellcheck="false">';
2561 if ($conf->browser->layout ==
'phone') {
2564 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
2565 print
"\n".
'<script type="text/javascript">'.
"\n";
2568 jQuery(document).ready(function () {
2569 function init_check_no_email(input) {
2570 if (input.val()!="") {
2571 $(".noemail").addClass("fieldrequired");
2573 $(".noemail").removeClass("fieldrequired");
2576 $("#email").keyup(function() {
2577 init_check_no_email($(this));
2579 init_check_no_email($("#email"));
2581 print
'</script>'.
"\n";
2583 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
2584 $result =
$object->getNoEmail();
2589 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
2591 $useempty = (int) (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
2592 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
$object->no_email), 1, 0, $useempty);
2602 $object->showSocialNetwork($socialnetworks, $colspan);
2604 print
'<tr><td colspan="'.$colspan.
'"><hr></td></tr>';
2610 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2613 while ($i <= $NBPROFIDMAX) {
2614 $idprof = $langs->transcountry(
'ProfId'.$i,
$object->country_code);
2615 if ($idprof !=
'-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate[
'ProfId'.$i.$object->country_code]))) {
2618 if (($j % $NBCOLS) == 0) {
2622 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2623 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (
int) (
getDolGlobalString($idprof_mandatory) &&
$object->isACompany())).
'</td><td>';
2624 print $formcompany->get_input_id_prof($i, $key,
$object->$key,
$object->country_code);
2626 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2633 if ($NBCOLS > 0 && ($j % 2) == 1) {
2634 print
'<td colspan="2"></td></tr>';
2638 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2639 print
'<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (
$object->tva_assuj ?
'checked="checked"' :
'') .
' value="1">';
2644 if (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj ==
"1") {
2645 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code),
'localtax1assuj_value',
'',
$object, 0).
'</td><td>';
2646 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (
$object->localtax1_assuj ?
'checked="checked"' :
'') .
' value="1">';
2648 print
'<span class="cblt1"> '.$langs->transcountry(
"Type",
$mysoc->country_code).
': ';
2649 $formcompany->select_localtax(1, (
float)
$object->localtax1_value,
"lt1");
2654 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2655 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (
$object->localtax2_assuj ?
'checked="checked"' :
'') .
' value="1"></td></tr>';
2657 print
'<span class="cblt2"> '.$langs->transcountry(
"Type",
$mysoc->country_code).
': ';
2658 $formcompany->select_localtax(2, (
float)
$object->localtax2_value,
"lt2");
2662 } elseif (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj !=
"1") {
2663 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2664 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (
$object->localtax1_assuj ?
'checked="checked"' :
'') .
' value="1">';
2666 print
'<span class="cblt1"> '.$langs->transcountry(
"Type",
$mysoc->country_code).
': ';
2667 $formcompany->select_localtax(1, (
float)
$object->localtax1_value,
"lt1");
2671 } elseif (
$mysoc->localtax2_assuj ==
"1" &&
$mysoc->localtax1_assuj !=
"1") {
2672 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2673 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (
$object->localtax2_assuj ?
'checked="checked"' :
'') .
' value="1">';
2675 print
'<span class="cblt2"> '.$langs->transcountry(
"Type",
$mysoc->country_code).
': ';
2676 $formcompany->select_localtax(2, (
float)
$object->localtax2_value,
"lt2");
2684 print
'<tr><td>' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'', $object, 0) .
'</td><td colspan="3">';
2685 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
2690 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2691 print
'<td colspan="3">';
2692 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2697 if ($conf->use_javascript_ajax) {
2699 if (!empty($conf->dol_use_jmobile)) {
2704 print
'<script type="text/javascript">';
2705 print
"function CheckVAT(a) {\n";
2706 if (
$mysoc->country_code ==
'GR' &&
$object->country_code ==
'GR' && !empty($u)) {
2707 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
2709 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2714 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2715 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2717 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", (
string)
$object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2726 print
'<tr><td colspan="'.$colspan.
'"><hr></td></tr>';
2729 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
2731 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2732 print
'<td colspan="3">';
2733 print $form->selectCategories(Categorie::TYPE_CUSTOMER,
'custcats', $object);
2737 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
2738 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2739 print
'<td colspan="3">';
2740 print $form->selectCategories(Categorie::TYPE_SUPPLIER,
'suppcats', $object);
2745 print
'<tr><td colspan="'.$colspan.
'"><br><a class="paddingtop paddingbottom morefieldslnk onreposition" id="morefieldslnk" href="#">'.$langs->trans(
"More").
'';
2747 print
'<span class="badge badge-secondary socialnetworklnk marginleftonly">'.$nbactive.
'</span></a>';
2752 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.(($conf->browser->layout ==
'phone' ||
getDolGlobalString(
'SOCIETE_DISABLE_WORKFORCE')) ?
' colspan="3"' :
'').
'>';
2753 print $form->selectarray(
"typent_id", $formcompany->typent_array(0),
$object->typent_id, 1, 0, 0,
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
2755 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2759 if ($conf->browser->layout ==
'phone') {
2760 print
'</tr><tr class="morefields">';
2762 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2763 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0),
$object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2765 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2768 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2773 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
2774 print
'<td class="maxwidthonsmartphone" colspan="3">';
2775 print $formcompany->select_juridicalstatus(
$object->forme_juridique_code,
$object->country_code,
'',
'forme_juridique_code');
2779 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'CompnanyBirthDate',
'birth',
'', $object, 0).
'</td>';
2780 print
'<td class="maxwidthonsmartphone" colspan="3">';
2781 print $form->selectDate(
$object->birth,
'birth', 0, 0, 1,
"", 1);
2785 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2786 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="width75" value="';
2789 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".
$object->multicurrency_code).
'</span></td></tr>';
2791 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2796 print
'<tr class="morefields"><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2797 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
$object->default_lang,
'default_lang', 0, array(),
'1', 0, 0,
'maxwidth300 widthcentpercentminusx');
2804 print
'<tr class="morefields">';
2805 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2806 print
'<td colspan="3" class="maxwidthonsmartphone">';
2807 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
2813 print
'<tr class="morefields">';
2814 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2815 print
'<td colspan="3" class="maxwidthonsmartphone">';
2816 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2817 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (
$object->multicurrency_code ?
$object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
2822 $parameters = array(
'socid' => $socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2823 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2825 print
'<tr class="morefieldsbis tdsmallheight"><td colspan="4"></td></tr>';
2829 print
'<tr class="morefieldsbis">';
2830 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
2831 print
'<td colspan="3" class="maxwidthonsmartphone">';
2832 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2833 print $form->select_company(
GETPOST(
'parent_company_id') ?
GETPOST(
'parent_company_id') :
$object->parent,
'parent_company_id',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
2838 print
'<tr class="morefieldsbis">';
2839 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2840 print
'<td colspan="3" class="maxwidthonsmartphone">';
2841 $userlist = $form->select_dolusers(
'',
'', 0,
null, 0,
'',
'',
'0', 0, 0,
'u.statut:=:1', 0,
'',
'', 0, 1);
2842 $arrayselected =
GETPOST(
'commercial',
'array');
2843 if (empty($arrayselected)) {
2844 $arrayselected =
$object->getSalesRepresentatives($user, 1);
2846 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2850 print
'<tr class="hideonsmartphone morefieldsbis">';
2851 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2852 print
'<td colspan="3">';
2854 print $form->showphoto(
'societe', $object, 100, 0, 0,
'inline-block');
2857 if ($caneditfield) {
2861 print
'<table class="nobordernopadding">';
2863 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans(
"Delete").
'</photo><br></td></tr>';
2868 $maxmin = $maxfilesizearray[
'maxmin'];
2870 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2872 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2879 print
'</table>'.
"\n";
2881 print
'<script nonce="'.getNonce().
'" type="text/javascript">
2882 $("document").ready(function() { toogleMoreFields(false); });
2884 jQuery(".morefieldslnk").click(function() {
2885 console.log("Click on link .morefieldslnk (edit)");
2886 toogleMoreFields(true);
2890 function toogleMoreFields(chgCookieState) {
2891 const lnk = $("#morefieldslnk");
2892 const items = $(".morefields, .trextrafields:not(.trextrafieldsgroup)");
2893 var cookieState = document.cookie.split(";").some((item) => item.trim().startsWith("DOLUSER_MOREFIELDS_SHOW=true")) == true;
2895 if (!chgCookieState) cookieState = !cookieState ;
2899 if (chgCookieState) { document.cookie = "DOLUSER_MOREFIELDS_SHOW=false; SameSite=Strict"};
2902 if (chgCookieState) { document.cookie = "DOLUSER_MOREFIELDS_SHOW=true; SameSite=Strict";}
2910 print
'<table class="border centpercent">';
2915 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2917 print $formaccounting->select_account(
$object->accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1);
2921 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2923 print $formaccounting->select_account(
$object->accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1);
2927 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2928 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2932 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2933 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2944 print $form->buttonsSaveCancel();
2951 $res =
$object->fetch_optionals();
2956 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ThirdParty"), -1,
'company', 0,
'',
'', 0,
'', 1);
2961 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2962 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".
$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2965 if ($action ==
'merge') {
2966 $formquestion = array(
2968 'name' =>
'soc_origin',
2969 'label' => $langs->trans(
'MergeOriginThirdparty'),
2971 'value' => $form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth200',
'',
'', 1, array(),
false, array(
$object->id))
2975 $formconfirm .= $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".
$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 300);
2979 if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2980 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2982 $formquestionclone = array(
2983 'text' => $langs->trans(
"ConfirmClone"),
2984 0 => array(
'type' =>
'text',
'name' =>
'clone_name',
'label' => $langs->trans(
"NewSocNameForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->nom : $tmpcode,
'morecss' =>
'width250'),
2986 $formconfirm .= $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneThirdparties',
$object->name),
'confirm_clone', $formquestionclone,
'yes',
'action-clone', 350, 600);
2990 $parameters = array(
'formConfirm' => $formconfirm);
2991 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2992 if (empty($reshook)) {
2993 $formconfirm .= $hookmanager->resPrint;
2994 } elseif ($reshook > 0) {
2995 $formconfirm = $hookmanager->resPrint;
3003 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
3005 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/societe/vcard.php?id='.
$object->id.
'" class="refid">';
3006 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard',
'class="valignmiddle marginleftonly paddingrightonly"');
3007 $morehtmlref .=
'</a>';
3009 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom', $morehtmlref);
3012 $parameters = array();
3014 $reshook = $hookmanager->executeHooks(
'tabContentViewThirdparty', $parameters, $object, $action);
3015 if (empty($reshook)) {
3016 print
'<div class="fichecenter">';
3017 print
'<div class="fichehalfleft">';
3019 print
'<div class="underbanner clearboth"></div>';
3020 print
'<table class="border tableforfield centpercent">';
3023 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
3030 print $langs->trans(
'CustomerCode');
3034 $tmpcheck =
$object->check_codeclient();
3035 if ($tmpcheck != 0 && $tmpcheck != -5) {
3036 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
3043 if (((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) &&
$object->fournisseur) {
3045 print $langs->trans(
'SupplierCode').
'</td><td>';
3047 $tmpcheck =
$object->check_codefournisseur();
3048 if ($tmpcheck != 0 && $tmpcheck != -5) {
3049 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
3068 while ($i <= $NBPROFIDMAX) {
3069 $idprof = $langs->transcountry(
'ProfId'.$i,
$object->country_code);
3070 if (!empty($conf->dol_optimize_smallscreen)) {
3071 $idprof = $langs->transcountry(
'ProfId'.$i.
'Short',
$object->country_code);
3073 if ($idprof !=
'-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate[
'ProfId'.$i.$object->country_code]))) {
3075 print
'<td>'.$idprof.
'</td><td>';
3079 if (
$object->id_prof_check($i, $object) > 0) {
3080 $profidurl =
$object->id_prof_url($i, $object);
3081 if (!empty($profidurl)) {
3082 print
' '.$profidurl;
3085 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
3103 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
3112 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
3114 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
3122 if (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj ==
"1") {
3123 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
3125 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
3130 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3131 print
'<input type="hidden" name="action" value="set_localtax1">';
3132 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3133 print
'<tr><td>'.$langs->transcountry(
"Localtax1",
$mysoc->country_code).
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editRE&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3134 if ($action ==
'editRE') {
3135 print
'<td class="left">';
3136 $formcompany->select_localtax(1, (
float)
$object->localtax1_value,
"lt1");
3137 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3139 print
'<td>'.$object->localtax1_value.
'</td>';
3141 print
'</tr></form>';
3144 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3145 print
'<input type="hidden" name="action" value="set_localtax2">';
3146 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3147 print
'<tr><td>'.$langs->transcountry(
"Localtax2",
$mysoc->country_code).
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editIRPF&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3148 if ($action ==
'editIRPF') {
3149 print
'<td class="left">';
3150 $formcompany->select_localtax(2, (
float)
$object->localtax2_value,
"lt2");
3151 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3153 print
'<td>'.$object->localtax2_value.
'</td>';
3155 print
'</tr></form>';
3157 } elseif (
$mysoc->localtax1_assuj ==
"1" &&
$mysoc->localtax2_assuj !=
"1") {
3158 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed",
$mysoc->country_code).
'</td><td>';
3162 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3163 print
'<input type="hidden" name="action" value="set_localtax1">';
3164 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3165 print
'<tr><td> '.$langs->transcountry(
"Localtax1",
$mysoc->country_code).
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editRE&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3166 if ($action ==
'editRE') {
3167 print
'<td class="left">';
3168 $formcompany->select_localtax(1, (
float)
$object->localtax1_value,
"lt1");
3169 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3171 print
'<td>'.$object->localtax1_value.
'</td>';
3173 print
'</tr></form>';
3175 } elseif (
$mysoc->localtax2_assuj ==
"1" &&
$mysoc->localtax1_assuj !=
"1") {
3176 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed",
$mysoc->country_code).
'</td><td>';
3180 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3181 print
'<input type="hidden" name="action" value="set_localtax2">';
3182 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3183 print
'<tr><td> '.$langs->transcountry(
"Localtax2",
$mysoc->country_code).
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editIRPF&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3184 if ($action ==
'editIRPF') {
3185 print
'<td class="left">';
3186 $formcompany->select_localtax(2, (
float)
$object->localtax2_value,
"lt2");
3187 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3189 print
'<td>'.$object->localtax2_value.
'</td>';
3191 print
'</tr></form>';
3198 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
3202 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
3207 if ($conf->use_javascript_ajax) {
3209 if (!empty($conf->dol_use_jmobile)) {
3214 print
'<script type="text/javascript">';
3215 print
"function CheckVAT(a) {\n";
3216 if (
$mysoc->country_code ==
'GR' &&
$object->country_code ==
'GR' && !empty($u)) {
3217 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
3219 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
3224 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(jQuery(\'#tva_intra\').val());">'.$langs->trans(
"VATIntraCheck").
'</a>';
3225 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
3227 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", (
string)
$object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
3238 $langs->load(
'stocks');
3239 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3241 print
'<tr class="nowrap">';
3243 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->hasRight(
'societe',
'creer'));
3245 if ($action ==
'editwarehouse') {
3246 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_warehouse,
'fk_warehouse', 1);
3248 if (
$object->fk_warehouse > 0) {
3249 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
3251 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_warehouse,
'none');
3260 print
'<div class="fichehalfright">';
3262 print
'<div class="underbanner clearboth"></div>';
3263 print
'<table class="border tableforfield centpercent">';
3266 if (
isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
3269 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
3271 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
3276 if (((
isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) &&
$object->fournisseur) {
3277 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
3279 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
3286 print
'<tr><td class="titlefieldmiddle">';
3287 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
3288 if ($action !=
'editthirdpartytype' && $user->hasRight(
'societe',
'creer')) {
3289 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editthirdpartytype&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a></td>';
3291 print
'</tr></table>';
3293 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
3294 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->typent_id, $html_name,
'');
3299 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.
$object->effectif.
'</td></tr>';
3303 print
'<tr><td>'.$langs->trans(
'JuridicalStatus').
'</td><td>'.
dolPrintHTML(
$object->forme_juridique).
'</td></tr>';
3306 print
'<tr><td>'.$langs->trans(
'CompnanyBirthDate').
'</td><td>'.
dol_print_date(
$object->birth).
'</td></tr>';
3309 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
3310 if (
$object->capital !==
null) {
3314 print
price(
$object->capital, 0, $langs, 0, -1, -1, $conf->currency);
3321 $result =
$object->getNoEmail();
3325 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
3329 $langs->load(
"mails");
3330 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
3333 $langs->load(
"mails");
3334 print
' <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans(
"NbOfEMailingsSend")).
'">'.
$object->getNbOfEMailings().
'</span>';
3341 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3342 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
3345 $langs->load(
"languages");
3346 $labellang = (
$object->default_lang ? $langs->trans(
'Language_'.
$object->default_lang) :
'');
3355 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
3356 if ($action !=
'editincoterm' && $user->hasRight(
'societe',
'creer')) {
3357 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
3359 print
'</tr></table>';
3360 print
'</td><td colspan="3">';
3361 if ($action !=
'editincoterm') {
3362 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3364 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.
$object->id);
3372 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
3380 print
'<tr><td class="nowrap">';
3381 print $langs->trans(
"ProductAccountancySellCode");
3382 print
'</td><td colspan="2">';
3384 if (!empty(
$object->accountancy_code_sell)) {
3386 $accountingaccount->fetch(0,
$object->accountancy_code_sell, 1);
3388 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
3391 print
$object->accountancy_code_sell;
3396 print
'<tr><td class="nowrap">';
3397 print $langs->trans(
"ProductAccountancyBuyCode");
3398 print
'</td><td colspan="2">';
3400 if (!empty(
$object->accountancy_code_buy)) {
3402 $accountingaccount2->fetch(0,
$object->accountancy_code_buy, 1);
3404 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3407 print
$object->accountancy_code_buy;
3413 $parameters = array(
'socid' => $socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3414 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3419 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3420 if ($action !=
'editparentcompany' && $user->hasRight(
'societe',
'creer')) {
3421 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editparentcompany&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a></td>';
3423 print
'</tr></table>';
3425 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3426 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id, (
string)
$object->parent, $html_name,
'', 1, 0, 0, array(), 0, array(
$object->id));
3431 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3435 $langs->load(
"members");
3436 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3439 $result = $adh->fetch(0,
'',
$object->id);
3441 $adh->ref = $adh->getFullName($langs);
3442 print $adh->getNomUrl(-1);
3444 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3446 print
"</td></tr>\n";
3469 print
'<div class="clearboth"></div>';
3478 if ($action !=
'presend') {
3479 print
'<div class="tabsAction">'.
"\n";
3481 $parameters = array();
3482 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3483 if (empty($reshook)) {
3484 $at_least_one_email_contact =
false;
3485 $TContact =
$object->contact_array_objects();
3486 foreach ($TContact as &$contact) {
3487 if (!empty($contact->email)) {
3488 $at_least_one_email_contact =
true;
3493 if (empty($user->socid)) {
3494 $langs->load(
"mails");
3496 if (empty(
$object->email) && !$at_least_one_email_contact) {
3497 $title = $langs->trans(
'NoEMail');
3499 print
dolGetButtonAction($title, $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle',
'btn-send-mail', (!empty(
$object->email) || $at_least_one_email_contact) ? 1 : -1);
3502 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
3504 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
3505 $cloneSocietetUrl =
'';
3506 $cloneButtonId =
'action-clone';
3508 $cloneSocietetUrl =
'';
3509 $cloneButtonId =
'';
3511 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneSocietetUrl, $cloneButtonId, $user->hasRight(
'societe',
'creer'));
3515 $result = $adh->fetch(0,
'',
$object->id);
3517 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/adherents/card.php?&action=create&socid='.
$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"NewMember")).
'">'.$langs->trans(
"NewMember").
'</a>'.
"\n";
3521 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=merge&token='.
newToken(),
'', $permissiontodelete);
3523 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=delete&token='.
newToken();
3524 $buttonId =
'action-delete-no-ajax';
3525 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3527 $buttonId =
'action-delete';
3529 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3532 print
'</div>'.
"\n";
3536 if (
GETPOST(
'modelselected')) {
3537 $action =
'presend';
3540 if ($action !=
'presend') {
3541 print
'<div class="fichecenter"><div class="fichehalfleft">';
3544 print
'<a name="builddoc"></a>';
3549 $filedir = $conf->societe->multidir_output[
$object->entity ?? $conf->entity].
'/'.
$object->id;
3550 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
3551 $genallowed = $user->hasRight(
'societe',
'lire');
3552 $delallowed = $user->hasRight(
'societe',
'creer');
3554 print $formfile->showdocuments(
'company', (
string)
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 0, 0, 0, 28, 0,
'entity='.$object->entity,
'',
'',
$object->default_lang);
3563 print
'</div><div class="fichehalfright">';
3567 $morehtmlcenter =
'<div class="nowraponall">';
3568 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/societe/messaging.php?socid='.
$object->id);
3569 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.
$object->id);
3570 $morehtmlcenter .=
'</div>';
3573 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3575 $somethingshown = $formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3577 print
'</div></div>';
3582 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id);
3588 $modelmail =
'thirdparty';
3589 $defaulttopic =
'Information';
3590 $diroutput = $conf->societe->multidir_output[
$object->entity ?? $conf->entity];
3591 $trackid =
'thi'.$object->id;
3593 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
3606function GRVAT(a, u, p, myafm) {
3607 var afm = a.replace(/\D/g,
"");
3611 url:
'<?php echo DOL_URL_ROOT ?>/societe/checkvat/checkVatGr.php',
3613 success:
function(data) {
3617 if (obj.RgWsPublicBasicRt_out.afm ===
null) {
3618 alert(obj.pErrorRec_out.errorDescr);
3620 $(
"#name").val(obj.RgWsPublicBasicRt_out.onomasia);
3621 $(
"#address").val(obj.RgWsPublicBasicRt_out.postalAddress +
" " + obj.RgWsPublicBasicRt_out.postalAddressNo);
3622 $(
"#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode);
3623 $(
"#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription);
3624 $(
"#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr);
3625 $(
"#name_alias_input").val(obj.RgWsPublicBasicRt_out.commerTitle);
3627 if (obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser) {
3628 var firmActUser = obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser;
3630 if (Array.isArray(firmActUser)) {
3631 var primaryFirmAct = firmActUser.find(item => item.firmActKindDescr ===
"ΚΥΡΙΑ");
3632 if (primaryFirmAct) {
3633 $(
"#idprof1").val(primaryFirmAct.firmActDescr);
3636 $(
"#idprof1").val(firmActUser.firmActDescr);
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage third parties objects (customers, suppliers, prospects...)
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
currency_name($code_iso, $withcode=0, $outputlangs=null)
Return label of currency or code+label.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null, $forceFullTextIndexation='')
Add a file into database index.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $keyforsourcefile='addedfile', $upload_dir='', $mode=0)
Check validity of a file upload from an GUI page, and move it to its final destination.
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded', $object=null)
Delete files into database index using search criteria.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.