44require
'../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
55if (isModEnabled(
'member')) {
56 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
58if (isModEnabled(
'accounting')) {
59 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
61if (isModEnabled(
'accounting')) {
62 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
64if (isModEnabled(
'accounting')) {
65 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
67if (isModEnabled(
'eventorganization')) {
68 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
83if ($mysoc->country_code ==
'GR') {
92$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
94if (isModEnabled(
'member')) {
95 $langs->load(
"members");
97if (isModEnabled(
'category')) {
98 $langs->load(
"categories");
100if (isModEnabled(
'incoterm')) {
101 $langs->load(
"incoterm");
103if (isModEnabled(
'notification')) {
104 $langs->load(
"mails");
106if (isModEnabled(
'accounting')) {
107 $langs->load(
"products");
115$action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
116$cancel =
GETPOST(
'cancel',
'alpha');
117$backtopage =
GETPOST(
'backtopage',
'alpha');
118$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
119$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
120$confirm =
GETPOST(
'confirm',
'alpha');
122$dol_openinpopup =
'';
123if (!empty($backtopagejsfields)) {
124 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
125 $dol_openinpopup = preg_replace(
'/[^a-z0-9_]/i',
'', $tmpbacktopagejsfields[0]);
130 if (in_array($action, [
'add',
'create',
'merge',
'confirm_merge',
'delete',
'confirm_delete'])) {
134 $socid = $user->socid;
136if (empty($socid) && $action ==
'view') {
146$extrafields->fetch_name_optionals_label(
$object->table_element);
151$hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
157if (!(
$object->id > 0) && $action ==
'view') {
164if (!empty($canvas)) {
165 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
166 $objcanvas =
new Canvas($db, $action);
167 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
171$permissiontoread = $user->hasRight(
'societe',
'lire');
172$permissiontoadd = $user->hasRight(
'societe',
'creer');
173$permissiontodelete = $user->hasRight(
'societe',
'supprimer') || ($permissiontoadd && isset(
$object->status) &&
$object->status == 0);
174$permissionnote = $user->hasRight(
'societe',
'creer');
175$permissiondellink = $user->hasRight(
'societe',
'creer');
176$upload_dir =
$conf->societe->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
179$result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
187$parameters = array(
'id' => $socid,
'objcanvas' => $objcanvas);
189$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
194if (empty($reshook)) {
195 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
197 if (empty($backtopage) || ($cancel && empty($id))) {
198 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
199 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
200 $backtopage = $backurlforlist;
202 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
208 if (!empty($backtopageforcancel)) {
209 header(
"Location: ".$backtopageforcancel);
211 } elseif (!empty($backtopage)) {
212 header(
"Location: ".$backtopage);
218 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $permissiontoadd) {
220 $soc_origin =
new Societe($db);
222 if ($soc_origin_id <= 0) {
223 $langs->load(
'errors');
224 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
226 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
231 $result =
$object->mergeCompany($soc_origin_id);
242 if (
GETPOST(
'getcustomercode')) {
244 $_POST[
"customer_code"] =
"Acompleter";
247 if (
GETPOST(
'getsuppliercode')) {
249 $_POST[
"supplier_code"] =
"Acompleter";
252 if ($action ==
'set_localtax1' && $permissiontoadd) {
256 $res =
$object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
258 if ($action ==
'set_localtax2' && $permissiontoadd) {
262 $res =
$object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
265 if ($action ==
'update_extras' && $permissiontoadd) {
271 $extrafields->fetch_name_optionals_label(
$object->table_element);
273 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
279 $result =
$object->insertExtraFields(
'COMPANY_MODIFY');
287 $action =
'edit_extras';
292 if ((!
GETPOST(
'getcustomercode') && !
GETPOST(
'getsuppliercode')) && ($action ==
'add' || $action ==
'update') && $permissiontoadd) {
293 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
296 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
300 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Customer")),
null,
'errors');
304 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Prospect")),
null,
'errors');
307 if (GETPOSTISSET(
'supplier') &&
GETPOSTINT(
'supplier') < 0) {
308 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
312 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOSTINT(
'contact_no_email') == -1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
314 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
317 if (isModEnabled(
'mailing') &&
GETPOSTINT(
"private") == 1 &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOSTINT(
'contact_no_email') == -1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
319 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
323 if ($action ==
'update') {
350 $object->socialnetworks = array();
351 if (isModEnabled(
'socialnetworks')) {
352 foreach ($socialnetworks as $key => $value) {
353 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
360 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
362 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
364 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
372 $object->code_client = GETPOSTISSET(
'customer_code') ?
GETPOST(
'customer_code',
'alpha') :
GETPOST(
'code_client',
'alpha');
373 $object->code_fournisseur = GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
379 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
396 $customer = (
GETPOSTINT(
'customer') > 0 ? 1 : 0);
397 $prospect = (
GETPOSTINT(
'prospect') > 0 ? 2 : 0);
398 $prospectcustomer = $customer + $prospect;
400 $object->client = $prospectcustomer;
403 if ($action ==
'add') {
406 $form =
new Form($db);
407 $form->load_cache_types_paiements();
409 $paymentTermId =
GETPOSTINT(
'cond_reglement_id');
410 $paymentTypeId =
GETPOSTINT(
'mode_reglement_id');
412 $object->cond_reglement_id = $paymentTermId;
414 $filterPaymentTypeIdArr = array(0, 2, 3);
415 if (!empty($form->cache_types_paiements[$paymentTypeId]) && isset($form->cache_types_paiements[$paymentTypeId][
'type']) && in_array($form->cache_types_paiements[$paymentTypeId][
'type'], $filterPaymentTypeIdArr)) {
416 $object->mode_reglement_id = $paymentTypeId;
420 if (
$object->fournisseur > 0) {
421 $object->cond_reglement_supplier_id = $paymentTermId;
423 $filterPaymentTypeIdArr = array(1, 2, 3);
424 if (!empty($form->cache_types_paiements[$paymentTypeId]) && isset($form->cache_types_paiements[$paymentTypeId][
'type']) && in_array($form->cache_types_paiements[$paymentTypeId][
'type'], $filterPaymentTypeIdArr)) {
425 $object->mode_reglement_supplier_id = $paymentTypeId;
435 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
436 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
438 if (GETPOSTISSET(
'accountancy_code_sell')) {
439 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
441 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
442 $object->accountancy_code_sell =
'';
444 $object->accountancy_code_sell = $accountancy_code_sell;
447 if (GETPOSTISSET(
'accountancy_code_buy')) {
448 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
450 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
451 $object->accountancy_code_buy =
'';
453 $object->accountancy_code_buy = $accountancy_code_buy;
458 if (isModEnabled(
'incoterm')) {
460 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
464 if (isModEnabled(
"multicurrency")) {
465 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
469 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
475 $ret =
$object->setValuesForExtraLanguages();
481 if (!empty($_FILES[
'photo'][
'name'])) {
492 if (!
GETPOST(
'cancel',
'alpha')) {
494 $langs->load(
"errors");
499 $langs->load(
"errors");
502 if (!empty(
$object->webservices_url)) {
504 if (strpos(
$object->webservices_url,
"http") ===
false) {
505 $object->webservices_url =
"http://".$object->webservices_url;
508 $langs->load(
"errors");
510 $errors[] = $langs->trans(
"ErrorBadUrl",
$object->webservices_url);
518 $object->country_code = $tmparray[
'code'];
519 $object->country = $tmparray[
'label'];
525 if ($action ==
'add' && $permissiontoadd) {
533 if (empty(
$object->fournisseur)) {
534 $object->code_fournisseur =
'';
537 $result =
$object->create($user);
539 if ($result >= 0 && isModEnabled(
'mailing') && !empty(
$object->email) &&
$object->no_email == 1) {
542 if ($resultnoemail < 0) {
551 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
552 $contcats =
GETPOST(
'contcats',
'array');
554 $result =
$object->create_individual($user, $no_email, $contcats);
562 $salesreps =
GETPOST(
'commercial',
'array');
563 $result =
$object->setSalesRep($salesreps,
true);
570 $custcats =
GETPOST(
'custcats',
'array');
571 $result =
$object->setCategories($custcats,
'customer');
578 $suppcats =
GETPOST(
'suppcats',
'array');
579 $result =
$object->setCategories($suppcats,
'supplier');
587 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
596 if (!($result > 0)) {
597 $errors[] =
"ErrorFailedToSaveFile";
605 switch ($_FILES[
'photo'][
'error']) {
608 $errors[] =
"ErrorFileSizeTooLarge";
611 $errors[] =
"ErrorFilePartiallyUploaded";
616 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed',
$object->errors)) {
617 $duplicate_code_error =
true;
621 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed',
$object->errors)) {
622 $duplicate_code_error =
true;
623 $object->code_fournisseur =
'';
626 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
627 $duplicate_code_error =
true;
634 if ($result >= 0 && !$error) {
637 if ($backtopagejsfields) {
640 $retstring =
'<script>';
641 $retstring .=
'jQuery(document).ready(function() {
642 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
643 console.log(\
'id = '.
$object->id.
'\');
644 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.
$object->id.
'\');
645 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.
$object->name.
'\');
646 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
648 $retstring .=
'</script>';
655 if (!empty($backtopage)) {
656 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
657 if (preg_match(
'/\?/', $backtopage)) {
658 $backtopage .=
'&socid='.$object->id;
660 header(
"Location: ".$backtopage);
663 $url = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
665 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".
$object->id;
666 } elseif (
$object->fournisseur == 1) {
667 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".
$object->id;
670 header(
"Location: ".$url);
679 if ($action ==
'update' && $permissiontoadd) {
682 if (
GETPOST(
'cancel',
'alpha')) {
683 if (!empty($backtopage)) {
684 header(
"Location: ".$backtopage);
687 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
693 if (empty(
$object->client) && empty(
$object->oldcopy->code_client)) {
696 if (empty(
$object->fournisseur) && empty(
$object->oldcopy->code_fournisseur)) {
697 $object->code_fournisseur =
'';
701 $result =
$object->update($socid, $user, 1,
$object->oldcopy->codeclient_modifiable(),
$object->oldcopy->codefournisseur_modifiable(),
'update', 0);
705 if (GETPOSTISSET(
'no_email') &&
$object->email) {
707 $result =
$object->setNoEmail($no_email);
726 $salesreps =
GETPOST(
'commercial',
'array');
727 $result =
$object->setSalesRep($salesreps);
734 if (!$error && $user->hasRight(
'categorie',
'lire')) {
736 $categories =
GETPOST(
'custcats',
'array');
737 $result =
$object->setCategories($categories,
'customer');
744 $categories =
GETPOST(
'suppcats',
'array');
745 $result =
$object->setCategories($categories,
'supplier');
754 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
756 $fileimg = $dir.
'/'.
$object->logo;
757 $dirthumbs = $dir.
'/thumbs';
763 if ($current_logo !=
$object->logo) {
764 $fileimg = $dir.
'/'.$current_logo;
765 $dirthumbs = $dir.
'/thumbs';
776 if (!($result > 0)) {
777 $errors[] =
"ErrorFailedToSaveFile";
784 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
793 $errors[] =
"ErrorBadImageFormat";
796 switch ($_FILES[
'photo'][
'error']) {
799 $errors[] =
"ErrorFileSizeTooLarge";
802 $errors[] =
"ErrorFilePartiallyUploaded";
811 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
812 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
813 if (!
$object->db->query($sql)) {
820 if (!$error && !count($errors)) {
821 if (!empty($backtopage)) {
822 header(
"Location: ".$backtopage);
825 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
834 $action = ($action ==
'add' ?
'create' :
'edit');
839 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'supprimer')) {
842 $result =
$object->delete($socid, $user);
845 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode(
$object->name));
848 $langs->load(
"errors");
856 if ($action ==
'set_thirdpartytype' && $permissiontoadd) {
862 if ($action ==
'set_incoterms' && $permissiontoadd && isModEnabled(
'incoterm')) {
868 if ($action ==
'set_thirdparty' && $permissiontoadd) {
874 if ($action ==
'set_salesrepresentatives' && $permissiontoadd) {
880 if ($action ==
'setwarehouse' && $permissiontoadd) {
884 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
888 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
894 if (!empty(
GETPOST(
'clone_name'))) {
896 $clone->name =
GETPOST(
'clone_name',
'alphanohtml');
898 $clone->fournisseur = 0;
903 $clone->context[
'createfromclone'] =
'createfromclone';
904 $id = $clone->create($user);
912 unset($clone->context[
'createfromclone']);
919 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
923 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
936 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
940 $triggersendname =
'COMPANY_SENTBYMAIL';
941 $paramname =
'socid';
942 $mode =
'emailfromthirdparty';
943 $trackid =
'thi'.$object->id;
944 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
948 $upload_dir = !empty(
$conf->societe->multidir_output[
$object->entity]) ?
$conf->societe->multidir_output[
$object->entity] :
$conf->societe->dir_output;
949 $permissiontoadd = $user->hasRight(
'societe',
'creer');
950 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
958$form =
new Form($db);
962if (isModEnabled(
'accounting')) {
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')) {
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';
1030 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1031 $module = substr($module, 0,
dol_strlen($module) - 4);
1033 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
1034 foreach ($dirsociete as $dirroot) {
1040 $modCodeFournisseur =
new $module($db);
1041 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
1044 if (
GETPOST(
"type",
'aZ') !=
'f') {
1051 if (
GETPOST(
"type",
'aZ') ==
'c') {
1058 if (
GETPOST(
"type",
'aZ') ==
'p') {
1066 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) && (
GETPOST(
"type") ==
'f' || (
GETPOST(
"type") ==
'' &&
getDolGlobalString(
'THIRDPARTY_SUPPLIER_BY_DEFAULT')))) {
1073 $object->particulier = $private;
1077 if (empty($duplicate_code_error)) {
1082 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
null,
'warnings');
1090 $object->socialnetworks = array();
1091 if (isModEnabled(
'socialnetworks')) {
1092 foreach ($socialnetworks as $key => $value) {
1093 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
1100 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
1102 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1105 $paymentTermId =
GETPOSTINT(
'cond_reglement_id');
1106 if (empty($paymentTermId) && !GETPOSTISSET(
'cond_reglement_id')) {
1109 $object->cond_reglement_id = $paymentTermId;
1110 $paymentTypeId =
GETPOSTINT(
'mode_reglement_id');
1111 if (empty($paymentTypeId) && !GETPOSTISSET(
'mode_reglement_id')) {
1114 $object->mode_reglement_id = $paymentTypeId;
1127 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1142 if (GETPOSTISSET(
'accountancy_code_sell')) {
1143 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1145 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1146 $object->accountancy_code_sell =
'';
1148 $object->accountancy_code_sell = $accountancy_code_sell;
1151 if (GETPOSTISSET(
'accountancy_code_buy')) {
1152 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1154 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1155 $object->accountancy_code_buy =
'';
1157 $object->accountancy_code_buy = $accountancy_code_buy;
1165 $file_OK = (isset($_FILES[
'photo']) ? is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1170 if (@is_dir($dir)) {
1174 if (!($result > 0)) {
1175 $errors[] =
"ErrorFailedToSaveFile";
1188 $object->country_code = $tmparray[
'code'];
1189 $object->country = $tmparray[
'label'];
1194 if (isModEnabled(
"multicurrency")) {
1200 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1202 if (!empty(
$conf->use_javascript_ajax)) {
1204 print
"\n".
'<script type="text/javascript">';
1205 print
'$(document).ready(function () {
1208 is_private=' . $private.
';
1210 $(".individualline").show();
1212 $(".individualline").hide();
1214 $("#radiocompany").click(function() {
1215 $(".individualline").hide();
1216 $("#typent_id").val(0);
1217 $("#typent_id").change();
1218 $("#effectif_id").val(0);
1219 $("#effectif_id").change();
1220 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1221 document.formsoc.private.value=0;
1223 $("#radioprivate").click(function() {
1224 $(".individualline").show();
1225 $("#typent_id").val(id_te_private);
1226 $("#typent_id").change();
1227 $("#effectif_id").val(id_ef15);
1228 $("#effectif_id").change();
1229 /* Force to recompute the width of a select2 field when it was hidden and then shown programmatically */
1230 if ($("#civility_id").data("select2")) {
1231 $("#civility_id").select2({width: "resolve"});
1233 $("#TypeName").html(document.formsoc.LastName.value);
1234 document.formsoc.private.value=1;
1239 function init_check_no_email(input) {
1240 if (input.val()!="") {
1241 $(".noemail").addClass("fieldrequired");
1243 $(".noemail").removeClass("fieldrequired");
1246 $("#email").keyup(function() {
1247 init_check_no_email($(this));
1249 init_check_no_email($("#email"));';
1252 print
'</script>'.
"\n";
1254 print
'<div id="selectthirdpartytype">';
1255 print
'<div class="hideonsmartphone float">';
1256 print $langs->trans(
"ThirdPartyType").
': ';
1258 print
'<label for="radiocompany" class="radiocompany">';
1259 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1261 print $langs->trans(
"CreateThirdPartyOnly");
1263 print
' ';
1264 print
'<label for="radioprivate" class="radioprivate">';
1265 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1267 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1268 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1269 print $form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1275 print
'<script type="text/javascript">';
1276 print
'$(document).ready(function () {
1277 var canHaveCustomerCategoryIfNotCustomerProspectSupplier = ' . (!
getDolGlobalString(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'0' :
'1') .
';
1279 init_customer_categ();
1280 $("#customerprospect").change(function() {
1281 init_customer_categ();
1283 function init_customer_categ() {
1284 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1285 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspectSupplier) {
1286 jQuery(".visibleifcustomer").hide();
1288 jQuery(".visibleifcustomer").show();
1292 init_supplier_categ();
1293 $("#fournisseur").change(function() {
1294 init_supplier_categ();
1296 function init_supplier_categ() {
1297 console.log("is supplier = "+jQuery("#fournisseur").val());
1298 if (jQuery("#fournisseur").val() == 0) {
1299 jQuery(".visibleifsupplier").hide();
1301 jQuery(".visibleifsupplier").show();
1305 $("#selectcountry_id").change(function() {
1306 console.log("selectcountry_id change");
1307 document.formsoc.action.value="create";
1308 document.formsoc.submit();
1311 print
'</script>'.
"\n";
1316 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1318 print
'<input type="hidden" name="action" value="add">';
1319 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1320 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1321 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1322 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
1323 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1324 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1325 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1326 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1327 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1328 print
'<input type="hidden" name="code_auto" value="1">';
1334 $parameters = array();
1336 $reshook = $hookmanager->executeHooks(
'tabContentCreateThirdparty', $parameters,
$object, $action);
1337 if (empty($reshook)) {
1338 print
'<table class="border centpercent">';
1341 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1342 if (
$object->particulier || $private) {
1343 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1345 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'',
$object, 0).
'</span>';
1347 print
'</td><td'.(!
getDolGlobalString(
'SOCIETE_USEPREFIX') ?
' colspan="3"' :
'').
'>';
1349 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag(
$object->name).
'" autofocus="autofocus">';
1350 print $form->widgetForTranslation(
"name",
$object, $permissiontoadd,
'string',
'alphanohtml',
'minwidth300');
1445 print
'<td>'.$langs->trans(
'Prefix').
'</td><td><input type="text" size="5" maxlength="5" name="prefix_comm" value="'.
dol_escape_htmltag(
$object->prefix_comm).
'"></td>';
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).
'"></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><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1466 print
'<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag(
$object->name_alias).
'"></td></tr>';
1470 $selectedcustomer = 0;
1471 $selectedprospect = 0;
1472 switch ($selected) {
1474 $selectedcustomer = 1;
1477 $selectedprospect = 1;
1480 $selectedprospect = 1;
1481 $selectedcustomer = 1;
1487 $selectedprospect = (GETPOSTISSET(
'prospect') ?
GETPOSTINT(
'prospect') : $selectedprospect);
1488 $selectedcustomer = (GETPOSTISSET(
'customer') ?
GETPOSTINT(
'customer') : $selectedcustomer);
1489 print
'<tr class="marginbottomlarge height50">';
1490 if (
$conf->browser->layout !=
'phone') {
1491 print
'<td class="titlefieldcreate">'.$form->editfieldkey(
'',
'customerprospect',
'',
$object, 0,
'string',
'', 0).
'</td>';
1493 print
'<td class="maxwidthonsmartphone"'.($conf->browser->layout !=
'phone' ?
'colspan="3"' :
'colspan="2"').
'>';
1496 print
'<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans(
"Prospect").
'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ?
' checked="checked"' :
'').
'></label></span>';
1500 print
'<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans(
"Customer").
'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ?
' checked="checked"' :
'').
'></label></span>';
1503 if ((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))
1504 || (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
1506 $selected = (GETPOSTISSET(
'supplier') ?
GETPOSTINT(
'supplier') :
$object->fournisseur);
1507 print
'<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans(
"Vendor").
'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selected ?
' checked="checked"' :
'').
'></label></span>';
1510 if (
$conf->use_javascript_ajax) {
1512 function refreshNatureCss() {
1513 jQuery(".spannature").each(function( index ) {
1514 id = $(this).attr("id").split("spannature")[1];
1515 console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
1516 if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
1518 jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
1521 jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
1524 jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
1527 jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
1532 function manageprospectcustomer(element) {
1533 console.log("We uncheck unwanted values on a nature");
1534 id = $(element).attr("id").split("spannature")[1];
1536 $("#spannature2 .checkforselect").prop("checked", false);
1539 $("#spannature1 .checkforselect").prop("checked", false);
1543 jQuery(".spannature").click(function(){
1544 console.log("We click on a nature");
1545 '.(getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ?
'manageprospectcustomer($(this));' :
'').
'
1554 print
'<tr><td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'',
$object, 0).
'</td><td>';
1555 print
'<table class="nobordernopadding"><tr><td>';
1556 $tmpcode =
$object->code_client;
1557 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1558 $tmpcode = $modCodeClient->getNextValue(
$object, 0);
1560 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1562 $s = $modCodeClient->getToolTip($langs,
$object, 0);
1563 print $form->textwithpicto(
'', $s, 1);
1564 print
'</td></tr></table>';
1567 if (
$conf->browser->layout ==
'phone') {
1571 print
'<td>'.$form->editfieldkey(
'SupplierCode',
'supplier_code',
'',
$object, 0).
'</td><td>';
1573 if ((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
1574 print
'<table class="nobordernopadding"><tr><td>';
1575 $tmpcode =
$object->code_fournisseur;
1576 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1577 $tmpcode = $modCodeFournisseur->getNextValue(
$object, 1);
1579 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1581 $s = $modCodeFournisseur->getToolTip($langs,
$object, 1);
1582 print $form->textwithpicto(
'', $s, 1);
1583 print
'</td></tr></table>';
1588 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'',
$object, 0).
'</td><td colspan="3">';
1589 print $form->selectarray(
'status', array(
'1' => $langs->trans(
'InActivity'),
'0' => $langs->trans(
'ActivityCeased')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1593 if (isModEnabled(
'barcode')) {
1594 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'',
$object, 0).
'</td>';
1595 print
'<td colspan="3">';
1596 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1597 print
'<input type="text" class="minwidth200 maxwidth300 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag(
$object->barcode).
'">';
1601 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
1602 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'> </td></tr>';
1605 print
'<tr><td class="tdtop">';
1606 print $form->editfieldkey(
'Address',
'address',
'',
$object, 0);
1608 print
'<td colspan="3">';
1609 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1611 print
'</textarea>';
1612 print $form->widgetForTranslation(
"address",
$object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1616 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'',
$object, 0).
'</td><td>';
1617 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1619 if (
$conf->browser->layout ==
'phone') {
1622 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'',
$object, 0).
'</td><td>';
1623 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1624 print $form->widgetForTranslation(
"town",
$object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1628 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1629 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1630 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth200 maxwidth300 widthcentpercentminusx');
1632 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1639 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1641 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1645 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1646 print $formcompany->select_state(
$object->state_id,
$object->country_code,
'state_id',
'minwidth200 maxwidth300 widthcentpercentminusx');
1648 print $countrynotdefined;
1654 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'',
$object, 0).
'</td>';
1655 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone') ?
GETPOST(
'phone',
'alpha') :
$object->phone).
'"></td>';
1657 if (
$conf->browser->layout ==
'phone') {
1662 print
'<td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'',
$object, 0).
'</td>';
1663 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"').
' <input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'"></td></tr>';
1667 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'',
$object, 0).
'</td>';
1668 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"').
' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') :
$object->fax).
'"></td></tr>';
1671 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'',
$object, 0).
'</td>';
1672 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.
$object->url.
'"></td></tr>';
1675 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'',
$object, 0,
'string',
'',
getDolGlobalString(
'SOCIETE_EMAIL_MANDATORY')).
'</td>';
1676 print
'<td'.(($conf->browser->layout ==
'phone') || !isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_email',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.
$object->email.
'"></td>';
1679 if (isModEnabled(
'mailing')) {
1680 if (
$conf->browser->layout ==
'phone') {
1683 if (
$conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1684 print
"\n".
'<script type="text/javascript">'.
"\n";
1685 print
'$(document).ready(function () {
1686 $("#email").keyup(function() {
1687 console.log("We change email content");
1688 if ($(this).val()!="") {
1689 $(".noemail").addClass("fieldrequired");
1691 $(".noemail").removeClass("fieldrequired");
1695 print
'</script>'.
"\n";
1697 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
1698 $result =
$object->getNoEmail();
1703 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1705 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 ? 1 : 0), 1);
1711 if (isModEnabled(
'mailing') &&
getDolGlobalString(
'THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
1713 if (
$conf->browser->layout !=
'phone') {
1717 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'',
$object, 0).
'</td>';
1718 print
'<td class="individualline" '.(($conf->browser->layout ==
'phone') || !isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>'.$form->selectyesno(
'contact_no_email', (GETPOSTISSET(
"contact_no_email") ?
GETPOST(
"contact_no_email",
'alpha') : (empty(
$object->no_email) ? 0 : 1)), 1, false, 1).
'</td>';
1723 if (isModEnabled(
'socialnetworks')) {
1724 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
1726 $object->showSocialNetwork($socialnetworks, $colspan);
1728 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'><hr></td></tr>';
1734 $NBCOLS = (
$conf->browser->layout ==
'phone' ? 1 : 2);
1737 while ($i <= $NBPROFIDMAX) {
1738 $idprof = $langs->transcountry(
'ProfId'.$i,
$object->country_code);
1739 if ($idprof !=
'-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate[
'ProfId'.$i.$object->country_code]))) {
1742 if (($j % $NBCOLS) == 0) {
1746 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1747 print
'<td>'.$form->editfieldkey($idprof, $key,
'',
$object, 0,
'string',
'', (empty(
$conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1749 print $formcompany->get_input_id_prof($i, $key,
$object->$key,
$object->country_code);
1751 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1758 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1759 print
'<td colspan="2"></td></tr>';
1763 print
'<tr><td><label for="assujtva_value">'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'',
$object, 0).
'</label></td>';
1765 print
'<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (GETPOSTISSET(
'assujtva_value') ? (
GETPOST(
'assujtva',
'alpha') !=
'' ?
' checked="checked"' :
'') :
'checked="checked"') .
' value="1">';
1767 if (
$conf->browser->layout ==
'phone') {
1770 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'',
$object, 0).
'</td>';
1771 print
'<td class="nowrap">';
1772 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1777 if (!empty(
$conf->use_javascript_ajax)) {
1779 if (!empty(
$conf->dol_use_jmobile)) {
1784 print
'<script type="text/javascript">';
1785 print
"function CheckVAT(a) {\n";
1786 if ($mysoc->country_code ==
'GR' &&
$object->country_code ==
'GR' && !empty($u)) {
1787 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
1789 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1794 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1795 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1797 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL",
$object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1806 print
'<tr><td><label for="vat_reverse_charge">' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'',
$object, 0) .
'</label></td><td colspan="3">';
1807 print
'<input type="checkbox" name="vat_reverse_charge" id="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
1813 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1814 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1815 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (isset(
$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ?
'checked="checked"' :
'') .
' value="1">';
1817 if (
$conf->browser->layout ==
'phone') {
1820 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1821 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (isset(
$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ?
'checked="checked"' :
'') .
' value="1">';
1823 } elseif ($mysoc->localtax1_assuj ==
"1") {
1824 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1825 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (isset(
$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ?
'checked="checked"' :
'') .
' value="1">';
1827 } elseif ($mysoc->localtax2_assuj ==
"1") {
1828 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1829 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (isset(
$conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ?
'checked="checked"' :
'') .
' value="1">';
1834 print
'<tr><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone"'.((
$conf->browser->layout ==
'phone' ||
getDolGlobalString(
'SOCIETE_DISABLE_WORKFORCE')) ?
' colspan="3"' :
'').
'>'.
"\n";
1835 $sortparam = (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' :
$conf->global->SOCIETE_SORT_ON_TYPEENT);
1836 print $form->selectarray(
"typent_id", $formcompany->typent_array(0),
$object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1838 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1842 if (
$conf->browser->layout ==
'phone') {
1845 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone"'.(
$conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1846 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0),
$object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1848 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1851 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1856 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'',
$object, 0).
'</td>';
1857 print
'<td colspan="3" class="maxwidthonsmartphone">';
1859 print $formcompany->select_juridicalstatus(
$object->forme_juridique_code,
$object->country_code,
'',
'forme_juridique_code');
1861 print $countrynotdefined;
1866 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'',
$object, 0).
'</td>';
1867 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1868 if (isModEnabled(
"multicurrency")) {
1869 print
'<span class="hideonsmartphone">';
1871 print $langs->getCurrencySymbol(
$object->multicurrency_code);
1872 print
'</span></td></tr>';
1874 print
'<span class="hideonsmartphone">';
1875 print $langs->getCurrencySymbol(
$conf->currency);
1877 print
'</span></td></tr>';
1880 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1881 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : (
$object->default_lang ?
$object->default_lang :
''),
'default_lang', 0, array(), 1, 0, 0,
'maxwidth200onsmartphone');
1888 print
'<td>'.$form->editfieldkey(
'PaymentConditions',
'cond_reglement_id',
'',
$object, 0).
'</td>';
1889 print
'<td colspan="3" class="maxwidthonsmartphone">';
1890 print $form->getSelectConditionsPaiements(
$object->cond_reglement_id,
'cond_reglement_id', 1, 1, 1,
'',
$object->deposit_percent);
1895 print
'<td>'.$form->editfieldkey(
'PaymentMode',
'mode_reglement_id',
'',
$object, 0).
'</td>';
1896 print
'<td colspan="3" class="maxwidthonsmartphone">';
1897 print $form->select_types_paiements(
$object->mode_reglement_id,
'mode_reglement_id',
'', 0, 1, 1, 0, 1);
1901 if (isModEnabled(
'incoterm')) {
1903 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'',
$object, 0).
'</td>';
1904 print
'<td colspan="3" class="maxwidthonsmartphone">';
1905 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
1910 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
1911 $langs->load(
'categories');
1914 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'',
$object, 0).
'</td><td colspan="3">';
1915 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
'',
'parent', 64, 0, 3);
1916 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'), 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1920 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'',
$object, 0).
'</td><td colspan="3">';
1921 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
'',
'parent', 64, 0, 3);
1922 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'), 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1927 if (isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
1928 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'',
$object, 0).
'</td><td colspan="3">';
1929 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER,
'',
'parent', 64, 0, 3);
1930 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'), 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1936 if (isModEnabled(
"multicurrency")) {
1938 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
1939 print
'<td colspan="3" class="maxwidthonsmartphone">';
1940 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1941 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (
$object->multicurrency_code ?
$object->multicurrency_code :
$conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
1946 $parameters = array(
'socid' => $socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1947 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1952 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1953 print
'<td colspan="3" class="maxwidthonsmartphone">';
1954 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1955 print $form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1961 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'',
$object, 0).
'</td>';
1962 print
'<td colspan="3" class="maxwidthonsmartphone">';
1964 $userlist = $form->select_dolusers($selected,
'', 0,
null, 0,
'',
'',
'0', 0, 0,
'u.statut:=:1', 0,
'',
'', 0, 2);
1967 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1971 print
'<tr class="hideonsmartphone">';
1972 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'',
$object, 0).
'</td>';
1973 print
'<td colspan="3">';
1974 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1978 print
'</table>'.
"\n";
1982 print
'<table class="border centpercent">';
1984 if (isModEnabled(
'accounting')) {
1987 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1989 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1990 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1,
'');
1994 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1996 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1997 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1,
'');
2001 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2002 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
2006 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2007 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
2017 print $form->buttonsSaveCancel(
'AddThirdParty',
'Cancel', array(), 0,
'', $dol_openinpopup);
2019 print
'</form>'.
"\n";
2020 } elseif ($action ==
'edit') {
2024 $res =
$object->fetch_optionals();
2031 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
2032 $module = substr($module, 0,
dol_strlen($module) - 4);
2034 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
2035 foreach ($dirsociete as $dirroot) {
2041 $modCodeClient =
new $module($db);
2042 '@phan-var-force ModeleThirdPartyCode $modCodeClient';
2044 if ($modCodeClient->code_auto) {
2045 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
2047 $prefixCustomerIsUsed =
false;
2050 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
2051 $module = substr($module, 0,
dol_strlen($module) - 4);
2053 $dirsociete = array_merge(array(
'/core/modules/societe/'),
$conf->modules_parts[
'societe']);
2054 foreach ($dirsociete as $dirroot) {
2060 $modCodeFournisseur =
new $module($db);
2061 '@phan-var-force ModeleThirdPartyCode $modCodeFournisseur';
2063 if ($modCodeFournisseur->code_auto) {
2064 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
2066 $prefixSupplierIsUsed =
false;
2071 if (GETPOSTISSET(
'name')) {
2087 $object->socialnetworks = array();
2088 if (isModEnabled(
'socialnetworks')) {
2089 foreach ($socialnetworks as $key => $value) {
2090 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
2097 $object->phone_mobile = (string)
GETPOST(
'phone_mobile',
'alpha');
2099 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
2116 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
2121 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
2122 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
2124 if (GETPOSTISSET(
'accountancy_code_sell')) {
2125 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
2127 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
2128 $object->accountancy_code_sell =
'';
2130 $object->accountancy_code_sell = $accountancy_code_sell;
2133 if (GETPOSTISSET(
'accountancy_code_buy')) {
2134 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
2136 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
2137 $object->accountancy_code_buy =
'';
2139 $object->accountancy_code_buy = $accountancy_code_buy;
2144 if (isModEnabled(
'incoterm')) {
2146 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
2157 if (
$object->country_id > 0) {
2159 $object->country_code = $tmparray[
'code'];
2160 $object->country = $tmparray[
'label'];
2164 if (isModEnabled(
"multicurrency")) {
2169 if (
$object->localtax1_assuj == 0) {
2174 if (
$object->localtax2_assuj == 0) {
2180 if (!empty(
$conf->use_javascript_ajax)) {
2181 print
"\n".
'<script type="text/javascript">';
2182 print
'$(document).ready(function () {
2185 if("#localtax1assuj_value".value==undefined){
2192 if("#localtax2assuj_value".value==undefined){
2199 $("#localtax1assuj_value").change(function() {
2200 var value=document.getElementById("localtax1assuj_value").value;
2207 $("#localtax2assuj_value").change(function() {
2208 var value=document.getElementById("localtax2assuj_value").value;
2216 var canHaveCustomerCategoryIfNotCustomerProspect = ' . (
getDolGlobalInt(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'1' :
'0') .
';
2218 init_customer_categ();
2219 $("#customerprospect").change(function() {
2220 init_customer_categ();
2222 function init_customer_categ() {
2223 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
2224 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspect)
2226 jQuery(".visibleifcustomer").hide();
2230 jQuery(".visibleifcustomer").show();
2234 init_supplier_categ();
2235 $("#fournisseur").change(function() {
2236 init_supplier_categ();
2238 function init_supplier_categ() {
2239 console.log("is supplier = "+jQuery("#fournisseur").val());
2240 if (jQuery("#fournisseur").val() == 0)
2242 jQuery(".visibleifsupplier").hide();
2246 jQuery(".visibleifsupplier").show();
2250 $("#selectcountry_id").change(function() {
2251 console.log("selectcountry_id change");
2252 document.formsoc.action.value="edit";
2253 document.formsoc.submit();
2257 print
'</script>'.
"\n";
2260 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'" method="post" name="formsoc">';
2261 print
'<input type="hidden" name="action" value="update">';
2262 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2263 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2264 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2265 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2266 print
'<input type="hidden" name="code_auto" value="1">';
2272 print
'<div class="fichecenter2">';
2274 $parameters = array();
2276 $reshook = $hookmanager->executeHooks(
'tabContentEditThirdparty', $parameters,
$object, $action);
2277 if (empty($reshook)) {
2278 print
'<table class="border centpercent">';
2282 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2288 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'',
$object, 0,
'string',
'', 1).
'</td>';
2289 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag(
$object->name).
'" autofocus="autofocus">';
2290 print $form->widgetForTranslation(
"name",
$object, $permissiontoadd,
'string',
'alphanohtml',
'minwidth300');
2294 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
2295 print
'<td colspan="3"><input type="text" class="minwidth300" name="name_alias" id="name_alias_input" value="'.dol_escape_htmltag(
$object->name_alias).
'"></td></tr>';
2299 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'',
$object, 0).
'</td><td colspan="3">';
2301 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) &&
$object->prefix_comm) {
2302 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag(
$object->prefix_comm).
'">';
2305 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag(
$object->prefix_comm).
'">';
2312 $selectedcustomer = 0;
2313 $selectedprospect = 0;
2314 switch ($selected) {
2316 $selectedcustomer = 1;
2319 $selectedprospect = 1;
2322 $selectedprospect = 1;
2323 $selectedcustomer = 1;
2330 $selectedprospect = (GETPOSTISSET(
'prospect') ?
GETPOSTINT(
'prospect') : $selectedprospect);
2331 $selectedcustomer = (GETPOSTISSET(
'customer') ?
GETPOSTINT(
'customer') : $selectedcustomer);
2332 print
'<tr class="marginbottomlarge height50"><td class="titlefieldcreate">'.$form->editfieldkey(
'',
'customerprospect',
'',
$object, 0,
'string',
'', 0).
'</td>';
2333 print
'<td class="maxwidthonsmartphone" colspan="3">';
2336 print
'<span id="spannature1" class="spannature prospect-back paddinglarge marginrightonly"><label for="prospectinput" class="valignmiddle">'.$langs->trans(
"Prospect").
'<input id="prospectinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="prospect" value="2"'.($selectedprospect ?
' checked="checked"' :
'').
'></label></span>';
2340 print
'<span id="spannature2" class="spannature customer-back paddinglarge marginrightonly"><label for="customerinput" class="valignmiddle">'.$langs->trans(
"Customer").
'<input id="customerinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="customer" value="1"'.($selectedcustomer ?
' checked="checked"' :
'').
'></label></span>';
2342 if ((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))
2343 || (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
2345 $selected = (GETPOSTISSET(
'supplier') ?
GETPOSTINT(
'supplier') :
$object->fournisseur);
2346 print
'<span id="spannature3" class="spannature vendor-back paddinglarge marginrightonly"><label for="supplierinput" class="valignmiddle">'.$langs->trans(
"Vendor").
'<input id="supplierinput" class="flat checkforselect marginleftonly valignmiddle" type="checkbox" name="supplier" value="1"'.($selected ?
' checked="checked"' :
'').
'></label></span>';
2350 if (
$conf->use_javascript_ajax) {
2352 function refreshNatureCss() {
2353 jQuery(".spannature").each(function( index ) {
2354 id = $(this).attr("id").split("spannature")[1];
2355 console.log(jQuery("#spannature"+(id)+" .checkforselect").is(":checked"));
2356 if (jQuery("#spannature"+(id)+" .checkforselect").is(":checked")) {
2358 jQuery("#spannature"+(id)).addClass("prospect-back").removeClass("nonature-back");
2361 jQuery("#spannature"+(id)).addClass("customer-back").removeClass("nonature-back");
2364 jQuery("#spannature"+(id)).addClass("vendor-back").removeClass("nonature-back");
2367 jQuery("#spannature"+(id)).removeClass("prospect-back").removeClass("customer-back").removeClass("vendor-back").addClass("nonature-back");
2372 function manageprospectcustomer(element) {
2373 console.log("We uncheck unwanted values on a nature");
2374 id = $(element).attr("id").split("spannature")[1];
2376 $("#spannature2 .checkforselect").prop("checked", false);
2379 $("#spannature1 .checkforselect").prop("checked", false);
2383 jQuery(".spannature").click(function(){
2384 console.log("We click on a nature");
2385 '.(getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTSCUSTOMERS') ?
'manageprospectcustomer($(this));' :
'').
'
2393 print
'<tr><td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'',
$object, 0).
'</td><td>';
2394 print
'<table class="nobordernopadding"><tr><td>';
2395 $tmpcode =
$object->code_client;
2396 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2397 $tmpcode = $modCodeClient->getNextValue(
$object, 0);
2399 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2401 $s = $modCodeClient->getToolTip($langs,
$object, 0);
2402 print $form->textwithpicto(
'', $s, 1);
2403 print
'</td></tr></table>';
2406 if (
$conf->browser->layout ==
'phone') {
2410 print
'<td>'.$form->editfieldkey(
'SupplierCode',
'supplier_code',
'',
$object, 0).
'</td><td>';
2412 if ((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
2413 print
'<table class="nobordernopadding"><tr><td>';
2414 $tmpcode =
$object->code_fournisseur;
2415 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2416 $tmpcode = $modCodeFournisseur->getNextValue(
$object, 1);
2418 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2420 $s = $modCodeFournisseur->getToolTip($langs,
$object, 1);
2421 print $form->textwithpicto(
'', $s, 1);
2422 print
'</td></tr></table>';
2428 if (isModEnabled(
'barcode')) {
2429 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'',
$object, 0).
'</td>';
2430 print
'<td colspan="3">';
2431 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
2432 print
'<input type="text" class="minwidth100 maxwidth200 widthcentpercentminusx" name="barcode" id="barcode" value="'.dol_escape_htmltag(
$object->barcode).
'">';
2437 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'',
$object, 0).
'</td><td colspan="3">';
2438 print $form->selectarray(
'status', array(
'0' => $langs->trans(
'ActivityCeased'),
'1' => $langs->trans(
'InActivity')),
$object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2441 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
2442 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'> </td></tr>';
2445 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'',
$object, 0).
'</td>';
2446 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2448 print
'</textarea>';
2449 print $form->widgetForTranslation(
"address",
$object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2453 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'',
$object, 0).
'</td><td'.(
$conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
2454 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2456 if (
$conf->browser->layout ==
'phone') {
2459 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'',
$object, 0).
'</td><td'.(
$conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
2460 print $formcompany->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2461 print $form->widgetForTranslation(
"town",
$object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2465 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'',
$object, 0).
'</td><td colspan="3">';
2466 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
2467 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth200 maxwidth400 widthcentpercentminusx');
2469 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2476 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'',
$object, 0).
'</td><td colspan="3">';
2478 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'',
$object, 0).
'</td><td colspan="3">';
2481 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2482 print $formcompany->select_state(
$object->state_id,
$object->country_code,
'state_id',
'minwidth200 maxwidth400 widthcentpercentminusx');
2487 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'),
$object, 0).
'</td>';
2488 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"').
' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone') ?
GETPOST(
'phone',
'alpha') :
$object->phone).
'"></td>';
2489 if (
$conf->browser->layout ==
'phone') {
2492 print
'<td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'),
$object, 0).
'</td>';
2493 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"').
' <input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'"></td></tr>';
2495 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'),
$object, 0).
'</td>';
2496 print
'<td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"').
' <input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') :
$object->fax).
'"></td>';
2500 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'),
$object, 0).
'</td>';
2501 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" name="url" id="url" class="maxwidth200onsmartphone maxwidth300 widthcentpercentminusx " value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url',
'alpha') :
$object->url).
'"></td></tr>';
2504 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'),
$object, 0,
'string',
'', (
getDolGlobalString(
'SOCIETE_EMAIL_MANDATORY'))).
'</td>';
2505 print
'<td'.(($conf->browser->layout ==
'phone') || !isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>';
2506 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2507 print
'<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->
email).
'">';
2511 if (isModEnabled(
'mailing')) {
2512 if (
$conf->browser->layout ==
'phone') {
2515 if (
$conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
2516 print
"\n".
'<script type="text/javascript">'.
"\n";
2519 jQuery(document).ready(function () {
2520 function init_check_no_email(input) {
2521 if (input.val()!="") {
2522 $(".noemail").addClass("fieldrequired");
2524 $(".noemail").removeClass("fieldrequired");
2527 $("#email").keyup(function() {
2528 init_check_no_email($(this));
2530 init_check_no_email($("#email"));
2532 print
'</script>'.
"\n";
2534 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
2535 $result =
$object->getNoEmail();
2540 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
2542 $useempty = (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
2543 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
$object->no_email), 1, false, $useempty);
2549 if (isModEnabled(
'socialnetworks')) {
2550 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
2552 $object->showSocialNetwork($socialnetworks, $colspan);
2554 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'><hr></td></tr>';
2560 $NBCOLS = (
$conf->browser->layout ==
'phone' ? 1 : 2);
2563 while ($i <= $NBPROFIDMAX) {
2564 $idprof = $langs->transcountry(
'ProfId'.$i,
$object->country_code);
2565 if ($idprof !=
'-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate[
'ProfId'.$i.$object->country_code]))) {
2568 if (($j % $NBCOLS) == 0) {
2572 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2573 print
'<td>'.$form->editfieldkey($idprof, $key,
'',
$object, 0,
'string',
'', !(empty(
$conf->global->$idprof_mandatory) || !
$object->isACompany())).
'</td><td>';
2574 print $formcompany->get_input_id_prof($i, $key,
$object->$key,
$object->country_code);
2576 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2583 if ($NBCOLS > 0 && ($j % 2) == 1) {
2584 print
'<td colspan="2"></td></tr>';
2588 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'',
$object, 0).
'</td><td colspan="3">';
2589 print
'<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (
$object->tva_assuj ?
'checked="checked"' :
'') .
' value="1">';
2594 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2595 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'',
$object, 0).
'</td><td>';
2596 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (
$object->localtax1_assuj ?
'checked="checked"' :
'') .
' value="1">';
2598 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2599 $formcompany->select_localtax(1,
$object->localtax1_value,
"lt1");
2604 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'',
$object, 0).
'</td><td>';
2605 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (
$object->localtax2_assuj ?
'checked="checked"' :
'') .
' value="1"></td></tr>';
2607 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2608 $formcompany->select_localtax(2,
$object->localtax2_value,
"lt2");
2612 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2613 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'',
$object, 0).
'</td><td colspan="3">';
2614 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (
$object->localtax1_assuj ?
'checked="checked"' :
'') .
' value="1">';
2616 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2617 $formcompany->select_localtax(1,
$object->localtax1_value,
"lt1");
2621 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2622 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'',
$object, 0).
'</td><td colspan="3">';
2623 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (
$object->localtax2_assuj ?
'checked="checked"' :
'') .
' value="1">';
2625 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2626 $formcompany->select_localtax(2,
$object->localtax2_value,
"lt2");
2634 print
'<tr><td>' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'',
$object, 0) .
'</td><td colspan="3">';
2635 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
2640 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'',
$object, 0).
'</td>';
2641 print
'<td colspan="3">';
2642 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2647 if (
$conf->use_javascript_ajax) {
2649 if (!empty(
$conf->dol_use_jmobile)) {
2654 print
'<script type="text/javascript">';
2655 print
"function CheckVAT(a) {\n";
2656 if ($mysoc->country_code ==
'GR' &&
$object->country_code ==
'GR' && !empty($u)) {
2657 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
2659 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2664 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2665 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2667 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL",
$object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2675 print
'<tr><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone"'.((
$conf->browser->layout ==
'phone' ||
getDolGlobalString(
'SOCIETE_DISABLE_WORKFORCE')) ?
' colspan="3"' :
'').
'>';
2676 print $form->selectarray(
"typent_id", $formcompany->typent_array(0),
$object->typent_id, 1, 0, 0,
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' :
$conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
2678 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2682 if (
$conf->browser->layout ==
'phone') {
2685 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone">';
2686 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0),
$object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2688 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2691 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2696 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2697 print $formcompany->select_juridicalstatus(
$object->forme_juridique_code,
$object->country_code,
'',
'forme_juridique_code');
2701 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'',
$object, 0).
'</td>';
2702 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2704 if (isModEnabled(
"multicurrency")) {
2705 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".
$object->multicurrency_code).
'</span></td></tr>';
2707 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".
$conf->currency).
'</span></td></tr>';
2712 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'',
$object, 0).
'</td><td colspan="3">'.
"\n";
2713 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
$object->default_lang,
'default_lang', 0, array(),
'1', 0, 0,
'maxwidth300 widthcentpercentminusx');
2719 if (isModEnabled(
'incoterm')) {
2721 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'',
$object, 0).
'</td>';
2722 print
'<td colspan="3" class="maxwidthonsmartphone">';
2723 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''));
2728 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
2730 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'',
$object, 0).
'</td>';
2731 print
'<td colspan="3">';
2732 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
'',
'', 64, 0, 3);
2734 $cats = $c->containing(
$object->id, Categorie::TYPE_CUSTOMER);
2735 $arrayselected = array();
2736 foreach ($cats as $cat) {
2737 $arrayselected[] = $cat->id;
2739 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2743 if ((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) {
2744 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'',
$object, 0).
'</td>';
2745 print
'<td colspan="3">';
2746 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER,
'',
'', 64, 0, 3);
2748 $cats = $c->containing(
$object->id, Categorie::TYPE_SUPPLIER);
2749 $arrayselected = array();
2750 foreach ($cats as $cat) {
2751 $arrayselected[] = $cat->id;
2753 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2759 if (isModEnabled(
"multicurrency")) {
2761 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
2762 print
'<td colspan="3" class="maxwidthonsmartphone">';
2763 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2764 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : (
$object->multicurrency_code ?
$object->multicurrency_code :
$conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
2769 $parameters = array(
'socid' => $socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2770 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2775 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
2776 print
'<td colspan="3" class="maxwidthonsmartphone">';
2777 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2778 print $form->select_company(
GETPOST(
'parent_company_id') ?
GETPOST(
'parent_company_id') :
$object->parent,
'parent_company_id',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
2783 print
'<tr class="hideonsmartphone">';
2784 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'',
$object, 0).
'</td>';
2785 print
'<td colspan="3">';
2787 print $form->showphoto(
'societe',
$object, 100, 0, 0,
'inline-block');
2790 if ($caneditfield) {
2794 print
'<table class="nobordernopadding">';
2796 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans(
"Delete").
'</photo><br></td></tr>';
2801 $maxmin = $maxfilesizearray[
'maxmin'];
2803 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2805 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2814 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'',
$object, 0).
'</td>';
2815 print
'<td colspan="3" class="maxwidthonsmartphone">';
2816 $userlist = $form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'u.statut:=:1', 0,
'',
'', 0, 1);
2817 $arrayselected =
GETPOST(
'commercial',
'array');
2818 if (empty($arrayselected)) {
2819 $arrayselected =
$object->getSalesRepresentatives($user, 1);
2821 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2828 print
'<table class="border centpercent">';
2830 if (isModEnabled(
'accounting')) {
2833 print
'<tr><td>'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2835 print $formaccounting->select_account(
$object->accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1);
2839 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2841 print $formaccounting->select_account(
$object->accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1);
2845 print
'<tr><td>'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2846 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2850 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2851 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2862 print $form->buttonsSaveCancel();
2869 $res =
$object->fetch_optionals();
2876 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ThirdParty"), -1,
'company', 0,
'',
'', 0,
'', 1);
2881 if ($action ==
'delete' || (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile))) {
2882 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".
$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2885 if ($action ==
'merge') {
2886 $formquestion = array(
2888 'name' =>
'soc_origin',
2889 'label' => $langs->trans(
'MergeOriginThirdparty'),
2891 'value' => $form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 1, 0, array(), 0,
'minwidth200',
'',
'', 1, array(),
false, array(
$object->id))
2895 $formconfirm .= $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".
$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2899 if (($action ==
'clone' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
2900 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
2902 $formquestionclone = array(
2903 'text' => $langs->trans(
"ConfirmClone"),
2904 0 => array(
'type' =>
'text',
'name' =>
'clone_name',
'label' => $langs->trans(
"NewSocNameForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->nom : $tmpcode,
'morecss' =>
'width250'),
2906 $formconfirm .= $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneThirdparties',
$object->name),
'confirm_clone', $formquestionclone,
'yes',
'action-clone', 350, 600);
2910 $parameters = array(
'formConfirm' => $formconfirm);
2911 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2912 if (empty($reshook)) {
2913 $formconfirm .= $hookmanager->resPrint;
2914 } elseif ($reshook > 0) {
2915 $formconfirm = $hookmanager->resPrint;
2923 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2925 dol_banner_tab(
$object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2928 $parameters = array();
2930 $reshook = $hookmanager->executeHooks(
'tabContentViewThirdparty', $parameters,
$object, $action);
2931 if (empty($reshook)) {
2932 print
'<div class="fichecenter">';
2933 print
'<div class="fichehalfleft">';
2935 print
'<div class="underbanner clearboth"></div>';
2936 print
'<table class="border tableforfield centpercent">';
2939 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2952 print $langs->trans(
'CustomerCode');
2956 $tmpcheck =
$object->check_codeclient();
2957 if ($tmpcheck != 0 && $tmpcheck != -5) {
2958 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2965 if (((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) &&
$object->fournisseur) {
2967 print $langs->trans(
'SupplierCode').
'</td><td>';
2969 $tmpcheck =
$object->check_codefournisseur();
2970 if ($tmpcheck != 0 && $tmpcheck != -5) {
2971 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2978 if (isModEnabled(
'barcode')) {
2990 while ($i <= $NBPROFIDMAX) {
2991 $idprof = $langs->transcountry(
'ProfId'.$i,
$object->country_code);
2992 if (!empty(
$conf->dol_optimize_smallscreen)) {
2993 $idprof = $langs->transcountry(
'ProfId'.$i.
'Short',
$object->country_code);
2995 if ($idprof !=
'-' && ($i <= $NBPROFIDMIN || !empty($langs->tab_translate[
'ProfId'.$i.$object->country_code]))) {
2997 print
'<td>'.$idprof.
'</td><td>';
3003 print
' '.$object->id_prof_url($i,
$object);
3006 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
3024 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
3033 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
3035 print
'<input type="checkbox" name="vat_reverse_charge" ' . (
$object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
3042 if (
$object->fournisseur || $mysoc->country_code ==
'ES') {
3043 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
3044 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
3046 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
3051 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3052 print
'<input type="hidden" name="action" value="set_localtax1">';
3053 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3054 print
'<tr><td>'.$langs->transcountry(
"Localtax1", $mysoc->country_code).
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editRE&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3055 if ($action ==
'editRE') {
3056 print
'<td class="left">';
3057 $formcompany->select_localtax(1,
$object->localtax1_value,
"lt1");
3058 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3060 print
'<td>'.$object->localtax1_value.
'</td>';
3062 print
'</tr></form>';
3065 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3066 print
'<input type="hidden" name="action" value="set_localtax2">';
3067 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3068 print
'<tr><td>'.$langs->transcountry(
"Localtax2", $mysoc->country_code).
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editIRPF&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3069 if ($action ==
'editIRPF') {
3070 print
'<td class="left">';
3071 $formcompany->select_localtax(2,
$object->localtax2_value,
"lt2");
3072 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3074 print
'<td>'.$object->localtax2_value.
'</td>';
3076 print
'</tr></form>';
3078 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
3079 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
3083 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3084 print
'<input type="hidden" name="action" value="set_localtax1">';
3085 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3086 print
'<tr><td> '.$langs->transcountry(
"Localtax1", $mysoc->country_code).
'<a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editRE&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3087 if ($action ==
'editRE') {
3088 print
'<td class="left">';
3089 $formcompany->select_localtax(1,
$object->localtax1_value,
"lt1");
3090 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3092 print
'<td>'.$object->localtax1_value.
'</td>';
3094 print
'</tr></form>';
3096 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
3097 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
3101 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'">';
3102 print
'<input type="hidden" name="action" value="set_localtax2">';
3103 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3104 print
'<tr><td> '.$langs->transcountry(
"Localtax2", $mysoc->country_code).
' <a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editIRPF&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</td>';
3105 if ($action ==
'editIRPF') {
3106 print
'<td class="left">';
3107 $formcompany->select_localtax(2,
$object->localtax2_value,
"lt2");
3108 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
3110 print
'<td>'.$object->localtax2_value.
'</td>';
3112 print
'</tr></form>';
3119 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
3123 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
3128 if (
$conf->use_javascript_ajax) {
3130 if (!empty(
$conf->dol_use_jmobile)) {
3135 print
'<script type="text/javascript">';
3136 print
"function CheckVAT(a) {\n";
3137 if ($mysoc->country_code ==
'GR' &&
$object->country_code ==
'GR' && !empty($u)) {
3138 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
3140 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
3145 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(jQuery(\'#tva_intra\').val());">'.$langs->trans(
"VATIntraCheck").
'</a>';
3146 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
3148 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL",
$object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
3159 $langs->load(
'stocks');
3160 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
3162 print
'<tr class="nowrap">';
3164 print $form->editfieldkey(
"Warehouse",
'warehouse',
'',
$object, $user->hasRight(
'societe',
'creer'));
3166 if ($action ==
'editwarehouse') {
3167 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'fk_warehouse', 1);
3169 if (
$object->fk_warehouse > 0) {
3170 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
3172 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_warehouse,
'none');
3181 print
'<div class="fichehalfright">';
3183 print
'<div class="underbanner clearboth"></div>';
3184 print
'<table class="border tableforfield centpercent">';
3187 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
3190 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
3192 print $form->showCategories(
$object->id, Categorie::TYPE_CUSTOMER, 1);
3197 if (((isModEnabled(
"fournisseur") && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
"supplier_order") && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
"supplier_invoice") && $user->hasRight(
'supplier_invoice',
'lire'))) &&
$object->fournisseur) {
3198 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
3200 print $form->showCategories(
$object->id, Categorie::TYPE_SUPPLIER, 1);
3207 print
'<tr><td class="titlefieldmiddle">';
3208 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
3209 if ($action !=
'editthirdpartytype' && $user->hasRight(
'societe',
'creer')) {
3210 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editthirdpartytype&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a></td>';
3212 print
'</tr></table>';
3214 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
3215 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->typent_id, $html_name,
'');
3220 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.
$object->effectif.
'</td></tr>';
3224 print
'<tr><td>'.$langs->trans(
'JuridicalStatus').
'</td><td>'.
dolPrintHTML(
$object->forme_juridique).
'</td></tr>';
3227 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
3229 if (isModEnabled(
"multicurrency") && !empty(
$object->multicurrency_code)) {
3240 if (isModEnabled(
'mailing')) {
3241 $result =
$object->getNoEmail();
3245 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
3249 $langs->load(
"mails");
3250 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
3253 $langs->load(
"mails");
3254 print
' <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans(
"NbOfEMailingsSend")).
'">'.
$object->getNbOfEMailings().
'</span>';
3261 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3262 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
3265 $langs->load(
"languages");
3266 $labellang = (
$object->default_lang ? $langs->trans(
'Language_'.
$object->default_lang) :
'');
3273 if (isModEnabled(
'incoterm')) {
3275 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
3276 if ($action !=
'editincoterm' && $user->hasRight(
'societe',
'creer')) {
3277 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
3279 print
'</tr></table>';
3280 print
'</td><td colspan="3">';
3281 if ($action !=
'editincoterm') {
3282 print $form->textwithpicto(
$object->display_incoterms(),
$object->label_incoterms, 1);
3284 print $form->select_incoterms((!empty(
$object->fk_incoterms) ?
$object->fk_incoterms :
''), (!empty(
$object->location_incoterms) ?
$object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.
$object->id);
3290 if (isModEnabled(
"multicurrency")) {
3292 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'',
$object, 0).
'</td>';
3300 print
'<tr><td class="nowrap">';
3301 print $langs->trans(
"ProductAccountancySellCode");
3302 print
'</td><td colspan="2">';
3303 if (isModEnabled(
'accounting')) {
3304 if (!empty(
$object->accountancy_code_sell)) {
3306 $accountingaccount->fetch(0,
$object->accountancy_code_sell, 1);
3308 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
3311 print
$object->accountancy_code_sell;
3316 print
'<tr><td class="nowrap">';
3317 print $langs->trans(
"ProductAccountancyBuyCode");
3318 print
'</td><td colspan="2">';
3319 if (isModEnabled(
'accounting')) {
3320 if (!empty(
$object->accountancy_code_buy)) {
3322 $accountingaccount2->fetch(0,
$object->accountancy_code_buy, 1);
3324 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3327 print
$object->accountancy_code_buy;
3333 $parameters = array(
'socid' => $socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3334 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3339 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3340 if ($action !=
'editparentcompany' && $user->hasRight(
'societe',
'creer')) {
3341 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editparentcompany&token='.
newToken().
'&socid='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'Edit'), 1).
'</a></td>';
3343 print
'</tr></table>';
3345 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3346 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.
$object->id,
$object->parent, $html_name,
'', 1, 0, 0, array(), 0, array(
$object->id));
3351 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3354 if (isModEnabled(
'member')) {
3355 $langs->load(
"members");
3356 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3359 $result = $adh->fetch(0,
'',
$object->id);
3361 $adh->ref = $adh->getFullName($langs);
3362 print $adh->getNomUrl(-1);
3364 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3366 print
"</td></tr>\n";
3389 print
'<div class="clearboth"></div>';
3398 if ($action !=
'presend') {
3399 print
'<div class="tabsAction">'.
"\n";
3401 $parameters = array();
3402 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3403 if (empty($reshook)) {
3404 $at_least_one_email_contact =
false;
3405 $TContact =
$object->contact_array_objects();
3406 foreach ($TContact as &$contact) {
3407 if (!empty($contact->email)) {
3408 $at_least_one_email_contact =
true;
3413 if (empty($user->socid)) {
3414 $langs->load(
"mails");
3416 if (empty(
$object->email) && !$at_least_one_email_contact) {
3417 $title = $langs->trans(
'NoEMail');
3419 print
dolGetButtonAction($title, $langs->trans(
'SendMail'),
'default', $_SERVER[
'PHP_SELF'].
'?socid='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle',
'btn-send-mail', !empty(
$object->email) || $at_least_one_email_contact);
3422 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
3424 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3425 $cloneSocietetUrl =
'';
3426 $cloneButtonId =
'action-clone';
3428 $cloneSocietetUrl =
'';
3429 $cloneButtonId =
'';
3431 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneSocietetUrl, $cloneButtonId, $user->hasRight(
'societe',
'creer'));
3433 if (isModEnabled(
'member')) {
3435 $result = $adh->fetch(0,
'',
$object->id);
3437 print
'<a class="butAction" href="'.DOL_URL_ROOT.
'/adherents/card.php?&action=create&socid='.
$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"NewMember")).
'">'.$langs->trans(
"NewMember").
'</a>'.
"\n";
3441 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=merge&token='.
newToken(),
'', $permissiontodelete);
3443 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.
$object->id.
'&action=delete&token='.
newToken();
3444 $buttonId =
'action-delete-no-ajax';
3445 if (
$conf->use_javascript_ajax && empty(
$conf->dol_use_jmobile)) {
3447 $buttonId =
'action-delete';
3449 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3452 print
'</div>'.
"\n";
3456 if (
GETPOST(
'modelselected')) {
3457 $action =
'presend';
3460 if ($action !=
'presend') {
3461 print
'<div class="fichecenter"><div class="fichehalfleft">';
3464 print
'<a name="builddoc"></a>';
3470 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".
$object->id;
3471 $genallowed = $user->hasRight(
'societe',
'lire');
3472 $delallowed = $user->hasRight(
'societe',
'creer');
3474 print $formfile->showdocuments(
'company',
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 0, 0, 0, 28, 0,
'entity='.$object->entity, 0,
'',
$object->default_lang);
3483 print
'</div><div class="fichehalfright">';
3487 $morehtmlcenter =
'<div class="nowraponall">';
3488 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/societe/messaging.php?socid='.
$object->id);
3489 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.
$object->id);
3490 $morehtmlcenter .=
'</div>';
3493 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3495 $somethingshown = $formactions->showactions(
$object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3497 print
'</div></div>';
3508 $modelmail =
'thirdparty';
3509 $defaulttopic =
'Information';
3510 $diroutput =
$conf->societe->multidir_output[
$object->entity];
3511 $trackid =
'thi'.$object->id;
3513 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
3526function GRVAT(a, u, p, myafm) {
3527 var afm = a.replace(/\D/g,
"");
3531 url:
'<?php echo DOL_URL_ROOT ?>/societe/checkvat/checkVatGr.php',
3533 success:
function(data) {
3537 if (obj.RgWsPublicBasicRt_out.afm ===
null) {
3538 alert(obj.pErrorRec_out.errorDescr);
3540 $(
"#name").val(obj.RgWsPublicBasicRt_out.onomasia);
3541 $(
"#address").val(obj.RgWsPublicBasicRt_out.postalAddress +
" " + obj.RgWsPublicBasicRt_out.postalAddressNo);
3542 $(
"#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode);
3543 $(
"#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription);
3544 $(
"#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr);
3545 $(
"#name_alias_input").val(obj.RgWsPublicBasicRt_out.commerTitle);
3547 if (obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser) {
3548 var firmActUser = obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser;
3550 if (Array.isArray(firmActUser)) {
3551 var primaryFirmAct = firmActUser.find(item => item.firmActKindDescr ===
"ΚΥΡΙΑ");
3552 if (primaryFirmAct) {
3553 $(
"#idprof1").val(primaryFirmAct.firmActDescr);
3556 $(
"#idprof1").val(firmActUser.firmActDescr);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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 categories.
Class to manage third parties objects (customers, suppliers, prospects...)
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
currency_name($code_iso, $withcode=0, $outputlangs=null)
Return label of currency or code+label.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Check validity of a file upload from an GUI page, and move it to its final destination.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null, $forceFullTextIndexation='')
Add a file into database index.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded')
Delete files into database index using search criteria.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
recordNotFound($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Displays an error page when a record is not found.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1)
Format professional IDs according to their country.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
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.