39require
'../main.inc.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50if (isModEnabled(
'adherent')) {
51 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
53if (isModEnabled(
'accounting')) {
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
56if (isModEnabled(
'accounting')) {
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
59if (isModEnabled(
'accounting')) {
60 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
62if (isModEnabled(
'eventorganization')) {
63 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
69$langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
71if (isModEnabled(
'adherent')) {
72 $langs->load(
"members");
74if (isModEnabled(
'categorie')) {
75 $langs->load(
"categories");
77if (isModEnabled(
'incoterm')) {
78 $langs->load(
"incoterm");
80if (isModEnabled(
'notification')) {
81 $langs->load(
"mails");
83if (isModEnabled(
'accounting')) {
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');
99if (!empty($backtopagejsfields)) {
100 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
101 $dol_openinpopup = $tmpbacktopagejsfields[0];
106 $socid = $user->socid;
108if (empty($socid) && $action ==
'view') {
118$extrafields->fetch_name_optionals_label($object->table_element);
123$hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
126 $object->fetch($socid);
129if (!($object->id > 0) && $action ==
'view') {
130 $langs->load(
"errors");
131 print($langs->trans(
'ErrorRecordNotFound'));
136$canvas = $object->canvas ? $object->canvas :
GETPOST(
"canvas");
138if (!empty($canvas)) {
139 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
140 $objcanvas =
new Canvas($db, $action);
141 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
145$permissiontoread = $user->hasRight(
'societe',
'lire');
146$permissiontoadd = $user->hasRight(
'societe',
'creer');
147$permissiontodelete = $user->hasRight(
'societe',
'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0);
148$permissionnote = $user->hasRight(
'societe',
'creer');
149$permissiondellink = $user->hasRight(
'societe',
'creer');
150$upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
153$result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
161$parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
162$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
167if (empty($reshook)) {
168 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
170 if (empty($backtopage) || ($cancel && empty($id))) {
171 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
172 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
173 $backtopage = $backurlforlist;
175 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
181 if (!empty($backtopageforcancel)) {
182 header(
"Location: ".$backtopageforcancel);
184 } elseif (!empty($backtopage)) {
185 header(
"Location: ".$backtopage);
191 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
193 $soc_origin_id =
GETPOST(
'soc_origin',
'int');
194 $soc_origin =
new Societe($db);
196 if ($soc_origin_id <= 0) {
197 $langs->load(
'errors');
198 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
200 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
211 $object->client = $object->client | $soc_origin->client;
212 $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
213 $listofproperties = array(
214 'address',
'zip',
'town',
'state_id',
'country_id',
'phone',
'phone_pro',
'fax',
'email',
'socialnetworks',
'url',
'barcode',
215 'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
216 'tva_intra',
'effectif_id',
'forme_juridique',
'remise_percent',
'remise_supplier_percent',
'mode_reglement_supplier_id',
'cond_reglement_supplier_id',
'name_bis',
217 'stcomm_id',
'outstanding_limit',
'price_level',
'parent',
'default_lang',
'ref',
'ref_ext',
'import_key',
'fk_incoterms',
'fk_multicurrency',
218 'code_client',
'code_fournisseur',
'code_compta',
'code_compta_fournisseur',
219 'model_pdf',
'fk_projet'
221 foreach ($listofproperties as $property) {
222 if (empty($object->$property)) {
223 $object->$property = $soc_origin->$property;
228 $listofproperties = array(
229 'note_public',
'note_private'
231 foreach ($listofproperties as $property) {
232 $object->$property =
dol_concatdesc($object->$property, $soc_origin->$property);
236 if (is_array($soc_origin->array_options)) {
237 foreach ($soc_origin->array_options as $key => $val) {
238 if (empty($object->array_options[$key])) {
239 $object->array_options[$key] = $val;
245 if (empty($object->name_bis) && $object->name != $soc_origin->name) {
246 $object->name_bis = $soc_origin->name;
252 $custcats_ori = $static_cat->containing($soc_origin->id,
'customer',
'id');
253 $custcats = $static_cat->containing($object->id,
'customer',
'id');
254 $custcats = array_merge($custcats, $custcats_ori);
255 $object->setCategories($custcats,
'customer');
257 $suppcats_ori = $static_cat->containing($soc_origin->id,
'supplier',
'id');
258 $suppcats = $static_cat->containing($object->id,
'supplier',
'id');
259 $suppcats = array_merge($suppcats, $suppcats_ori);
260 $object->setCategories($suppcats,
'supplier');
263 if ($soc_origin->code_client == $object->code_client
264 || $soc_origin->code_fournisseur == $object->code_fournisseur
265 || $soc_origin->barcode == $object->barcode) {
266 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
267 $soc_origin->code_client =
'';
268 $soc_origin->code_fournisseur =
'';
269 $soc_origin->barcode =
'';
270 $soc_origin->update($soc_origin->id, $user, 0, 1, 1,
'merge');
274 $result = $object->update($object->id, $user, 0, 1, 1,
'merge');
286 'Adherent' =>
'/adherents/class/adherent.class.php',
287 'Don' => array(
'file' =>
'/don/class/don.class.php',
'enabled' => isModEnabled(
'don')),
288 'Societe' =>
'/societe/class/societe.class.php',
290 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
291 'Propal' =>
'/comm/propal/class/propal.class.php',
292 'Commande' =>
'/commande/class/commande.class.php',
293 'Facture' =>
'/compta/facture/class/facture.class.php',
294 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
295 'LignePrelevement' =>
'/compta/prelevement/class/ligneprelevement.class.php',
296 'Mo' =>
'/mrp/class/mo.class.php',
297 'Contact' =>
'/contact/class/contact.class.php',
298 'Contrat' =>
'/contrat/class/contrat.class.php',
299 'Expedition' =>
'/expedition/class/expedition.class.php',
300 'Fichinter' =>
'/fichinter/class/fichinter.class.php',
301 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
302 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
303 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
304 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
305 'Delivery' =>
'/delivery/class/delivery.class.php',
306 'Product' =>
'/product/class/product.class.php',
307 'Project' =>
'/projet/class/project.class.php',
308 'Ticket' => array(
'file' =>
'/ticket/class/ticket.class.php',
'enabled' => isModEnabled(
'ticket')),
309 'User' =>
'/user/class/user.class.php',
310 'Account' =>
'/compta/bank/class/account.class.php',
311 'ConferenceOrBoothAttendee' =>
'/eventorganization/class/conferenceorboothattendee.class.php'
315 foreach ($objects as $object_name => $object_file) {
316 if (is_array($object_file)) {
317 if (empty($object_file[
'enabled'])) {
320 $object_file = $object_file[
'file'];
323 require_once DOL_DOCUMENT_ROOT.$object_file;
325 if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) {
335 $parameters = array(
'soc_origin' => $soc_origin->id,
'soc_dest' => $object->id);
336 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', $parameters, $object, $action);
346 $object->context = array(
'merge'=>1,
'mergefromid'=>$soc_origin->id,
'mergefromname'=>$soc_origin->name);
349 $result = $object->call_trigger(
'COMPANY_MODIFY', $user);
359 if ($soc_origin->delete($soc_origin->id, $user) < 1) {
369 $langs->load(
"errors");
377 if (
GETPOST(
'getcustomercode')) {
379 $_POST[
"customer_code"] =
"Acompleter";
382 if (
GETPOST(
'getsuppliercode')) {
384 $_POST[
"supplier_code"] =
"Acompleter";
387 if ($action ==
'set_localtax1') {
390 $object->fetch($socid);
391 $res = $object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
393 if ($action ==
'set_localtax2') {
396 $object->fetch($socid);
397 $res = $object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
400 if ($action ==
'update_extras') {
401 $object->fetch($socid);
406 $extrafields->fetch_name_optionals_label($object->table_element);
408 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
414 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
422 $action =
'edit_extras';
428 && ($action ==
'add' || $action ==
'update') && $user->hasRight(
'societe',
'creer')) {
429 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
432 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
436 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")),
null,
'errors');
439 if (GETPOSTISSET(
'fournisseur') &&
GETPOST(
'fournisseur',
'int') < 0) {
440 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
444 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
446 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
449 if (isModEnabled(
'mailing') &&
GETPOST(
"private",
'int') == 1 &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
451 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
455 if ($action ==
'update') {
456 $ret = $object->fetch($socid);
457 $object->oldcopy = clone $object;
459 $object->canvas = $canvas;
462 if (
GETPOST(
"private",
'int') == 1) {
463 $object->particulier =
GETPOST(
"private",
'int');
466 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
468 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
469 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
471 $object->name =
GETPOST(
'name',
'alphanohtml');
473 $object->entity = (GETPOSTISSET(
'entity') ?
GETPOST(
'entity',
'int') : $conf->entity);
474 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
475 $object->parent = GETPOSTISSET(
'parent_company_id') ?
GETPOST(
'parent_company_id',
'int') : $object->parent;
476 $object->address =
GETPOST(
'address',
'alphanohtml');
477 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
478 $object->town =
GETPOST(
'town',
'alphanohtml');
479 $object->country_id =
GETPOST(
'country_id',
'int');
480 $object->state_id =
GETPOST(
'state_id',
'int');
482 $object->socialnetworks = array();
483 if (isModEnabled(
'socialnetworks')) {
484 foreach ($socialnetworks as $key => $value) {
485 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
486 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
491 $object->phone =
GETPOST(
'phone',
'alpha');
492 $object->fax =
GETPOST(
'fax',
'alpha');
493 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
494 $object->no_email =
GETPOST(
"no_email",
"int");
495 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
496 $object->idprof1 = trim(
GETPOST(
'idprof1',
'alphanohtml'));
497 $object->idprof2 = trim(
GETPOST(
'idprof2',
'alphanohtml'));
498 $object->idprof3 = trim(
GETPOST(
'idprof3',
'alphanohtml'));
499 $object->idprof4 = trim(
GETPOST(
'idprof4',
'alphanohtml'));
500 $object->idprof5 = trim(
GETPOST(
'idprof5',
'alphanohtml'));
501 $object->idprof6 = trim(
GETPOST(
'idprof6',
'alphanohtml'));
502 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
503 $object->code_client = GETPOSTISSET(
'customer_code') ?
GETPOST(
'customer_code',
'alpha') :
GETPOST(
'code_client',
'alpha');
504 $object->code_fournisseur = GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
505 $object->capital =
GETPOST(
'capital',
'alphanohtml');
506 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
508 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
509 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
510 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
511 $object->status =
GETPOST(
'status',
'alpha');
514 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
515 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
517 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
518 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
520 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
521 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
522 $object->typent_id =
GETPOST(
'typent_id',
'int');
524 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
526 $object->client =
GETPOST(
'client',
'int');
527 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
529 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
530 $object->default_lang =
GETPOST(
'default_lang');
533 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
534 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
536 if (GETPOSTISSET(
'accountancy_code_sell')) {
537 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
539 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
540 $object->accountancy_code_sell =
'';
542 $object->accountancy_code_sell = $accountancy_code_sell;
545 if (GETPOSTISSET(
'accountancy_code_buy')) {
546 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
548 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
549 $object->accountancy_code_buy =
'';
551 $object->accountancy_code_buy = $accountancy_code_buy;
556 if (isModEnabled(
'incoterm')) {
557 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
558 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
562 if (isModEnabled(
"multicurrency")) {
563 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
567 $ret = $extrafields->setOptionalsFromPost(
null, $object);
573 $ret = $object->setValuesForExtraLanguages();
579 if (!empty($_FILES[
'photo'][
'name'])) {
580 $current_logo = $object->logo;
585 if (!
GETPOST(
'cancel',
'alpha')) {
586 if (!empty($object->email) && !isValidEMail($object->email)) {
587 $langs->load(
"errors");
589 setEventMessages($langs->trans(
"ErrorBadEMail", $object->email),
null,
'errors');
591 if (!empty($object->url) && !
isValidUrl($object->url)) {
592 $langs->load(
"errors");
593 setEventMessages($langs->trans(
"ErrorBadUrl", $object->url),
null,
'errors');
595 if (!empty($object->webservices_url)) {
597 if (strpos($object->webservices_url,
"http") ===
false) {
598 $object->webservices_url =
"http://".$object->webservices_url;
601 $langs->load(
"errors");
602 $error++; $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
607 $object->country_id =
GETPOST(
'country_id',
'int') !=
'' ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
608 if ($object->country_id) {
609 $tmparray =
getCountry($object->country_id,
'all');
610 $object->country_code = $tmparray[
'code'];
611 $object->country = $tmparray[
'label'];
617 if ($action ==
'add') {
622 if (empty($object->client)) {
623 $object->code_client =
'';
625 if (empty($object->fournisseur)) {
626 $object->code_fournisseur =
'';
629 $result = $object->create($user);
631 if ($result >= 0 && isModEnabled(
'mailing') && !empty($object->email) && $object->no_email == 1) {
633 $resultnoemail = $object->setNoEmail($object->no_email);
634 if ($resultnoemail < 0) {
636 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
642 if ($object->particulier) {
643 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
644 $contcats =
GETPOST(
'contcats',
'array');
645 $no_email =
GETPOST(
'contact_no_email',
'int');
646 $result = $object->create_individual($user, $no_email, $contcats);
654 $salesreps =
GETPOST(
'commercial',
'array');
655 $result = $object->setSalesRep($salesreps,
true);
662 $custcats =
GETPOST(
'custcats',
'array');
663 $result = $object->setCategories($custcats,
'customer');
670 $suppcats =
GETPOST(
'suppcats',
'array');
671 $result = $object->setCategories($suppcats,
'supplier');
678 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
679 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
688 if (!($result > 0)) {
689 $errors[] =
"ErrorFailedToSaveFile";
692 $object->addThumbs($newfile);
697 switch ($_FILES[
'photo'][
'error']) {
700 $errors[] =
"ErrorFileSizeTooLarge";
703 $errors[] =
"ErrorFilePartiallyUploaded";
708 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors)) {
709 $duplicate_code_error =
true;
710 $object->code_client =
null;
713 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors)) {
714 $duplicate_code_error =
true;
715 $object->code_fournisseur =
null;
718 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
719 $duplicate_code_error =
true;
726 if ($result >= 0 && !$error) {
729 if ($backtopagejsfields) {
732 $retstring =
'<script>';
733 $retstring .=
'jQuery(document).ready(function() {
734 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
735 console.log(\
'id = '.$object->id.
'\');
736 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->id.
'\');
737 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->name.
'\');
738 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
740 $retstring .=
'</script>';
747 if (!empty($backtopage)) {
748 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
749 if (preg_match(
'/\?/', $backtopage)) {
750 $backtopage .=
'&socid='.$object->id;
752 header(
"Location: ".$backtopage);
755 $url = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
756 if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
757 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".$object->id;
758 } elseif ($object->fournisseur == 1) {
759 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".$object->id;
762 header(
"Location: ".$url);
771 if ($action ==
'update') {
774 if (
GETPOST(
'cancel',
'alpha')) {
775 if (!empty($backtopage)) {
776 header(
"Location: ".$backtopage);
779 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
785 if (empty($object->client) && empty($object->oldcopy->code_client)) {
786 $object->code_client =
'';
788 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
789 $object->code_fournisseur =
'';
793 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
797 if (GETPOSTISSET(
'no_email') && $object->email) {
798 $no_email =
GETPOST(
'no_email',
'int');
799 $result = $object->setNoEmail($no_email);
818 $salesreps =
GETPOST(
'commercial',
'array');
819 $result = $object->setSalesRep($salesreps);
826 if (!$error && $user->hasRight(
'categorie',
'lire')) {
828 $categories =
GETPOST(
'custcats',
'array');
829 $result = $object->setCategories($categories,
'customer');
836 $categories =
GETPOST(
'suppcats',
'array');
837 $result = $object->setCategories($categories,
'supplier');
845 $dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id.
"/logos";
846 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
847 if (
GETPOST(
'deletephoto') && $object->logo) {
848 $fileimg = $dir.
'/'.$object->logo;
849 $dirthumbs = $dir.
'/thumbs';
855 if ($current_logo != $object->logo) {
856 $fileimg = $dir.
'/'.$current_logo;
857 $dirthumbs = $dir.
'/thumbs';
868 if (!($result > 0)) {
869 $errors[] =
"ErrorFailedToSaveFile";
872 $object->addThumbs($newfile);
875 if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) {
876 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
885 $errors[] =
"ErrorBadImageFormat";
888 switch ($_FILES[
'photo'][
'error']) {
891 $errors[] =
"ErrorFileSizeTooLarge";
894 $errors[] =
"ErrorFilePartiallyUploaded";
902 if (!$error && $object->fk_soc > 0) {
903 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
904 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
905 if (!$object->db->query($sql)) {
907 $object->error .= $object->db->lasterror();
912 if (!$error && !count($errors)) {
913 if (!empty($backtopage)) {
914 header(
"Location: ".$backtopage);
917 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
921 $object->id = $socid;
926 $action = ($action ==
'add' ?
'create' :
'edit');
931 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'supprimer')) {
932 $object->fetch($socid);
933 $object->oldcopy = clone $object;
934 $result = $object->delete($socid, $user);
937 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
940 $langs->load(
"errors");
948 if ($action ==
'set_thirdpartytype' && $user->hasRight(
'societe',
'creer')) {
949 $object->fetch($socid);
950 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
954 if ($action ==
'set_incoterms' && $user->hasRight(
'societe',
'creer') && isModEnabled(
'incoterm')) {
955 $object->fetch($socid);
956 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
960 if ($action ==
'set_thirdparty' && $user->hasRight(
'societe',
'creer')) {
961 $object->fetch($socid);
962 $result = $object->setParent(
GETPOST(
'parent_id',
'int'));
966 if ($action ==
'set_salesrepresentatives' && $user->hasRight(
'societe',
'creer')) {
967 $object->fetch($socid);
968 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
972 if ($action ==
'setwarehouse' && $user->hasRight(
'societe',
'creer')) {
973 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
977 $object->fetch($socid);
980 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
981 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
985 $triggersendname =
'COMPANY_SENTBYMAIL';
986 $paramname =
'socid';
987 $mode =
'emailfromthirdparty';
988 $trackid =
'thi'.$object->id;
989 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
993 $upload_dir = !empty($conf->societe->multidir_output[$object->entity])?$conf->societe->multidir_output[$object->entity]:$conf->societe->dir_output;
994 $permissiontoadd = $user->hasRight(
'societe',
'creer');
995 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1003$form =
new Form($db);
1007if (isModEnabled(
'accounting')) {
1011if ($socid > 0 && empty($object->id)) {
1012 $result = $object->fetch($socid);
1019$title = $langs->trans(
"ThirdParty");
1020if ($action ==
'create') {
1021 $title = $langs->trans(
"NewThirdParty");
1023if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
1024 $title = $object->name.
" - ".$langs->trans(
'Card');
1026$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
1030$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
1032if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
1036 $objcanvas->assign_values($action, $object->id, $object->ref);
1037 $objcanvas->display_canvas($action);
1042 if ($action ==
'create') {
1046 $private =
GETPOST(
"private",
"int");
1047 if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !GETPOSTISSET(
'private')) {
1050 if (empty($private)) {
1055 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1056 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1057 $module = substr($module, 0,
dol_strlen($module) - 4);
1059 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1060 foreach ($dirsociete as $dirroot) {
1066 $modCodeClient =
new $module;
1068 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1069 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1070 $module = substr($module, 0,
dol_strlen($module) - 4);
1072 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1073 foreach ($dirsociete as $dirroot) {
1079 $modCodeFournisseur =
new $module;
1082 if (
GETPOST(
"type",
'aZ') !=
'f') {
1083 $object->client = -1;
1084 if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) {
1085 $object->client = 3;
1089 if (
GETPOST(
"type",
'aZ') ==
'c') {
1090 if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
1091 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
1093 $object->client = 3;
1096 if (
GETPOST(
"type",
'aZ') ==
'p') {
1097 $object->client = 2;
1100 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) {
1101 $object->client = 1;
1104 if ((isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) && (
GETPOST(
"type") ==
'f' || (
GETPOST(
"type") ==
'' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) {
1105 $object->fournisseur = 1;
1108 $object->name =
GETPOST(
'name',
'alphanohtml');
1109 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1110 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
1111 $object->particulier = $private;
1112 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1113 $object->client =
GETPOST(
'client',
'int') ?
GETPOST(
'client',
'int') : $object->client;
1115 if (empty($duplicate_code_error)) {
1116 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1117 $object->fournisseur =
GETPOST(
'fournisseur') ?
GETPOST(
'fournisseur',
'int') : $object->fournisseur;
1118 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1120 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
null,
'warnings');
1123 $object->address =
GETPOST(
'address',
'alphanohtml');
1124 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1125 $object->town =
GETPOST(
'town',
'alphanohtml');
1126 $object->state_id =
GETPOST(
'state_id',
'int');
1128 $object->socialnetworks = array();
1129 if (isModEnabled(
'socialnetworks')) {
1130 foreach ($socialnetworks as $key => $value) {
1131 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
1132 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1137 $object->phone =
GETPOST(
'phone',
'alpha');
1138 $object->fax =
GETPOST(
'fax',
'alpha');
1139 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1140 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1141 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1142 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1143 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1144 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1145 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1146 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1147 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1148 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1149 $object->typent_id =
GETPOST(
'typent_id',
'int');
1150 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1151 $object->civility_id =
GETPOST(
'civility_id',
'alpha');
1153 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1154 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
1155 $object->status =
GETPOST(
'status',
'int');
1158 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1159 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1161 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1162 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1164 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1166 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1167 $object->default_lang =
GETPOST(
'default_lang');
1169 if (GETPOSTISSET(
'accountancy_code_sell')) {
1170 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1172 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1173 $object->accountancy_code_sell =
'';
1175 $object->accountancy_code_sell = $accountancy_code_sell;
1178 if (GETPOSTISSET(
'accountancy_code_buy')) {
1179 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1181 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1182 $object->accountancy_code_buy =
'';
1184 $object->accountancy_code_buy = $accountancy_code_buy;
1188 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
1191 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos";
1192 $file_OK = (isset($_FILES[
'photo']) ?is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1197 if (@is_dir($dir)) {
1201 if (!($result > 0)) {
1202 $errors[] =
"ErrorFailedToSaveFile";
1205 $object->addThumbs($newfile);
1212 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1213 if ($object->country_id) {
1214 $tmparray =
getCountry($object->country_id,
'all');
1215 $object->country_code = $tmparray[
'code'];
1216 $object->country = $tmparray[
'label'];
1218 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
1221 if (isModEnabled(
"multicurrency")) {
1222 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1227 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1229 if (!empty($conf->use_javascript_ajax)) {
1230 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1231 print
"\n".
'<script type="text/javascript">';
1232 print
'$(document).ready(function () {
1235 is_private=' . $private.
';
1237 $(".individualline").show();
1239 $(".individualline").hide();
1241 $("#radiocompany").click(function() {
1242 $(".individualline").hide();
1243 $("#typent_id").val(0);
1244 $("#typent_id").change();
1245 $("#effectif_id").val(0);
1246 $("#effectif_id").change();
1247 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1248 document.formsoc.private.value=0;
1250 $("#radioprivate").click(function() {
1251 $(".individualline").show();
1252 $("#typent_id").val(id_te_private);
1253 $("#typent_id").change();
1254 $("#effectif_id").val(id_ef15);
1255 $("#effectif_id").change();
1256 /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
1257 if ($("#civility_id").data("select2")) {
1258 $("#civility_id").select2({width: "resolve"});
1260 $("#TypeName").html(document.formsoc.LastName.value);
1261 document.formsoc.private.value=1;
1264 var canHaveCustomerCategoryIfNotCustomerProspect = ' . (
getDolGlobalInt(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'1' :
'0') .
';
1266 init_customer_categ();
1267 $("#customerprospect").change(function() {
1268 init_customer_categ();
1270 function init_customer_categ() {
1271 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1272 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspect)
1274 jQuery(".visibleifcustomer").hide();
1278 jQuery(".visibleifcustomer").show();
1282 init_supplier_categ();
1283 $("#fournisseur").change(function() {
1284 init_supplier_categ();
1286 function init_supplier_categ() {
1287 console.log("is supplier = "+jQuery("#fournisseur").val());
1288 if (jQuery("#fournisseur").val() == 0)
1290 jQuery(".visibleifsupplier").hide();
1294 jQuery(".visibleifsupplier").show();
1298 $("#selectcountry_id").change(function() {
1299 document.formsoc.action.value="create";
1300 document.formsoc.submit();
1304 function init_check_no_email(input) {
1305 if (input.val()!="") {
1306 $(".noemail").addClass("fieldrequired");
1308 $(".noemail").removeClass("fieldrequired");
1311 $("#email").keyup(function() {
1312 init_check_no_email($(this));
1314 init_check_no_email($("#email"));';
1317 print
'</script>'.
"\n";
1319 print
'<div id="selectthirdpartytype">';
1320 print
'<div class="hideonsmartphone float">';
1321 print $langs->trans(
"ThirdPartyType").
': ';
1323 print
'<label for="radiocompany" class="radiocompany">';
1324 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1326 print $langs->trans(
"CreateThirdPartyOnly");
1328 print
' ';
1329 print
'<label for="radioprivate" class="radioprivate">';
1330 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1332 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1333 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1334 print $form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1339 print
'<script type="text/javascript">';
1340 print
'$(document).ready(function () {
1341 $("#selectcountry_id").change(function() {
1342 document.formsoc.action.value="create";
1343 document.formsoc.submit();
1346 print
'</script>'.
"\n";
1352 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1354 print
'<input type="hidden" name="action" value="add">';
1355 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1356 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1357 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1358 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
1359 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1360 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1361 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1362 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1363 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1364 print
'<input type="hidden" name="code_auto" value="1">';
1369 print
'<table class="border centpercent">';
1372 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1373 if ($object->particulier || $private) {
1374 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1376 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1378 print
'</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ?
' colspan="3"' :
'').
'>';
1380 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
1381 print $form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
1475 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
1476 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>';
1481 if ($conf->use_javascript_ajax) {
1482 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1484 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1485 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).
'"></td>';
1489 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1490 print $formcompany->select_civility($object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1496 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1497 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>';
1500 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1501 print
'<td class="maxwidthonsmartphone">';
1502 $selected = (GETPOSTISSET(
'client') ?
GETPOST(
'client',
'int') : $object->client);
1503 print $formcompany->selectProspectCustomerType($selected);
1506 if ($conf->browser->layout ==
'phone') {
1510 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1511 print
'<table class="nobordernopadding"><tr><td>';
1512 $tmpcode = $object->code_client;
1513 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1514 $tmpcode = $modCodeClient->getNextValue($object, 0);
1516 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1518 $s = $modCodeClient->getToolTip($langs, $object, 0);
1519 print $form->textwithpicto(
'', $s, 1);
1520 print
'</td></tr></table>';
1523 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))
1524 || (isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->lire))) {
1527 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
1529 if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) {
1532 print $form->selectyesno(
"fournisseur", (
GETPOST(
'fournisseur',
'int') !=
'' ?
GETPOST(
'fournisseur',
'int') : (
GETPOST(
"type",
'alpha') ==
'' ? $default : $object->fournisseur)), 1, 0, (
GETPOST(
"type",
'alpha') ==
'' ? 1 : 0), 1);
1536 if ($conf->browser->layout ==
'phone') {
1541 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))) {
1542 print $form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1545 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))) {
1546 print
'<table class="nobordernopadding"><tr><td>';
1547 $tmpcode = $object->code_fournisseur;
1548 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1549 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1551 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1553 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1554 print $form->textwithpicto(
'', $s, 1);
1555 print
'</td></tr></table>';
1561 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
1562 print $form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1566 if (isModEnabled(
'barcode')) {
1567 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1568 print
'<td colspan="3">';
1569 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1570 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
1575 print
'<tr><td class="tdtop">';
1576 print $form->editfieldkey(
'Address',
'address',
'', $object, 0);
1578 print
'<td colspan="3">';
1579 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1581 print
'</textarea>';
1582 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1586 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1587 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1589 if ($conf->browser->layout ==
'phone') {
1592 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1593 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1594 print $form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1598 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1599 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1600 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
1602 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1607 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1608 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)) {
1609 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1611 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1614 if ($object->country_id) {
1615 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1616 print $formcompany->select_state($object->state_id, $object->country_code);
1618 print $countrynotdefined;
1624 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1625 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>';
1626 if ($conf->browser->layout ==
'phone') {
1629 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1630 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>';
1633 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ?
'' : $conf->global->SOCIETE_EMAIL_MANDATORY).
'</td>';
1634 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>';
1635 if (isModEnabled(
'mailing') && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1636 if ($conf->browser->layout ==
'phone') {
1639 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1640 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>';
1643 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1644 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.
'"></td></tr>';
1647 if (isModEnabled(
'mailing')) {
1648 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1649 print
"\n".
'<script type="text/javascript">'.
"\n";
1650 print
'$(document).ready(function () {
1651 $("#email").keyup(function() {
1652 if ($(this).val()!="") {
1653 $(".noemail").addClass("fieldrequired");
1655 $(".noemail").removeClass("fieldrequired");
1659 print
'</script>'.
"\n";
1661 if (!GETPOSTISSET(
"no_email") && !empty($object->email)) {
1662 $result = $object->getNoEmail();
1668 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1670 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') :
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2));
1676 if (isModEnabled(
'socialnetworks')) {
1677 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
1681 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1683 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1684 if ($idprof !=
'-') {
1687 if (($j % $NBCOLS) == 0) {
1691 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1692 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1694 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1696 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1703 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1704 print
'<td colspan="2"></td></tr>';
1708 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1710 print $form->selectyesno(
'assujtva_value', GETPOSTISSET(
'assujtva_value') ?
GETPOST(
'assujtva_value',
'int') : 1, 1);
1712 if ($conf->browser->layout ==
'phone') {
1715 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1716 print
'<td class="nowrap">';
1717 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1719 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
1722 if (!empty($conf->use_javascript_ajax)) {
1724 if (!empty($conf->dol_use_jmobile)) {
1729 print
'<script type="text/javascript">';
1730 print
"function CheckVAT(a) {\n";
1731 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1735 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1736 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1738 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1746 if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
1747 print
'<tr><td>' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'', $object, 0) .
'</td><td colspan="3">';
1748 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
1754 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1755 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1756 print $form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1758 if ($conf->browser->layout ==
'phone') {
1761 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1762 print $form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1764 } elseif ($mysoc->localtax1_assuj ==
"1") {
1765 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1766 print $form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1768 } elseif ($mysoc->localtax2_assuj ==
"1") {
1769 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1770 print $form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1775 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";
1776 $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1777 print $form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1779 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1781 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
1783 if ($conf->browser->layout ==
'phone') {
1786 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1787 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1789 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1792 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1797 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1798 print
'<td colspan="3" class="maxwidthonsmartphone">';
1799 if ($object->country_id) {
1800 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1802 print $countrynotdefined;
1807 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1808 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1809 if (isModEnabled(
"multicurrency")) {
1810 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
1812 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
1815 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1816 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');
1822 if (isModEnabled(
'incoterm')) {
1824 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1825 print
'<td colspan="3" class="maxwidthonsmartphone">';
1826 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1831 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
1832 $langs->load(
'categories');
1835 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1836 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
'parent',
null,
null, 1);
1837 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1840 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1841 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1842 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
1843 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1848 if (isModEnabled(
"supplier_proposal") || isModEnabled(
"supplier_order") || isModEnabled(
"supplier_invoice")) {
1849 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1850 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
'parent',
null,
null, 1);
1851 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1857 if (isModEnabled(
"multicurrency")) {
1859 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1860 print
'<td colspan="3" class="maxwidthonsmartphone">';
1861 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1862 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
1867 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1868 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1871 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
1873 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1874 print
'<td colspan="3" class="maxwidthonsmartphone">';
1875 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1876 print $form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1882 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1883 print
'<td colspan="3" class="maxwidthonsmartphone">';
1884 $userlist = $form->select_dolusers(
'',
'', 0,
null, 0,
'',
'',
'0', 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 2);
1886 $selected = (count(
GETPOST(
'commercial',
'array')) > 0 ?
GETPOST(
'commercial',
'array') : (
GETPOST(
'commercial',
'int') > 0 ? array(
GETPOST(
'commercial',
'int')) : array($user->id)));
1887 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected,
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1891 print
'<tr class="hideonsmartphone">';
1892 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1893 print
'<td colspan="3">';
1894 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1898 print
'</table>'.
"\n";
1901 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
1902 print
'<table class="border centpercent">';
1904 if (isModEnabled(
'accounting')) {
1906 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1908 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1909 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'');
1913 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1915 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1916 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'');
1920 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1921 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1925 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1926 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1935 print $form->buttonsSaveCancel(
"AddThirdParty",
'Cancel',
null, 0,
'', $dol_openinpopup);
1937 print
'</form>'.
"\n";
1938 } elseif ($action ==
'edit') {
1942 $res = $object->fetch_optionals();
1948 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1949 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1950 $module = substr($module, 0,
dol_strlen($module) - 4);
1952 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1953 foreach ($dirsociete as $dirroot) {
1959 $modCodeClient =
new $module($db);
1961 if ($modCodeClient->code_auto) {
1962 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1964 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1965 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1966 $module = substr($module, 0,
dol_strlen($module) - 4);
1968 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1969 foreach ($dirsociete as $dirroot) {
1975 $modCodeFournisseur =
new $module($db);
1977 if ($modCodeFournisseur->code_auto) {
1978 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1981 $object->oldcopy = clone $object;
1983 if (GETPOSTISSET(
'name')) {
1985 $object->name =
GETPOST(
'name',
'alphanohtml');
1986 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1987 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1988 $object->client =
GETPOST(
'client',
'int');
1989 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1990 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
1991 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1992 $object->address =
GETPOST(
'address',
'alphanohtml');
1993 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1994 $object->town =
GETPOST(
'town',
'alphanohtml');
1995 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
1996 $object->state_id =
GETPOST(
'state_id',
'int');
1997 $object->parent =
GETPOST(
'parent_company_id',
'int');
1999 $object->socialnetworks = array();
2000 if (isModEnabled(
'socialnetworks')) {
2001 foreach ($socialnetworks as $key => $value) {
2002 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
2003 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
2008 $object->phone =
GETPOST(
'phone',
'alpha');
2009 $object->fax =
GETPOST(
'fax',
'alpha');
2010 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
2011 $object->no_email =
GETPOST(
"no_email",
"int");
2012 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
2013 $object->capital =
GETPOST(
'capital',
'alphanohtml');
2014 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
2015 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
2016 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
2017 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
2018 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
2019 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
2020 $object->typent_id =
GETPOST(
'typent_id',
'int');
2021 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
2022 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
2023 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
2024 $object->default_lang =
GETPOST(
'default_lang',
'alpha');
2026 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
2027 $object->vat_reverse_charge =
GETPOST(
'vat_reverse_charge') ==
'on' ? 1 : 0;
2028 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
2029 $object->status =
GETPOST(
'status',
'int');
2032 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
2033 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
2035 if (GETPOSTISSET(
'accountancy_code_sell')) {
2036 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
2038 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
2039 $object->accountancy_code_sell =
'';
2041 $object->accountancy_code_sell = $accountancy_code_sell;
2044 if (GETPOSTISSET(
'accountancy_code_buy')) {
2045 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
2047 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
2048 $object->accountancy_code_buy =
'';
2050 $object->accountancy_code_buy = $accountancy_code_buy;
2055 if (isModEnabled(
'incoterm')) {
2056 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
2057 $object->location_incoterms =
GETPOST(
'lcoation_incoterms',
'alpha');
2061 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value');
2062 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value');
2064 $object->localtax1_value =
GETPOST(
'lt1');
2065 $object->localtax2_value =
GETPOST(
'lt2');
2068 if ($object->country_id > 0) {
2069 $tmparray =
getCountry($object->country_id,
'all');
2070 $object->country_code = $tmparray[
'code'];
2071 $object->country = $tmparray[
'label'];
2075 if (isModEnabled(
"multicurrency")) {
2076 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $object->multicurrency_code;
2080 if ($object->localtax1_assuj == 0) {
2085 if ($object->localtax2_assuj == 0) {
2091 if (!empty($conf->use_javascript_ajax)) {
2092 print
"\n".
'<script type="text/javascript">';
2093 print
'$(document).ready(function () {
2096 if("#localtax1assuj_value".value==undefined){
2103 if("#localtax2assuj_value".value==undefined){
2110 $("#localtax1assuj_value").change(function() {
2111 var value=document.getElementById("localtax1assuj_value").value;
2118 $("#localtax2assuj_value").change(function() {
2119 var value=document.getElementById("localtax2assuj_value").value;
2127 var canHaveCustomerCategoryIfNotCustomerProspect = ' . (
getDolGlobalInt(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT') ?
'1' :
'0') .
';
2129 init_customer_categ();
2130 $("#customerprospect").change(function() {
2131 init_customer_categ();
2133 function init_customer_categ() {
2134 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
2135 if (jQuery("#customerprospect").val() == 0 && !canHaveCustomerCategoryIfNotCustomerProspect)
2137 jQuery(".visibleifcustomer").hide();
2141 jQuery(".visibleifcustomer").show();
2145 init_supplier_categ();
2146 $("#fournisseur").change(function() {
2147 init_supplier_categ();
2149 function init_supplier_categ() {
2150 console.log("is supplier = "+jQuery("#fournisseur").val());
2151 if (jQuery("#fournisseur").val() == 0)
2153 jQuery(".visibleifsupplier").hide();
2157 jQuery(".visibleifsupplier").show();
2161 $("#selectcountry_id").change(function() {
2162 document.formsoc.action.value="edit";
2163 document.formsoc.submit();
2167 print
'</script>'.
"\n";
2170 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'" method="post" name="formsoc">';
2171 print
'<input type="hidden" name="action" value="update">';
2172 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2173 print
'<input type="hidden" name="socid" value="'.$object->id.
'">';
2174 print
'<input type="hidden" name="entity" value="'.$object->entity.
'">';
2175 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
2176 print
'<input type="hidden" name="code_auto" value="1">';
2182 print
'<div class="fichecenter2">';
2183 print
'<table class="border centpercent">';
2186 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
2187 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ID").
'</td><td colspan="3">';
2193 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0,
'string',
'', 1).
'</td>';
2194 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
2195 print $form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
2199 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
2200 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>';
2203 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2204 print
'<tr><td>'.$form->editfieldkey(
'Prefix',
'prefix',
'', $object, 0).
'</td><td colspan="3">';
2206 if (($prefixCustomerIsUsed || $prefixSupplierIsUsed) && $object->prefix_comm) {
2207 print
'<input type="hidden" name="prefix_comm" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2208 print $object->prefix_comm;
2210 print
'<input type="text" size="5" maxlength="5" name="prefix_comm" id="prefix" value="'.dol_escape_htmltag($object->prefix_comm).
'">';
2216 print
'<tr><td>'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
2217 print
'<td class="maxwidthonsmartphone">';
2218 print $formcompany->selectProspectCustomerType($object->client);
2220 if ($conf->browser->layout ==
'phone') {
2223 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
2225 print
'<table class="nobordernopadding"><tr><td>';
2226 if ((!$object->code_client || $object->code_client == -1) && $modCodeClient->code_auto) {
2227 $tmpcode = $object->code_client;
2228 if (empty($tmpcode) && !empty($object->oldcopy->code_client)) {
2229 $tmpcode = $object->oldcopy->code_client;
2231 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
2232 $tmpcode = $modCodeClient->getNextValue($object, 0);
2234 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2235 } elseif ($object->codeclient_modifiable()) {
2236 print
'<input type="text" name="customer_code" id="customer_code" size="16" value="'.dol_escape_htmltag($object->code_client).
'" maxlength="24">';
2238 print $object->code_client;
2239 print
'<input type="hidden" name="customer_code" value="'.dol_escape_htmltag($object->code_client).
'">';
2242 $s = $modCodeClient->getToolTip($langs, $object, 0);
2243 print $form->textwithpicto(
'', $s, 1);
2244 print
'</td></tr></table>';
2249 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)))
2250 || (isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->lire))) {
2252 print
'<td>'.$form->editfieldkey(
'Supplier',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td>';
2253 print
'<td class="maxwidthonsmartphone">';
2254 print $form->selectyesno(
"fournisseur", $object->fournisseur, 1,
false, 0, 1);
2256 if ($conf->browser->layout ==
'phone') {
2260 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))) {
2261 print $form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
2265 print
'<table class="nobordernopadding"><tr><td>';
2266 if ((!$object->code_fournisseur || $object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) {
2267 $tmpcode = $object->code_fournisseur;
2268 if (empty($tmpcode) && !empty($object->oldcopy->code_fournisseur)) {
2269 $tmpcode = $object->oldcopy->code_fournisseur;
2271 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
2272 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
2274 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
2275 } elseif ($object->codefournisseur_modifiable()) {
2276 print
'<input type="text" name="supplier_code" id="supplier_code" size="16" value="'.dol_escape_htmltag($object->code_fournisseur).
'" maxlength="24">';
2278 print $object->code_fournisseur;
2279 print
'<input type="hidden" name="supplier_code" value="'.$object->code_fournisseur.
'">';
2282 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
2283 print $form->textwithpicto(
'', $s, 1);
2284 print
'</td></tr></table>';
2289 if (isModEnabled(
'barcode')) {
2290 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
2291 print
'<td colspan="3">';
2293 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
2298 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
2299 print $form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), $object->status, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
2303 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
2304 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
2306 print
'</textarea>';
2307 print $form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
2311 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"':
'').
'>';
2312 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
2314 if ($conf->browser->layout ==
'phone') {
2317 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"':
'').
'>';
2318 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
2319 print $form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
2323 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcounty_id',
'', $object, 0).
'</td><td colspan="3">';
2324 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2325 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
2327 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2332 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
2333 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)) {
2334 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2336 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
2339 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2340 print $formcompany->select_state($object->state_id, $object->country_code);
2345 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
GETPOST(
'phone',
'alpha'), $object, 0).
'</td>';
2346 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>';
2347 if ($conf->browser->layout ==
'phone') {
2350 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
2351 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>';
2355 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
GETPOST(
'url',
'alpha'), $object, 0).
'</td>';
2356 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>';
2359 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
2360 print
'<td colspan="3">';
2361 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
2362 print
'<input type="text" name="email" id="email" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'">';
2366 if (isModEnabled(
'mailing')) {
2367 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
2368 print
"\n".
'<script type="text/javascript">'.
"\n";
2371 jQuery(document).ready(function () {
2372 function init_check_no_email(input) {
2373 if (input.val()!="") {
2374 $(".noemail").addClass("fieldrequired");
2376 $(".noemail").removeClass("fieldrequired");
2379 $("#email").keyup(function() {
2380 init_check_no_email($(this));
2382 init_check_no_email($("#email"));
2384 print
'</script>'.
"\n";
2386 if (!GETPOSTISSET(
"no_email") && !empty($object->email)) {
2387 $result = $object->getNoEmail();
2393 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
2395 $useempty = (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
2396 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $object->no_email), 1, false, $useempty);
2402 if (isModEnabled(
'socialnetworks')) {
2403 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
2409 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2411 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2412 if ($idprof !=
'-') {
2415 if (($j % $NBCOLS) == 0) {
2419 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2420 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).
'</td><td>';
2421 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2423 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2430 if ($NBCOLS > 0 && $j % 2 == 1) {
2431 print
'<td colspan="2"></td></tr>';
2435 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2436 print $form->selectyesno(
'assujtva_value', $object->tva_assuj, 1);
2441 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2442 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td>';
2443 print $form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2445 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2446 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2451 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2452 print $form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2454 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2455 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2459 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2460 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2461 print $form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2463 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2464 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2468 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2469 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2470 print $form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2472 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2473 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2480 if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
2481 print
'<tr><td>' . $form->editfieldkey(
'VATReverseChargeByDefault',
'vat_reverse_charge',
'', $object, 0) .
'</td><td colspan="3">';
2482 print
'<input type="checkbox" name="vat_reverse_charge" '.($object->vat_reverse_charge ==
'1' ?
' checked' :
'').
'>';
2487 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2488 print
'<td colspan="3">';
2489 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2491 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2494 if ($conf->use_javascript_ajax) {
2496 if (!empty($conf->dol_use_jmobile)) {
2501 print
'<script type="text/javascript">';
2502 print
"function CheckVAT(a) {\n";
2503 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2507 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2508 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2510 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2518 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"' :
'').
'>';
2519 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);
2521 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2523 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2525 if ($conf->browser->layout ==
'phone') {
2528 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2529 print $form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2531 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2534 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2539 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2540 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
2544 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2545 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2547 if (isModEnabled(
"multicurrency")) {
2548 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
2550 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2555 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2556 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->default_lang,
'default_lang', 0,
null,
'1', 0, 0,
'maxwidth300 widthcentpercentminusx');
2562 if (isModEnabled(
'incoterm')) {
2564 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2565 print
'<td colspan="3" class="maxwidthonsmartphone">';
2566 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
2571 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
2573 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2574 print
'<td colspan="3">';
2575 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
null,
null,
null, 1);
2577 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2578 $arrayselected = array();
2579 foreach ($cats as $cat) {
2580 $arrayselected[] = $cat->id;
2582 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2586 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))) {
2587 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2588 print
'<td colspan="3">';
2589 $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
null,
null,
null, 1);
2591 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2592 $arrayselected = array();
2593 foreach ($cats as $cat) {
2594 $arrayselected[] = $cat->id;
2596 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2602 if (isModEnabled(
"multicurrency")) {
2604 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2605 print
'<td colspan="3" class="maxwidthonsmartphone">';
2606 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2607 print $form->selectMultiCurrency((GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'', false,
'maxwidth150 widthcentpercentminusx');
2612 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2613 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2616 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
2618 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
2619 print
'<td colspan="3" class="maxwidthonsmartphone">';
2620 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2621 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');
2626 if (!empty($conf->syncsupplierwebservices->enabled)) {
2627 print
'<tr><td>'.$form->editfieldkey(
'WebServiceURL',
'webservices_url',
'', $object, 0).
'</td>';
2628 print
'<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.
'"></td>';
2629 print
'<td>'.$form->editfieldkey(
'WebServiceKey',
'webservices_key',
'', $object, 0).
'</td>';
2630 print
'<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.
'"></td></tr>';
2634 print
'<tr class="hideonsmartphone">';
2635 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2636 print
'<td colspan="3">';
2637 if ($object->logo) {
2638 print $form->showphoto(
'societe', $object);
2641 if ($caneditfield) {
2642 if ($object->logo) {
2645 print
'<table class="nobordernopadding">';
2646 if ($object->logo) {
2647 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> <label for="photodelete">'.$langs->trans(
"Delete").
'</photo><br><br></td></tr>';
2652 $maxmin = $maxfilesizearray[
'maxmin'];
2654 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2656 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2665 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2666 print
'<td colspan="3" class="maxwidthonsmartphone">';
2667 $userlist = $form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
2668 $arrayselected =
GETPOST(
'commercial',
'array');
2669 if (empty($arrayselected)) {
2670 $arrayselected = $object->getSalesRepresentatives($user, 1);
2672 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2677 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2679 print
'<table class="border centpercent">';
2681 if (isModEnabled(
'accounting')) {
2683 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2685 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
2689 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2691 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
2695 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2696 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2700 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2701 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2711 print $form->buttonsSaveCancel();
2720 if (!empty($object->id)) {
2721 $res = $object->fetch_optionals();
2733 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2734 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2737 if ($action ==
'merge') {
2738 $formquestion = array(
2740 'name' =>
'soc_origin',
2741 'label' => $langs->trans(
'MergeOriginThirdparty'),
2743 'value' => $form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200',
'',
'', 1,
null,
false, array($object->id))
2747 $formconfirm .= $form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2751 $parameters = array(
'formConfirm' => $formconfirm);
2752 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2753 if (empty($reshook)) {
2754 $formconfirm .= $hookmanager->resPrint;
2755 } elseif ($reshook > 0) {
2756 $formconfirm = $hookmanager->resPrint;
2764 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2766 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2769 print
'<div class="fichecenter">';
2770 print
'<div class="fichehalfleft">';
2772 print
'<div class="underbanner clearboth"></div>';
2773 print
'<table class="border tableforfield centpercent">';
2776 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2777 print $object->getTypeUrl(1);
2781 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2782 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.
dol_escape_htmltag($object->prefix_comm).
'</td>';
2787 if ($object->client) {
2789 print $langs->trans(
'CustomerCode');
2793 $tmpcheck = $object->check_codeclient();
2794 if ($tmpcheck != 0 && $tmpcheck != -5) {
2795 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2802 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) {
2804 print $langs->trans(
'SupplierCode').
'</td><td>';
2806 $tmpcheck = $object->check_codefournisseur();
2807 if ($tmpcheck != 0 && $tmpcheck != -5) {
2808 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2815 if (isModEnabled(
'barcode')) {
2825 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2826 if ($idprof !=
'-') {
2829 print
'<td>'.$idprof.
'</td><td>';
2832 if ($object->$key) {
2833 if ($object->id_prof_check($i, $object) > 0) {
2834 if (!empty($object->id_prof_url($i, $object))) {
2835 print
' '.$object->id_prof_url($i, $object);
2838 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
2855 if ($object->fournisseur) {
2858 print $form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2860 print
yn($object->tva_assuj);
2864 if (!empty($conf->global->ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE)) {
2867 print $form->textwithpicto($langs->trans(
'VATReverseChargeByDefault'), $langs->trans(
'VATReverseChargeByDefaultDesc'));
2869 print
'<input type="checkbox" name="vat_reverse_charge" ' . ($object->vat_reverse_charge ==
'1' ?
' checked' :
'') .
' disabled>';
2876 if ($object->fournisseur || $mysoc->country_code ==
'ES') {
2877 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2878 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2879 print
yn($object->localtax1_assuj);
2880 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2881 print
yn($object->localtax2_assuj);
2885 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2886 print
'<input type="hidden" name="action" value="set_localtax1">';
2887 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2888 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>';
2889 if ($action ==
'editRE') {
2890 print
'<td class="left">';
2891 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2892 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2894 print
'<td>'.$object->localtax1_value.
'</td>';
2896 print
'</tr></form>';
2899 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2900 print
'<input type="hidden" name="action" value="set_localtax2">';
2901 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2902 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>';
2903 if ($action ==
'editIRPF') {
2904 print
'<td class="left">';
2905 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2906 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2908 print
'<td>'.$object->localtax2_value.
'</td>';
2910 print
'</tr></form>';
2912 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2913 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2914 print
yn($object->localtax1_assuj);
2917 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2918 print
'<input type="hidden" name="action" value="set_localtax1">';
2919 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2920 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>';
2921 if ($action ==
'editRE') {
2922 print
'<td class="left">';
2923 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2924 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2926 print
'<td>'.$object->localtax1_value.
'</td>';
2928 print
'</tr></form>';
2930 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2931 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2932 print
yn($object->localtax2_assuj);
2935 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2936 print
'<input type="hidden" name="action" value="set_localtax2">';
2937 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2938 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>';
2939 if ($action ==
'editIRPF') {
2940 print
'<td class="left">';
2941 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2942 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2944 print
'<td>'.$object->localtax2_value.
'</td>';
2946 print
'</tr></form>';
2953 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
2954 if ($object->tva_intra) {
2957 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2959 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2962 if ($conf->use_javascript_ajax) {
2964 if (!empty($conf->dol_use_jmobile)) {
2969 print
'<script type="text/javascript">';
2970 print
"function CheckVAT(a) {\n";
2971 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2975 $s .=
'<a href="#" class="hideonsmartphone" onclick="CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans(
"VATIntraCheck").
'</a>';
2976 $s = $form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2978 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2988 if (isModEnabled(
'stock') && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
2989 $langs->load(
'stocks');
2990 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2992 print
'<tr class="nowrap">';
2994 print $form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->rights->societe->creer);
2996 if ($action ==
'editwarehouse') {
2997 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
2999 if ($object->fk_warehouse > 0) {
3000 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
3002 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
3011 print
'<div class="fichehalfright">';
3013 print
'<div class="underbanner clearboth"></div>';
3014 print
'<table class="border tableforfield centpercent">';
3017 if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
3019 if ($object->prospect || $object->client ||
getDolGlobalInt(
'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT')) {
3020 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
3022 print $form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
3027 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) {
3028 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
3030 print $form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
3038 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
3039 if ($action !=
'editthirdpartytype' && $user->hasRight(
'societe',
'creer')) {
3040 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>';
3042 print
'</tr></table>';
3044 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
3045 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
3049 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
3050 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
3054 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
3057 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
3058 if ($object->capital) {
3059 if (isModEnabled(
"multicurrency") && !empty($object->multicurrency_code)) {
3060 print
price($object->capital,
'', $langs, 0, -1, -1, $object->multicurrency_code);
3062 print
price($object->capital,
'', $langs, 0, -1, -1, $conf->currency);
3070 if (isModEnabled(
'mailing')) {
3071 $result = $object->getNoEmail();
3075 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
3076 if ($object->email) {
3077 print
yn($object->no_email);
3079 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
3082 $langs->load(
"mails");
3083 print
' <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans(
"NbOfEMailingsSend")).
'">'.$object->getNbOfEMailings().
'</span>';
3090 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3091 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
3094 $langs->load(
"languages");
3095 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
3096 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
3102 if (isModEnabled(
'incoterm')) {
3104 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
3105 if ($action !=
'editincoterm' && $user->hasRight(
'societe',
'creer')) {
3106 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=editincoterm&token='.newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
3108 print
'</tr></table>';
3109 print
'</td><td colspan="3">';
3110 if ($action !=
'editincoterm') {
3111 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
3113 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.$object->id);
3119 if (isModEnabled(
"multicurrency")) {
3121 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
3123 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
3127 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
3129 print
'<tr><td class="nowrap">';
3130 print $langs->trans(
"ProductAccountancySellCode");
3131 print
'</td><td colspan="2">';
3132 if (isModEnabled(
'accounting')) {
3133 if (!empty($object->accountancy_code_sell)) {
3135 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
3137 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
3140 print $object->accountancy_code_sell;
3145 print
'<tr><td class="nowrap">';
3146 print $langs->trans(
"ProductAccountancyBuyCode");
3147 print
'</td><td colspan="2">';
3148 if (isModEnabled(
'accounting')) {
3149 if (!empty($object->accountancy_code_buy)) {
3151 $accountingaccount2->fetch(
'', $object->accountancy_code_buy, 1);
3153 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3156 print $object->accountancy_code_buy;
3162 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3163 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3166 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
3168 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3169 if ($action !=
'editparentcompany' && $user->hasRight(
'societe',
'creer')) {
3170 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>';
3172 print
'</tr></table>';
3174 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3175 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->parent, $html_name,
'', 1, 0, 0,
null, 0, array($object->id));
3180 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3183 if (isModEnabled(
'adherent')) {
3184 $langs->load(
"members");
3185 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3188 $result = $adh->fetch(
'',
'', $object->id);
3190 $adh->ref = $adh->getFullName($langs);
3191 print $adh->getNomUrl(-1);
3193 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3195 print
"</td></tr>\n";
3215 if (!empty($conf->syncsupplierwebservices->enabled)) {
3216 print
'<tr><td>'.$langs->trans(
"WebServiceURL").
'</td><td>'.
dol_print_url($object->webservices_url).
'</td>';
3217 print
'<td class="nowrap">'.$langs->trans(
'WebServiceKey').
'</td><td>'.$object->webservices_key.
'</td></tr>';
3224 print
'<div class="clearboth"></div>';
3232 if ($action !=
'presend') {
3233 print
'<div class="tabsAction">'.
"\n";
3235 $parameters = array();
3236 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3237 if (empty($reshook)) {
3238 $at_least_one_email_contact =
false;
3239 $TContact = $object->contact_array_objects();
3240 foreach ($TContact as &$contact) {
3241 if (!empty($contact->email)) {
3242 $at_least_one_email_contact =
true;
3247 if (empty($user->socid)) {
3248 $langs->load(
"mails");
3250 if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans(
'NoEMail'); }
3251 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);
3254 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
3256 if (isModEnabled(
'adherent')) {
3258 $result = $adh->fetch(
'',
'', $object->id);
3259 if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) {
3260 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";
3264 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=merge&token='.newToken(),
'', $permissiontodelete);
3266 if ($user->hasRight(
'societe',
'supprimer')) {
3267 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.newToken();
3268 $buttonId =
'action-delete-no-ajax';
3269 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3271 $buttonId =
'action-delete';
3273 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3277 print
'</div>'.
"\n";
3281 if (
GETPOST(
'modelselected')) {
3282 $action =
'presend';
3285 if ($action !=
'presend') {
3286 print
'<div class="fichecenter"><div class="fichehalfleft">';
3288 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
3289 print
'<a name="builddoc"></a>';
3294 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
3295 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
3296 $genallowed = $user->hasRight(
'societe',
'lire');
3297 $delallowed = $user->hasRight(
'societe',
'creer');
3299 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);
3303 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) {
3307 print
'</div><div class="fichehalfright">';
3311 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
3314 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3316 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3318 print
'</div></div>';
3320 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
3322 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
3323 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3329 $modelmail =
'thirdparty';
3330 $defaulttopic =
'Information';
3331 $diroutput = $conf->societe->multidir_output[$object->entity];
3332 $trackid =
'thi'.$object->id;
3334 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage categories.
Class to manage third parties objects (customers, suppliers, prospects...)
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null)
Add a file into database index.
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded')
Delete files into database index using search criterias.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='float')
Show Url link.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
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.