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' =>
'/don/class/don.class.php',
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' =>
'/ticket/class/ticket.class.php',
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 require_once DOL_DOCUMENT_ROOT.$object_file;
298 if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) {
308 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', array(
309 'soc_origin' => $soc_origin->id,
310 'soc_dest' => $object->id
311 ), $object, $action);
321 $object->context = array(
'merge'=>1,
'mergefromid'=>$soc_origin->id);
324 $result = $object->call_trigger(
'COMPANY_MODIFY', $user);
334 if ($soc_origin->delete($soc_origin->id, $user) < 1) {
343 $langs->load(
"errors");
351 if (
GETPOST(
'getcustomercode')) {
353 $_POST[
"customer_code"] =
"Acompleter";
356 if (
GETPOST(
'getsuppliercode')) {
358 $_POST[
"supplier_code"] =
"Acompleter";
361 if ($action ==
'set_localtax1') {
364 $object->fetch($socid);
365 $res = $object->setValueFrom(
'localtax1_value', $value,
'', null,
'text',
'', $user,
'COMPANY_MODIFY');
367 if ($action ==
'set_localtax2') {
370 $object->fetch($socid);
371 $res = $object->setValueFrom(
'localtax2_value', $value,
'', null,
'text',
'', $user,
'COMPANY_MODIFY');
374 if ($action ==
'update_extras') {
375 $object->fetch($socid);
380 $extrafields->fetch_name_optionals_label($object->table_element);
382 $ret = $extrafields->setOptionalsFromPost(null, $object,
GETPOST(
'attribute',
'restricthtml'));
388 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
396 $action =
'edit_extras';
402 && ($action ==
'add' || $action ==
'update') && $user->rights->societe->creer) {
403 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
406 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")), null,
'errors');
410 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")), null,
'errors');
414 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")), null,
'errors');
418 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))) {
420 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")), null,
'errors');
423 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))) {
425 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")), null,
'errors');
429 if ($action ==
'update') {
430 $ret = $object->fetch($socid);
431 $object->oldcopy = clone $object;
433 $object->canvas = $canvas;
436 if (
GETPOST(
"private",
'int') == 1) {
437 $object->particulier =
GETPOST(
"private",
'int');
440 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
442 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
443 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
445 $object->name =
GETPOST(
'name',
'alphanohtml');
448 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
449 $object->parent =
GETPOST(
'parent_company_id',
'int');
450 $object->address =
GETPOST(
'address',
'alphanohtml');
451 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
452 $object->town =
GETPOST(
'town',
'alphanohtml');
453 $object->country_id =
GETPOST(
'country_id',
'int');
454 $object->state_id =
GETPOST(
'state_id',
'int');
456 $object->socialnetworks = array();
457 if (!empty($conf->socialnetworks->enabled)) {
458 foreach ($socialnetworks as $key => $value) {
460 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
465 $object->phone =
GETPOST(
'phone',
'alpha');
466 $object->fax =
GETPOST(
'fax',
'alpha');
467 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
468 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
469 $object->idprof1 = trim(
GETPOST(
'idprof1',
'alphanohtml'));
470 $object->idprof2 = trim(
GETPOST(
'idprof2',
'alphanohtml'));
471 $object->idprof3 = trim(
GETPOST(
'idprof3',
'alphanohtml'));
472 $object->idprof4 = trim(
GETPOST(
'idprof4',
'alphanohtml'));
473 $object->idprof5 = trim(
GETPOST(
'idprof5',
'alphanohtml'));
474 $object->idprof6 = trim(
GETPOST(
'idprof6',
'alphanohtml'));
475 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
477 $object->code_fournisseur =
GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
478 $object->capital =
GETPOST(
'capital',
'alphanohtml');
479 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
481 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
482 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
483 $object->status =
GETPOST(
'status',
'alpha');
486 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
487 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
489 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
490 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
492 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
493 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
494 $object->typent_id =
GETPOST(
'typent_id',
'int');
496 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
498 $object->client =
GETPOST(
'client',
'int');
499 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
501 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
502 $object->default_lang =
GETPOST(
'default_lang');
505 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
506 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
509 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
511 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
512 $object->accountancy_code_sell =
'';
514 $object->accountancy_code_sell = $accountancy_code_sell;
518 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
520 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
521 $object->accountancy_code_buy =
'';
523 $object->accountancy_code_buy = $accountancy_code_buy;
528 if (!empty($conf->incoterm->enabled)) {
529 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
530 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
534 if (!empty($conf->multicurrency->enabled)) {
535 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
539 $ret = $extrafields->setOptionalsFromPost(null, $object);
545 $ret = $object->setValuesForExtraLanguages();
551 if (!empty($_FILES[
'photo'][
'name'])) {
552 $current_logo = $object->logo;
557 if (!
GETPOST(
'cancel',
'alpha')) {
558 if (!empty($object->email) && !isValidEMail($object->email)) {
559 $langs->load(
"errors");
561 setEventMessages(
'', $langs->trans(
"ErrorBadEMail", $object->email),
'errors');
563 if (!empty($object->url) && !
isValidUrl($object->url)) {
564 $langs->load(
"errors");
567 if (!empty($object->webservices_url)) {
569 if (strpos($object->webservices_url,
"http") ===
false) {
570 $object->webservices_url =
"http://".$object->webservices_url;
573 $langs->load(
"errors");
574 $error++; $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
579 $object->country_id =
GETPOST(
'country_id',
'int') !=
'' ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
580 if ($object->country_id) {
581 $tmparray =
getCountry($object->country_id,
'all');
582 $object->country_code = $tmparray[
'code'];
583 $object->country = $tmparray[
'label'];
589 if ($action ==
'add') {
594 if (empty($object->client)) {
595 $object->code_client =
'';
597 if (empty($object->fournisseur)) {
598 $object->code_fournisseur =
'';
601 $result = $object->create($user);
604 if ($object->particulier) {
605 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
606 $contcats =
GETPOST(
'contcats',
'array');
607 $no_email =
GETPOST(
'contact_no_email',
'int');
608 $result = $object->create_individual($user, $no_email, $contcats);
616 $salesreps =
GETPOST(
'commercial',
'array');
617 $result = $object->setSalesRep($salesreps,
true);
624 $custcats =
GETPOST(
'custcats',
'array');
625 $result = $object->setCategories($custcats,
'customer');
632 $suppcats =
GETPOST(
'suppcats',
'array');
633 $result = $object->setCategories($suppcats,
'supplier');
640 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
641 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
650 if (!($result > 0)) {
651 $errors[] =
"ErrorFailedToSaveFile";
654 $object->addThumbs($newfile);
659 switch ($_FILES[
'photo'][
'error']) {
662 $errors[] =
"ErrorFileSizeTooLarge";
665 $errors[] =
"ErrorFilePartiallyUploaded";
670 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors)) {
671 $duplicate_code_error =
true;
672 $object->code_client = null;
675 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors)) {
676 $duplicate_code_error =
true;
677 $object->code_fournisseur = null;
680 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
681 $duplicate_code_error =
true;
688 if ($result >= 0 && !$error) {
691 if ($backtopagejsfields) {
694 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
695 $dol_openinpopup = $tmpbacktopagejsfields[0];
697 $retstring =
'<script>';
698 $retstring .=
'jQuery(document).ready(function() {
699 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
700 console.log(\
'id = '.$object->id.
'\');
701 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->id.
'\');
702 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->name.
'\');
703 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
705 $retstring .=
'</script>';
712 if (!empty($backtopage)) {
713 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
714 if (preg_match(
'/\?/', $backtopage)) {
715 $backtopage .=
'&socid='.$object->id;
717 header(
"Location: ".$backtopage);
720 $url = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
721 if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
722 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".$object->id;
723 } elseif ($object->fournisseur == 1) {
724 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".$object->id;
727 header(
"Location: ".$url);
736 if ($action ==
'update') {
739 if (
GETPOST(
'cancel',
'alpha')) {
740 if (!empty($backtopage)) {
741 header(
"Location: ".$backtopage);
744 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
750 if (empty($object->client) && empty($object->oldcopy->code_client)) {
751 $object->code_client =
'';
753 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
754 $object->code_fournisseur =
'';
758 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
766 $salesreps =
GETPOST(
'commercial',
'array');
767 $result = $object->setSalesRep($salesreps);
774 if (!$error && !empty($user->rights->categorie->lire)) {
776 $categories =
GETPOST(
'custcats',
'array');
777 $result = $object->setCategories($categories,
'customer');
784 $categories =
GETPOST(
'suppcats',
'array');
785 $result = $object->setCategories($categories,
'supplier');
793 $dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id.
"/logos";
794 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
795 if (
GETPOST(
'deletephoto') && $object->logo) {
796 $fileimg = $dir.
'/'.$object->logo;
797 $dirthumbs = $dir.
'/thumbs';
803 if ($current_logo != $object->logo) {
804 $fileimg = $dir.
'/'.$current_logo;
805 $dirthumbs = $dir.
'/thumbs';
816 if (!($result > 0)) {
817 $errors[] =
"ErrorFailedToSaveFile";
820 $object->addThumbs($newfile);
823 if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) {
824 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
833 $errors[] =
"ErrorBadImageFormat";
836 switch ($_FILES[
'photo'][
'error']) {
839 $errors[] =
"ErrorFileSizeTooLarge";
842 $errors[] =
"ErrorFilePartiallyUploaded";
850 if (!$error && $object->fk_soc > 0) {
851 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
852 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
853 if (!$object->db->query($sql)) {
855 $object->error .= $object->db->lasterror();
860 if (!$error && !count($errors)) {
861 if (!empty($backtopage)) {
862 header(
"Location: ".$backtopage);
865 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
869 $object->id = $socid;
874 $action = ($action ==
'add' ?
'create' :
'edit');
879 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->societe->supprimer) {
880 $object->fetch($socid);
881 $object->oldcopy = clone $object;
882 $result = $object->delete($socid, $user);
885 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
888 $langs->load(
"errors");
896 if ($action ==
'set_thirdpartytype' && $user->rights->societe->creer) {
897 $object->fetch($socid);
898 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
902 if ($action ==
'set_incoterms' && $user->rights->societe->creer && !empty($conf->incoterm->enabled)) {
903 $object->fetch($socid);
904 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
908 if ($action ==
'set_thirdparty' && $user->rights->societe->creer) {
909 $object->fetch($socid);
910 $result = $object->setParent(
GETPOST(
'parent_id',
'int'));
914 if ($action ==
'set_salesrepresentatives' && $user->rights->societe->creer) {
915 $object->fetch($socid);
916 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
920 if ($action ==
'setwarehouse' && $user->rights->societe->creer) {
921 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
925 $object->fetch($socid);
928 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
929 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
933 $triggersendname =
'COMPANY_SENTBYMAIL';
934 $paramname =
'socid';
935 $mode =
'emailfromthirdparty';
936 $trackid =
'thi'.$object->id;
937 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
941 $upload_dir = !empty($conf->societe->multidir_output[$object->entity])?$conf->societe->multidir_output[$object->entity]:$conf->societe->dir_output;
942 $permissiontoadd = $user->rights->societe->creer;
943 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
955 if (!empty($conf->accounting->enabled)) {
959 if ($socid > 0 && empty($object->id)) {
960 $result = $object->fetch($socid);
967 $title = $langs->trans(
"ThirdParty");
968 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
969 $title = $object->name.
" - ".$langs->trans(
'Card');
972 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
976 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
978 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
982 $objcanvas->assign_values($action, $object->id, $object->ref);
983 $objcanvas->display_canvas($action);
988 if ($action ==
'create') {
992 $private =
GETPOST(
"private",
"int");
993 if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !
GETPOSTISSET(
'private')) {
996 if (empty($private)) {
1001 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1002 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1003 $module = substr($module, 0,
dol_strlen($module) - 4);
1005 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1006 foreach ($dirsociete as $dirroot) {
1012 $modCodeClient =
new $module;
1014 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1015 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1016 $module = substr($module, 0,
dol_strlen($module) - 4);
1018 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1019 foreach ($dirsociete as $dirroot) {
1025 $modCodeFournisseur =
new $module;
1028 if (
GETPOST(
"type",
'aZ') !=
'f') {
1029 $object->client = -1;
1030 if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) {
1031 $object->client = 3;
1035 if (
GETPOST(
"type",
'aZ') ==
'c') {
1036 if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
1037 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
1039 $object->client = 3;
1042 if (
GETPOST(
"type",
'aZ') ==
'p') {
1043 $object->client = 2;
1046 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) {
1047 $object->client = 1;
1050 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)))) {
1051 $object->fournisseur = 1;
1054 $object->name =
GETPOST(
'name',
'alphanohtml');
1055 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1056 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
1057 $object->particulier = $private;
1058 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1059 $object->client =
GETPOST(
'client',
'int') ?
GETPOST(
'client',
'int') : $object->client;
1061 if (empty($duplicate_code_error)) {
1062 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1063 $object->fournisseur =
GETPOST(
'fournisseur') ?
GETPOST(
'fournisseur',
'int') : $object->fournisseur;
1064 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1066 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
'',
'warnings');
1069 $object->address =
GETPOST(
'address',
'alphanohtml');
1070 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1071 $object->town =
GETPOST(
'town',
'alphanohtml');
1072 $object->state_id =
GETPOST(
'state_id',
'int');
1074 $object->socialnetworks = array();
1075 if (!empty($conf->socialnetworks->enabled)) {
1076 foreach ($socialnetworks as $key => $value) {
1078 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1083 $object->phone =
GETPOST(
'phone',
'alpha');
1084 $object->fax =
GETPOST(
'fax',
'alpha');
1085 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1086 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1087 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1088 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1089 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1090 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1091 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1092 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1093 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1094 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1095 $object->typent_id =
GETPOST(
'typent_id',
'int');
1096 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1097 $object->civility_id =
GETPOST(
'civility_id',
'alpha');
1099 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1100 $object->status =
GETPOST(
'status',
'int');
1103 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1104 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1106 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1107 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1109 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1111 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1112 $object->default_lang =
GETPOST(
'default_lang');
1115 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1117 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1118 $object->accountancy_code_sell =
'';
1120 $object->accountancy_code_sell = $accountancy_code_sell;
1124 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1126 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1127 $object->accountancy_code_buy =
'';
1129 $object->accountancy_code_buy = $accountancy_code_buy;
1133 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
1136 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos";
1137 $file_OK = (isset($_FILES[
'photo']) ?is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1142 if (@is_dir($dir)) {
1146 if (!($result > 0)) {
1147 $errors[] =
"ErrorFailedToSaveFile";
1150 $object->addThumbs($newfile);
1157 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1158 if ($object->country_id) {
1159 $tmparray =
getCountry($object->country_id,
'all');
1160 $object->country_code = $tmparray[
'code'];
1161 $object->country = $tmparray[
'label'];
1163 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
1166 if (!empty($conf->multicurrency->enabled)) {
1167 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1172 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1174 if (!empty($conf->use_javascript_ajax)) {
1175 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1176 print
"\n".
'<script type="text/javascript">';
1177 print
'$(document).ready(function () {
1180 is_private=' . $private.
';
1182 $(".individualline").show();
1184 $(".individualline").hide();
1186 $("#radiocompany").click(function() {
1187 $(".individualline").hide();
1188 $("#typent_id").val(0);
1189 $("#typent_id").change();
1190 $("#effectif_id").val(0);
1191 $("#effectif_id").change();
1192 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1193 document.formsoc.private.value=0;
1195 $("#radioprivate").click(function() {
1196 $(".individualline").show();
1197 $("#typent_id").val(id_te_private);
1198 $("#typent_id").change();
1199 $("#effectif_id").val(id_ef15);
1200 $("#effectif_id").change();
1201 /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
1202 if ($("#civility_id").data("select2")) {
1203 $("#civility_id").select2({width: "resolve"});
1205 $("#TypeName").html(document.formsoc.LastName.value);
1206 document.formsoc.private.value=1;
1209 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
1211 init_customer_categ();
1212 $("#customerprospect").change(function() {
1213 init_customer_categ();
1215 function init_customer_categ() {
1216 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1217 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
1219 jQuery(".visibleifcustomer").hide();
1223 jQuery(".visibleifcustomer").show();
1227 init_supplier_categ();
1228 $("#fournisseur").change(function() {
1229 init_supplier_categ();
1231 function init_supplier_categ() {
1232 console.log("is supplier = "+jQuery("#fournisseur").val());
1233 if (jQuery("#fournisseur").val() == 0)
1235 jQuery(".visibleifsupplier").hide();
1239 jQuery(".visibleifsupplier").show();
1243 $("#selectcountry_id").change(function() {
1244 document.formsoc.action.value="create";
1245 document.formsoc.submit();
1247 if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1249 function init_check_no_email(input) {
1250 if (input.val()!="") {
1251 $(".noemail").addClass("fieldrequired");
1253 $(".noemail").removeClass("fieldrequired");
1256 $("#email").keyup(function() {
1257 init_check_no_email($(this));
1259 init_check_no_email($("#email"));';
1262 print
'</script>'.
"\n";
1264 print
'<div id="selectthirdpartytype">';
1265 print
'<div class="hideonsmartphone float">';
1266 print $langs->trans(
"ThirdPartyType").
': ';
1268 print
'<label for="radiocompany" class="radiocompany">';
1269 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1271 print $langs->trans(
"CreateThirdPartyOnly");
1273 print
' ';
1274 print
'<label for="radioprivate" class="radioprivate">';
1275 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1277 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1278 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1279 print
$form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1284 print
'<script type="text/javascript">';
1285 print
'$(document).ready(function () {
1286 $("#selectcountry_id").change(function() {
1287 document.formsoc.action.value="create";
1288 document.formsoc.submit();
1291 print
'</script>'.
"\n";
1297 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1299 print
'<input type="hidden" name="action" value="add">';
1300 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1301 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1302 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1303 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1304 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1305 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1306 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1307 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1308 print
'<input type="hidden" name="code_auto" value="1">';
1313 print
'<table class="border centpercent">';
1316 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1317 if ($object->particulier || $private) {
1318 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1320 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1322 print
'</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ?
' colspan="3"' :
'').
'>';
1324 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
1325 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
1420 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
1421 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>';
1426 if ($conf->use_javascript_ajax) {
1427 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1429 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1430 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).
'"></td>';
1434 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1435 print $formcompany->select_civility($object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1441 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1442 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>';
1445 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1446 print
'<td class="maxwidthonsmartphone">';
1448 print $formcompany->selectProspectCustomerType($selected);
1451 if ($conf->browser->layout ==
'phone') {
1455 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1456 print
'<table class="nobordernopadding"><tr><td>';
1457 $tmpcode = $object->code_client;
1458 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1459 $tmpcode = $modCodeClient->getNextValue($object, 0);
1461 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1463 $s = $modCodeClient->getToolTip($langs, $object, 0);
1464 print
$form->textwithpicto(
'', $s, 1);
1465 print
'</td></tr></table>';
1468 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))
1469 || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) {
1472 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
1474 if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) {
1477 print
$form->selectyesno(
"fournisseur", (
GETPOST(
'fournisseur',
'int') !=
'' ?
GETPOST(
'fournisseur',
'int') : (
GETPOST(
"type",
'alpha') ==
'' ? $default : $object->fournisseur)), 1, 0, (
GETPOST(
"type",
'alpha') ==
'' ? 1 : 0), 1);
1481 if ($conf->browser->layout ==
'phone') {
1486 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))) {
1487 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1490 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))) {
1491 print
'<table class="nobordernopadding"><tr><td>';
1492 $tmpcode = $object->code_fournisseur;
1493 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1494 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1496 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1498 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1499 print
$form->textwithpicto(
'', $s, 1);
1500 print
'</td></tr></table>';
1506 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
1507 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1511 if (!empty($conf->barcode->enabled)) {
1512 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1513 print
'<td colspan="3">';
1514 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1515 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
1520 print
'<tr><td class="tdtop">';
1521 print
$form->editfieldkey(
'Address',
'address',
'', $object, 0);
1523 print
'<td colspan="3">';
1524 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1526 print
'</textarea>';
1527 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1531 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1532 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1534 if ($conf->browser->layout ==
'phone') {
1537 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1538 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1539 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1543 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1544 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1545 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
1547 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1552 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1553 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)) {
1554 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1556 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1559 if ($object->country_id) {
1560 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1561 print $formcompany->select_state($object->state_id, $object->country_code);
1563 print $countrynotdefined;
1569 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1570 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>';
1571 if ($conf->browser->layout ==
'phone') {
1574 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1575 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>';
1578 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ?
'' : $conf->global->SOCIETE_EMAIL_MANDATORY).
'</td>';
1579 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>';
1580 if (!empty($conf->mailing->enabled) && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1581 if ($conf->browser->layout ==
'phone') {
1584 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1585 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>';
1588 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1589 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.
'"></td></tr>';
1592 if (!empty($conf->socialnetworks->enabled)) {
1593 foreach ($socialnetworks as $key => $value) {
1594 if ($value[
'active']) {
1596 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1597 print
'<td colspan="3">';
1598 if (!empty($value[
'icon'])) {
1599 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1601 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])).
'">';
1604 } elseif (!empty($object->socialnetworks[$key])) {
1605 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1611 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1613 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1614 if ($idprof !=
'-') {
1617 if (($j % $NBCOLS) == 0) {
1621 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1622 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1624 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1626 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1633 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1634 print
'<td colspan="2"></td></tr>';
1638 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1640 print
$form->selectyesno(
'assujtva_value',
GETPOSTISSET(
'assujtva_value') ?
GETPOST(
'assujtva_value',
'int') : 1, 1);
1642 if ($conf->browser->layout ==
'phone') {
1645 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1646 print
'<td class="nowrap">';
1647 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1649 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
1652 if (!empty($conf->use_javascript_ajax)) {
1654 if (!empty($conf->dol_use_jmobile)) {
1659 print
'<script type="text/javascript">';
1660 print
"function CheckVAT(a) {\n";
1661 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1665 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1666 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1668 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1677 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1678 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1679 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1681 if ($conf->browser->layout ==
'phone') {
1684 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1685 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1687 } elseif ($mysoc->localtax1_assuj ==
"1") {
1688 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1689 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1691 } elseif ($mysoc->localtax2_assuj ==
"1") {
1692 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1693 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1698 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";
1699 $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1700 print
$form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1702 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1704 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
1706 if ($conf->browser->layout ==
'phone') {
1709 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1710 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1712 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1715 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1720 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1721 print
'<td colspan="3" class="maxwidthonsmartphone">';
1722 if ($object->country_id) {
1723 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1725 print $countrynotdefined;
1730 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1731 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1732 if (!empty($conf->multicurrency->enabled)) {
1733 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
1735 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
1737 if (!empty($conf->global->MAIN_MULTILANGS)) {
1738 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1739 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');
1745 if (!empty($conf->incoterm->enabled)) {
1747 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1748 print
'<td colspan="3" class="maxwidthonsmartphone">';
1749 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1754 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1755 $langs->load(
'categories');
1758 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1759 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER, null,
'parent', null, null, 1);
1760 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'), null, null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1763 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1764 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1765 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT, null,
'parent', null, null, 1);
1766 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'), null, null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1771 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) {
1772 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1773 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER, null,
'parent', null, null, 1);
1774 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'), null, null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1780 if (!empty($conf->multicurrency->enabled)) {
1782 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1783 print
'<td colspan="3" class="maxwidthonsmartphone">';
1784 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1);
1789 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1790 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1793 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
1795 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1796 print
'<td colspan="3" class="maxwidthonsmartphone">';
1797 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1798 print
$form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0, null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1804 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1805 print
'<td colspan="3" class="maxwidthonsmartphone">';
1806 $userlist =
$form->select_dolusers(
'',
'', 0, null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
1808 $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())));
1809 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected, null, null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1813 print
'<tr class="hideonsmartphone">';
1814 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1815 print
'<td colspan="3">';
1816 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1820 print
'</table>'.
"\n";
1823 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
1824 print
'<table class="border" width="100%">';
1826 if (! empty($conf->accounting->enabled)) {
1828 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1830 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1831 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, null, 1, 1,
'');
1835 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1837 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1838 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, null, 1, 1,
'');
1842 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1843 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1847 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1848 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1857 print
$form->buttonsSaveCancel(
"AddThirdParty",
'Cancel', null, 0,
'', $dol_openinpopup);
1859 print
'</form>'.
"\n";
1860 } elseif ($action ==
'edit') {
1864 $res = $object->fetch_optionals();
1870 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1871 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1872 $module = substr($module, 0,
dol_strlen($module) - 4);
1874 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1875 foreach ($dirsociete as $dirroot) {
1881 $modCodeClient =
new $module($db);
1883 if ($modCodeClient->code_auto) {
1884 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1886 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1887 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1888 $module = substr($module, 0,
dol_strlen($module) - 4);
1890 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1891 foreach ($dirsociete as $dirroot) {
1897 $modCodeFournisseur =
new $module($db);
1899 if ($modCodeFournisseur->code_auto) {
1900 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1903 $object->oldcopy = clone $object;
1907 $object->name =
GETPOST(
'name',
'alphanohtml');
1908 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1909 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1910 $object->client =
GETPOST(
'client',
'int');
1911 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1912 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
1913 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1914 $object->address =
GETPOST(
'address',
'alphanohtml');
1915 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1916 $object->town =
GETPOST(
'town',
'alphanohtml');
1917 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
1918 $object->state_id =
GETPOST(
'state_id',
'int');
1920 $object->socialnetworks = array();
1921 if (!empty($conf->socialnetworks->enabled)) {
1922 foreach ($socialnetworks as $key => $value) {
1924 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1929 $object->phone =
GETPOST(
'phone',
'alpha');
1930 $object->fax =
GETPOST(
'fax',
'alpha');
1931 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1932 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1933 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1934 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1935 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1936 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1937 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1938 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1939 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1940 $object->typent_id =
GETPOST(
'typent_id',
'int');
1941 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1942 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1943 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
1944 $object->default_lang =
GETPOST(
'default_lang',
'alpha');
1946 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1947 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1948 $object->status =
GETPOST(
'status',
'int');
1951 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
1952 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
1955 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1957 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1958 $object->accountancy_code_sell =
'';
1960 $object->accountancy_code_sell = $accountancy_code_sell;
1964 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1966 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1967 $object->accountancy_code_buy =
'';
1969 $object->accountancy_code_buy = $accountancy_code_buy;
1974 if (!empty($conf->incoterm->enabled)) {
1975 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
1976 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
1980 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value');
1981 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value');
1983 $object->localtax1_value =
GETPOST(
'lt1');
1984 $object->localtax2_value =
GETPOST(
'lt2');
1987 if ($object->country_id > 0) {
1988 $tmparray =
getCountry($object->country_id,
'all');
1989 $object->country_code = $tmparray[
'code'];
1990 $object->country = $tmparray[
'label'];
1994 if (!empty($conf->multicurrency->enabled)) {
1995 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $object->multicurrency_code;
1999 if ($object->localtax1_assuj == 0) {
2004 if ($object->localtax2_assuj == 0) {
2010 if (!empty($conf->use_javascript_ajax)) {
2011 print
"\n".
'<script type="text/javascript">';
2012 print
'$(document).ready(function () {
2015 if("#localtax1assuj_value".value==undefined){
2022 if("#localtax2assuj_value".value==undefined){
2029 $("#localtax1assuj_value").change(function() {
2030 var value=document.getElementById("localtax1assuj_value").value;
2037 $("#localtax2assuj_value").change(function() {
2038 var value=document.getElementById("localtax2assuj_value").value;
2046 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
2048 init_customer_categ();
2049 $("#customerprospect").change(function() {
2050 init_customer_categ();
2052 function init_customer_categ() {
2053 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
2054 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
2056 jQuery(".visibleifcustomer").hide();
2060 jQuery(".visibleifcustomer").show();
2064 init_supplier_categ();
2065 $("#fournisseur").change(function() {
2066 init_supplier_categ();
2068 function init_supplier_categ() {
2069 console.log("is supplier = "+jQuery("#fournisseur").val());
2070 if (jQuery("#fournisseur").val() == 0)
2072 jQuery(".visibleifsupplier").hide();
2076 jQuery(".visibleifsupplier").show();
2080 $("#selectcountry_id").change(function() {
2081 document.formsoc.action.value="edit";
2082 document.formsoc.submit();
2086 print
'</script>'.
"\n";
2089 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post" name="formsoc">';
2090 print
'<input type="hidden" name="action" value="update">';
2091 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2092 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2093 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2094 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2095 print
'<input type="hidden" name="code_auto" value="1">';
2101 print
'<div class="fichecenter2">';
2102 print
'<table class="border centpercent">';
2105 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2106 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2112 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0,
'string',
'', 1).
'</td>';
2113 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
2114 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
2118 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
2119 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>';
2122 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2123 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'', $object, 0).
'</td><td colspan="3">';
2125 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
2126 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2127 print $object->prefix_comm;
2129 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2135 print
'<tr><td>'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
2136 print
'<td class="maxwidthonsmartphone">';
2137 print $formcompany->selectProspectCustomerType($object->client);
2139 if ($conf->browser->layout ==
'phone') {
2142 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
2144 print
'<table class="nobordernopadding"><tr><td>';
2145 if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) {
2146 $tmpcode = $object->code_client;
2147 if (empty($tmpcode) && !empty($object->oldcopy->code_client)) {
2148 $tmpcode = $object->oldcopy->code_client;
2150 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2151 $tmpcode = $modCodeClient->getNextValue($object, 0);
2153 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2154 } elseif ($object->codeclient_modifiable()) {
2155 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).
'" maxlength="24">';
2157 print $object->code_client;
2158 print
'<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).
'">';
2161 $s = $modCodeClient->getToolTip($langs, $object, 0);
2162 print
$form->textwithpicto(
'', $s, 1);
2163 print
'</td></tr></table>';
2168 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)))
2169 || (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->lire))) {
2171 print
'<td>'.$form->editfieldkey(
'Supplier',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td>';
2172 print
'<td class="maxwidthonsmartphone">';
2173 print
$form->selectyesno(
"fournisseur", $object->fournisseur, 1,
false, 0, 1);
2175 if ($conf->browser->layout ==
'phone') {
2179 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))) {
2180 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
2184 print
'<table class="nobordernopadding"><tr><td>';
2185 if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
2186 $tmpcode = $object->code_fournisseur;
2187 if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) {
2188 $tmpcode = $object->oldcopy->code_fournisseur;
2190 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2191 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2193 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2194 } elseif ($object->codefournisseur_modifiable()) {
2195 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).
'" maxlength="24">';
2197 print $object->code_fournisseur;
2198 print
'<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.
'">';
2201 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2202 print
$form->textwithpicto(
'', $s, 1);
2203 print
'</td></tr></table>';
2208 if (!empty($conf->barcode->enabled)) {
2209 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
2210 print
'<td colspan="3">';
2212 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
2217 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
2218 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), $object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2222 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2223 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2225 print
'</textarea>';
2226 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2230 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
2231 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2233 if ($conf->browser->layout ==
'phone') {
2236 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
2237 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2238 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2242 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td colspan="3">';
2243 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2244 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
2246 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2251 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
2252 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)) {
2253 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2255 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2258 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2259 print $formcompany->select_state($object->state_id, $object->country_code);
2264 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'), $object, 0).
'</td>';
2265 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>';
2266 if ($conf->browser->layout ==
'phone') {
2269 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
2270 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>';
2273 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
2274 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>';
2275 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'), $object, 0).
'</td>';
2276 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>';
2279 if (!empty($conf->socialnetworks->enabled)) {
2280 foreach ($socialnetworks as $key => $value) {
2281 if ($value[
'active']) {
2283 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
2284 print
'<td colspan="3">';
2285 if (!empty($value[
'icon'])) {
2286 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2288 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth500 widthcentpercentminusx" maxlength="80" value="'.(empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key]).
'">';
2291 } elseif (!empty($object->socialnetworks[$key])) {
2292 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2300 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2302 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2303 if ($idprof !=
'-') {
2306 if (($j % $NBCOLS) == 0) {
2310 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2311 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).
'</td><td>';
2312 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2314 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2321 if ($NBCOLS > 0 && $j % 2 == 1) {
2322 print
'<td colspan="2"></td></tr>';
2326 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2327 print
$form->selectyesno(
'assujtva_value', $object->tva_assuj, 1);
2332 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2333 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td>';
2334 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2336 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2337 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2342 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2343 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2345 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2346 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2350 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2351 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2352 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2354 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2355 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2359 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2360 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2361 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2363 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2364 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2371 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2372 print
'<td colspan="3">';
2373 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2375 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2378 if ($conf->use_javascript_ajax) {
2380 if (!empty($conf->dol_use_jmobile)) {
2385 print
'<script type="text/javascript">';
2386 print
"function CheckVAT(a) {\n";
2387 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2391 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2392 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2394 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2402 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"' :
'').
'>';
2403 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);
2405 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2407 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2409 if ($conf->browser->layout ==
'phone') {
2412 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2413 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2415 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2418 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2423 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2424 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
2428 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2429 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2431 if (!empty($conf->multicurrency->enabled)) {
2432 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
2434 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2438 if (!empty($conf->global->MAIN_MULTILANGS)) {
2439 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2440 print
img_picto(
'',
'language').$formadmin->select_language($object->default_lang,
'default_lang', 0, 0, 1);
2446 if (!empty($conf->incoterm->enabled)) {
2448 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2449 print
'<td colspan="3" class="maxwidthonsmartphone">';
2450 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
2455 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
2457 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2458 print
'<td colspan="3">';
2459 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1);
2461 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2462 $arrayselected = array();
2463 foreach ($cats as $cat) {
2464 $arrayselected[] = $cat->id;
2466 print
img_picto(
'',
'category').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2470 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))) {
2471 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2472 print
'<td colspan="3">';
2473 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1);
2475 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2476 $arrayselected = array();
2477 foreach ($cats as $cat) {
2478 $arrayselected[] = $cat->id;
2480 print
img_picto(
'',
'category').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2486 if (!empty($conf->multicurrency->enabled)) {
2488 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2489 print
'<td colspan="3" class="maxwidthonsmartphone">';
2490 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1);
2495 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2496 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2499 if (!empty($conf->syncsupplierwebservices->enabled)) {
2500 print
'<tr><td>'.$form->editfieldkey(
'WebServiceURL',
'webservices_url',
'', $object, 0).
'</td>';
2501 print
'<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.
'"></td>';
2502 print
'<td>'.$form->editfieldkey(
'WebServiceKey',
'webservices_key',
'', $object, 0).
'</td>';
2503 print
'<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.
'"></td></tr>';
2507 print
'<tr class="hideonsmartphone">';
2508 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2509 print
'<td colspan="3">';
2510 if ($object->logo) {
2511 print
$form->showphoto(
'societe', $object);
2514 if ($caneditfield) {
2515 if ($object->logo) {
2518 print
'<table class="nobordernopadding">';
2519 if ($object->logo) {
2520 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
2525 $maxmin = $maxfilesizearray[
'maxmin'];
2527 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2529 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2538 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2539 print
'<td colspan="3" class="maxwidthonsmartphone">';
2540 $userlist =
$form->select_dolusers(
'',
'', 0, null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
2541 $arrayselected =
GETPOST(
'commercial',
'array');
2542 if (empty($arrayselected)) {
2543 $arrayselected = $object->getSalesRepresentatives($user, 1);
2545 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2550 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2552 print
'<table class="border centpercent">';
2554 if (! empty($conf->accounting->enabled)) {
2556 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2558 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
2562 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2564 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
2568 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2569 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2573 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2574 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2584 print
$form->buttonsSaveCancel();
2593 if (!empty($object->id)) {
2594 $res = $object->fetch_optionals();
2606 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2607 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2610 if ($action ==
'merge') {
2611 $formquestion = array(
2613 'name' =>
'soc_origin',
2614 'label' => $langs->trans(
'MergeOriginThirdparty'),
2616 'value' =>
$form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200',
'',
'', 1, null,
false, array($object->id))
2620 $formconfirm .=
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2624 $parameters = array(
'formConfirm' => $formconfirm);
2625 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2626 if (empty($reshook)) {
2627 $formconfirm .= $hookmanager->resPrint;
2628 } elseif ($reshook > 0) {
2629 $formconfirm = $hookmanager->resPrint;
2637 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2639 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2642 print
'<div class="fichecenter">';
2643 print
'<div class="fichehalfleft">';
2645 print
'<div class="underbanner clearboth"></div>';
2646 print
'<table class="border tableforfield centpercent">';
2649 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2650 print $object->getTypeUrl(1);
2654 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2655 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.
dol_escape_htmltag($object->prefix_comm).
'</td>';
2660 if ($object->client) {
2662 print $langs->trans(
'CustomerCode');
2666 $tmpcheck = $object->check_codeclient();
2667 if ($tmpcheck != 0 && $tmpcheck != -5) {
2668 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2675 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) {
2677 print $langs->trans(
'SupplierCode').
'</td><td>';
2679 $tmpcheck = $object->check_codefournisseur();
2680 if ($tmpcheck != 0 && $tmpcheck != -5) {
2681 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2688 if (!empty($conf->barcode->enabled)) {
2698 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2699 if ($idprof !=
'-') {
2702 print
'<td>'.$idprof.
'</td><td>';
2705 if ($object->$key) {
2706 if ($object->id_prof_check($i, $object) > 0) {
2707 if (!empty($object->id_prof_url($i, $object))) {
2708 print
' '.$object->id_prof_url($i, $object);
2711 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
2728 if ($object->fournisseur) {
2731 print
$form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2733 print
yn($object->tva_assuj);
2739 if ($object->fournisseur || $mysoc->country_code ==
'ES') {
2740 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2741 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2742 print
yn($object->localtax1_assuj);
2743 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2744 print
yn($object->localtax2_assuj);
2748 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2749 print
'<input type="hidden" name="action" value="set_localtax1">';
2750 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2751 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>';
2752 if ($action ==
'editRE') {
2753 print
'<td class="left">';
2754 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2755 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2757 print
'<td>'.$object->localtax1_value.
'</td>';
2759 print
'</tr></form>';
2762 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2763 print
'<input type="hidden" name="action" value="set_localtax2">';
2764 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2765 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>';
2766 if ($action ==
'editIRPF') {
2767 print
'<td class="left">';
2768 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2769 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2771 print
'<td>'.$object->localtax2_value.
'</td>';
2773 print
'</tr></form>';
2775 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2776 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2777 print
yn($object->localtax1_assuj);
2780 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2781 print
'<input type="hidden" name="action" value="set_localtax1">';
2782 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2783 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>';
2784 if ($action ==
'editRE') {
2785 print
'<td class="left">';
2786 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2787 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2789 print
'<td>'.$object->localtax1_value.
'</td>';
2791 print
'</tr></form>';
2793 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2794 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2795 print
yn($object->localtax2_assuj);
2798 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2799 print
'<input type="hidden" name="action" value="set_localtax2">';
2800 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2801 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>';
2802 if ($action ==
'editIRPF') {
2803 print
'<td class="left">';
2804 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2805 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2807 print
'<td>'.$object->localtax2_value.
'</td>';
2809 print
'</tr></form>';
2816 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
2817 if ($object->tva_intra) {
2819 $s .=
dol_print_profids($object->tva_intra,
'VATIntra', $object->country_code, 1);
2820 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2822 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2825 if ($conf->use_javascript_ajax) {
2827 if (!empty($conf->dol_use_jmobile)) {
2832 print
'<script type="text/javascript">';
2833 print
"function CheckVAT(a) {\n";
2834 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2838 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans(
"VATIntraCheck").
'</a>';
2839 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2841 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2851 if (!empty($conf->stock->enabled) && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
2852 $langs->load(
'stocks');
2853 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2855 print
'<tr class="nowrap">';
2857 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->rights->societe->creer);
2859 if ($action ==
'editwarehouse') {
2860 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
2862 if ($object->fk_warehouse > 0) {
2863 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
2865 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
2874 print
'<div class="fichehalfright">';
2876 print
'<div class="underbanner clearboth"></div>';
2877 print
'<table class="border tableforfield centpercent">';
2880 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
2882 if ($object->prospect || $object->client || !empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT)) {
2883 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
2885 print
$form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
2890 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) {
2891 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
2893 print
$form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
2901 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
2902 if ($action !=
'editthirdpartytype' && $user->rights->societe->creer) {
2903 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>';
2905 print
'</tr></table>';
2907 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
2908 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
2912 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2913 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
2917 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
2920 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
2921 if ($object->capital) {
2922 if (!empty($conf->multicurrency->enabled) && !empty($object->multicurrency_code)) {
2923 print
price($object->capital,
'', $langs, 0, -1, -1, $object->multicurrency_code);
2925 print
price($object->capital,
'', $langs, 0, -1, -1, $conf->currency);
2933 if (!empty($conf->global->MAIN_MULTILANGS)) {
2934 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2935 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
2938 $langs->load(
"languages");
2939 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
2940 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
2946 if (!empty($conf->incoterm->enabled)) {
2948 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
2949 if ($action !=
'editincoterm' && $user->rights->societe->creer) {
2950 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
2952 print
'</tr></table>';
2953 print
'</td><td colspan="3">';
2954 if ($action !=
'editincoterm') {
2955 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
2957 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.$object->id);
2963 if (!empty($conf->multicurrency->enabled)) {
2965 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2967 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
2971 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2973 print
'<tr><td class="nowrap">';
2974 print $langs->trans(
"ProductAccountancySellCode");
2975 print
'</td><td colspan="2">';
2976 if (! empty($conf->accounting->enabled)) {
2977 if (! empty($object->accountancy_code_sell)) {
2979 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
2981 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2984 print $object->accountancy_code_sell;
2989 print
'<tr><td class="nowrap">';
2990 print $langs->trans(
"ProductAccountancyBuyCode");
2991 print
'</td><td colspan="2">';
2992 if (! empty($conf->accounting->enabled)) {
2993 if (! empty($object->accountancy_code_buy)) {
2995 $accountingaccount2->fetch(
'', $object->accountancy_code_buy, 1);
2997 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3000 print $object->accountancy_code_buy;
3006 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3007 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3010 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
3012 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3013 if ($action !=
'editparentcompany' && $user->rights->societe->creer) {
3014 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>';
3016 print
'</tr></table>';
3018 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3019 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->parent, $html_name,
'', 1, 0, 0, null, 0, array($object->id));
3024 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3027 if (!empty($conf->adherent->enabled)) {
3028 $langs->load(
"members");
3029 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3032 $result = $adh->fetch(
'',
'', $object->id);
3034 $adh->ref = $adh->getFullName($langs);
3035 print $adh->getNomUrl(-1);
3037 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3039 print
"</td></tr>\n";
3059 if (!empty($conf->syncsupplierwebservices->enabled)) {
3060 print
'<tr><td>'.$langs->trans(
"WebServiceURL").
'</td><td>'.
dol_print_url($object->webservices_url).
'</td>';
3061 print
'<td class="nowrap">'.$langs->trans(
'WebServiceKey').
'</td><td>'.$object->webservices_key.
'</td></tr>';
3068 print
'<div style="clear:both"></div>';
3076 if ($action !=
'presend') {
3077 print
'<div class="tabsAction">'.
"\n";
3079 $parameters = array();
3080 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3081 if (empty($reshook)) {
3082 $at_least_one_email_contact =
false;
3083 $TContact = $object->contact_array_objects();
3084 foreach ($TContact as &$contact) {
3085 if (!empty($contact->email)) {
3086 $at_least_one_email_contact =
true;
3091 if (empty($user->socid)) {
3092 $langs->load(
"mails");
3094 if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans(
'NoEMail'); }
3095 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);
3098 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
3100 if (!empty($conf->adherent->enabled)) {
3102 $result = $adh->fetch(
'',
'', $object->id);
3103 if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) {
3104 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";
3108 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=merge&token='.
newToken(),
'', $permissiontodelete);
3110 if ($user->rights->societe->supprimer) {
3111 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.
newToken();
3112 $buttonId =
'action-delete-no-ajax';
3113 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3115 $buttonId =
'action-delete';
3117 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3121 print
'</div>'.
"\n";
3125 if (
GETPOST(
'modelselected')) {
3126 $action =
'presend';
3129 if ($action !=
'presend') {
3130 print
'<div class="fichecenter"><div class="fichehalfleft">';
3132 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
3133 print
'<a name="builddoc"></a>';
3138 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
3139 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
3140 $genallowed = $user->rights->societe->lire;
3141 $delallowed = $user->rights->societe->creer;
3143 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);
3147 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) {
3151 print
'</div><div class="fichehalfright">';
3155 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
3158 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3160 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3162 print
'</div></div>';
3164 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
3166 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
3167 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3171 if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) {
3172 $result = show_addresses($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3178 $modelmail =
'thirdparty';
3179 $defaulttopic =
'Information';
3180 $diroutput = $conf->societe->multidir_output[$object->entity];
3181 $trackid =
'thi'.$object->id;
3183 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getMaxFileSizeArray()
Return the max allowed for file upload.
show_contacts($conf, $langs, $db, $object, $backtopage= '', $showuserlogin=0)
Show html area for list of contacts.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow= '')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
deleteFilesIntoDatabaseIndex($dir, $file, $mode= 'uploaded')
Delete files into database index using search criterias.
dol_mkdir($dir, $dataroot= '', $newmask= '')
Creation of a directory (this can create recursive subdir)
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
dolGetButtonTitle($label, $helpText= '', $iconClass= 'fa fa-file', $url= '', $id= '', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
dolGetButtonAction($label, $html= '', $actionType= 'default', $url= '', $id= '', $userRight=1, $params=array())
Function dolGetButtonAction.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor]...
currency_name($code_iso, $withcode= '', $outputlangs=null)
Return label of currency or code+label.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage members of a foundation.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles= 'addedfile', $upload_dir= '')
Make control on an uploaded file from an GUI page and move it to final destination.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_htmloutput_mesg($mesgstring= '', $mesgarray=array(), $style= 'ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig= '', $mode= 'uploaded', $setsharekey=0, $object=null)
Add a file into database index.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage accounting accounts.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
picto_from_langcode($codelang, $moreatt= '', $notitlealt=0)
Return img flag of country for a language code or country code.
$formconfirm
if ($action == 'delbookkeepingyear') {
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_print_profids($profID, $profIDtype, $countrycode= '', $addcpButton=1, $separ= ' ')
Format profIDs according to country.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.