39 require
'../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
69 $langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
72 $langs->load(
"members");
75 $langs->load(
"categories");
78 $langs->load(
"incoterm");
81 $langs->load(
"mails");
84 $langs->load(
"products");
87 $error = 0; $errors = array();
91 $action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
92 $cancel =
GETPOST(
'cancel',
'alpha');
93 $backtopage =
GETPOST(
'backtopage',
'alpha');
94 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
95 $backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
96 $confirm =
GETPOST(
'confirm',
'alpha');
98 if (!empty($backtopagejsfields)) {
99 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
100 $dol_openinpopup = $tmpbacktopagejsfields[0];
105 $socid = $user->socid;
107 if (empty($socid) && $action ==
'view') {
117 $extrafields->fetch_name_optionals_label($object->table_element);
122 $hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
125 $object->fetch($socid);
128 if (!($object->id > 0) && $action ==
'view') {
129 $langs->load(
"errors");
130 print($langs->trans(
'ErrorRecordNotFound'));
135 $canvas = $object->canvas ? $object->canvas :
GETPOST(
"canvas");
137 if (!empty($canvas)) {
138 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
139 $objcanvas =
new Canvas($db, $action);
140 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
144 $permissiontoread = $user->hasRight(
'societe',
'lire');
145 $permissiontoadd = $user->hasRight(
'societe',
'creer');
146 $permissiontodelete = $user->hasRight(
'societe',
'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0);
147 $permissionnote = $user->hasRight(
'societe',
'creer');
148 $permissiondellink = $user->hasRight(
'societe',
'creer');
149 $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
152 $result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
160 $parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
161 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
166 if (empty($reshook)) {
167 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
169 if (empty($backtopage) || ($cancel && empty($id))) {
170 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
171 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
172 $backtopage = $backurlforlist;
174 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
180 if (!empty($backtopageforcancel)) {
181 header(
"Location: ".$backtopageforcancel);
183 } elseif (!empty($backtopage)) {
184 header(
"Location: ".$backtopage);
190 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->rights->societe->creer) {
192 $soc_origin_id =
GETPOST(
'soc_origin',
'int');
193 $soc_origin =
new Societe($db);
195 if ($soc_origin_id <= 0) {
196 $langs->load(
'errors');
197 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
199 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
210 $object->client = $object->client | $soc_origin->client;
211 $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
212 $listofproperties = array(
213 'address',
'zip',
'town',
'state_id',
'country_id',
'phone',
'phone_pro',
'fax',
'email',
'socialnetworks',
'url',
'barcode',
214 'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
215 'tva_intra',
'effectif_id',
'forme_juridique',
'remise_percent',
'remise_supplier_percent',
'mode_reglement_supplier_id',
'cond_reglement_supplier_id',
'name_bis',
216 'stcomm_id',
'outstanding_limit',
'price_level',
'parent',
'default_lang',
'ref',
'ref_ext',
'import_key',
'fk_incoterms',
'fk_multicurrency',
217 'code_client',
'code_fournisseur',
'code_compta',
'code_compta_fournisseur',
218 'model_pdf',
'fk_projet'
220 foreach ($listofproperties as $property) {
221 if (empty($object->$property)) {
222 $object->$property = $soc_origin->$property;
227 $listofproperties = array(
228 'note_public',
'note_private'
230 foreach ($listofproperties as $property) {
231 $object->$property =
dol_concatdesc($object->$property, $soc_origin->$property);
235 if (is_array($soc_origin->array_options)) {
236 foreach ($soc_origin->array_options as $key => $val) {
237 if (empty($object->array_options[$key])) {
238 $object->array_options[$key] = $val;
246 $custcats_ori = $static_cat->containing($soc_origin->id,
'customer',
'id');
247 $custcats = $static_cat->containing($object->id,
'customer',
'id');
248 $custcats = array_merge($custcats, $custcats_ori);
249 $object->setCategories($custcats,
'customer');
251 $suppcats_ori = $static_cat->containing($soc_origin->id,
'supplier',
'id');
252 $suppcats = $static_cat->containing($object->id,
'supplier',
'id');
253 $suppcats = array_merge($suppcats, $suppcats_ori);
254 $object->setCategories($suppcats,
'supplier');
257 if ($soc_origin->code_client == $object->code_client
258 || $soc_origin->code_fournisseur == $object->code_fournisseur
259 || $soc_origin->barcode == $object->barcode) {
260 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
261 $soc_origin->code_client =
'';
262 $soc_origin->code_fournisseur =
'';
263 $soc_origin->barcode =
'';
264 $soc_origin->update($soc_origin->id, $user, 0, 1, 1,
'merge');
268 $result = $object->update($object->id, $user, 0, 1, 1,
'merge');
280 'Adherent' =>
'/adherents/class/adherent.class.php',
281 'Don' =>
'/don/class/don.class.php',
282 'Societe' =>
'/societe/class/societe.class.php',
284 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
285 'Propal' =>
'/comm/propal/class/propal.class.php',
286 'Commande' =>
'/commande/class/commande.class.php',
287 'Facture' =>
'/compta/facture/class/facture.class.php',
288 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
289 'LignePrelevement' =>
'/compta/prelevement/class/ligneprelevement.class.php',
290 'Mo' =>
'/mrp/class/mo.class.php',
291 'Contact' =>
'/contact/class/contact.class.php',
292 'Contrat' =>
'/contrat/class/contrat.class.php',
293 'Expedition' =>
'/expedition/class/expedition.class.php',
294 'Fichinter' =>
'/fichinter/class/fichinter.class.php',
295 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
296 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
297 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
298 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
299 'Delivery' =>
'/delivery/class/delivery.class.php',
300 'Product' =>
'/product/class/product.class.php',
301 'Project' =>
'/projet/class/project.class.php',
302 'Ticket' =>
'/ticket/class/ticket.class.php',
303 'User' =>
'/user/class/user.class.php',
304 'Account' =>
'/compta/bank/class/account.class.php',
305 'ConferenceOrBoothAttendee' =>
'/eventorganization/class/conferenceorboothattendee.class.php'
309 foreach ($objects as $object_name => $object_file) {
310 require_once DOL_DOCUMENT_ROOT.$object_file;
312 if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) {
322 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', array(
323 'soc_origin' => $soc_origin->id,
324 'soc_dest' => $object->id
325 ), $object, $action);
335 $object->context = array(
'merge'=>1,
'mergefromid'=>$soc_origin->id);
338 $result = $object->call_trigger(
'COMPANY_MODIFY', $user);
348 if ($soc_origin->delete($soc_origin->id, $user) < 1) {
358 $langs->load(
"errors");
366 if (
GETPOST(
'getcustomercode')) {
368 $_POST[
"customer_code"] =
"Acompleter";
371 if (
GETPOST(
'getsuppliercode')) {
373 $_POST[
"supplier_code"] =
"Acompleter";
376 if ($action ==
'set_localtax1') {
379 $object->fetch($socid);
380 $res = $object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
382 if ($action ==
'set_localtax2') {
385 $object->fetch($socid);
386 $res = $object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
389 if ($action ==
'update_extras') {
390 $object->fetch($socid);
395 $extrafields->fetch_name_optionals_label($object->table_element);
397 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
403 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
411 $action =
'edit_extras';
417 && ($action ==
'add' || $action ==
'update') && $user->rights->societe->creer) {
418 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
421 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
425 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")),
null,
'errors');
429 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
433 if (
isModEnabled(
'mailing') && !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))) {
435 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
438 if (
isModEnabled(
'mailing') &&
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))) {
440 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
444 if ($action ==
'update') {
445 $ret = $object->fetch($socid);
446 $object->oldcopy = clone $object;
448 $object->canvas = $canvas;
451 if (
GETPOST(
"private",
'int') == 1) {
452 $object->particulier =
GETPOST(
"private",
'int');
455 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
457 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
458 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
460 $object->name =
GETPOST(
'name',
'alphanohtml');
463 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
464 $object->parent =
GETPOST(
'parent_company_id',
'int');
465 $object->address =
GETPOST(
'address',
'alphanohtml');
466 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
467 $object->town =
GETPOST(
'town',
'alphanohtml');
468 $object->country_id =
GETPOST(
'country_id',
'int');
469 $object->state_id =
GETPOST(
'state_id',
'int');
471 $object->socialnetworks = array();
473 foreach ($socialnetworks as $key => $value) {
475 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
480 $object->phone =
GETPOST(
'phone',
'alpha');
481 $object->fax =
GETPOST(
'fax',
'alpha');
482 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
483 $object->no_email =
GETPOST(
"no_email",
"int");
484 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
485 $object->idprof1 = trim(
GETPOST(
'idprof1',
'alphanohtml'));
486 $object->idprof2 = trim(
GETPOST(
'idprof2',
'alphanohtml'));
487 $object->idprof3 = trim(
GETPOST(
'idprof3',
'alphanohtml'));
488 $object->idprof4 = trim(
GETPOST(
'idprof4',
'alphanohtml'));
489 $object->idprof5 = trim(
GETPOST(
'idprof5',
'alphanohtml'));
490 $object->idprof6 = trim(
GETPOST(
'idprof6',
'alphanohtml'));
491 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
493 $object->code_fournisseur =
GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
494 $object->capital =
GETPOST(
'capital',
'alphanohtml');
495 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
497 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
498 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
499 $object->status =
GETPOST(
'status',
'alpha');
502 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
503 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
505 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
506 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
508 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
509 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
510 $object->typent_id =
GETPOST(
'typent_id',
'int');
512 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
514 $object->client =
GETPOST(
'client',
'int');
515 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
517 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
518 $object->default_lang =
GETPOST(
'default_lang');
521 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
522 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
525 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
527 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
528 $object->accountancy_code_sell =
'';
530 $object->accountancy_code_sell = $accountancy_code_sell;
534 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
536 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
537 $object->accountancy_code_buy =
'';
539 $object->accountancy_code_buy = $accountancy_code_buy;
545 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
546 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
551 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
555 $ret = $extrafields->setOptionalsFromPost(
null, $object);
561 $ret = $object->setValuesForExtraLanguages();
567 if (!empty($_FILES[
'photo'][
'name'])) {
568 $current_logo = $object->logo;
573 if (!
GETPOST(
'cancel',
'alpha')) {
574 if (!empty($object->email) && !isValidEMail($object->email)) {
575 $langs->load(
"errors");
577 setEventMessages($langs->trans(
"ErrorBadEMail", $object->email),
null,
'errors');
579 if (!empty($object->url) && !
isValidUrl($object->url)) {
580 $langs->load(
"errors");
581 setEventMessages($langs->trans(
"ErrorBadUrl", $object->url),
null,
'errors');
583 if (!empty($object->webservices_url)) {
585 if (strpos($object->webservices_url,
"http") ===
false) {
586 $object->webservices_url =
"http://".$object->webservices_url;
589 $langs->load(
"errors");
590 $error++; $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
595 $object->country_id =
GETPOST(
'country_id',
'int') !=
'' ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
596 if ($object->country_id) {
597 $tmparray =
getCountry($object->country_id,
'all');
598 $object->country_code = $tmparray[
'code'];
599 $object->country = $tmparray[
'label'];
605 if ($action ==
'add') {
610 if (empty($object->client)) {
611 $object->code_client =
'';
613 if (empty($object->fournisseur)) {
614 $object->code_fournisseur =
'';
617 $result = $object->create($user);
619 if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email) && $object->no_email == 1) {
621 $result = $object->setNoEmail($object->no_email);
624 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
630 if ($object->particulier) {
631 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
632 $contcats =
GETPOST(
'contcats',
'array');
633 $no_email =
GETPOST(
'contact_no_email',
'int');
634 $result = $object->create_individual($user, $no_email, $contcats);
642 $salesreps =
GETPOST(
'commercial',
'array');
643 $result = $object->setSalesRep($salesreps,
true);
650 $custcats =
GETPOST(
'custcats',
'array');
651 $result = $object->setCategories($custcats,
'customer');
658 $suppcats =
GETPOST(
'suppcats',
'array');
659 $result = $object->setCategories($suppcats,
'supplier');
666 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
667 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
676 if (!($result > 0)) {
677 $errors[] =
"ErrorFailedToSaveFile";
680 $object->addThumbs($newfile);
685 switch ($_FILES[
'photo'][
'error']) {
688 $errors[] =
"ErrorFileSizeTooLarge";
691 $errors[] =
"ErrorFilePartiallyUploaded";
696 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors)) {
697 $duplicate_code_error =
true;
698 $object->code_client =
null;
701 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors)) {
702 $duplicate_code_error =
true;
703 $object->code_fournisseur =
null;
706 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
707 $duplicate_code_error =
true;
714 if ($result >= 0 && !$error) {
717 if ($backtopagejsfields) {
720 $retstring =
'<script>';
721 $retstring .=
'jQuery(document).ready(function() {
722 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
723 console.log(\
'id = '.$object->id.
'\');
724 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->id.
'\');
725 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->name.
'\');
726 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
728 $retstring .=
'</script>';
735 if (!empty($backtopage)) {
736 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
737 if (preg_match(
'/\?/', $backtopage)) {
738 $backtopage .=
'&socid='.$object->id;
740 header(
"Location: ".$backtopage);
743 $url = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
744 if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
745 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".$object->id;
746 } elseif ($object->fournisseur == 1) {
747 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".$object->id;
750 header(
"Location: ".$url);
759 if ($action ==
'update') {
762 if (
GETPOST(
'cancel',
'alpha')) {
763 if (!empty($backtopage)) {
764 header(
"Location: ".$backtopage);
767 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
773 if (empty($object->client) && empty($object->oldcopy->code_client)) {
774 $object->code_client =
'';
776 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
777 $object->code_fournisseur =
'';
781 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
786 $no_email =
GETPOST(
'no_email',
'int');
787 $result = $object->setNoEmail($no_email);
806 $salesreps =
GETPOST(
'commercial',
'array');
807 $result = $object->setSalesRep($salesreps);
814 if (!$error && !empty($user->rights->categorie->lire)) {
816 $categories =
GETPOST(
'custcats',
'array');
817 $result = $object->setCategories($categories,
'customer');
824 $categories =
GETPOST(
'suppcats',
'array');
825 $result = $object->setCategories($categories,
'supplier');
833 $dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id.
"/logos";
834 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
835 if (
GETPOST(
'deletephoto') && $object->logo) {
836 $fileimg = $dir.
'/'.$object->logo;
837 $dirthumbs = $dir.
'/thumbs';
843 if ($current_logo != $object->logo) {
844 $fileimg = $dir.
'/'.$current_logo;
845 $dirthumbs = $dir.
'/thumbs';
856 if (!($result > 0)) {
857 $errors[] =
"ErrorFailedToSaveFile";
860 $object->addThumbs($newfile);
863 if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) {
864 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
873 $errors[] =
"ErrorBadImageFormat";
876 switch ($_FILES[
'photo'][
'error']) {
879 $errors[] =
"ErrorFileSizeTooLarge";
882 $errors[] =
"ErrorFilePartiallyUploaded";
890 if (!$error && $object->fk_soc > 0) {
891 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
892 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
893 if (!$object->db->query($sql)) {
895 $object->error .= $object->db->lasterror();
900 if (!$error && !count($errors)) {
901 if (!empty($backtopage)) {
902 header(
"Location: ".$backtopage);
905 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
909 $object->id = $socid;
914 $action = ($action ==
'add' ?
'create' :
'edit');
919 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'supprimer')) {
920 $object->fetch($socid);
921 $object->oldcopy = clone $object;
922 $result = $object->delete($socid, $user);
925 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
928 $langs->load(
"errors");
936 if ($action ==
'set_thirdpartytype' && $user->rights->societe->creer) {
937 $object->fetch($socid);
938 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
942 if ($action ==
'set_incoterms' && $user->rights->societe->creer &&
isModEnabled(
'incoterm')) {
943 $object->fetch($socid);
944 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
948 if ($action ==
'set_thirdparty' && $user->rights->societe->creer) {
949 $object->fetch($socid);
950 $result = $object->setParent(
GETPOST(
'parent_id',
'int'));
954 if ($action ==
'set_salesrepresentatives' && $user->rights->societe->creer) {
955 $object->fetch($socid);
956 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
960 if ($action ==
'setwarehouse' && $user->rights->societe->creer) {
961 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
965 $object->fetch($socid);
968 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
969 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
973 $triggersendname =
'COMPANY_SENTBYMAIL';
974 $paramname =
'socid';
975 $mode =
'emailfromthirdparty';
976 $trackid =
'thi'.$object->id;
977 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
981 $upload_dir = !empty($conf->societe->multidir_output[$object->entity])?$conf->societe->multidir_output[$object->entity]:$conf->societe->dir_output;
982 $permissiontoadd = $user->hasRight(
'societe',
'creer');
983 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
999 if ($socid > 0 && empty($object->id)) {
1000 $result = $object->fetch($socid);
1007 $title = $langs->trans(
"ThirdParty");
1008 if ($action ==
'create') {
1009 $title = $langs->trans(
"NewThirdParty");
1011 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
1012 $title = $object->name.
" - ".$langs->trans(
'Card');
1014 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
1018 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
1020 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
1024 $objcanvas->assign_values($action, $object->id, $object->ref);
1025 $objcanvas->display_canvas($action);
1030 if ($action ==
'create') {
1034 $private =
GETPOST(
"private",
"int");
1035 if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !
GETPOSTISSET(
'private')) {
1038 if (empty($private)) {
1043 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1044 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1045 $module = substr($module, 0,
dol_strlen($module) - 4);
1047 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1048 foreach ($dirsociete as $dirroot) {
1054 $modCodeClient =
new $module;
1056 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1057 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1058 $module = substr($module, 0,
dol_strlen($module) - 4);
1060 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1061 foreach ($dirsociete as $dirroot) {
1067 $modCodeFournisseur =
new $module;
1070 if (
GETPOST(
"type",
'aZ') !=
'f') {
1071 $object->client = -1;
1072 if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) {
1073 $object->client = 3;
1077 if (
GETPOST(
"type",
'aZ') ==
'c') {
1078 if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
1079 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
1081 $object->client = 3;
1084 if (
GETPOST(
"type",
'aZ') ==
'p') {
1085 $object->client = 2;
1088 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) {
1089 $object->client = 1;
1092 if (((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order") ||
isModEnabled(
"supplier_invoice")) && (
GETPOST(
"type") ==
'f' || (
GETPOST(
"type") ==
'' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) {
1093 $object->fournisseur = 1;
1096 $object->name =
GETPOST(
'name',
'alphanohtml');
1097 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1098 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
1099 $object->particulier = $private;
1100 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1101 $object->client =
GETPOST(
'client',
'int') ?
GETPOST(
'client',
'int') : $object->client;
1103 if (empty($duplicate_code_error)) {
1104 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1105 $object->fournisseur =
GETPOST(
'fournisseur') ?
GETPOST(
'fournisseur',
'int') : $object->fournisseur;
1106 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1108 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
null,
'warnings');
1111 $object->address =
GETPOST(
'address',
'alphanohtml');
1112 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1113 $object->town =
GETPOST(
'town',
'alphanohtml');
1114 $object->state_id =
GETPOST(
'state_id',
'int');
1116 $object->socialnetworks = array();
1118 foreach ($socialnetworks as $key => $value) {
1120 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1125 $object->phone =
GETPOST(
'phone',
'alpha');
1126 $object->fax =
GETPOST(
'fax',
'alpha');
1127 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1128 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1129 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1130 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1131 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1132 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1133 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1134 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1135 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1136 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1137 $object->typent_id =
GETPOST(
'typent_id',
'int');
1138 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1139 $object->civility_id =
GETPOST(
'civility_id',
'alpha');
1141 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1142 $object->status =
GETPOST(
'status',
'int');
1145 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1146 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1148 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1149 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1151 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1153 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1154 $object->default_lang =
GETPOST(
'default_lang');
1157 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1159 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1160 $object->accountancy_code_sell =
'';
1162 $object->accountancy_code_sell = $accountancy_code_sell;
1166 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1168 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1169 $object->accountancy_code_buy =
'';
1171 $object->accountancy_code_buy = $accountancy_code_buy;
1175 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
1178 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos";
1179 $file_OK = (isset($_FILES[
'photo']) ?is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1184 if (@is_dir($dir)) {
1188 if (!($result > 0)) {
1189 $errors[] =
"ErrorFailedToSaveFile";
1192 $object->addThumbs($newfile);
1199 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1200 if ($object->country_id) {
1201 $tmparray =
getCountry($object->country_id,
'all');
1202 $object->country_code = $tmparray[
'code'];
1203 $object->country = $tmparray[
'label'];
1205 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
1209 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1214 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1216 if (!empty($conf->use_javascript_ajax)) {
1217 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1218 print
"\n".
'<script type="text/javascript">';
1219 print
'$(document).ready(function () {
1222 is_private=' . $private.
';
1224 $(".individualline").show();
1226 $(".individualline").hide();
1228 $("#radiocompany").click(function() {
1229 $(".individualline").hide();
1230 $("#typent_id").val(0);
1231 $("#typent_id").change();
1232 $("#effectif_id").val(0);
1233 $("#effectif_id").change();
1234 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1235 document.formsoc.private.value=0;
1237 $("#radioprivate").click(function() {
1238 $(".individualline").show();
1239 $("#typent_id").val(id_te_private);
1240 $("#typent_id").change();
1241 $("#effectif_id").val(id_ef15);
1242 $("#effectif_id").change();
1243 /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
1244 if ($("#civility_id").data("select2")) {
1245 $("#civility_id").select2({width: "resolve"});
1247 $("#TypeName").html(document.formsoc.LastName.value);
1248 document.formsoc.private.value=1;
1251 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
1253 init_customer_categ();
1254 $("#customerprospect").change(function() {
1255 init_customer_categ();
1257 function init_customer_categ() {
1258 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1259 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
1261 jQuery(".visibleifcustomer").hide();
1265 jQuery(".visibleifcustomer").show();
1269 init_supplier_categ();
1270 $("#fournisseur").change(function() {
1271 init_supplier_categ();
1273 function init_supplier_categ() {
1274 console.log("is supplier = "+jQuery("#fournisseur").val());
1275 if (jQuery("#fournisseur").val() == 0)
1277 jQuery(".visibleifsupplier").hide();
1281 jQuery(".visibleifsupplier").show();
1285 $("#selectcountry_id").change(function() {
1286 document.formsoc.action.value="create";
1287 document.formsoc.submit();
1289 if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1291 function init_check_no_email(input) {
1292 if (input.val()!="") {
1293 $(".noemail").addClass("fieldrequired");
1295 $(".noemail").removeClass("fieldrequired");
1298 $("#email").keyup(function() {
1299 init_check_no_email($(this));
1301 init_check_no_email($("#email"));';
1304 print
'</script>'.
"\n";
1306 print
'<div id="selectthirdpartytype">';
1307 print
'<div class="hideonsmartphone float">';
1308 print $langs->trans(
"ThirdPartyType").
': ';
1310 print
'<label for="radiocompany" class="radiocompany">';
1311 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1313 print $langs->trans(
"CreateThirdPartyOnly");
1315 print
' ';
1316 print
'<label for="radioprivate" class="radioprivate">';
1317 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1319 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1320 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1321 print
$form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1326 print
'<script type="text/javascript">';
1327 print
'$(document).ready(function () {
1328 $("#selectcountry_id").change(function() {
1329 document.formsoc.action.value="create";
1330 document.formsoc.submit();
1333 print
'</script>'.
"\n";
1339 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1341 print
'<input type="hidden" name="action" value="add">';
1342 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1343 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1344 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1345 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
1346 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1347 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1348 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1349 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1350 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1351 print
'<input type="hidden" name="code_auto" value="1">';
1356 print
'<table class="border centpercent">';
1359 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1360 if ($object->particulier || $private) {
1361 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1363 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1365 print
'</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ?
' colspan="3"' :
'').
'>';
1367 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
1368 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
1463 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
1464 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>';
1469 if ($conf->use_javascript_ajax) {
1470 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1472 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1473 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).
'"></td>';
1477 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1478 print $formcompany->select_civility($object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1484 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1485 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>';
1488 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1489 print
'<td class="maxwidthonsmartphone">';
1491 print $formcompany->selectProspectCustomerType($selected);
1494 if ($conf->browser->layout ==
'phone') {
1498 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1499 print
'<table class="nobordernopadding"><tr><td>';
1500 $tmpcode = $object->code_client;
1501 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1502 $tmpcode = $modCodeClient->getNextValue($object, 0);
1504 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1506 $s = $modCodeClient->getToolTip($langs, $object, 0);
1507 print
$form->textwithpicto(
'', $s, 1);
1508 print
'</td></tr></table>';
1511 if ((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))
1512 || (
isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->lire))) {
1515 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
1517 if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) {
1520 print
$form->selectyesno(
"fournisseur", (
GETPOST(
'fournisseur',
'int') !=
'' ?
GETPOST(
'fournisseur',
'int') : (
GETPOST(
"type",
'alpha') ==
'' ? $default : $object->fournisseur)), 1, 0, (
GETPOST(
"type",
'alpha') ==
'' ? 1 : 0), 1);
1524 if ($conf->browser->layout ==
'phone') {
1529 if ((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) {
1530 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1533 if ((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) {
1534 print
'<table class="nobordernopadding"><tr><td>';
1535 $tmpcode = $object->code_fournisseur;
1536 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1537 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1539 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1541 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1542 print
$form->textwithpicto(
'', $s, 1);
1543 print
'</td></tr></table>';
1549 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
1550 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1555 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1556 print
'<td colspan="3">';
1557 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1558 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
1563 print
'<tr><td class="tdtop">';
1564 print
$form->editfieldkey(
'Address',
'address',
'', $object, 0);
1566 print
'<td colspan="3">';
1567 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1569 print
'</textarea>';
1570 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1574 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1575 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1577 if ($conf->browser->layout ==
'phone') {
1580 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1581 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1582 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1586 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1587 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1588 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
1590 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1595 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1596 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)) {
1597 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1599 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1602 if ($object->country_id) {
1603 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1604 print $formcompany->select_state($object->state_id, $object->country_code);
1606 print $countrynotdefined;
1612 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1613 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>';
1614 if ($conf->browser->layout ==
'phone') {
1617 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1618 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>';
1621 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ?
'' : $conf->global->SOCIETE_EMAIL_MANDATORY).
'</td>';
1622 print
'<td'.(($conf->browser->layout ==
'phone') || !
isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>'.
img_picto(
'',
'object_email',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth200 widthcentpercentminusx" name="email" id="email" value="'.$object->email.
'"></td>';
1623 if (
isModEnabled(
'mailing') && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1624 if ($conf->browser->layout ==
'phone') {
1627 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1628 print
'<td class="individualline" '.(($conf->browser->layout ==
'phone') || !
isModEnabled(
'mailing') ?
' colspan="3"' :
'').
'>'.
$form->selectyesno(
'contact_no_email', (
GETPOSTISSET(
"contact_no_email") ?
GETPOST(
"contact_no_email",
'alpha') : (empty($object->no_email) ? 0 : 1)), 1, false, 1).
'</td>';
1631 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1632 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.
'"></td></tr>';
1635 if (!empty($conf->mailing->enabled)) {
1636 if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1637 print
"\n".
'<script type="text/javascript">'.
"\n";
1638 print
'$(document).ready(function () {
1639 $("#email").keyup(function() {
1640 if ($(this).val()!="") {
1641 $(".noemail").addClass("fieldrequired");
1643 $(".noemail").removeClass("fieldrequired");
1647 print
'</script>'.
"\n";
1649 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
1650 $result = $object->getNoEmail();
1656 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1658 print
$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1,
false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
1665 foreach ($socialnetworks as $key => $value) {
1666 if ($value[
'active']) {
1668 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1669 print
'<td colspan="3">';
1670 if (!empty($value[
'icon'])) {
1671 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1673 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])).
'">';
1676 } elseif (!empty($object->socialnetworks[$key])) {
1677 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1683 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1685 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1686 if ($idprof !=
'-') {
1689 if (($j % $NBCOLS) == 0) {
1693 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1694 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1696 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1698 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1705 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1706 print
'<td colspan="2"></td></tr>';
1710 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1712 print
$form->selectyesno(
'assujtva_value',
GETPOSTISSET(
'assujtva_value') ?
GETPOST(
'assujtva_value',
'int') : 1, 1);
1714 if ($conf->browser->layout ==
'phone') {
1717 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1718 print
'<td class="nowrap">';
1719 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1721 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
1724 if (!empty($conf->use_javascript_ajax)) {
1726 if (!empty($conf->dol_use_jmobile)) {
1731 print
'<script type="text/javascript">';
1732 print
"function CheckVAT(a) {\n";
1733 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1737 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1738 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1740 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1749 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1750 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1751 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1753 if ($conf->browser->layout ==
'phone') {
1756 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1757 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1759 } elseif ($mysoc->localtax1_assuj ==
"1") {
1760 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1761 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1763 } elseif ($mysoc->localtax2_assuj ==
"1") {
1764 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1765 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1770 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";
1771 $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1772 print
$form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1774 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1776 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
1778 if ($conf->browser->layout ==
'phone') {
1781 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1782 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1784 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1787 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1792 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1793 print
'<td colspan="3" class="maxwidthonsmartphone">';
1794 if ($object->country_id) {
1795 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1797 print $countrynotdefined;
1802 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1803 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1805 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
1807 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
1810 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1811 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');
1819 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1820 print
'<td colspan="3" class="maxwidthonsmartphone">';
1821 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1826 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
1827 $langs->load(
'categories');
1830 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1831 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
'parent',
null,
null, 1);
1832 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1835 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1836 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1837 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
1838 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1844 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1845 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
'parent',
null,
null, 1);
1846 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1854 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1855 print
'<td colspan="3" class="maxwidthonsmartphone">';
1856 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1857 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'',
false,
'maxwidth150 widthcentpercentminusx');
1862 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1863 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1866 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
1868 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1869 print
'<td colspan="3" class="maxwidthonsmartphone">';
1870 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1871 print
$form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1877 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1878 print
'<td colspan="3" class="maxwidthonsmartphone">';
1879 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
1881 $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())));
1882 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected,
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1886 print
'<tr class="hideonsmartphone">';
1887 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1888 print
'<td colspan="3">';
1889 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1893 print
'</table>'.
"\n";
1896 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
1897 print
'<table class="border centpercent">';
1901 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1903 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1904 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'');
1908 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1910 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1911 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'');
1915 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1916 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1920 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1921 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1930 print
$form->buttonsSaveCancel(
"AddThirdParty",
'Cancel',
null, 0,
'', $dol_openinpopup);
1932 print
'</form>'.
"\n";
1933 } elseif ($action ==
'edit') {
1937 $res = $object->fetch_optionals();
1943 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1944 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1945 $module = substr($module, 0,
dol_strlen($module) - 4);
1947 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1948 foreach ($dirsociete as $dirroot) {
1954 $modCodeClient =
new $module($db);
1956 if ($modCodeClient->code_auto) {
1957 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1959 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1960 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1961 $module = substr($module, 0,
dol_strlen($module) - 4);
1963 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1964 foreach ($dirsociete as $dirroot) {
1970 $modCodeFournisseur =
new $module($db);
1972 if ($modCodeFournisseur->code_auto) {
1973 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1976 $object->oldcopy = clone $object;
1980 $object->name =
GETPOST(
'name',
'alphanohtml');
1981 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1982 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1983 $object->client =
GETPOST(
'client',
'int');
1984 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1985 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
1986 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1987 $object->address =
GETPOST(
'address',
'alphanohtml');
1988 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1989 $object->town =
GETPOST(
'town',
'alphanohtml');
1990 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
1991 $object->state_id =
GETPOST(
'state_id',
'int');
1992 $object->parent =
GETPOST(
'parent_company_id',
'int');
1994 $object->socialnetworks = array();
1996 foreach ($socialnetworks as $key => $value) {
1998 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
2003 $object->phone =
GETPOST(
'phone',
'alpha');
2004 $object->fax =
GETPOST(
'fax',
'alpha');
2005 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
2006 $object->no_email =
GETPOST(
"no_email",
"int");
2007 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
2008 $object->capital =
GETPOST(
'capital',
'alphanohtml');
2009 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
2010 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
2011 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
2012 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
2013 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
2014 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
2015 $object->typent_id =
GETPOST(
'typent_id',
'int');
2016 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
2017 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
2018 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
2019 $object->default_lang =
GETPOST(
'default_lang',
'alpha');
2021 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
2022 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
2023 $object->status =
GETPOST(
'status',
'int');
2026 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
2027 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
2030 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
2032 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
2033 $object->accountancy_code_sell =
'';
2035 $object->accountancy_code_sell = $accountancy_code_sell;
2039 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
2041 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
2042 $object->accountancy_code_buy =
'';
2044 $object->accountancy_code_buy = $accountancy_code_buy;
2050 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
2051 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
2055 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value');
2056 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value');
2058 $object->localtax1_value =
GETPOST(
'lt1');
2059 $object->localtax2_value =
GETPOST(
'lt2');
2062 if ($object->country_id > 0) {
2063 $tmparray =
getCountry($object->country_id,
'all');
2064 $object->country_code = $tmparray[
'code'];
2065 $object->country = $tmparray[
'label'];
2070 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $object->multicurrency_code;
2074 if ($object->localtax1_assuj == 0) {
2079 if ($object->localtax2_assuj == 0) {
2085 if (!empty($conf->use_javascript_ajax)) {
2086 print
"\n".
'<script type="text/javascript">';
2087 print
'$(document).ready(function () {
2090 if("#localtax1assuj_value".value==undefined){
2097 if("#localtax2assuj_value".value==undefined){
2104 $("#localtax1assuj_value").change(function() {
2105 var value=document.getElementById("localtax1assuj_value").value;
2112 $("#localtax2assuj_value").change(function() {
2113 var value=document.getElementById("localtax2assuj_value").value;
2121 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
2123 init_customer_categ();
2124 $("#customerprospect").change(function() {
2125 init_customer_categ();
2127 function init_customer_categ() {
2128 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
2129 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
2131 jQuery(".visibleifcustomer").hide();
2135 jQuery(".visibleifcustomer").show();
2139 init_supplier_categ();
2140 $("#fournisseur").change(function() {
2141 init_supplier_categ();
2143 function init_supplier_categ() {
2144 console.log("is supplier = "+jQuery("#fournisseur").val());
2145 if (jQuery("#fournisseur").val() == 0)
2147 jQuery(".visibleifsupplier").hide();
2151 jQuery(".visibleifsupplier").show();
2155 $("#selectcountry_id").change(function() {
2156 document.formsoc.action.value="edit";
2157 document.formsoc.submit();
2161 print
'</script>'.
"\n";
2164 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post" name="formsoc">';
2165 print
'<input type="hidden" name="action" value="update">';
2166 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2167 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2168 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2169 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2170 print
'<input type="hidden" name="code_auto" value="1">';
2176 print
'<div class="fichecenter2">';
2177 print
'<table class="border centpercent">';
2180 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2181 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2187 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0,
'string',
'', 1).
'</td>';
2188 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
2189 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
2193 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
2194 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>';
2197 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2198 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'', $object, 0).
'</td><td colspan="3">';
2200 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
2201 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2202 print $object->prefix_comm;
2204 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2210 print
'<tr><td>'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
2211 print
'<td class="maxwidthonsmartphone">';
2212 print $formcompany->selectProspectCustomerType($object->client);
2214 if ($conf->browser->layout ==
'phone') {
2217 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
2219 print
'<table class="nobordernopadding"><tr><td>';
2220 if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) {
2221 $tmpcode = $object->code_client;
2222 if (empty($tmpcode) && !empty($object->oldcopy->code_client)) {
2223 $tmpcode = $object->oldcopy->code_client;
2225 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2226 $tmpcode = $modCodeClient->getNextValue($object, 0);
2228 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2229 } elseif ($object->codeclient_modifiable()) {
2230 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).
'" maxlength="24">';
2232 print $object->code_client;
2233 print
'<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).
'">';
2236 $s = $modCodeClient->getToolTip($langs, $object, 0);
2237 print
$form->textwithpicto(
'', $s, 1);
2238 print
'</td></tr></table>';
2243 if (((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire)))
2244 || (
isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->lire))) {
2246 print
'<td>'.$form->editfieldkey(
'Supplier',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td>';
2247 print
'<td class="maxwidthonsmartphone">';
2248 print
$form->selectyesno(
"fournisseur", $object->fournisseur, 1,
false, 0, 1);
2250 if ($conf->browser->layout ==
'phone') {
2254 if ((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) {
2255 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
2259 print
'<table class="nobordernopadding"><tr><td>';
2260 if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
2261 $tmpcode = $object->code_fournisseur;
2262 if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) {
2263 $tmpcode = $object->oldcopy->code_fournisseur;
2265 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2266 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2268 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2269 } elseif ($object->codefournisseur_modifiable()) {
2270 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).
'" maxlength="24">';
2272 print $object->code_fournisseur;
2273 print
'<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.
'">';
2276 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2277 print
$form->textwithpicto(
'', $s, 1);
2278 print
'</td></tr></table>';
2284 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
2285 print
'<td colspan="3">';
2287 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
2292 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
2293 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), $object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2297 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2298 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2300 print
'</textarea>';
2301 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2305 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"':
'').
'>';
2306 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2308 if ($conf->browser->layout ==
'phone') {
2311 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"':
'').
'>';
2312 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2313 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2317 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td colspan="3">';
2318 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2319 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
2321 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2326 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
2327 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)) {
2328 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2330 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2333 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2334 print $formcompany->select_state($object->state_id, $object->country_code);
2339 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'), $object, 0).
'</td>';
2340 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>';
2341 if ($conf->browser->layout ==
'phone') {
2344 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
2345 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>';
2349 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'), $object, 0).
'</td>';
2350 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" name="url" id="url" class="maxwidth200onsmartphone maxwidth300 widthcentpercentminusx " value="'.(
GETPOSTISSET(
'url') ?
GETPOST(
'url',
'alpha') : $object->url).
'"></td></tr>';
2353 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
2354 print
'<td colspan="3">';
2355 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2356 print
'<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'">';
2360 if (!empty($conf->mailing->enabled)) {
2361 if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
2362 print
"\n".
'<script type="text/javascript">'.
"\n";
2365 jQuery(document).ready(function () {
2366 function init_check_no_email(input) {
2367 if (input.val()!="") {
2368 $(".noemail").addClass("fieldrequired");
2370 $(".noemail").removeClass("fieldrequired");
2373 $("#email").keyup(function() {
2374 init_check_no_email($(this));
2376 init_check_no_email($("#email"));
2378 print
'</script>'.
"\n";
2380 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
2381 $result = $object->getNoEmail();
2387 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
2389 $useempty = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
2390 print
$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $object->no_email), 1, false, $useempty);
2397 foreach ($socialnetworks as $key => $value) {
2398 if ($value[
'active']) {
2400 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
2401 print
'<td colspan="3">';
2402 if (!empty($value[
'icon'])) {
2403 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2405 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth500 widthcentpercentminusx" maxlength="80" value="'.(empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key]).
'">';
2408 } elseif (!empty($object->socialnetworks[$key])) {
2409 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2417 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2419 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2420 if ($idprof !=
'-') {
2423 if (($j % $NBCOLS) == 0) {
2427 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2428 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).
'</td><td>';
2429 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2431 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2438 if ($NBCOLS > 0 && $j % 2 == 1) {
2439 print
'<td colspan="2"></td></tr>';
2443 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2444 print
$form->selectyesno(
'assujtva_value', $object->tva_assuj, 1);
2449 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2450 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td>';
2451 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2453 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2454 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2459 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2460 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2462 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2463 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2467 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2468 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2469 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2471 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2472 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2476 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2477 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2478 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2480 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2481 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2488 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2489 print
'<td colspan="3">';
2490 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2492 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2495 if ($conf->use_javascript_ajax) {
2497 if (!empty($conf->dol_use_jmobile)) {
2502 print
'<script type="text/javascript">';
2503 print
"function CheckVAT(a) {\n";
2504 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2508 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2509 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2511 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2519 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"' :
'').
'>';
2520 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);
2522 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2524 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2526 if ($conf->browser->layout ==
'phone') {
2529 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2530 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2532 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2535 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2540 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2541 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
2545 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2546 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2549 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
2551 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2556 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2557 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->default_lang,
'default_lang', 0,
null,
'1', 0, 0,
'maxwidth300 widthcentpercentminusx');
2565 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2566 print
'<td colspan="3" class="maxwidthonsmartphone">';
2567 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
2572 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
2574 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2575 print
'<td colspan="3">';
2576 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
null,
null,
null, 1);
2578 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2579 $arrayselected = array();
2580 foreach ($cats as $cat) {
2581 $arrayselected[] = $cat->id;
2583 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2587 if ((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) {
2588 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2589 print
'<td colspan="3">';
2590 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
null,
null,
null, 1);
2592 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2593 $arrayselected = array();
2594 foreach ($cats as $cat) {
2595 $arrayselected[] = $cat->id;
2597 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2605 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2606 print
'<td colspan="3" class="maxwidthonsmartphone">';
2607 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2608 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'',
false,
'maxwidth150 widthcentpercentminusx');
2613 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2614 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2617 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
2619 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
2620 print
'<td colspan="3" class="maxwidthonsmartphone">';
2621 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2622 print
$form->select_company(
GETPOST(
'parent_company_id') ?
GETPOST(
'parent_company_id') : $object->parent,
'parent_company_id',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
2627 if (!empty($conf->syncsupplierwebservices->enabled)) {
2628 print
'<tr><td>'.$form->editfieldkey(
'WebServiceURL',
'webservices_url',
'', $object, 0).
'</td>';
2629 print
'<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.
'"></td>';
2630 print
'<td>'.$form->editfieldkey(
'WebServiceKey',
'webservices_key',
'', $object, 0).
'</td>';
2631 print
'<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.
'"></td></tr>';
2635 print
'<tr class="hideonsmartphone">';
2636 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2637 print
'<td colspan="3">';
2638 if ($object->logo) {
2639 print
$form->showphoto(
'societe', $object);
2642 if ($caneditfield) {
2643 if ($object->logo) {
2646 print
'<table class="nobordernopadding">';
2647 if ($object->logo) {
2648 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
2653 $maxmin = $maxfilesizearray[
'maxmin'];
2655 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2657 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2666 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2667 print
'<td colspan="3" class="maxwidthonsmartphone">';
2668 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
2669 $arrayselected =
GETPOST(
'commercial',
'array');
2670 if (empty($arrayselected)) {
2671 $arrayselected = $object->getSalesRepresentatives($user, 1);
2673 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2678 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2680 print
'<table class="border centpercent">';
2684 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2686 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
2690 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2692 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
2696 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2697 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2701 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2702 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2712 print
$form->buttonsSaveCancel();
2721 if (!empty($object->id)) {
2722 $res = $object->fetch_optionals();
2734 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2735 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2738 if ($action ==
'merge') {
2739 $formquestion = array(
2741 'name' =>
'soc_origin',
2742 'label' => $langs->trans(
'MergeOriginThirdparty'),
2744 'value' =>
$form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200',
'',
'', 1,
null,
false, array($object->id))
2748 $formconfirm .=
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2753 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2754 if (empty($reshook)) {
2756 } elseif ($reshook > 0) {
2765 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2767 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2770 print
'<div class="fichecenter">';
2771 print
'<div class="fichehalfleft">';
2773 print
'<div class="underbanner clearboth"></div>';
2774 print
'<table class="border tableforfield centpercent">';
2777 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2778 print $object->getTypeUrl(1);
2782 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2783 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.
dol_escape_htmltag($object->prefix_comm).
'</td>';
2788 if ($object->client) {
2790 print $langs->trans(
'CustomerCode');
2794 $tmpcheck = $object->check_codeclient();
2795 if ($tmpcheck != 0 && $tmpcheck != -5) {
2796 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2803 if (((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) && $object->fournisseur) {
2805 print $langs->trans(
'SupplierCode').
'</td><td>';
2807 $tmpcheck = $object->check_codefournisseur();
2808 if ($tmpcheck != 0 && $tmpcheck != -5) {
2809 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2826 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2827 if ($idprof !=
'-') {
2830 print
'<td>'.$idprof.
'</td><td>';
2833 if ($object->$key) {
2834 if ($object->id_prof_check($i, $object) > 0) {
2835 if (!empty($object->id_prof_url($i, $object))) {
2836 print
' '.$object->id_prof_url($i, $object);
2839 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
2856 if ($object->fournisseur) {
2859 print
$form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2861 print
yn($object->tva_assuj);
2867 if ($object->fournisseur || $mysoc->country_code ==
'ES') {
2868 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2869 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2870 print
yn($object->localtax1_assuj);
2871 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2872 print
yn($object->localtax2_assuj);
2876 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2877 print
'<input type="hidden" name="action" value="set_localtax1">';
2878 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2879 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>';
2880 if ($action ==
'editRE') {
2881 print
'<td class="left">';
2882 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2883 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2885 print
'<td>'.$object->localtax1_value.
'</td>';
2887 print
'</tr></form>';
2890 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2891 print
'<input type="hidden" name="action" value="set_localtax2">';
2892 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2893 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>';
2894 if ($action ==
'editIRPF') {
2895 print
'<td class="left">';
2896 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2897 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2899 print
'<td>'.$object->localtax2_value.
'</td>';
2901 print
'</tr></form>';
2903 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2904 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2905 print
yn($object->localtax1_assuj);
2908 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2909 print
'<input type="hidden" name="action" value="set_localtax1">';
2910 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2911 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>';
2912 if ($action ==
'editRE') {
2913 print
'<td class="left">';
2914 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2915 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2917 print
'<td>'.$object->localtax1_value.
'</td>';
2919 print
'</tr></form>';
2921 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2922 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2923 print
yn($object->localtax2_assuj);
2926 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2927 print
'<input type="hidden" name="action" value="set_localtax2">';
2928 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2929 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>';
2930 if ($action ==
'editIRPF') {
2931 print
'<td class="left">';
2932 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2933 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2935 print
'<td>'.$object->localtax2_value.
'</td>';
2937 print
'</tr></form>';
2944 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
2945 if ($object->tva_intra) {
2948 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2950 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2953 if ($conf->use_javascript_ajax) {
2955 if (!empty($conf->dol_use_jmobile)) {
2960 print
'<script type="text/javascript">';
2961 print
"function CheckVAT(a) {\n";
2962 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2966 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans(
"VATIntraCheck").
'</a>';
2967 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2969 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2979 if (
isModEnabled(
'stock') && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
2980 $langs->load(
'stocks');
2981 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2983 print
'<tr class="nowrap">';
2985 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->rights->societe->creer);
2987 if ($action ==
'editwarehouse') {
2988 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
2990 if ($object->fk_warehouse > 0) {
2991 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
2993 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
3002 print
'<div class="fichehalfright">';
3004 print
'<div class="underbanner clearboth"></div>';
3005 print
'<table class="border tableforfield centpercent">';
3008 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
3010 if ($object->prospect || $object->client || !empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT)) {
3011 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
3013 print
$form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
3018 if (((
isModEnabled(
"fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (
isModEnabled(
"supplier_order") && !empty($user->rights->supplier_order->lire)) || (
isModEnabled(
"supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) && $object->fournisseur) {
3019 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
3021 print
$form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
3029 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
3030 if ($action !=
'editthirdpartytype' && $user->hasRight(
'societe',
'creer')) {
3031 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>';
3033 print
'</tr></table>';
3035 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
3036 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
3040 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
3041 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
3045 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
3048 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
3049 if ($object->capital) {
3050 if (
isModEnabled(
"multicurrency") && !empty($object->multicurrency_code)) {
3051 print
price($object->capital,
'', $langs, 0, -1, -1, $object->multicurrency_code);
3053 print
price($object->capital,
'', $langs, 0, -1, -1, $conf->currency);
3061 if (!empty($conf->mailing->enabled)) {
3062 $result = $object->getNoEmail();
3066 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
3067 if ($object->email) {
3068 print
yn($object->no_email);
3070 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
3073 $langs->load(
"mails");
3074 print
' <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans(
"NbOfEMailingsSend")).
'">'.$object->getNbOfEMailings().
'</span>';
3081 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3082 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
3085 $langs->load(
"languages");
3086 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
3087 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
3095 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
3096 if ($action !=
'editincoterm' && $user->hasRight(
'societe',
'creer')) {
3097 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
3099 print
'</tr></table>';
3100 print
'</td><td colspan="3">';
3101 if ($action !=
'editincoterm') {
3102 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
3104 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.$object->id);
3112 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
3114 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
3118 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
3120 print
'<tr><td class="nowrap">';
3121 print $langs->trans(
"ProductAccountancySellCode");
3122 print
'</td><td colspan="2">';
3124 if (!empty($object->accountancy_code_sell)) {
3126 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
3128 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
3131 print $object->accountancy_code_sell;
3136 print
'<tr><td class="nowrap">';
3137 print $langs->trans(
"ProductAccountancyBuyCode");
3138 print
'</td><td colspan="2">';
3140 if (!empty($object->accountancy_code_buy)) {
3142 $accountingaccount2->fetch(
'', $object->accountancy_code_buy, 1);
3144 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3147 print $object->accountancy_code_buy;
3153 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3154 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3157 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
3159 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3160 if ($action !=
'editparentcompany' && $user->hasRight(
'societe',
'creer')) {
3161 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>';
3163 print
'</tr></table>';
3165 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3166 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->parent, $html_name,
'', 1, 0, 0,
null, 0, array($object->id));
3171 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3175 $langs->load(
"members");
3176 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3179 $result = $adh->fetch(
'',
'', $object->id);
3181 $adh->ref = $adh->getFullName($langs);
3182 print $adh->getNomUrl(-1);
3184 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3186 print
"</td></tr>\n";
3206 if (!empty($conf->syncsupplierwebservices->enabled)) {
3207 print
'<tr><td>'.$langs->trans(
"WebServiceURL").
'</td><td>'.
dol_print_url($object->webservices_url).
'</td>';
3208 print
'<td class="nowrap">'.$langs->trans(
'WebServiceKey').
'</td><td>'.$object->webservices_key.
'</td></tr>';
3215 print
'<div style="clear:both"></div>';
3223 if ($action !=
'presend') {
3224 print
'<div class="tabsAction">'.
"\n";
3227 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
3228 if (empty($reshook)) {
3229 $at_least_one_email_contact =
false;
3230 $TContact = $object->contact_array_objects();
3231 foreach ($TContact as &$contact) {
3232 if (!empty($contact->email)) {
3233 $at_least_one_email_contact =
true;
3238 if (empty($user->socid)) {
3239 $langs->load(
"mails");
3241 if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans(
'NoEMail'); }
3242 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);
3245 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
3249 $result = $adh->fetch(
'',
'', $object->id);
3250 if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) {
3251 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";
3255 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=merge&token='.
newToken(),
'', $permissiontodelete);
3257 if ($user->hasRight(
'societe',
'supprimer')) {
3258 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.
newToken();
3259 $buttonId =
'action-delete-no-ajax';
3260 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3262 $buttonId =
'action-delete';
3264 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3268 print
'</div>'.
"\n";
3272 if (
GETPOST(
'modelselected')) {
3273 $action =
'presend';
3276 if ($action !=
'presend') {
3277 print
'<div class="fichecenter"><div class="fichehalfleft">';
3279 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
3280 print
'<a name="builddoc"></a>';
3285 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
3286 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
3287 $genallowed = $user->hasRight(
'societe',
'lire');
3288 $delallowed = $user->hasRight(
'societe',
'creer');
3290 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);
3294 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) {
3298 print
'</div><div class="fichehalfright">';
3302 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
3305 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3307 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3309 print
'</div></div>';
3311 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
3313 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
3314 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3320 $modelmail =
'thirdparty';
3321 $defaulttopic =
'Information';
3322 $diroutput = $conf->societe->multidir_output[$object->entity];
3323 $trackid =
'thi'.$object->id;
3325 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
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.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage categories.
Class to manage third parties objects (customers, suppliers, prospects...)
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null)
Add a file into database index.
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded')
Delete files into database index using search criterias.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0)
Show Url link.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
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_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1, $separ=' ')
Format profIDs according to country.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
$formconfirm
if ($action == 'delbookkeepingyear') {
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.