42require
'../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
53if (isModEnabled(
'adherent')) {
54 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
56if (isModEnabled(
'accounting')) {
57 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
59if (isModEnabled(
'accounting')) {
60 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
62if (isModEnabled(
'accounting')) {
63 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
65if (isModEnabled(
'eventorganization')) {
66 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
69if ($mysoc->country_code ==
'GR') {
78$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
80if (isModEnabled(
'adherent')) {
81 $langs->load(
"members");
83if (isModEnabled(
'categorie')) {
84 $langs->load(
"categories");
86if (isModEnabled(
'incoterm')) {
87 $langs->load(
"incoterm");
89if (isModEnabled(
'notification')) {
90 $langs->load(
"mails");
92if (isModEnabled(
'accounting')) {
93 $langs->load(
"products");
96$error = 0; $errors = array();
100$action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
101$cancel =
GETPOST(
'cancel',
'alpha');
102$backtopage =
GETPOST(
'backtopage',
'alpha');
103$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
104$backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
105$confirm =
GETPOST(
'confirm',
'alpha');
107$dol_openinpopup =
'';
108if (!empty($backtopagejsfields)) {
109 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
110 $dol_openinpopup = $tmpbacktopagejsfields[0];
115 $socid = $user->socid;
117if (empty($socid) && $action ==
'view') {
127$extrafields->fetch_name_optionals_label($object->table_element);
132$hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
135 $object->fetch($socid);
138if (!($object->id > 0) && $action ==
'view') {
139 $langs->load(
"errors");
140 print($langs->trans(
'ErrorRecordNotFound'));
145$canvas = $object->canvas ? $object->canvas :
GETPOST(
"canvas");
147if (!empty($canvas)) {
148 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
149 $objcanvas =
new Canvas($db, $action);
150 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
154$permissiontoread = $user->hasRight(
'societe',
'lire');
155$permissiontoadd = $user->hasRight(
'societe',
'creer');
156$permissiontodelete = $user->hasRight(
'societe',
'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0);
157$permissionnote = $user->hasRight(
'societe',
'creer');
158$permissiondellink = $user->hasRight(
'societe',
'creer');
159$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
162$result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
170$parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
171$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176if (empty($reshook)) {
177 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
179 if (empty($backtopage) || ($cancel && empty($id))) {
180 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
181 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
182 $backtopage = $backurlforlist;
184 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
190 if (!empty($backtopageforcancel)) {
191 header(
"Location: ".$backtopageforcancel);
193 } elseif (!empty($backtopage)) {
194 header(
"Location: ".$backtopage);
200 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
201 $soc_origin_id =
GETPOST(
'soc_origin',
'int');
202 $soc_origin =
new Societe($db);
204 if ($soc_origin_id <= 0) {
205 $langs->load(
'errors');
206 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
208 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
213 $result = $object->mergeCompany($soc_origin_id);
224 if (
GETPOST(
'getcustomercode')) {
226 $_POST[
"customer_code"] =
"Acompleter";
229 if (
GETPOST(
'getsuppliercode')) {
231 $_POST[
"supplier_code"] =
"Acompleter";
234 if ($action ==
'set_localtax1') {
237 $object->fetch($socid);
238 $res = $object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
240 if ($action ==
'set_localtax2') {
243 $object->fetch($socid);
244 $res = $object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
247 if ($action ==
'update_extras') {
248 $object->fetch($socid);
250 $object->oldcopy =
dol_clone($object, 2);
253 $extrafields->fetch_name_optionals_label($object->table_element);
255 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
261 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
269 $action =
'edit_extras';
275 && ($action ==
'add' || $action ==
'update') && $user->hasRight(
'societe',
'creer')) {
276 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
279 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
283 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")),
null,
'errors');
286 if (GETPOSTISSET(
'fournisseur') &&
GETPOST(
'fournisseur',
'int') < 0) {
287 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
291 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
293 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
296 if (isModEnabled(
'mailing') &&
GETPOST(
"private",
'int') == 1 &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
298 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
302 if ($action ==
'update') {
303 $ret = $object->fetch($socid);
304 $object->oldcopy = clone $object;
306 $object->canvas = $canvas;
309 if (
GETPOST(
"private",
'int') == 1) {
310 $object->particulier =
GETPOST(
"private",
'int');
313 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
315 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
316 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
318 $object->name =
GETPOST(
'name',
'alphanohtml');
320 $object->entity = (GETPOSTISSET(
'entity') ?
GETPOST(
'entity',
'int') : $conf->entity);
321 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
322 $object->parent = GETPOSTISSET(
'parent_company_id') ?
GETPOST(
'parent_company_id',
'int') : $object->parent;
323 $object->address =
GETPOST(
'address',
'alphanohtml');
324 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
325 $object->town =
GETPOST(
'town',
'alphanohtml');
326 $object->country_id =
GETPOST(
'country_id',
'int');
327 $object->state_id =
GETPOST(
'state_id',
'int');
329 $object->socialnetworks = array();
330 if (isModEnabled(
'socialnetworks')) {
331 foreach ($socialnetworks as $key => $value) {
332 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
333 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
338 $object->phone =
GETPOST(
'phone',
'alpha');
339 $object->fax =
GETPOST(
'fax',
'alpha');
340 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
341 $object->no_email =
GETPOST(
"no_email",
"int");
342 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
343 $object->idprof1 = trim(
GETPOST(
'idprof1',
'alphanohtml'));
344 $object->idprof2 = trim(
GETPOST(
'idprof2',
'alphanohtml'));
345 $object->idprof3 = trim(
GETPOST(
'idprof3',
'alphanohtml'));
346 $object->idprof4 = trim(
GETPOST(
'idprof4',
'alphanohtml'));
347 $object->idprof5 = trim(
GETPOST(
'idprof5',
'alphanohtml'));
348 $object->idprof6 = trim(
GETPOST(
'idprof6',
'alphanohtml'));
349 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
350 $object->code_client = GETPOSTISSET(
'customer_code') ?
GETPOST(
'customer_code',
'alpha') :
GETPOST(
'code_client',
'alpha');
351 $object->code_fournisseur = GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
352 $object->capital =
GETPOST(
'capital',
'alphanohtml');
353 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
355 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
356 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
357 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
358 $object->status =
GETPOST(
'status',
'alpha');
361 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
362 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
364 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
365 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
367 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
368 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
369 $object->typent_id =
GETPOST(
'typent_id',
'int');
371 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
373 $object->client =
GETPOST(
'client',
'int');
374 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
376 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
377 $object->default_lang =
GETPOST(
'default_lang');
380 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
381 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
383 if (GETPOSTISSET(
'accountancy_code_sell')) {
384 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
386 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
387 $object->accountancy_code_sell =
'';
389 $object->accountancy_code_sell = $accountancy_code_sell;
392 if (GETPOSTISSET(
'accountancy_code_buy')) {
393 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
395 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
396 $object->accountancy_code_buy =
'';
398 $object->accountancy_code_buy = $accountancy_code_buy;
403 if (isModEnabled(
'incoterm')) {
404 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
405 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
409 if (isModEnabled(
"multicurrency")) {
410 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
414 $ret = $extrafields->setOptionalsFromPost(
null, $object);
420 $ret = $object->setValuesForExtraLanguages();
426 if (!empty($_FILES[
'photo'][
'name'])) {
427 $current_logo = $object->logo;
432 if (!
GETPOST(
'cancel',
'alpha')) {
433 if (!empty($object->email) && !isValidEMail($object->email)) {
434 $langs->load(
"errors");
436 setEventMessages($langs->trans(
"ErrorBadEMail", $object->email),
null,
'errors');
438 if (!empty($object->url) && !
isValidUrl($object->url)) {
439 $langs->load(
"errors");
440 setEventMessages($langs->trans(
"ErrorBadUrl", $object->url),
null,
'errors');
442 if (!empty($object->webservices_url)) {
444 if (strpos($object->webservices_url,
"http") ===
false) {
445 $object->webservices_url =
"http://".$object->webservices_url;
448 $langs->load(
"errors");
450 $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
455 $object->country_id =
GETPOST(
'country_id',
'int') !=
'' ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
456 if ($object->country_id) {
457 $tmparray =
getCountry($object->country_id,
'all');
458 $object->country_code = $tmparray[
'code'];
459 $object->country = $tmparray[
'label'];
465 if ($action ==
'add') {
470 if (empty($object->client)) {
471 $object->code_client =
'';
473 if (empty($object->fournisseur)) {
474 $object->code_fournisseur =
'';
477 $result = $object->create($user);
479 if ($result >= 0 && isModEnabled(
'mailing') && !empty($object->email) && $object->no_email == 1) {
481 $resultnoemail = $object->setNoEmail($object->no_email);
482 if ($resultnoemail < 0) {
484 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
490 if ($object->particulier) {
491 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
492 $contcats =
GETPOST(
'contcats',
'array');
493 $no_email =
GETPOST(
'contact_no_email',
'int');
494 $result = $object->create_individual($user, $no_email, $contcats);
502 $salesreps =
GETPOST(
'commercial',
'array');
503 $result = $object->setSalesRep($salesreps,
true);
510 $custcats =
GETPOST(
'custcats',
'array');
511 $result = $object->setCategories($custcats,
'customer');
518 $suppcats =
GETPOST(
'suppcats',
'array');
519 $result = $object->setCategories($suppcats,
'supplier');
526 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
527 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
536 if (!($result > 0)) {
537 $errors[] =
"ErrorFailedToSaveFile";
540 $object->addThumbs($newfile);
545 switch ($_FILES[
'photo'][
'error']) {
548 $errors[] =
"ErrorFileSizeTooLarge";
551 $errors[] =
"ErrorFilePartiallyUploaded";
556 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors)) {
557 $duplicate_code_error =
true;
558 $object->code_client =
null;
561 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors)) {
562 $duplicate_code_error =
true;
563 $object->code_fournisseur =
null;
566 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
567 $duplicate_code_error =
true;
574 if ($result >= 0 && !$error) {
577 if ($backtopagejsfields) {
580 $retstring =
'<script>';
581 $retstring .=
'jQuery(document).ready(function() {
582 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
583 console.log(\
'id = '.$object->id.
'\');
584 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->id.
'\');
585 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->name.
'\');
586 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
588 $retstring .=
'</script>';
595 if (!empty($backtopage)) {
596 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
597 if (preg_match(
'/\?/', $backtopage)) {
598 $backtopage .=
'&socid='.$object->id;
600 header(
"Location: ".$backtopage);
603 $url = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
604 if (($object->client == 1 || $object->client == 3) && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS')) {
605 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".$object->id;
606 } elseif ($object->fournisseur == 1) {
607 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".$object->id;
610 header(
"Location: ".$url);
619 if ($action ==
'update') {
622 if (
GETPOST(
'cancel',
'alpha')) {
623 if (!empty($backtopage)) {
624 header(
"Location: ".$backtopage);
627 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
633 if (empty($object->client) && empty($object->oldcopy->code_client)) {
634 $object->code_client =
'';
636 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
637 $object->code_fournisseur =
'';
641 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
645 if (GETPOSTISSET(
'no_email') && $object->email) {
646 $no_email =
GETPOST(
'no_email',
'int');
647 $result = $object->setNoEmail($no_email);
666 $salesreps =
GETPOST(
'commercial',
'array');
667 $result = $object->setSalesRep($salesreps);
674 if (!$error && $user->hasRight(
'categorie',
'lire')) {
676 $categories =
GETPOST(
'custcats',
'array');
677 $result = $object->setCategories($categories,
'customer');
684 $categories =
GETPOST(
'suppcats',
'array');
685 $result = $object->setCategories($categories,
'supplier');
693 $dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id.
"/logos";
694 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
695 if (
GETPOST(
'deletephoto') && $object->logo) {
696 $fileimg = $dir.
'/'.$object->logo;
697 $dirthumbs = $dir.
'/thumbs';
703 if ($current_logo != $object->logo) {
704 $fileimg = $dir.
'/'.$current_logo;
705 $dirthumbs = $dir.
'/thumbs';
716 if (!($result > 0)) {
717 $errors[] =
"ErrorFailedToSaveFile";
720 $object->addThumbs($newfile);
724 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
733 $errors[] =
"ErrorBadImageFormat";
736 switch ($_FILES[
'photo'][
'error']) {
739 $errors[] =
"ErrorFileSizeTooLarge";
742 $errors[] =
"ErrorFilePartiallyUploaded";
750 if (!$error && $object->fk_soc > 0) {
751 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
752 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
753 if (!$object->db->query($sql)) {
755 $object->error .= $object->db->lasterror();
760 if (!$error && !count($errors)) {
761 if (!empty($backtopage)) {
762 header(
"Location: ".$backtopage);
765 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
769 $object->id = $socid;
774 $action = ($action ==
'add' ?
'create' :
'edit');
779 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'supprimer')) {
780 $object->fetch($socid);
781 $object->oldcopy = clone $object;
782 $result = $object->delete($socid, $user);
785 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
788 $langs->load(
"errors");
796 if ($action ==
'set_thirdpartytype' && $user->hasRight(
'societe',
'creer')) {
797 $object->fetch($socid);
798 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
802 if ($action ==
'set_incoterms' && $user->hasRight(
'societe',
'creer') && isModEnabled(
'incoterm')) {
803 $object->fetch($socid);
804 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
808 if ($action ==
'set_thirdparty' && $user->hasRight(
'societe',
'creer')) {
809 $object->fetch($socid);
810 $result = $object->setParent(
GETPOST(
'parent_id',
'int'));
814 if ($action ==
'set_salesrepresentatives' && $user->hasRight(
'societe',
'creer')) {
815 $object->fetch($socid);
816 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
820 if ($action ==
'setwarehouse' && $user->hasRight(
'societe',
'creer')) {
821 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
825 $object->fetch($socid);
829 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
833 $triggersendname =
'COMPANY_SENTBYMAIL';
834 $paramname =
'socid';
835 $mode =
'emailfromthirdparty';
836 $trackid =
'thi'.$object->id;
837 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
841 $upload_dir = !empty($conf->societe->multidir_output[$object->entity]) ? $conf->societe->multidir_output[$object->entity] : $conf->societe->dir_output;
842 $permissiontoadd = $user->hasRight(
'societe',
'creer');
843 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
851$form =
new Form($db);
855if (isModEnabled(
'accounting')) {
859if ($socid > 0 && empty($object->id)) {
860 $result = $object->fetch($socid);
867$title = $langs->trans(
"ThirdParty");
868if ($action ==
'create') {
869 $title = $langs->trans(
"NewThirdParty");
871if (
getDolGlobalString(
'MAIN_HTML_TITLE') && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
872 $title = $object->name.
" - ".$langs->trans(
'Card');
874$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
878$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
880$canvasdisplayaction = $action;
881if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
882 $canvasdisplayaction =
'view';
885if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
889 $objcanvas->assign_values($canvasdisplayaction, $object->id, $object->ref);
890 $objcanvas->display_canvas($canvasdisplayaction);
895 if ($action ==
'create') {
899 $private =
GETPOST(
"private",
"int");
900 if (
getDolGlobalString(
'THIRDPARTY_DEFAULT_CREATE_CONTACT') && !GETPOSTISSET(
'private')) {
903 if (empty($private)) {
908 $module = (
getDolGlobalString(
'SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
909 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
910 $module = substr($module, 0,
dol_strlen($module) - 4);
912 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
913 foreach ($dirsociete as $dirroot) {
919 $modCodeClient =
new $module();
921 $module = (
getDolGlobalString(
'SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
922 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
923 $module = substr($module, 0,
dol_strlen($module) - 4);
925 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
926 foreach ($dirsociete as $dirroot) {
932 $modCodeFournisseur =
new $module();
935 if (
GETPOST(
"type",
'aZ') !=
'f') {
936 $object->client = -1;
942 if (
GETPOST(
"type",
'aZ') ==
'c') {
944 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
949 if (
GETPOST(
"type",
'aZ') ==
'p') {
953 if (
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTSCUSTOMERS') && $object->client == 3) {
957 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) && (
GETPOST(
"type") ==
'f' || (
GETPOST(
"type") ==
'' &&
getDolGlobalString(
'THIRDPARTY_SUPPLIER_BY_DEFAULT')))) {
958 $object->fournisseur = 1;
961 $object->name =
GETPOST(
'name',
'alphanohtml');
962 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
963 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
964 $object->particulier = $private;
965 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
966 $object->client =
GETPOST(
'client',
'int') ?
GETPOST(
'client',
'int') : $object->client;
968 if (empty($duplicate_code_error)) {
969 $object->code_client =
GETPOST(
'customer_code',
'alpha');
970 $object->fournisseur =
GETPOST(
'fournisseur') ?
GETPOST(
'fournisseur',
'int') : $object->fournisseur;
971 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
973 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
null,
'warnings');
976 $object->address =
GETPOST(
'address',
'alphanohtml');
977 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
978 $object->town =
GETPOST(
'town',
'alphanohtml');
979 $object->state_id =
GETPOST(
'state_id',
'int');
981 $object->socialnetworks = array();
982 if (isModEnabled(
'socialnetworks')) {
983 foreach ($socialnetworks as $key => $value) {
984 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
985 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
990 $object->phone =
GETPOST(
'phone',
'alpha');
991 $object->fax =
GETPOST(
'fax',
'alpha');
992 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
993 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
994 $object->capital =
GETPOST(
'capital',
'alphanohtml');
995 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
996 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
997 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
998 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
999 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1000 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1001 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1002 $object->typent_id =
GETPOST(
'typent_id',
'int');
1003 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1004 $object->civility_id =
GETPOST(
'civility_id',
'alpha');
1006 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1007 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1008 $object->status =
GETPOST(
'status',
'int');
1011 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1012 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1014 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1015 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1017 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1019 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1020 $object->default_lang =
GETPOST(
'default_lang');
1022 if (GETPOSTISSET(
'accountancy_code_sell')) {
1023 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1025 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1026 $object->accountancy_code_sell =
'';
1028 $object->accountancy_code_sell = $accountancy_code_sell;
1031 if (GETPOSTISSET(
'accountancy_code_buy')) {
1032 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1034 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1035 $object->accountancy_code_buy =
'';
1037 $object->accountancy_code_buy = $accountancy_code_buy;
1041 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
1044 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos";
1045 $file_OK = (isset($_FILES[
'photo']) ? is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1050 if (@is_dir($dir)) {
1054 if (!($result > 0)) {
1055 $errors[] =
"ErrorFailedToSaveFile";
1058 $object->addThumbs($newfile);
1065 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1066 if ($object->country_id) {
1067 $tmparray =
getCountry($object->country_id,
'all');
1068 $object->country_code = $tmparray[
'code'];
1069 $object->country = $tmparray[
'label'];
1071 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
1074 if (isModEnabled(
"multicurrency")) {
1075 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1080 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1082 if (!empty($conf->use_javascript_ajax)) {
1084 print
"\n".
'<script type="text/javascript">';
1085 print
'$(document).ready(function () {
1088 is_private=' . $private.
';
1090 $(".individualline").show();
1092 $(".individualline").hide();
1094 $("#radiocompany").click(function() {
1095 $(".individualline").hide();
1096 $("#typent_id").val(0);
1097 $("#typent_id").change();
1098 $("#effectif_id").val(0);
1099 $("#effectif_id").change();
1100 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1101 document.formsoc.private.value=0;
1103 $("#radioprivate").click(function() {
1104 $(".individualline").show();
1105 $("#typent_id").val(id_te_private);
1106 $("#typent_id").change();
1107 $("#effectif_id").val(id_ef15);
1108 $("#effectif_id").change();
1109 /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
1110 if ($("#civility_id").data("select2")) {
1111 $("#civility_id").select2({width: "resolve"});
1113 $("#TypeName").html(document.formsoc.LastName.value);
1114 document.formsoc.private.value=1;
1119 function init_check_no_email(input) {
1120 if (input.val()!="") {
1121 $(".noemail").addClass("fieldrequired");
1123 $(".noemail").removeClass("fieldrequired");
1126 $("#email").keyup(function() {
1127 init_check_no_email($(this));
1129 init_check_no_email($("#email"));';
1132 print
'</script>'.
"\n";
1134 print
'<div id="selectthirdpartytype">';
1135 print
'<div class="hideonsmartphone float">';
1136 print $langs->trans(
"ThirdPartyType").
': ';
1138 print
'<label for="radiocompany" class="radiocompany">';
1139 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1141 print $langs->trans(
"CreateThirdPartyOnly");
1143 print
' ';
1144 print
'<label for="radioprivate" class="radioprivate">';
1145 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1147 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1148 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1149 print $form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1155 print
'<script type="text/javascript">';
1156 print
'$(document).ready(function () {
1157 var canHaveCustomerCategoryIfNotCustomerProspectSupplier = ' . (!
getDolGlobalString(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'0' :
'1') .
';
1159 init_customer_categ();
1160 $("#customerprospect").change(function() {
1161 init_customer_categ();
1163 function init_customer_categ() {
1164 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1165 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspectSupplier) {
1166 jQuery(".visibleifcustomer").hide();
1168 jQuery(".visibleifcustomer").show();
1172 init_supplier_categ();
1173 $("#fournisseur").change(function() {
1174 init_supplier_categ();
1176 function init_supplier_categ() {
1177 console.log("is supplier = "+jQuery("#fournisseur").val());
1178 if (jQuery("#fournisseur").val() == 0) {
1179 jQuery(".visibleifsupplier").hide();
1181 jQuery(".visibleifsupplier").show();
1185 $("#selectcountry_id").change(function() {
1186 document.formsoc.action.value="create";
1187 document.formsoc.submit();
1190 print
'</script>'.
"\n";
1195 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1197 print
'<input type="hidden" name="action" value="add">';
1198 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1199 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1200 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1201 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
1202 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1203 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1204 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1205 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1206 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1207 print
'<input type="hidden" name="code_auto" value="1">';
1213 $parameters = array();
1215 $reshook = $hookmanager->executeHooks(
'tabContentCreateThirdparty', $parameters, $object, $action);
1216 if (empty($reshook)) {
1217 print
'<table class="border centpercent">';
1220 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1221 if ($object->particulier || $private) {
1222 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1224 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1226 print
'</td><td'.(!
getDolGlobalString(
'SOCIETE_USEPREFIX') ?
' colspan="3"' :
'').
'>';
1228 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
1229 print $form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alphanohtml',
'minwidth300');
1324 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>';
1329 if ($conf->use_javascript_ajax) {
1332 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1333 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).
'"></td>';
1337 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1338 print $formcompany->select_civility($object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1344 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1345 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>';
1348 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1349 print
'<td class="maxwidthonsmartphone">';
1350 $selected = (GETPOSTISSET(
'client') ?
GETPOST(
'client',
'int') : $object->client);
1351 print $formcompany->selectProspectCustomerType($selected);
1354 if ($conf->browser->layout ==
'phone') {
1358 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1359 print
'<table class="nobordernopadding"><tr><td>';
1360 $tmpcode = $object->code_client;
1361 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1362 $tmpcode = $modCodeClient->getNextValue($object, 0);
1364 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1366 $s = $modCodeClient->getToolTip($langs, $object, 0);
1367 print $form->textwithpicto(
'', $s, 1);
1368 print
'</td></tr></table>';
1371 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'))
1372 || (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
1375 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
1380 print $form->selectyesno(
"fournisseur", (
GETPOST(
'fournisseur',
'int') !=
'' ?
GETPOST(
'fournisseur',
'int') : (
GETPOST(
"type",
'alpha') ==
'' ? $default : $object->fournisseur)), 1, 0, (
GETPOST(
"type",
'alpha') ==
'' ? 1 : 0), 1);
1384 if ($conf->browser->layout ==
'phone') {
1389 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'))) {
1390 print $form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1393 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'))) {
1394 print
'<table class="nobordernopadding"><tr><td>';
1395 $tmpcode = $object->code_fournisseur;
1396 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1397 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1399 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1401 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1402 print $form->textwithpicto(
'', $s, 1);
1403 print
'</td></tr></table>';
1409 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
1410 print $form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1414 if (isModEnabled(
'barcode')) {
1415 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1416 print
'<td colspan="3">';
1417 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1418 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
1423 print
'<tr><td class="tdtop">';
1424 print $form->editfieldkey(
'Address',
'address',
'', $object, 0);
1426 print
'<td colspan="3">';
1427 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1429 print
'</textarea>';
1430 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1434 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1435 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1437 if ($conf->browser->layout ==
'phone') {
1440 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1441 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1442 print $form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1446 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1447 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1448 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
1450 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1457 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1459 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1462 if ($object->country_id) {
1463 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1464 print $formcompany->select_state($object->state_id, $object->country_code);
1466 print $countrynotdefined;
1472 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1473 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>';
1474 if ($conf->browser->layout ==
'phone') {
1477 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1478 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>';
1481 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'', !
getDolGlobalString(
'SOCIETE_EMAIL_MANDATORY') ?
'' : $conf->global->SOCIETE_EMAIL_MANDATORY).
'</td>';
1482 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>';
1483 if (isModEnabled(
'mailing') &&
getDolGlobalString(
'THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION')) {
1484 if ($conf->browser->layout ==
'phone') {
1487 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1488 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>';
1491 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1492 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.
'"></td></tr>';
1495 if (isModEnabled(
'mailing')) {
1496 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1497 print
"\n".
'<script type="text/javascript">'.
"\n";
1498 print
'$(document).ready(function () {
1499 $("#email").keyup(function() {
1500 if ($(this).val()!="") {
1501 $(".noemail").addClass("fieldrequired");
1503 $(".noemail").removeClass("fieldrequired");
1507 print
'</script>'.
"\n";
1509 if (!GETPOSTISSET(
"no_email") && !empty($object->email)) {
1510 $result = $object->getNoEmail();
1516 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1518 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') :
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2));
1524 if (isModEnabled(
'socialnetworks')) {
1525 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
1531 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1533 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1534 if ($idprof !=
'-') {
1537 if (($j % $NBCOLS) == 0) {
1541 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1542 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1544 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1546 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1553 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1554 print
'<td colspan="2"></td></tr>';
1558 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1560 print
'<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . (GETPOSTISSET(
'assujtva_value') ?
'checked="checked"' :
'checked="checked"') .
' value="1">';
1562 if ($conf->browser->layout ==
'phone') {
1565 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1566 print
'<td class="nowrap">';
1567 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1572 if (!empty($conf->use_javascript_ajax)) {
1574 if (!empty($conf->dol_use_jmobile)) {
1579 print
'<script type="text/javascript">';
1580 print
"function CheckVAT(a) {\n";
1581 if ($mysoc->country_code ==
'GR' && $object->country_code ==
'GR' && !empty($u)) {
1582 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
1584 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1589 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1590 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1592 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1601 print
'<tr><td>' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'', $object, 0) .
'</td><td colspan="3">';
1602 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
1608 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1609 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1610 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ?
'checked="checked"' :
'') .
' value="1">';
1612 if ($conf->browser->layout ==
'phone') {
1615 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1616 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ?
'checked="checked"' :
'') .
' value="1">';
1618 } elseif ($mysoc->localtax1_assuj ==
"1") {
1619 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1620 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ?
'checked="checked"' :
'') .
' value="1">';
1622 } elseif ($mysoc->localtax2_assuj ==
"1") {
1623 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1624 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ?
'checked="checked"' :
'') .
' value="1">';
1629 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";
1630 $sortparam = (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1631 print $form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1633 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1637 if ($conf->browser->layout ==
'phone') {
1640 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1641 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1643 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1646 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1651 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1652 print
'<td colspan="3" class="maxwidthonsmartphone">';
1653 if ($object->country_id) {
1654 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1656 print $countrynotdefined;
1661 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1662 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1663 if (isModEnabled(
"multicurrency")) {
1664 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
1666 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
1669 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1670 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, 0, 1, 0, 0,
'maxwidth200onsmartphone');
1676 if (isModEnabled(
'incoterm')) {
1678 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1679 print
'<td colspan="3" class="maxwidthonsmartphone">';
1680 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1685 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
1686 $langs->load(
'categories');
1689 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1690 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
'parent',
null,
null, 1);
1691 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1695 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1696 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
1697 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1702 if (isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
1703 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1704 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
'parent',
null,
null, 1);
1705 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1711 if (isModEnabled(
"multicurrency")) {
1713 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1714 print
'<td colspan="3" class="maxwidthonsmartphone">';
1715 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1716 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
1721 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1722 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1727 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1728 print
'<td colspan="3" class="maxwidthonsmartphone">';
1729 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1730 print $form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1736 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1737 print
'<td colspan="3" class="maxwidthonsmartphone">';
1738 $userlist = $form->select_dolusers(
'',
'', 0,
null, 0,
'',
'',
'0', 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 2);
1740 $selected = (count(
GETPOST(
'commercial',
'array')) > 0 ?
GETPOST(
'commercial',
'array') : (
GETPOST(
'commercial',
'int') > 0 ? array(
GETPOST(
'commercial',
'int')) : array($user->id)));
1741 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected,
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1745 print
'<tr class="hideonsmartphone">';
1746 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1747 print
'<td colspan="3">';
1748 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1752 print
'</table>'.
"\n";
1756 print
'<table class="border centpercent">';
1758 if (isModEnabled(
'accounting')) {
1760 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1762 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1763 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'');
1767 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1769 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1770 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'');
1774 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1775 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1779 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1780 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1790 print $form->buttonsSaveCancel(
"AddThirdParty",
'Cancel',
null, 0,
'', $dol_openinpopup);
1792 print
'</form>'.
"\n";
1793 } elseif ($action ==
'edit') {
1797 $res = $object->fetch_optionals();
1803 $module = (
getDolGlobalString(
'SOCIETE_CODECLIENT_ADDON') ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1804 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1805 $module = substr($module, 0,
dol_strlen($module) - 4);
1807 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1808 foreach ($dirsociete as $dirroot) {
1814 $modCodeClient =
new $module($db);
1816 if ($modCodeClient->code_auto) {
1817 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1819 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1820 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1821 $module = substr($module, 0,
dol_strlen($module) - 4);
1823 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1824 foreach ($dirsociete as $dirroot) {
1830 $modCodeFournisseur =
new $module($db);
1832 if ($modCodeFournisseur->code_auto) {
1833 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1836 $object->oldcopy = clone $object;
1838 if (GETPOSTISSET(
'name')) {
1840 $object->name =
GETPOST(
'name',
'alphanohtml');
1841 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1842 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1843 $object->client =
GETPOST(
'client',
'int');
1844 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1845 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
1846 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1847 $object->address =
GETPOST(
'address',
'alphanohtml');
1848 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1849 $object->town =
GETPOST(
'town',
'alphanohtml');
1850 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
1851 $object->state_id =
GETPOST(
'state_id',
'int');
1852 $object->parent =
GETPOST(
'parent_company_id',
'int');
1854 $object->socialnetworks = array();
1855 if (isModEnabled(
'socialnetworks')) {
1856 foreach ($socialnetworks as $key => $value) {
1857 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
1858 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1863 $object->phone =
GETPOST(
'phone',
'alpha');
1864 $object->fax =
GETPOST(
'fax',
'alpha');
1865 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1866 $object->no_email =
GETPOST(
"no_email",
"int");
1867 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1868 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1869 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1870 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1871 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1872 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1873 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1874 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1875 $object->typent_id =
GETPOST(
'typent_id',
'int');
1876 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1877 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1878 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
1879 $object->default_lang =
GETPOST(
'default_lang',
'alpha');
1881 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1882 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1883 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1884 $object->status =
GETPOST(
'status',
'int');
1887 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
1888 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
1890 if (GETPOSTISSET(
'accountancy_code_sell')) {
1891 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1893 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1894 $object->accountancy_code_sell =
'';
1896 $object->accountancy_code_sell = $accountancy_code_sell;
1899 if (GETPOSTISSET(
'accountancy_code_buy')) {
1900 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1902 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1903 $object->accountancy_code_buy =
'';
1905 $object->accountancy_code_buy = $accountancy_code_buy;
1910 if (isModEnabled(
'incoterm')) {
1911 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
1912 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
1916 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value');
1917 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value');
1919 $object->localtax1_value =
GETPOST(
'lt1');
1920 $object->localtax2_value =
GETPOST(
'lt2');
1923 if ($object->country_id > 0) {
1924 $tmparray =
getCountry($object->country_id,
'all');
1925 $object->country_code = $tmparray[
'code'];
1926 $object->country = $tmparray[
'label'];
1930 if (isModEnabled(
"multicurrency")) {
1931 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $object->multicurrency_code;
1935 if ($object->localtax1_assuj == 0) {
1940 if ($object->localtax2_assuj == 0) {
1946 if (!empty($conf->use_javascript_ajax)) {
1947 print
"\n".
'<script type="text/javascript">';
1948 print
'$(document).ready(function () {
1951 if("#localtax1assuj_value".value==undefined){
1958 if("#localtax2assuj_value".value==undefined){
1965 $("#localtax1assuj_value").change(function() {
1966 var value=document.getElementById("localtax1assuj_value").value;
1973 $("#localtax2assuj_value").change(function() {
1974 var value=document.getElementById("localtax2assuj_value").value;
1982 var canHaveCustomerCategoryIfNotCustomerProspect = ' . (
getDolGlobalInt(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'1' :
'0') .
';
1984 init_customer_categ();
1985 $("#customerprospect").change(function() {
1986 init_customer_categ();
1988 function init_customer_categ() {
1989 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1990 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspect)
1992 jQuery(".visibleifcustomer").hide();
1996 jQuery(".visibleifcustomer").show();
2000 init_supplier_categ();
2001 $("#fournisseur").change(function() {
2002 init_supplier_categ();
2004 function init_supplier_categ() {
2005 console.log("is supplier = "+jQuery("#fournisseur").val());
2006 if (jQuery("#fournisseur").val() == 0)
2008 jQuery(".visibleifsupplier").hide();
2012 jQuery(".visibleifsupplier").show();
2016 $("#selectcountry_id").change(function() {
2017 document.formsoc.action.value="edit";
2018 document.formsoc.submit();
2022 print
'</script>'.
"\n";
2025 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post" name="formsoc">';
2026 print
'<input type="hidden" name="action" value="update">';
2027 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2028 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2029 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2030 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2031 print
'<input type="hidden" name="code_auto" value="1">';
2037 print
'<div class="fichecenter2">';
2039 $parameters = array();
2041 $reshook = $hookmanager->executeHooks(
'tabContentEditThirdparty', $parameters, $object, $action);
2042 if (empty($reshook)) {
2043 print
'<table class="border centpercent">';
2047 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2053 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0,
'string',
'', 1).
'</td>';
2054 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
2055 print $form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alphanohtml',
'minwidth300');
2059 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
2060 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>';
2064 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'', $object, 0).
'</td><td colspan="3">';
2066 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
2067 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2068 print $object->prefix_comm;
2070 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2076 print
'<tr><td>'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
2077 print
'<td class="maxwidthonsmartphone">';
2078 print $formcompany->selectProspectCustomerType($object->client);
2080 if ($conf->browser->layout ==
'phone') {
2083 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
2085 print
'<table class="nobordernopadding"><tr><td>';
2086 if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) {
2087 $tmpcode = $object->code_client;
2088 if (empty($tmpcode) && !empty($object->oldcopy->code_client)) {
2089 $tmpcode = $object->oldcopy->code_client;
2091 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2092 $tmpcode = $modCodeClient->getNextValue($object, 0);
2094 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2095 } elseif ($object->codeclient_modifiable()) {
2096 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).
'" maxlength="24">';
2098 print $object->code_client;
2099 print
'<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).
'">';
2102 $s = $modCodeClient->getToolTip($langs, $object, 0);
2103 print $form->textwithpicto(
'', $s, 1);
2104 print
'</td></tr></table>';
2109 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')))
2110 || (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire'))) {
2112 print
'<td>'.$form->editfieldkey(
'Supplier',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td>';
2113 print
'<td class="maxwidthonsmartphone">';
2114 print $form->selectyesno(
"fournisseur", $object->fournisseur, 1,
false, 0, 1);
2116 if ($conf->browser->layout ==
'phone') {
2120 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'))) {
2121 print $form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
2125 print
'<table class="nobordernopadding"><tr><td>';
2126 if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
2127 $tmpcode = $object->code_fournisseur;
2128 if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) {
2129 $tmpcode = $object->oldcopy->code_fournisseur;
2131 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2132 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2134 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2135 } elseif ($object->codefournisseur_modifiable()) {
2136 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).
'" maxlength="24">';
2138 print $object->code_fournisseur;
2139 print
'<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.
'">';
2142 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2143 print $form->textwithpicto(
'', $s, 1);
2144 print
'</td></tr></table>';
2149 if (isModEnabled(
'barcode')) {
2150 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
2151 print
'<td colspan="3">';
2153 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
2158 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
2159 print $form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), $object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2163 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2164 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2166 print
'</textarea>';
2167 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2171 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
2172 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2174 if ($conf->browser->layout ==
'phone') {
2177 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
2178 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2179 print $form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2183 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td colspan="3">';
2184 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2185 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
2187 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2194 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2196 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2199 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2200 print $formcompany->select_state($object->state_id, $object->country_code);
2205 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'), $object, 0).
'</td>';
2206 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>';
2207 if ($conf->browser->layout ==
'phone') {
2210 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
2211 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>';
2215 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'), $object, 0).
'</td>';
2216 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>';
2219 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (
getDolGlobalString(
'SOCIETE_EMAIL_MANDATORY'))).
'</td>';
2220 print
'<td colspan="3">';
2221 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2222 print
'<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'">';
2226 if (isModEnabled(
'mailing')) {
2227 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
2228 print
"\n".
'<script type="text/javascript">'.
"\n";
2231 jQuery(document).ready(function () {
2232 function init_check_no_email(input) {
2233 if (input.val()!="") {
2234 $(".noemail").addClass("fieldrequired");
2236 $(".noemail").removeClass("fieldrequired");
2239 $("#email").keyup(function() {
2240 init_check_no_email($(this));
2242 init_check_no_email($("#email"));
2244 print
'</script>'.
"\n";
2246 if (!GETPOSTISSET(
"no_email") && !empty($object->email)) {
2247 $result = $object->getNoEmail();
2253 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
2255 $useempty = (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
2256 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $object->no_email), 1, false, $useempty);
2262 if (isModEnabled(
'socialnetworks')) {
2263 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
2269 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2271 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2272 if ($idprof !=
'-') {
2275 if (($j % $NBCOLS) == 0) {
2279 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2280 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).
'</td><td>';
2281 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2283 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2290 if ($NBCOLS > 0 && $j % 2 == 1) {
2291 print
'<td colspan="2"></td></tr>';
2295 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2296 print
'<input id="assujtva_value" name="assujtva_value" type="checkbox" ' . ($object->tva_assuj ?
'checked="checked"' :
'') .
' value="1">';
2301 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2302 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td>';
2303 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . ($object->localtax1_assuj ?
'checked="checked"' :
'') .
' value="1">';
2305 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2306 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2311 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2312 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . ($object->localtax2_assuj ?
'checked="checked"' :
'') .
' value="1"></td></tr>';
2314 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2315 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2319 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2320 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2321 print
'<input id="localtax1assuj_value" name="localtax1assuj_value" type="checkbox" ' . ($object->localtax1_assuj ?
'checked="checked"' :
'') .
' value="1">';
2323 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2324 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2328 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2329 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2330 print
'<input id="localtax2assuj_value" name="localtax2assuj_value" type="checkbox" ' . ($object->localtax2_assuj ?
'checked="checked"' :
'') .
' value="1">';
2332 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2333 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2341 print
'<tr><td>' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'', $object, 0) .
'</td><td colspan="3">';
2342 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
2347 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2348 print
'<td colspan="3">';
2349 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2354 if ($conf->use_javascript_ajax) {
2356 if (!empty($conf->dol_use_jmobile)) {
2361 print
'<script type="text/javascript">';
2362 print
"function CheckVAT(a) {\n";
2363 if ($mysoc->country_code ==
'GR' && $object->country_code ==
'GR' && !empty($u)) {
2364 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
2366 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2371 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2372 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2374 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2382 print
'<tr><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.(($conf->browser->layout ==
'phone' ||
getDolGlobalString(
'SOCIETE_DISABLE_WORKFORCE')) ?
' colspan="3"' :
'').
'>';
2383 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);
2385 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2389 if ($conf->browser->layout ==
'phone') {
2392 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2393 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2395 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2398 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2403 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2404 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
2408 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2409 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2411 if (isModEnabled(
"multicurrency")) {
2412 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
2414 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2419 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2420 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->default_lang,
'default_lang', 0,
null,
'1', 0, 0,
'maxwidth300 widthcentpercentminusx');
2426 if (isModEnabled(
'incoterm')) {
2428 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2429 print
'<td colspan="3" class="maxwidthonsmartphone">';
2430 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
2435 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
2437 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2438 print
'<td colspan="3">';
2439 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
null,
null,
null, 1);
2441 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2442 $arrayselected = array();
2443 foreach ($cats as $cat) {
2444 $arrayselected[] = $cat->id;
2446 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2450 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'))) {
2451 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2452 print
'<td colspan="3">';
2453 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
null,
null,
null, 1);
2455 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2456 $arrayselected = array();
2457 foreach ($cats as $cat) {
2458 $arrayselected[] = $cat->id;
2460 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2466 if (isModEnabled(
"multicurrency")) {
2468 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2469 print
'<td colspan="3" class="maxwidthonsmartphone">';
2470 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2471 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
2476 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2477 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2482 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
2483 print
'<td colspan="3" class="maxwidthonsmartphone">';
2484 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2485 print $form->select_company(
GETPOST(
'parent_company_id') ?
GETPOST(
'parent_company_id') : $object->parent,
'parent_company_id',
'',
'SelectThirdParty', 0, 0, null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
2490 if (!empty($conf->syncsupplierwebservices->enabled)) {
2491 print
'<tr><td>'.$form->editfieldkey(
'WebServiceURL',
'webservices_url',
'', $object, 0).
'</td>';
2492 print
'<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.
'"></td>';
2493 print
'<td>'.$form->editfieldkey(
'WebServiceKey',
'webservices_key',
'', $object, 0).
'</td>';
2494 print
'<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.
'"></td></tr>';
2498 print
'<tr class="hideonsmartphone">';
2499 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2500 print
'<td colspan="3">';
2501 if ($object->logo) {
2502 print $form->showphoto(
'societe', $object);
2505 if ($caneditfield) {
2506 if ($object->logo) {
2509 print
'<table class="nobordernopadding">';
2510 if ($object->logo) {
2511 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans(
"Delete").
'</photo><br><br></td></tr>';
2516 $maxmin = $maxfilesizearray[
'maxmin'];
2518 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2520 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2529 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2530 print
'<td colspan="3" class="maxwidthonsmartphone">';
2531 $userlist = $form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
2532 $arrayselected =
GETPOST(
'commercial',
'array');
2533 if (empty($arrayselected)) {
2534 $arrayselected = $object->getSalesRepresentatives($user, 1);
2536 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2543 print
'<table class="border centpercent">';
2545 if (isModEnabled(
'accounting')) {
2547 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2549 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
2553 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2555 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
2559 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2560 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2564 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2565 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2576 print $form->buttonsSaveCancel();
2585 if (!empty($object->id)) {
2586 $res = $object->fetch_optionals();
2598 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2599 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2602 if ($action ==
'merge') {
2603 $formquestion = array(
2605 'name' =>
'soc_origin',
2606 'label' => $langs->trans(
'MergeOriginThirdparty'),
2608 'value' => $form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200',
'',
'', 1,
null,
false, array($object->id))
2612 $formconfirm .= $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2616 $parameters = array(
'formConfirm' => $formconfirm);
2617 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2618 if (empty($reshook)) {
2619 $formconfirm .= $hookmanager->resPrint;
2620 } elseif ($reshook > 0) {
2621 $formconfirm = $hookmanager->resPrint;
2629 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2631 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2634 $parameters = array();
2636 $reshook = $hookmanager->executeHooks(
'tabContentViewThirdparty', $parameters, $object, $action);
2637 if (empty($reshook)) {
2638 print
'<div class="fichecenter">';
2639 print
'<div class="fichehalfleft">';
2641 print
'<div class="underbanner clearboth"></div>';
2642 print
'<table class="border tableforfield centpercent">';
2645 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2646 print $object->getTypeUrl(1);
2651 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.
dol_escape_htmltag($object->prefix_comm).
'</td>';
2656 if ($object->client) {
2658 print $langs->trans(
'CustomerCode');
2662 $tmpcheck = $object->check_codeclient();
2663 if ($tmpcheck != 0 && $tmpcheck != -5) {
2664 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2671 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) {
2673 print $langs->trans(
'SupplierCode').
'</td><td>';
2675 $tmpcheck = $object->check_codefournisseur();
2676 if ($tmpcheck != 0 && $tmpcheck != -5) {
2677 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2684 if (isModEnabled(
'barcode')) {
2695 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2696 if ($idprof !=
'-') {
2699 print
'<td>'.$idprof.
'</td><td>';
2702 if ($object->$key) {
2703 if ($object->id_prof_check($i, $object) > 0) {
2704 if (!empty($object->id_prof_url($i, $object))) {
2705 print
' '.$object->id_prof_url($i, $object);
2708 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
2725 if ($object->fournisseur) {
2728 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2730 print
yn($object->tva_assuj);
2737 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
2739 print
'<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
2746 if ($object->fournisseur || $mysoc->country_code ==
'ES') {
2747 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2748 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2749 print
yn($object->localtax1_assuj);
2750 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2751 print
yn($object->localtax2_assuj);
2755 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2756 print
'<input type="hidden" name="action" value="set_localtax1">';
2757 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2758 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>';
2759 if ($action ==
'editRE') {
2760 print
'<td class="left">';
2761 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2762 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2764 print
'<td>'.$object->localtax1_value.
'</td>';
2766 print
'</tr></form>';
2769 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2770 print
'<input type="hidden" name="action" value="set_localtax2">';
2771 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2772 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>';
2773 if ($action ==
'editIRPF') {
2774 print
'<td class="left">';
2775 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2776 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2778 print
'<td>'.$object->localtax2_value.
'</td>';
2780 print
'</tr></form>';
2782 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2783 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2784 print
yn($object->localtax1_assuj);
2787 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2788 print
'<input type="hidden" name="action" value="set_localtax1">';
2789 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2790 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>';
2791 if ($action ==
'editRE') {
2792 print
'<td class="left">';
2793 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2794 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2796 print
'<td>'.$object->localtax1_value.
'</td>';
2798 print
'</tr></form>';
2800 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2801 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2802 print
yn($object->localtax2_assuj);
2805 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2806 print
'<input type="hidden" name="action" value="set_localtax2">';
2807 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2808 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>';
2809 if ($action ==
'editIRPF') {
2810 print
'<td class="left">';
2811 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2812 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2814 print
'<td>'.$object->localtax2_value.
'</td>';
2816 print
'</tr></form>';
2823 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
2824 if ($object->tva_intra) {
2827 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2832 if ($conf->use_javascript_ajax) {
2834 if (!empty($conf->dol_use_jmobile)) {
2839 print
'<script type="text/javascript">';
2840 print
"function CheckVAT(a) {\n";
2841 if ($mysoc->country_code ==
'GR' && $object->country_code ==
'GR' && !empty($u)) {
2842 print
"GRVAT(a,'{$u}','{$p}','{$myafm}');\n";
2844 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2849 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans(
"VATIntraCheck").
'</a>';
2850 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2852 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2863 $langs->load(
'stocks');
2864 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2866 print
'<tr class="nowrap">';
2868 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->hasRight(
'societe',
'creer'));
2870 if ($action ==
'editwarehouse') {
2871 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
2873 if ($object->fk_warehouse > 0) {
2874 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
2876 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
2885 print
'<div class="fichehalfright">';
2887 print
'<div class="underbanner clearboth"></div>';
2888 print
'<table class="border tableforfield centpercent">';
2891 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
2893 if ($object->prospect || $object->client ||
getDolGlobalString(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT')) {
2894 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
2896 print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
2901 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) {
2902 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
2904 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
2912 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
2913 if ($action !=
'editthirdpartytype' && $user->hasRight(
'societe',
'creer')) {
2914 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>';
2916 print
'</tr></table>';
2918 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
2919 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
2924 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
2928 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
2931 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
2932 if ($object->capital) {
2933 if (isModEnabled(
"multicurrency") && !empty($object->multicurrency_code)) {
2934 print
price($object->capital,
'', $langs, 0, -1, -1, $object->multicurrency_code);
2936 print
price($object->capital,
'', $langs, 0, -1, -1, $conf->currency);
2944 if (isModEnabled(
'mailing')) {
2945 $result = $object->getNoEmail();
2949 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
2950 if ($object->email) {
2951 print
yn($object->no_email);
2953 $langs->load(
"mails");
2954 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
2957 $langs->load(
"mails");
2958 print
' <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans(
"NbOfEMailingsSend")).
'">'.$object->getNbOfEMailings().
'</span>';
2965 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2966 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
2969 $langs->load(
"languages");
2970 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
2971 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
2977 if (isModEnabled(
'incoterm')) {
2979 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
2980 if ($action !=
'editincoterm' && $user->hasRight(
'societe',
'creer')) {
2981 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
2983 print
'</tr></table>';
2984 print
'</td><td colspan="3">';
2985 if ($action !=
'editincoterm') {
2986 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2988 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.$object->id);
2994 if (isModEnabled(
"multicurrency")) {
2996 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2998 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
3004 print
'<tr><td class="nowrap">';
3005 print $langs->trans(
"ProductAccountancySellCode");
3006 print
'</td><td colspan="2">';
3007 if (isModEnabled(
'accounting')) {
3008 if (!empty($object->accountancy_code_sell)) {
3010 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
3012 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
3015 print $object->accountancy_code_sell;
3020 print
'<tr><td class="nowrap">';
3021 print $langs->trans(
"ProductAccountancyBuyCode");
3022 print
'</td><td colspan="2">';
3023 if (isModEnabled(
'accounting')) {
3024 if (!empty($object->accountancy_code_buy)) {
3026 $accountingaccount2->fetch(
'', $object->accountancy_code_buy, 1);
3028 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3031 print $object->accountancy_code_buy;
3037 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3038 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3043 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3044 if ($action !=
'editparentcompany' && $user->hasRight(
'societe',
'creer')) {
3045 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>';
3047 print
'</tr></table>';
3049 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3050 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->parent, $html_name,
'', 1, 0, 0,
null, 0, array($object->id));
3055 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3058 if (isModEnabled(
'adherent')) {
3059 $langs->load(
"members");
3060 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3063 $result = $adh->fetch(
'',
'', $object->id);
3065 $adh->ref = $adh->getFullName($langs);
3066 print $adh->getNomUrl(-1);
3068 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3070 print
"</td></tr>\n";
3090 if (!empty($conf->syncsupplierwebservices->enabled)) {
3091 print
'<tr><td>'.$langs->trans(
"WebServiceURL").
'</td><td>'.
dol_print_url($object->webservices_url).
'</td>';
3092 print
'<td class="nowrap">'.$langs->trans(
'WebServiceKey').
'</td><td>'.$object->webservices_key.
'</td></tr>';
3099 print
'<div class="clearboth"></div>';
3108 if ($action !=
'presend') {
3109 print
'<div class="tabsAction">'.
"\n";
3111 $parameters = array();
3112 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3113 if (empty($reshook)) {
3114 $at_least_one_email_contact =
false;
3115 $TContact = $object->contact_array_objects();
3116 foreach ($TContact as &$contact) {
3117 if (!empty($contact->email)) {
3118 $at_least_one_email_contact =
true;
3123 if (empty($user->socid)) {
3124 $langs->load(
"mails");
3126 if (empty($object->email) && !$at_least_one_email_contact) {
3127 $title = $langs->trans(
'NoEMail');
3129 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);
3132 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
3134 if (isModEnabled(
'adherent')) {
3136 $result = $adh->fetch(
'',
'', $object->id);
3137 if ($result == 0 && ($object->client == 1 || $object->client == 3) &&
getDolGlobalString(
'MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS')) {
3138 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";
3142 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=merge&token='.newToken(),
'', $permissiontodelete);
3144 if ($user->hasRight(
'societe',
'supprimer')) {
3145 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.newToken();
3146 $buttonId =
'action-delete-no-ajax';
3147 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3149 $buttonId =
'action-delete';
3151 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3155 print
'</div>'.
"\n";
3159 if (
GETPOST(
'modelselected')) {
3160 $action =
'presend';
3163 if ($action !=
'presend') {
3164 print
'<div class="fichecenter"><div class="fichehalfleft">';
3167 print
'<a name="builddoc"></a>';
3172 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
3173 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
3174 $genallowed = $user->hasRight(
'societe',
'lire');
3175 $delallowed = $user->hasRight(
'societe',
'creer');
3177 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);
3186 print
'</div><div class="fichehalfright">';
3190 $morehtmlcenter =
'<div class="nowraponall">';
3191 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/societe/messaging.php?socid='.$object->id);
3192 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
3193 $morehtmlcenter .=
'</div>';
3196 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3198 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3200 print
'</div></div>';
3205 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3211 $modelmail =
'thirdparty';
3212 $defaulttopic =
'Information';
3213 $diroutput = $conf->societe->multidir_output[$object->entity];
3214 $trackid =
'thi'.$object->id;
3216 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
3229function GRVAT(a, u, p, myafm) {
3230 var afm = a.replace(/\D/g,
"");
3234 url:
'<?php echo DOL_URL_ROOT ?>/societe/checkvat/checkVatGr.php',
3236 success:
function(data) {
3240 if (obj.RgWsPublicBasicRt_out.afm ===
null) {
3241 alert(obj.pErrorRec_out.errorDescr);
3243 $(
"#name").val(obj.RgWsPublicBasicRt_out.onomasia);
3244 $(
"#address").val(obj.RgWsPublicBasicRt_out.postalAddress +
" " + obj.RgWsPublicBasicRt_out.postalAddressNo);
3245 $(
"#zipcode").val(obj.RgWsPublicBasicRt_out.postalZipCode);
3246 $(
"#town").val(obj.RgWsPublicBasicRt_out.postalAreaDescription);
3247 $(
"#idprof2").val(obj.RgWsPublicBasicRt_out.doyDescr);
3248 $(
"#name_alias_input").val(obj.RgWsPublicBasicRt_out.commerTitle);
3250 if (obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser) {
3251 var firmActUser = obj.arrayOfRgWsPublicFirmActRt_out.RgWsPublicFirmActRtUser;
3253 if (Array.isArray(firmActUser)) {
3254 var primaryFirmAct = firmActUser.find(item => item.firmActKindDescr ===
"ΚΥΡΙΑ");
3255 if (primaryFirmAct) {
3256 $(
"#idprof1").val(primaryFirmAct.firmActDescr);
3259 $(
"#idprof1").val(firmActUser.firmActDescr);
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
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.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or 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)
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
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='')
Make control on an uploaded file from an GUI page and move it to final destination.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null)
Add a file into database index.
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded')
Delete files into database index using search criterias.
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].
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_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.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 formated messages to output (Used to show messages on html output).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
if(preg_match('/crypted:/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.