37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
48 if (!empty($conf->adherent->enabled)) {
49 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
51 if (!empty($conf->accounting->enabled)) {
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
54 if (!empty($conf->accounting->enabled)) {
55 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
57 if (!empty($conf->accounting->enabled)) {
58 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
60 if (! empty($conf->eventorganization->enabled)) {
61 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
65 $langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
66 if (!empty($conf->adherent->enabled)) {
67 $langs->load(
"members");
69 if (!empty($conf->categorie->enabled)) {
70 $langs->load(
"categories");
72 if (!empty($conf->incoterm->enabled)) {
73 $langs->load(
"incoterm");
75 if (!empty($conf->notification->enabled)) {
76 $langs->load(
"mails");
78 if (!empty($conf->accounting->enabled)) {
79 $langs->load(
"products");
82 $error = 0; $errors = array();
84 $action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
85 $cancel =
GETPOST(
'cancel',
'alpha');
86 $backtopage =
GETPOST(
'backtopage',
'alpha');
87 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
88 $backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
89 $dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
90 $confirm =
GETPOST(
'confirm',
'alpha');
94 $socid = $user->socid;
96 if (empty($socid) && $action ==
'view') {
105 $extrafields->fetch_name_optionals_label($object->table_element);
110 $hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
113 $object->fetch($socid);
116 if (!($object->id > 0) && $action ==
'view') {
117 $langs->load(
"errors");
118 print($langs->trans(
'ErrorRecordNotFound'));
123 $canvas = $object->canvas ? $object->canvas :
GETPOST(
"canvas");
125 if (!empty($canvas)) {
126 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
127 $objcanvas =
new Canvas($db, $action);
128 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
131 $permissiontoread = $user->rights->societe->lire;
132 $permissiontoadd = $user->rights->societe->creer;
133 $permissiontodelete = $user->rights->societe->supprimer || ($permissiontoadd && isset($object->status) && $object->status == 0);
134 $permissionnote = $user->rights->societe->creer;
135 $permissiondellink = $user->rights->societe->creer;
136 $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
139 $result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
147 $parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
148 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
153 if (empty($reshook)) {
154 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
156 if (empty($backtopage) || ($cancel && empty($id))) {
157 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
158 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
159 $backtopage = $backurlforlist;
161 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
167 if (!empty($backtopageforcancel)) {
168 header(
"Location: ".$backtopageforcancel);
170 } elseif (!empty($backtopage)) {
171 header(
"Location: ".$backtopage);
177 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->rights->societe->creer) {
179 $soc_origin_id =
GETPOST(
'soc_origin',
'int');
180 $soc_origin =
new Societe($db);
182 if ($soc_origin_id <= 0) {
183 $langs->load(
'errors');
184 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
186 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
197 $object->client = $object->client | $soc_origin->client;
198 $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
199 $listofproperties = array(
200 'address',
'zip',
'town',
'state_id',
'country_id',
'phone',
'phone_pro',
'fax',
'email',
'socialnetworks',
'url',
'barcode',
201 'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
202 'tva_intra',
'effectif_id',
'forme_juridique',
'remise_percent',
'remise_supplier_percent',
'mode_reglement_supplier_id',
'cond_reglement_supplier_id',
'name_bis',
203 'stcomm_id',
'outstanding_limit',
'price_level',
'parent',
'default_lang',
'ref',
'ref_ext',
'import_key',
'fk_incoterms',
'fk_multicurrency',
204 'code_client',
'code_fournisseur',
'code_compta',
'code_compta_fournisseur',
205 'model_pdf',
'fk_projet'
207 foreach ($listofproperties as $property) {
208 if (empty($object->$property)) {
209 $object->$property = $soc_origin->$property;
214 $listofproperties = array(
215 'note_public',
'note_private'
217 foreach ($listofproperties as $property) {
218 $object->$property =
dol_concatdesc($object->$property, $soc_origin->$property);
222 if (is_array($soc_origin->array_options)) {
223 foreach ($soc_origin->array_options as $key => $val) {
224 if (empty($object->array_options[$key])) {
225 $object->array_options[$key] = $val;
233 $custcats_ori = $static_cat->containing($soc_origin->id,
'customer',
'id');
234 $custcats = $static_cat->containing($object->id,
'customer',
'id');
235 $custcats = array_merge($custcats, $custcats_ori);
236 $object->setCategories($custcats,
'customer');
238 $suppcats_ori = $static_cat->containing($soc_origin->id,
'supplier',
'id');
239 $suppcats = $static_cat->containing($object->id,
'supplier',
'id');
240 $suppcats = array_merge($suppcats, $suppcats_ori);
241 $object->setCategories($suppcats,
'supplier');
244 if ($soc_origin->code_client == $object->code_client
245 || $soc_origin->code_fournisseur == $object->code_fournisseur
246 || $soc_origin->barcode == $object->barcode) {
247 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
248 $soc_origin->code_client =
'';
249 $soc_origin->code_fournisseur =
'';
250 $soc_origin->barcode =
'';
251 $soc_origin->update($soc_origin->id, $user, 0, 1, 1,
'merge');
255 $result = $object->update($object->id, $user, 0, 1, 1,
'merge');
266 'Adherent' =>
'/adherents/class/adherent.class.php',
267 'Don' => array(
'file' =>
'/don/class/don.class.php',
'enabled' =>
isModEnabled(
'don')),
268 'Societe' =>
'/societe/class/societe.class.php',
270 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
271 'Propal' =>
'/comm/propal/class/propal.class.php',
272 'Commande' =>
'/commande/class/commande.class.php',
273 'Facture' =>
'/compta/facture/class/facture.class.php',
274 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
275 'LignePrelevement' =>
'/compta/prelevement/class/ligneprelevement.class.php',
276 'Mo' =>
'/mrp/class/mo.class.php',
277 'Contact' =>
'/contact/class/contact.class.php',
278 'Contrat' =>
'/contrat/class/contrat.class.php',
279 'Expedition' =>
'/expedition/class/expedition.class.php',
280 'Fichinter' =>
'/fichinter/class/fichinter.class.php',
281 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
282 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
283 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
284 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
285 'Delivery' =>
'/delivery/class/delivery.class.php',
286 'Product' =>
'/product/class/product.class.php',
287 'Project' =>
'/projet/class/project.class.php',
288 'Ticket' => array(
'file' =>
'/ticket/class/ticket.class.php',
'enabled' =>
isModEnabled(
'ticket')),
289 'User' =>
'/user/class/user.class.php',
290 'Account' =>
'/compta/bank/class/account.class.php',
291 'ConferenceOrBoothAttendee' =>
'/eventorganization/class/conferenceorboothattendee.class.php'
295 foreach ($objects as $object_name => $object_file) {
296 if (is_array($object_file)) {
297 if (empty($object_file[
'enabled'])) {
300 $object_file = $object_file[
'file'];
303 require_once DOL_DOCUMENT_ROOT.$object_file;
305 if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) {
315 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', array(
316 'soc_origin' => $soc_origin->id,
317 'soc_dest' => $object->id
318 ), $object, $action);
328 $object->context = array(
'merge'=>1,
'mergefromid'=>$soc_origin->id);
331 $result = $object->call_trigger(
'COMPANY_MODIFY', $user);
341 if ($soc_origin->delete($soc_origin->id, $user) < 1) {
350 $langs->load(
"errors");
358 if (
GETPOST(
'getcustomercode')) {
360 $_POST[
"customer_code"] =
"Acompleter";
363 if (
GETPOST(
'getsuppliercode')) {
365 $_POST[
"supplier_code"] =
"Acompleter";
368 if ($action ==
'set_localtax1') {
371 $object->fetch($socid);
372 $res = $object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
374 if ($action ==
'set_localtax2') {
377 $object->fetch($socid);
378 $res = $object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
381 if ($action ==
'update_extras') {
382 $object->fetch($socid);
387 $extrafields->fetch_name_optionals_label($object->table_element);
389 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
395 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
403 $action =
'edit_extras';
409 && ($action ==
'add' || $action ==
'update') && $user->rights->societe->creer) {
410 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
413 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
417 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")),
null,
'errors');
421 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
425 if (!empty($conf->mailing->enabled) && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
427 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
430 if (!empty($conf->mailing->enabled) &&
GETPOST(
"private",
'int') == 1 && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
432 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
436 if ($action ==
'update') {
437 $ret = $object->fetch($socid);
438 $object->oldcopy = clone $object;
440 $object->canvas = $canvas;
443 if (
GETPOST(
"private",
'int') == 1) {
444 $object->particulier =
GETPOST(
"private",
'int');
447 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
449 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
450 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
452 $object->name =
GETPOST(
'name',
'alphanohtml');
455 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
456 $object->parent =
GETPOST(
'parent_company_id',
'int');
457 $object->address =
GETPOST(
'address',
'alphanohtml');
458 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
459 $object->town =
GETPOST(
'town',
'alphanohtml');
460 $object->country_id =
GETPOST(
'country_id',
'int');
461 $object->state_id =
GETPOST(
'state_id',
'int');
463 $object->socialnetworks = array();
464 if (!empty($conf->socialnetworks->enabled)) {
465 foreach ($socialnetworks as $key => $value) {
467 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
472 $object->phone =
GETPOST(
'phone',
'alpha');
473 $object->fax =
GETPOST(
'fax',
'alpha');
474 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
475 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
476 $object->idprof1 = trim(
GETPOST(
'idprof1',
'alphanohtml'));
477 $object->idprof2 = trim(
GETPOST(
'idprof2',
'alphanohtml'));
478 $object->idprof3 = trim(
GETPOST(
'idprof3',
'alphanohtml'));
479 $object->idprof4 = trim(
GETPOST(
'idprof4',
'alphanohtml'));
480 $object->idprof5 = trim(
GETPOST(
'idprof5',
'alphanohtml'));
481 $object->idprof6 = trim(
GETPOST(
'idprof6',
'alphanohtml'));
482 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
484 $object->code_fournisseur =
GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
485 $object->capital =
GETPOST(
'capital',
'alphanohtml');
486 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
488 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
489 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
490 $object->status =
GETPOST(
'status',
'alpha');
493 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
494 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
496 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
497 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
499 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
500 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
501 $object->typent_id =
GETPOST(
'typent_id',
'int');
503 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
505 $object->client =
GETPOST(
'client',
'int');
506 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
508 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
509 $object->default_lang =
GETPOST(
'default_lang');
512 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
513 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
516 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
518 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
519 $object->accountancy_code_sell =
'';
521 $object->accountancy_code_sell = $accountancy_code_sell;
525 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
527 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
528 $object->accountancy_code_buy =
'';
530 $object->accountancy_code_buy = $accountancy_code_buy;
535 if (!empty($conf->incoterm->enabled)) {
536 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
537 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
541 if (!empty($conf->multicurrency->enabled)) {
542 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
546 $ret = $extrafields->setOptionalsFromPost(
null, $object);
552 $ret = $object->setValuesForExtraLanguages();
558 if (!empty($_FILES[
'photo'][
'name'])) {
559 $current_logo = $object->logo;
564 if (!
GETPOST(
'cancel',
'alpha')) {
565 if (!empty($object->email) && !isValidEMail($object->email)) {
566 $langs->load(
"errors");
568 setEventMessages(
'', $langs->trans(
"ErrorBadEMail", $object->email),
'errors');
570 if (!empty($object->url) && !
isValidUrl($object->url)) {
571 $langs->load(
"errors");
574 if (!empty($object->webservices_url)) {
576 if (strpos($object->webservices_url,
"http") ===
false) {
577 $object->webservices_url =
"http://".$object->webservices_url;
580 $langs->load(
"errors");
581 $error++; $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
586 $object->country_id =
GETPOST(
'country_id',
'int') !=
'' ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
587 if ($object->country_id) {
588 $tmparray =
getCountry($object->country_id,
'all');
589 $object->country_code = $tmparray[
'code'];
590 $object->country = $tmparray[
'label'];
596 if ($action ==
'add') {
601 if (empty($object->client)) {
602 $object->code_client =
'';
604 if (empty($object->fournisseur)) {
605 $object->code_fournisseur =
'';
608 $result = $object->create($user);
611 if ($object->particulier) {
612 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
613 $contcats =
GETPOST(
'contcats',
'array');
614 $no_email =
GETPOST(
'contact_no_email',
'int');
615 $result = $object->create_individual($user, $no_email, $contcats);
623 $salesreps =
GETPOST(
'commercial',
'array');
624 $result = $object->setSalesRep($salesreps,
true);
631 $custcats =
GETPOST(
'custcats',
'array');
632 $result = $object->setCategories($custcats,
'customer');
639 $suppcats =
GETPOST(
'suppcats',
'array');
640 $result = $object->setCategories($suppcats,
'supplier');
647 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
648 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
657 if (!($result > 0)) {
658 $errors[] =
"ErrorFailedToSaveFile";
661 $object->addThumbs($newfile);
666 switch ($_FILES[
'photo'][
'error']) {
669 $errors[] =
"ErrorFileSizeTooLarge";
672 $errors[] =
"ErrorFilePartiallyUploaded";
677 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors)) {
678 $duplicate_code_error =
true;
679 $object->code_client =
null;
682 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors)) {
683 $duplicate_code_error =
true;
684 $object->code_fournisseur =
null;
687 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
688 $duplicate_code_error =
true;
695 if ($result >= 0 && !$error) {
698 if ($backtopagejsfields) {
701 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
702 $dol_openinpopup = $tmpbacktopagejsfields[0];
704 $retstring =
'<script>';
705 $retstring .=
'jQuery(document).ready(function() {
706 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
707 console.log(\
'id = '.$object->id.
'\');
708 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->id.
'\');
709 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->name.
'\');
710 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
712 $retstring .=
'</script>';
719 if (!empty($backtopage)) {
720 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
721 if (preg_match(
'/\?/', $backtopage)) {
722 $backtopage .=
'&socid='.$object->id;
724 header(
"Location: ".$backtopage);
727 $url = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
728 if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
729 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".$object->id;
730 } elseif ($object->fournisseur == 1) {
731 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".$object->id;
734 header(
"Location: ".$url);
743 if ($action ==
'update') {
746 if (
GETPOST(
'cancel',
'alpha')) {
747 if (!empty($backtopage)) {
748 header(
"Location: ".$backtopage);
751 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
757 if (empty($object->client) && empty($object->oldcopy->code_client)) {
758 $object->code_client =
'';
760 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
761 $object->code_fournisseur =
'';
765 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
773 $salesreps =
GETPOST(
'commercial',
'array');
774 $result = $object->setSalesRep($salesreps);
781 if (!$error && !empty($user->rights->categorie->lire)) {
783 $categories =
GETPOST(
'custcats',
'array');
784 $result = $object->setCategories($categories,
'customer');
791 $categories =
GETPOST(
'suppcats',
'array');
792 $result = $object->setCategories($categories,
'supplier');
800 $dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id.
"/logos";
801 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
802 if (
GETPOST(
'deletephoto') && $object->logo) {
803 $fileimg = $dir.
'/'.$object->logo;
804 $dirthumbs = $dir.
'/thumbs';
810 if ($current_logo != $object->logo) {
811 $fileimg = $dir.
'/'.$current_logo;
812 $dirthumbs = $dir.
'/thumbs';
823 if (!($result > 0)) {
824 $errors[] =
"ErrorFailedToSaveFile";
827 $object->addThumbs($newfile);
830 if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) {
831 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
840 $errors[] =
"ErrorBadImageFormat";
843 switch ($_FILES[
'photo'][
'error']) {
846 $errors[] =
"ErrorFileSizeTooLarge";
849 $errors[] =
"ErrorFilePartiallyUploaded";
857 if (!$error && $object->fk_soc > 0) {
858 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
859 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
860 if (!$object->db->query($sql)) {
862 $object->error .= $object->db->lasterror();
867 if (!$error && !count($errors)) {
868 if (!empty($backtopage)) {
869 header(
"Location: ".$backtopage);
872 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
876 $object->id = $socid;
881 $action = ($action ==
'add' ?
'create' :
'edit');
886 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->societe->supprimer) {
887 $object->fetch($socid);
888 $object->oldcopy = clone $object;
889 $result = $object->delete($socid, $user);
892 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
895 $langs->load(
"errors");
903 if ($action ==
'set_thirdpartytype' && $user->rights->societe->creer) {
904 $object->fetch($socid);
905 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
909 if ($action ==
'set_incoterms' && $user->rights->societe->creer && !empty($conf->incoterm->enabled)) {
910 $object->fetch($socid);
911 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
915 if ($action ==
'set_thirdparty' && $user->rights->societe->creer) {
916 $object->fetch($socid);
917 $result = $object->setParent(
GETPOST(
'parent_id',
'int'));
921 if ($action ==
'set_salesrepresentatives' && $user->rights->societe->creer) {
922 $object->fetch($socid);
923 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
927 if ($action ==
'setwarehouse' && $user->rights->societe->creer) {
928 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
932 $object->fetch($socid);
935 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
936 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
940 $triggersendname =
'COMPANY_SENTBYMAIL';
941 $paramname =
'socid';
942 $mode =
'emailfromthirdparty';
943 $trackid =
'thi'.$object->id;
944 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
948 $upload_dir = !empty($conf->societe->multidir_output[$object->entity])?$conf->societe->multidir_output[$object->entity]:$conf->societe->dir_output;
949 $permissiontoadd = $user->rights->societe->creer;
950 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
962 if (!empty($conf->accounting->enabled)) {
966 if ($socid > 0 && empty($object->id)) {
967 $result = $object->fetch($socid);
974 $title = $langs->trans(
"ThirdParty");
975 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
976 $title = $object->name.
" - ".$langs->trans(
'Card');
979 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
983 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
985 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
989 $objcanvas->assign_values($action, $object->id, $object->ref);
990 $objcanvas->display_canvas($action);
995 if ($action ==
'create') {
999 $private =
GETPOST(
"private",
"int");
1000 if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !
GETPOSTISSET(
'private')) {
1003 if (empty($private)) {
1008 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1009 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1010 $module = substr($module, 0,
dol_strlen($module) - 4);
1012 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1013 foreach ($dirsociete as $dirroot) {
1019 $modCodeClient =
new $module;
1021 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1022 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1023 $module = substr($module, 0,
dol_strlen($module) - 4);
1025 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1026 foreach ($dirsociete as $dirroot) {
1032 $modCodeFournisseur =
new $module;
1035 if (
GETPOST(
"type",
'aZ') !=
'f') {
1036 $object->client = -1;
1037 if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) {
1038 $object->client = 3;
1042 if (
GETPOST(
"type",
'aZ') ==
'c') {
1043 if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
1044 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
1046 $object->client = 3;
1049 if (
GETPOST(
"type",
'aZ') ==
'p') {
1050 $object->client = 2;
1053 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) {
1054 $object->client = 1;
1057 if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && (
GETPOST(
"type") ==
'f' || (
GETPOST(
"type") ==
'' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) {
1058 $object->fournisseur = 1;
1061 $object->name =
GETPOST(
'name',
'alphanohtml');
1062 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1063 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
1064 $object->particulier = $private;
1065 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1066 $object->client =
GETPOST(
'client',
'int') ?
GETPOST(
'client',
'int') : $object->client;
1068 if (empty($duplicate_code_error)) {
1069 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1070 $object->fournisseur =
GETPOST(
'fournisseur') ?
GETPOST(
'fournisseur',
'int') : $object->fournisseur;
1071 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1073 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
'',
'warnings');
1076 $object->address =
GETPOST(
'address',
'alphanohtml');
1077 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1078 $object->town =
GETPOST(
'town',
'alphanohtml');
1079 $object->state_id =
GETPOST(
'state_id',
'int');
1081 $object->socialnetworks = array();
1082 if (!empty($conf->socialnetworks->enabled)) {
1083 foreach ($socialnetworks as $key => $value) {
1085 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1090 $object->phone =
GETPOST(
'phone',
'alpha');
1091 $object->fax =
GETPOST(
'fax',
'alpha');
1092 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1093 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1094 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1095 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1096 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1097 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1098 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1099 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1100 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1101 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1102 $object->typent_id =
GETPOST(
'typent_id',
'int');
1103 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1104 $object->civility_id =
GETPOST(
'civility_id',
'alpha');
1106 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1107 $object->status =
GETPOST(
'status',
'int');
1110 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1111 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1113 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1114 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1116 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1118 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1119 $object->default_lang =
GETPOST(
'default_lang');
1122 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1124 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1125 $object->accountancy_code_sell =
'';
1127 $object->accountancy_code_sell = $accountancy_code_sell;
1131 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1133 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1134 $object->accountancy_code_buy =
'';
1136 $object->accountancy_code_buy = $accountancy_code_buy;
1140 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
1143 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos";
1144 $file_OK = (isset($_FILES[
'photo']) ?is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1149 if (@is_dir($dir)) {
1153 if (!($result > 0)) {
1154 $errors[] =
"ErrorFailedToSaveFile";
1157 $object->addThumbs($newfile);
1164 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1165 if ($object->country_id) {
1166 $tmparray =
getCountry($object->country_id,
'all');
1167 $object->country_code = $tmparray[
'code'];
1168 $object->country = $tmparray[
'label'];
1170 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
1173 if (!empty($conf->multicurrency->enabled)) {
1174 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1179 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1181 if (!empty($conf->use_javascript_ajax)) {
1182 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1183 print
"\n".
'<script type="text/javascript">';
1184 print
'$(document).ready(function () {
1187 is_private=' . $private.
';
1189 $(".individualline").show();
1191 $(".individualline").hide();
1193 $("#radiocompany").click(function() {
1194 $(".individualline").hide();
1195 $("#typent_id").val(0);
1196 $("#typent_id").change();
1197 $("#effectif_id").val(0);
1198 $("#effectif_id").change();
1199 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1200 document.formsoc.private.value=0;
1202 $("#radioprivate").click(function() {
1203 $(".individualline").show();
1204 $("#typent_id").val(id_te_private);
1205 $("#typent_id").change();
1206 $("#effectif_id").val(id_ef15);
1207 $("#effectif_id").change();
1208 /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
1209 if ($("#civility_id").data("select2")) {
1210 $("#civility_id").select2({width: "resolve"});
1212 $("#TypeName").html(document.formsoc.LastName.value);
1213 document.formsoc.private.value=1;
1216 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
1218 init_customer_categ();
1219 $("#customerprospect").change(function() {
1220 init_customer_categ();
1222 function init_customer_categ() {
1223 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1224 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
1226 jQuery(".visibleifcustomer").hide();
1230 jQuery(".visibleifcustomer").show();
1234 init_supplier_categ();
1235 $("#fournisseur").change(function() {
1236 init_supplier_categ();
1238 function init_supplier_categ() {
1239 console.log("is supplier = "+jQuery("#fournisseur").val());
1240 if (jQuery("#fournisseur").val() == 0)
1242 jQuery(".visibleifsupplier").hide();
1246 jQuery(".visibleifsupplier").show();
1250 $("#selectcountry_id").change(function() {
1251 document.formsoc.action.value="create";
1252 document.formsoc.submit();
1254 if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1256 function init_check_no_email(input) {
1257 if (input.val()!="") {
1258 $(".noemail").addClass("fieldrequired");
1260 $(".noemail").removeClass("fieldrequired");
1263 $("#email").keyup(function() {
1264 init_check_no_email($(this));
1266 init_check_no_email($("#email"));';
1269 print
'</script>'.
"\n";
1271 print
'<div id="selectthirdpartytype">';
1272 print
'<div class="hideonsmartphone float">';
1273 print $langs->trans(
"ThirdPartyType").
': ';
1275 print
'<label for="radiocompany" class="radiocompany">';
1276 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1278 print $langs->trans(
"CreateThirdPartyOnly");
1280 print
' ';
1281 print
'<label for="radioprivate" class="radioprivate">';
1282 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1284 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1285 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1286 print
$form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1291 print
'<script type="text/javascript">';
1292 print
'$(document).ready(function () {
1293 $("#selectcountry_id").change(function() {
1294 document.formsoc.action.value="create";
1295 document.formsoc.submit();
1298 print
'</script>'.
"\n";
1304 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1306 print
'<input type="hidden" name="action" value="add">';
1307 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1308 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1309 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1310 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1311 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1312 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1313 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1314 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1315 print
'<input type="hidden" name="code_auto" value="1">';
1320 print
'<table class="border centpercent">';
1323 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1324 if ($object->particulier || $private) {
1325 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1327 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1329 print
'</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ?
' colspan="3"' :
'').
'>';
1331 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
1332 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
1427 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
1428 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>';
1433 if ($conf->use_javascript_ajax) {
1434 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1436 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1437 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).
'"></td>';
1441 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1442 print $formcompany->select_civility($object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1448 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1449 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>';
1452 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1453 print
'<td class="maxwidthonsmartphone">';
1455 print $formcompany->selectProspectCustomerType($selected);
1458 if ($conf->browser->layout ==
'phone') {
1462 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1463 print
'<table class="nobordernopadding"><tr><td>';
1464 $tmpcode = $object->code_client;
1465 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1466 $tmpcode = $modCodeClient->getNextValue($object, 0);
1468 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1470 $s = $modCodeClient->getToolTip($langs, $object, 0);
1471 print
$form->textwithpicto(
'', $s, 1);
1472 print
'</td></tr></table>';
1475 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))
1476 || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) {
1479 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
1481 if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) {
1484 print
$form->selectyesno(
"fournisseur", (
GETPOST(
'fournisseur',
'int') !=
'' ?
GETPOST(
'fournisseur',
'int') : (
GETPOST(
"type",
'alpha') ==
'' ? $default : $object->fournisseur)), 1, 0, (
GETPOST(
"type",
'alpha') ==
'' ? 1 : 0), 1);
1488 if ($conf->browser->layout ==
'phone') {
1493 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
1494 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1497 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
1498 print
'<table class="nobordernopadding"><tr><td>';
1499 $tmpcode = $object->code_fournisseur;
1500 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1501 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1503 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1505 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1506 print
$form->textwithpicto(
'', $s, 1);
1507 print
'</td></tr></table>';
1513 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
1514 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1518 if (!empty($conf->barcode->enabled)) {
1519 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1520 print
'<td colspan="3">';
1521 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1522 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
1527 print
'<tr><td class="tdtop">';
1528 print
$form->editfieldkey(
'Address',
'address',
'', $object, 0);
1530 print
'<td colspan="3">';
1531 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1533 print
'</textarea>';
1534 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1538 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1539 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1541 if ($conf->browser->layout ==
'phone') {
1544 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1545 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1546 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1550 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1551 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1552 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
1554 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1559 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1560 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) {
1561 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1563 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1566 if ($object->country_id) {
1567 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1568 print $formcompany->select_state($object->state_id, $object->country_code);
1570 print $countrynotdefined;
1576 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1577 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>';
1578 if ($conf->browser->layout ==
'phone') {
1581 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1582 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>';
1585 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ?
'' : $conf->global->SOCIETE_EMAIL_MANDATORY).
'</td>';
1586 print
'<td'.(($conf->browser->layout ==
'phone') || empty($conf->mailing->enabled) ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_email',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.
'"></td>';
1587 if (!empty($conf->mailing->enabled) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1588 if ($conf->browser->layout ==
'phone') {
1591 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1592 print
'<td class="individualline" '.(($conf->browser->layout ==
'phone') || empty($conf->mailing->enabled) ?
' 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>';
1595 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1596 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.
'"></td></tr>';
1599 if (!empty($conf->socialnetworks->enabled)) {
1600 foreach ($socialnetworks as $key => $value) {
1601 if ($value[
'active']) {
1603 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1604 print
'<td colspan="3">';
1605 if (!empty($value[
'icon'])) {
1606 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1608 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth300 widthcentpercentminusx" maxlength="80" value="'.
dol_escape_htmltag(
GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : (empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key])).
'">';
1611 } elseif (!empty($object->socialnetworks[$key])) {
1612 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1618 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1620 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1621 if ($idprof !=
'-') {
1624 if (($j % $NBCOLS) == 0) {
1628 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1629 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1631 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1633 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1640 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1641 print
'<td colspan="2"></td></tr>';
1645 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1647 print
$form->selectyesno(
'assujtva_value',
GETPOSTISSET(
'assujtva_value') ?
GETPOST(
'assujtva_value',
'int') : 1, 1);
1649 if ($conf->browser->layout ==
'phone') {
1652 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1653 print
'<td class="nowrap">';
1654 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1656 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
1659 if (!empty($conf->use_javascript_ajax)) {
1661 if (!empty($conf->dol_use_jmobile)) {
1666 print
'<script type="text/javascript">';
1667 print
"function CheckVAT(a) {\n";
1668 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1672 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1673 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1675 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1684 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1685 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1686 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1688 if ($conf->browser->layout ==
'phone') {
1691 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1692 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1694 } elseif ($mysoc->localtax1_assuj ==
"1") {
1695 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1696 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1698 } elseif ($mysoc->localtax2_assuj ==
"1") {
1699 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1700 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1705 print
'<tr><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.( ($conf->browser->layout ==
'phone' || !empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) ?
' colspan="3"' :
'').
'>'.
"\n";
1706 $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1707 print
$form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1709 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1711 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
1713 if ($conf->browser->layout ==
'phone') {
1716 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1717 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1719 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1722 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1727 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1728 print
'<td colspan="3" class="maxwidthonsmartphone">';
1729 if ($object->country_id) {
1730 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1732 print $countrynotdefined;
1737 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1738 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1739 if (!empty($conf->multicurrency->enabled)) {
1740 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
1742 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
1744 if (!empty($conf->global->MAIN_MULTILANGS)) {
1745 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1746 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');
1752 if (!empty($conf->incoterm->enabled)) {
1754 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1755 print
'<td colspan="3" class="maxwidthonsmartphone">';
1756 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1761 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1762 $langs->load(
'categories');
1765 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1766 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
'parent',
null,
null, 1);
1767 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1770 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1771 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1772 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
1773 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1778 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
1779 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1780 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
'parent',
null,
null, 1);
1781 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1787 if (!empty($conf->multicurrency->enabled)) {
1789 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1790 print
'<td colspan="3" class="maxwidthonsmartphone">';
1791 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1);
1796 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1797 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1800 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
1802 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1803 print
'<td colspan="3" class="maxwidthonsmartphone">';
1804 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1805 print
$form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1811 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1812 print
'<td colspan="3" class="maxwidthonsmartphone">';
1813 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
1815 $selected = (count(
GETPOST(
'commercial',
'array')) > 0 ?
GETPOST(
'commercial',
'array') : (
GETPOST(
'commercial',
'int') > 0 ? array(
GETPOST(
'commercial',
'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array())));
1816 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected,
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1820 print
'<tr class="hideonsmartphone">';
1821 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1822 print
'<td colspan="3">';
1823 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1827 print
'</table>'.
"\n";
1830 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
1831 print
'<table class="border" width="100%">';
1833 if (! empty($conf->accounting->enabled)) {
1835 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1837 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1838 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'');
1842 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1844 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1845 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'');
1849 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1850 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1854 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1855 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1864 print
$form->buttonsSaveCancel(
"AddThirdParty",
'Cancel',
null, 0,
'', $dol_openinpopup);
1866 print
'</form>'.
"\n";
1867 } elseif ($action ==
'edit') {
1871 $res = $object->fetch_optionals();
1877 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1878 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1879 $module = substr($module, 0,
dol_strlen($module) - 4);
1881 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1882 foreach ($dirsociete as $dirroot) {
1888 $modCodeClient =
new $module($db);
1890 if ($modCodeClient->code_auto) {
1891 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1893 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1894 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1895 $module = substr($module, 0,
dol_strlen($module) - 4);
1897 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1898 foreach ($dirsociete as $dirroot) {
1904 $modCodeFournisseur =
new $module($db);
1906 if ($modCodeFournisseur->code_auto) {
1907 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1910 $object->oldcopy = clone $object;
1914 $object->name =
GETPOST(
'name',
'alphanohtml');
1915 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1916 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1917 $object->client =
GETPOST(
'client',
'int');
1918 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1919 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
1920 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1921 $object->address =
GETPOST(
'address',
'alphanohtml');
1922 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1923 $object->town =
GETPOST(
'town',
'alphanohtml');
1924 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
1925 $object->state_id =
GETPOST(
'state_id',
'int');
1927 $object->socialnetworks = array();
1928 if (!empty($conf->socialnetworks->enabled)) {
1929 foreach ($socialnetworks as $key => $value) {
1931 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1936 $object->phone =
GETPOST(
'phone',
'alpha');
1937 $object->fax =
GETPOST(
'fax',
'alpha');
1938 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1939 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1940 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1941 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1942 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1943 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1944 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1945 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1946 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1947 $object->typent_id =
GETPOST(
'typent_id',
'int');
1948 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1949 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1950 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
1951 $object->default_lang =
GETPOST(
'default_lang',
'alpha');
1953 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1954 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1955 $object->status =
GETPOST(
'status',
'int');
1958 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
1959 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
1962 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1964 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1965 $object->accountancy_code_sell =
'';
1967 $object->accountancy_code_sell = $accountancy_code_sell;
1971 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1973 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1974 $object->accountancy_code_buy =
'';
1976 $object->accountancy_code_buy = $accountancy_code_buy;
1981 if (!empty($conf->incoterm->enabled)) {
1982 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
1983 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
1987 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value');
1988 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value');
1990 $object->localtax1_value =
GETPOST(
'lt1');
1991 $object->localtax2_value =
GETPOST(
'lt2');
1994 if ($object->country_id > 0) {
1995 $tmparray =
getCountry($object->country_id,
'all');
1996 $object->country_code = $tmparray[
'code'];
1997 $object->country = $tmparray[
'label'];
2001 if (!empty($conf->multicurrency->enabled)) {
2002 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $object->multicurrency_code;
2006 if ($object->localtax1_assuj == 0) {
2011 if ($object->localtax2_assuj == 0) {
2017 if (!empty($conf->use_javascript_ajax)) {
2018 print
"\n".
'<script type="text/javascript">';
2019 print
'$(document).ready(function () {
2022 if("#localtax1assuj_value".value==undefined){
2029 if("#localtax2assuj_value".value==undefined){
2036 $("#localtax1assuj_value").change(function() {
2037 var value=document.getElementById("localtax1assuj_value").value;
2044 $("#localtax2assuj_value").change(function() {
2045 var value=document.getElementById("localtax2assuj_value").value;
2053 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
2055 init_customer_categ();
2056 $("#customerprospect").change(function() {
2057 init_customer_categ();
2059 function init_customer_categ() {
2060 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
2061 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
2063 jQuery(".visibleifcustomer").hide();
2067 jQuery(".visibleifcustomer").show();
2071 init_supplier_categ();
2072 $("#fournisseur").change(function() {
2073 init_supplier_categ();
2075 function init_supplier_categ() {
2076 console.log("is supplier = "+jQuery("#fournisseur").val());
2077 if (jQuery("#fournisseur").val() == 0)
2079 jQuery(".visibleifsupplier").hide();
2083 jQuery(".visibleifsupplier").show();
2087 $("#selectcountry_id").change(function() {
2088 document.formsoc.action.value="edit";
2089 document.formsoc.submit();
2093 print
'</script>'.
"\n";
2096 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post" name="formsoc">';
2097 print
'<input type="hidden" name="action" value="update">';
2098 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2099 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2100 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2101 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2102 print
'<input type="hidden" name="code_auto" value="1">';
2108 print
'<div class="fichecenter2">';
2109 print
'<table class="border centpercent">';
2112 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2113 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2119 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0,
'string',
'', 1).
'</td>';
2120 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
2121 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
2125 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
2126 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>';
2129 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2130 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'', $object, 0).
'</td><td colspan="3">';
2132 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
2133 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2134 print $object->prefix_comm;
2136 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2142 print
'<tr><td>'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
2143 print
'<td class="maxwidthonsmartphone">';
2144 print $formcompany->selectProspectCustomerType($object->client);
2146 if ($conf->browser->layout ==
'phone') {
2149 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
2151 print
'<table class="nobordernopadding"><tr><td>';
2152 if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) {
2153 $tmpcode = $object->code_client;
2154 if (empty($tmpcode) && !empty($object->oldcopy->code_client)) {
2155 $tmpcode = $object->oldcopy->code_client;
2157 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2158 $tmpcode = $modCodeClient->getNextValue($object, 0);
2160 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2161 } elseif ($object->codeclient_modifiable()) {
2162 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).
'" maxlength="24">';
2164 print $object->code_client;
2165 print
'<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).
'">';
2168 $s = $modCodeClient->getToolTip($langs, $object, 0);
2169 print
$form->textwithpicto(
'', $s, 1);
2170 print
'</td></tr></table>';
2175 if (((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire)))
2176 || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) {
2178 print
'<td>'.$form->editfieldkey(
'Supplier',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td>';
2179 print
'<td class="maxwidthonsmartphone">';
2180 print
$form->selectyesno(
"fournisseur", $object->fournisseur, 1,
false, 0, 1);
2182 if ($conf->browser->layout ==
'phone') {
2186 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
2187 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
2191 print
'<table class="nobordernopadding"><tr><td>';
2192 if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
2193 $tmpcode = $object->code_fournisseur;
2194 if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) {
2195 $tmpcode = $object->oldcopy->code_fournisseur;
2197 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2198 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2200 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2201 } elseif ($object->codefournisseur_modifiable()) {
2202 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).
'" maxlength="24">';
2204 print $object->code_fournisseur;
2205 print
'<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.
'">';
2208 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2209 print
$form->textwithpicto(
'', $s, 1);
2210 print
'</td></tr></table>';
2215 if (!empty($conf->barcode->enabled)) {
2216 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
2217 print
'<td colspan="3">';
2219 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
2224 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
2225 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), $object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2229 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2230 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2232 print
'</textarea>';
2233 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2237 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2238 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2240 if ($conf->browser->layout ==
'phone') {
2243 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2244 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2245 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2249 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td colspan="3">';
2250 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2251 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
2253 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2258 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
2259 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2)) {
2260 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2262 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2265 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2266 print $formcompany->select_state($object->state_id, $object->country_code);
2271 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'), $object, 0).
'</td>';
2272 print
'<td>'.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>';
2273 if ($conf->browser->layout ==
'phone') {
2276 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
2277 print
'<td>'.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>';
2280 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
2281 print
'<td colspan="3">'.img_picto(
'',
'object_email',
'class="pictofixedwidth"').
' <input type="text" name="email" id="email" class="maxwidth200onsmartphone maxwidth500 widthcentpercentminusx" value="'.(
GETPOSTISSET(
'email') ?
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL) : $object->email).
'"></td></tr>';
2282 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'), $object, 0).
'</td>';
2283 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" name="url" id="url" class="maxwidth200onsmartphone maxwidth500 widthcentpercentminusx " value="'.(
GETPOSTISSET(
'url') ?
GETPOST(
'url',
'alpha') : $object->url).
'"></td></tr>';
2286 if (!empty($conf->socialnetworks->enabled)) {
2287 foreach ($socialnetworks as $key => $value) {
2288 if ($value[
'active']) {
2290 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
2291 print
'<td colspan="3">';
2292 if (!empty($value[
'icon'])) {
2293 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2295 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth500 widthcentpercentminusx" maxlength="80" value="'.(empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key]).
'">';
2298 } elseif (!empty($object->socialnetworks[$key])) {
2299 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2307 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2309 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2310 if ($idprof !=
'-') {
2313 if (($j % $NBCOLS) == 0) {
2317 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2318 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).
'</td><td>';
2319 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2321 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2328 if ($NBCOLS > 0 && $j % 2 == 1) {
2329 print
'<td colspan="2"></td></tr>';
2333 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2334 print
$form->selectyesno(
'assujtva_value', $object->tva_assuj, 1);
2339 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2340 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td>';
2341 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2343 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2344 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2349 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2350 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2352 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2353 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2357 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2358 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2359 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2361 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2362 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2366 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2367 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2368 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2370 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2371 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2378 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2379 print
'<td colspan="3">';
2380 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2382 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2385 if ($conf->use_javascript_ajax) {
2387 if (!empty($conf->dol_use_jmobile)) {
2392 print
'<script type="text/javascript">';
2393 print
"function CheckVAT(a) {\n";
2394 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2398 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2399 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2401 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2409 print
'<tr><td>'.$form->editfieldkey(
'ThirdPartyType',
'typent_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.( ($conf->browser->layout ==
'phone' || !empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) ?
' colspan="3"' :
'').
'>';
2410 print
$form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
2412 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2414 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2416 if ($conf->browser->layout ==
'phone') {
2419 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2420 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2422 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2425 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2430 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2431 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
2435 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2436 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2438 if (!empty($conf->multicurrency->enabled)) {
2439 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
2441 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2445 if (!empty($conf->global->MAIN_MULTILANGS)) {
2446 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2447 print
img_picto(
'',
'language').$formadmin->select_language($object->default_lang,
'default_lang', 0, 0, 1);
2453 if (!empty($conf->incoterm->enabled)) {
2455 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2456 print
'<td colspan="3" class="maxwidthonsmartphone">';
2457 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
2462 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
2464 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2465 print
'<td colspan="3">';
2466 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
null,
null,
null, 1);
2468 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2469 $arrayselected = array();
2470 foreach ($cats as $cat) {
2471 $arrayselected[] = $cat->id;
2473 print
img_picto(
'',
'category').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2477 if ((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) {
2478 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2479 print
'<td colspan="3">';
2480 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
null,
null,
null, 1);
2482 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2483 $arrayselected = array();
2484 foreach ($cats as $cat) {
2485 $arrayselected[] = $cat->id;
2487 print
img_picto(
'',
'category').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2493 if (!empty($conf->multicurrency->enabled)) {
2495 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2496 print
'<td colspan="3" class="maxwidthonsmartphone">';
2497 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1);
2502 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2503 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2506 if (!empty($conf->syncsupplierwebservices->enabled)) {
2507 print
'<tr><td>'.$form->editfieldkey(
'WebServiceURL',
'webservices_url',
'', $object, 0).
'</td>';
2508 print
'<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.
'"></td>';
2509 print
'<td>'.$form->editfieldkey(
'WebServiceKey',
'webservices_key',
'', $object, 0).
'</td>';
2510 print
'<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.
'"></td></tr>';
2514 print
'<tr class="hideonsmartphone">';
2515 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2516 print
'<td colspan="3">';
2517 if ($object->logo) {
2518 print
$form->showphoto(
'societe', $object);
2521 if ($caneditfield) {
2522 if ($object->logo) {
2525 print
'<table class="nobordernopadding">';
2526 if ($object->logo) {
2527 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
2532 $maxmin = $maxfilesizearray[
'maxmin'];
2534 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2536 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2545 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2546 print
'<td colspan="3" class="maxwidthonsmartphone">';
2547 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
2548 $arrayselected =
GETPOST(
'commercial',
'array');
2549 if (empty($arrayselected)) {
2550 $arrayselected = $object->getSalesRepresentatives($user, 1);
2552 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2557 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2559 print
'<table class="border centpercent">';
2561 if (! empty($conf->accounting->enabled)) {
2563 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2565 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
2569 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2571 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
2575 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2576 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2580 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2581 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2591 print
$form->buttonsSaveCancel();
2600 if (!empty($object->id)) {
2601 $res = $object->fetch_optionals();
2613 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2614 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2617 if ($action ==
'merge') {
2618 $formquestion = array(
2620 'name' =>
'soc_origin',
2621 'label' => $langs->trans(
'MergeOriginThirdparty'),
2623 'value' =>
$form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200',
'',
'', 1,
null,
false, array($object->id))
2627 $formconfirm .=
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2632 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2633 if (empty($reshook)) {
2635 } elseif ($reshook > 0) {
2644 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2646 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2649 print
'<div class="fichecenter">';
2650 print
'<div class="fichehalfleft">';
2652 print
'<div class="underbanner clearboth"></div>';
2653 print
'<table class="border tableforfield centpercent">';
2656 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2657 print $object->getTypeUrl(1);
2661 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2662 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.
dol_escape_htmltag($object->prefix_comm).
'</td>';
2667 if ($object->client) {
2669 print $langs->trans(
'CustomerCode');
2673 $tmpcheck = $object->check_codeclient();
2674 if ($tmpcheck != 0 && $tmpcheck != -5) {
2675 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2682 if (((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) && $object->fournisseur) {
2684 print $langs->trans(
'SupplierCode').
'</td><td>';
2686 $tmpcheck = $object->check_codefournisseur();
2687 if ($tmpcheck != 0 && $tmpcheck != -5) {
2688 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2695 if (!empty($conf->barcode->enabled)) {
2705 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2706 if ($idprof !=
'-') {
2709 print
'<td>'.$idprof.
'</td><td>';
2712 if ($object->$key) {
2713 if ($object->id_prof_check($i, $object) > 0) {
2714 if (!empty($object->id_prof_url($i, $object))) {
2715 print
' '.$object->id_prof_url($i, $object);
2718 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
2735 if ($object->fournisseur) {
2738 print
$form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2740 print
yn($object->tva_assuj);
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) {
2826 $s .=
dol_print_profids($object->tva_intra,
'VATIntra', $object->country_code, 1);
2827 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2829 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
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 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2845 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans(
"VATIntraCheck").
'</a>';
2846 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2848 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2858 if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
2859 $langs->load(
'stocks');
2860 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2862 print
'<tr class="nowrap">';
2864 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->rights->societe->creer);
2866 if ($action ==
'editwarehouse') {
2867 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
2869 if ($object->fk_warehouse > 0) {
2870 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
2872 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
2881 print
'<div class="fichehalfright">';
2883 print
'<div class="underbanner clearboth"></div>';
2884 print
'<table class="border tableforfield centpercent">';
2887 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
2889 if ($object->prospect || $object->client || !empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT)) {
2890 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
2892 print
$form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
2897 if (((!empty($conf->fournisseur->enabled) && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (!empty($conf->supplier_order->enabled) && !empty($user->rights->supplier_order->lire)) || (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->supplier_invoice->lire))) && $object->fournisseur) {
2898 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
2900 print
$form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
2908 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
2909 if ($action !=
'editthirdpartytype' && $user->rights->societe->creer) {
2910 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>';
2912 print
'</tr></table>';
2914 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
2915 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
2919 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2920 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
2924 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
2927 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
2928 if ($object->capital) {
2929 if (!empty($conf->multicurrency->enabled) && !empty($object->multicurrency_code)) {
2930 print
price($object->capital,
'', $langs, 0, -1, -1, $object->multicurrency_code);
2932 print
price($object->capital,
'', $langs, 0, -1, -1, $conf->currency);
2940 if (!empty($conf->global->MAIN_MULTILANGS)) {
2941 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2942 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
2945 $langs->load(
"languages");
2946 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
2947 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
2953 if (!empty($conf->incoterm->enabled)) {
2955 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
2956 if ($action !=
'editincoterm' && $user->rights->societe->creer) {
2957 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
2959 print
'</tr></table>';
2960 print
'</td><td colspan="3">';
2961 if ($action !=
'editincoterm') {
2962 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2964 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.$object->id);
2970 if (!empty($conf->multicurrency->enabled)) {
2972 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2974 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
2978 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2980 print
'<tr><td class="nowrap">';
2981 print $langs->trans(
"ProductAccountancySellCode");
2982 print
'</td><td colspan="2">';
2983 if (! empty($conf->accounting->enabled)) {
2984 if (! empty($object->accountancy_code_sell)) {
2986 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
2988 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2991 print $object->accountancy_code_sell;
2996 print
'<tr><td class="nowrap">';
2997 print $langs->trans(
"ProductAccountancyBuyCode");
2998 print
'</td><td colspan="2">';
2999 if (! empty($conf->accounting->enabled)) {
3000 if (! empty($object->accountancy_code_buy)) {
3002 $accountingaccount2->fetch(
'', $object->accountancy_code_buy, 1);
3004 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3007 print $object->accountancy_code_buy;
3013 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3014 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3017 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
3019 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3020 if ($action !=
'editparentcompany' && $user->rights->societe->creer) {
3021 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>';
3023 print
'</tr></table>';
3025 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3026 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->parent, $html_name,
'', 1, 0, 0,
null, 0, array($object->id));
3031 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3034 if (!empty($conf->adherent->enabled)) {
3035 $langs->load(
"members");
3036 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3039 $result = $adh->fetch(
'',
'', $object->id);
3041 $adh->ref = $adh->getFullName($langs);
3042 print $adh->getNomUrl(-1);
3044 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3046 print
"</td></tr>\n";
3066 if (!empty($conf->syncsupplierwebservices->enabled)) {
3067 print
'<tr><td>'.$langs->trans(
"WebServiceURL").
'</td><td>'.
dol_print_url($object->webservices_url).
'</td>';
3068 print
'<td class="nowrap">'.$langs->trans(
'WebServiceKey').
'</td><td>'.$object->webservices_key.
'</td></tr>';
3075 print
'<div style="clear:both"></div>';
3083 if ($action !=
'presend') {
3084 print
'<div class="tabsAction">'.
"\n";
3087 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
3088 if (empty($reshook)) {
3089 $at_least_one_email_contact =
false;
3090 $TContact = $object->contact_array_objects();
3091 foreach ($TContact as &$contact) {
3092 if (!empty($contact->email)) {
3093 $at_least_one_email_contact =
true;
3098 if (empty($user->socid)) {
3099 $langs->load(
"mails");
3101 if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans(
'NoEMail'); }
3102 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);
3105 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
3107 if (!empty($conf->adherent->enabled)) {
3109 $result = $adh->fetch(
'',
'', $object->id);
3110 if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) {
3111 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";
3115 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=merge&token='.
newToken(),
'', $permissiontodelete);
3117 if ($user->rights->societe->supprimer) {
3118 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.
newToken();
3119 $buttonId =
'action-delete-no-ajax';
3120 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3122 $buttonId =
'action-delete';
3124 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3128 print
'</div>'.
"\n";
3132 if (
GETPOST(
'modelselected')) {
3133 $action =
'presend';
3136 if ($action !=
'presend') {
3137 print
'<div class="fichecenter"><div class="fichehalfleft">';
3139 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
3140 print
'<a name="builddoc"></a>';
3145 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
3146 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
3147 $genallowed = $user->rights->societe->lire;
3148 $delallowed = $user->rights->societe->creer;
3150 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);
3154 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) {
3158 print
'</div><div class="fichehalfright">';
3162 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
3165 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3167 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3169 print
'</div></div>';
3171 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
3173 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
3174 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3178 if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) {
3179 $result = show_addresses($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3185 $modelmail =
'thirdparty';
3186 $defaulttopic =
'Information';
3187 $diroutput = $conf->societe->multidir_output[$object->entity];
3188 $trackid =
'thi'.$object->id;
3190 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';