39 require
'../main.inc.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/eventorganization/class/conferenceorboothattendee.class.php';
69 $langs->loadLangs(array(
"companies",
"commercial",
"bills",
"banks",
"users"));
72 $langs->load(
"members");
75 $langs->load(
"categories");
78 $langs->load(
"incoterm");
81 $langs->load(
"mails");
84 $langs->load(
"products");
87 $error = 0; $errors = array();
91 $action = (
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view');
92 $cancel =
GETPOST(
'cancel',
'alpha');
93 $backtopage =
GETPOST(
'backtopage',
'alpha');
94 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
95 $backtopagejsfields =
GETPOST(
'backtopagejsfields',
'alpha');
96 $dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
97 $confirm =
GETPOST(
'confirm',
'alpha');
101 $socid = $user->socid;
103 if (empty($socid) && $action ==
'view') {
113 $extrafields->fetch_name_optionals_label($object->table_element);
118 $hookmanager->initHooks(array(
'thirdpartycard',
'globalcard'));
121 $object->fetch($socid);
124 if (!($object->id > 0) && $action ==
'view') {
125 $langs->load(
"errors");
126 print($langs->trans(
'ErrorRecordNotFound'));
131 $canvas = $object->canvas ? $object->canvas :
GETPOST(
"canvas");
133 if (!empty($canvas)) {
134 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
135 $objcanvas =
new Canvas($db, $action);
136 $objcanvas->getCanvas(
'thirdparty',
'card', $canvas);
140 $permissiontoread = $user->hasRight(
'societe',
'lire');
141 $permissiontoadd = $user->hasRight(
'societe',
'creer');
142 $permissiontodelete = $user->hasRight(
'societe',
'supprimer') || ($permissiontoadd && isset($object->status) && $object->status == 0);
143 $permissionnote = $user->hasRight(
'societe',
'creer');
144 $permissiondellink = $user->hasRight(
'societe',
'creer');
145 $upload_dir = $conf->societe->multidir_output[isset($object->entity) ? $object->entity : 1];
148 $result =
restrictedArea($user,
'societe', $socid,
'&societe',
'',
'fk_soc',
'rowid', 0);
156 $parameters = array(
'id'=>$socid,
'objcanvas'=>$objcanvas);
157 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
162 if (empty($reshook)) {
163 $backurlforlist = DOL_URL_ROOT.
'/societe/list.php';
165 if (empty($backtopage) || ($cancel && empty($id))) {
166 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
167 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
168 $backtopage = $backurlforlist;
170 $backtopage = DOL_URL_ROOT.
'/societe/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
176 if (!empty($backtopageforcancel)) {
177 header(
"Location: ".$backtopageforcancel);
179 } elseif (!empty($backtopage)) {
180 header(
"Location: ".$backtopage);
186 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->rights->societe->creer) {
188 $soc_origin_id =
GETPOST(
'soc_origin',
'int');
189 $soc_origin =
new Societe($db);
191 if ($soc_origin_id <= 0) {
192 $langs->load(
'errors');
193 setEventMessages($langs->trans(
'ErrorThirdPartyIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginThirdparty')),
null,
'errors');
195 if (!$error && $soc_origin->fetch($soc_origin_id) < 1) {
206 $object->client = $object->client | $soc_origin->client;
207 $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
208 $listofproperties = array(
209 'address',
'zip',
'town',
'state_id',
'country_id',
'phone',
'phone_pro',
'fax',
'email',
'socialnetworks',
'url',
'barcode',
210 'idprof1',
'idprof2',
'idprof3',
'idprof4',
'idprof5',
'idprof6',
211 'tva_intra',
'effectif_id',
'forme_juridique',
'remise_percent',
'remise_supplier_percent',
'mode_reglement_supplier_id',
'cond_reglement_supplier_id',
'name_bis',
212 'stcomm_id',
'outstanding_limit',
'price_level',
'parent',
'default_lang',
'ref',
'ref_ext',
'import_key',
'fk_incoterms',
'fk_multicurrency',
213 'code_client',
'code_fournisseur',
'code_compta',
'code_compta_fournisseur',
214 'model_pdf',
'fk_projet'
216 foreach ($listofproperties as $property) {
217 if (empty($object->$property)) {
218 $object->$property = $soc_origin->$property;
223 $listofproperties = array(
224 'note_public',
'note_private'
226 foreach ($listofproperties as $property) {
227 $object->$property =
dol_concatdesc($object->$property, $soc_origin->$property);
231 if (is_array($soc_origin->array_options)) {
232 foreach ($soc_origin->array_options as $key => $val) {
233 if (empty($object->array_options[$key])) {
234 $object->array_options[$key] = $val;
242 $custcats_ori = $static_cat->containing($soc_origin->id,
'customer',
'id');
243 $custcats = $static_cat->containing($object->id,
'customer',
'id');
244 $custcats = array_merge($custcats, $custcats_ori);
245 $object->setCategories($custcats,
'customer');
247 $suppcats_ori = $static_cat->containing($soc_origin->id,
'supplier',
'id');
248 $suppcats = $static_cat->containing($object->id,
'supplier',
'id');
249 $suppcats = array_merge($suppcats, $suppcats_ori);
250 $object->setCategories($suppcats,
'supplier');
253 if ($soc_origin->code_client == $object->code_client
254 || $soc_origin->code_fournisseur == $object->code_fournisseur
255 || $soc_origin->barcode == $object->barcode) {
256 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
257 $soc_origin->code_client =
'';
258 $soc_origin->code_fournisseur =
'';
259 $soc_origin->barcode =
'';
260 $soc_origin->update($soc_origin->id, $user, 0, 1, 1,
'merge');
264 $result = $object->update($object->id, $user, 0, 1, 1,
'merge');
276 'Adherent' =>
'/adherents/class/adherent.class.php',
277 'Don' => array(
'file' =>
'/don/class/don.class.php',
'enabled' =>
isModEnabled(
'don')),
278 'Societe' =>
'/societe/class/societe.class.php',
280 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
281 'Propal' =>
'/comm/propal/class/propal.class.php',
282 'Commande' =>
'/commande/class/commande.class.php',
283 'Facture' =>
'/compta/facture/class/facture.class.php',
284 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
285 'LignePrelevement' =>
'/compta/prelevement/class/ligneprelevement.class.php',
286 'Mo' =>
'/mrp/class/mo.class.php',
287 'Contact' =>
'/contact/class/contact.class.php',
288 'Contrat' =>
'/contrat/class/contrat.class.php',
289 'Expedition' =>
'/expedition/class/expedition.class.php',
290 'Fichinter' =>
'/fichinter/class/fichinter.class.php',
291 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
292 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
293 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
294 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
295 'Delivery' =>
'/delivery/class/delivery.class.php',
296 'Product' =>
'/product/class/product.class.php',
297 'Project' =>
'/projet/class/project.class.php',
298 'Ticket' => array(
'file' =>
'/ticket/class/ticket.class.php',
'enabled' =>
isModEnabled(
'ticket')),
299 'User' =>
'/user/class/user.class.php',
300 'Account' =>
'/compta/bank/class/account.class.php',
301 'ConferenceOrBoothAttendee' =>
'/eventorganization/class/conferenceorboothattendee.class.php'
305 foreach ($objects as $object_name => $object_file) {
306 if (is_array($object_file)) {
307 if (empty($object_file[
'enabled'])) {
310 $object_file = $object_file[
'file'];
313 require_once DOL_DOCUMENT_ROOT.$object_file;
315 if (!$error && !$object_name::replaceThirdparty($db, $soc_origin->id, $object->id)) {
325 $reshook = $hookmanager->executeHooks(
'replaceThirdparty', array(
326 'soc_origin' => $soc_origin->id,
327 'soc_dest' => $object->id
328 ), $object, $action);
338 $object->context = array(
'merge'=>1,
'mergefromid'=>$soc_origin->id);
341 $result = $object->call_trigger(
'COMPANY_MODIFY', $user);
351 if ($soc_origin->delete($soc_origin->id, $user) < 1) {
361 $langs->load(
"errors");
369 if (
GETPOST(
'getcustomercode')) {
371 $_POST[
"customer_code"] =
"Acompleter";
374 if (
GETPOST(
'getsuppliercode')) {
376 $_POST[
"supplier_code"] =
"Acompleter";
379 if ($action ==
'set_localtax1') {
382 $object->fetch($socid);
383 $res = $object->setValueFrom(
'localtax1_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
385 if ($action ==
'set_localtax2') {
388 $object->fetch($socid);
389 $res = $object->setValueFrom(
'localtax2_value', $value,
'',
null,
'text',
'', $user,
'COMPANY_MODIFY');
392 if ($action ==
'update_extras') {
393 $object->fetch($socid);
398 $extrafields->fetch_name_optionals_label($object->table_element);
400 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
406 $result = $object->insertExtraFields(
'COMPANY_MODIFY');
414 $action =
'edit_extras';
420 && ($action ==
'add' || $action ==
'update') && $user->rights->societe->creer) {
421 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
424 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ThirdPartyName")),
null,
'errors');
428 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ProspectCustomer")),
null,
'errors');
432 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Supplier")),
null,
'errors');
436 if (
isModEnabled(
'mailing') && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
438 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
441 if (
isModEnabled(
'mailing') &&
GETPOST(
"private",
'int') == 1 && !empty($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
'contact_no_email',
'int')==-1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
443 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email")),
null,
'errors');
447 if ($action ==
'update') {
448 $ret = $object->fetch($socid);
449 $object->oldcopy = clone $object;
451 $object->canvas = $canvas;
454 if (
GETPOST(
"private",
'int') == 1) {
455 $object->particulier =
GETPOST(
"private",
'int');
458 $object->civility_id =
GETPOST(
'civility_id',
'alphanohtml');
460 $object->name_bis =
GETPOST(
'name',
'alphanohtml');
461 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
463 $object->name =
GETPOST(
'name',
'alphanohtml');
466 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
467 $object->parent =
GETPOSTISSET(
'parent_company_id') ?
GETPOST(
'parent_company_id',
'int') : $object->parent;
468 $object->address =
GETPOST(
'address',
'alphanohtml');
469 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
470 $object->town =
GETPOST(
'town',
'alphanohtml');
471 $object->country_id =
GETPOST(
'country_id',
'int');
472 $object->state_id =
GETPOST(
'state_id',
'int');
474 $object->socialnetworks = array();
476 foreach ($socialnetworks as $key => $value) {
478 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
483 $object->phone =
GETPOST(
'phone',
'alpha');
484 $object->fax =
GETPOST(
'fax',
'alpha');
485 $object->email = trim(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL));
486 $object->no_email =
GETPOST(
"no_email",
"int");
487 $object->url = trim(
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL));
488 $object->idprof1 = trim(
GETPOST(
'idprof1',
'alphanohtml'));
489 $object->idprof2 = trim(
GETPOST(
'idprof2',
'alphanohtml'));
490 $object->idprof3 = trim(
GETPOST(
'idprof3',
'alphanohtml'));
491 $object->idprof4 = trim(
GETPOST(
'idprof4',
'alphanohtml'));
492 $object->idprof5 = trim(
GETPOST(
'idprof5',
'alphanohtml'));
493 $object->idprof6 = trim(
GETPOST(
'idprof6',
'alphanohtml'));
494 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
496 $object->code_fournisseur =
GETPOSTISSET(
'supplier_code') ?
GETPOST(
'supplier_code',
'alpha') :
GETPOST(
'code_fournisseur',
'alpha');
497 $object->capital =
GETPOST(
'capital',
'alphanohtml');
498 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
500 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
501 $object->tva_assuj =
GETPOST(
'assujtva_value',
'alpha');
502 $object->status =
GETPOST(
'status',
'alpha');
505 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'alpha');
506 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'alpha');
508 $object->localtax1_value =
GETPOST(
'lt1',
'alpha');
509 $object->localtax2_value =
GETPOST(
'lt2',
'alpha');
511 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
512 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
513 $object->typent_id =
GETPOST(
'typent_id',
'int');
515 $object->typent_code =
dol_getIdFromCode($db, $object->typent_id,
'c_typent',
'id',
'code');
517 $object->client =
GETPOST(
'client',
'int');
518 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
520 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
521 $object->default_lang =
GETPOST(
'default_lang');
524 $object->webservices_url =
GETPOST(
'webservices_url',
'custom', 0, FILTER_SANITIZE_URL);
525 $object->webservices_key =
GETPOST(
'webservices_key',
'san_alpha');
528 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
530 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
531 $object->accountancy_code_sell =
'';
533 $object->accountancy_code_sell = $accountancy_code_sell;
537 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
539 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
540 $object->accountancy_code_buy =
'';
542 $object->accountancy_code_buy = $accountancy_code_buy;
548 $object->fk_incoterms =
GETPOST(
'incoterm_id',
'int');
549 $object->location_incoterms =
GETPOST(
'location_incoterms',
'alpha');
554 $object->multicurrency_code =
GETPOST(
'multicurrency_code',
'alpha');
558 $ret = $extrafields->setOptionalsFromPost(
null, $object);
564 $ret = $object->setValuesForExtraLanguages();
570 if (!empty($_FILES[
'photo'][
'name'])) {
571 $current_logo = $object->logo;
576 if (!
GETPOST(
'cancel',
'alpha')) {
577 if (!empty($object->email) && !isValidEMail($object->email)) {
578 $langs->load(
"errors");
580 setEventMessages($langs->trans(
"ErrorBadEMail", $object->email),
null,
'errors');
582 if (!empty($object->url) && !
isValidUrl($object->url)) {
583 $langs->load(
"errors");
584 setEventMessages($langs->trans(
"ErrorBadUrl", $object->url),
null,
'errors');
586 if (!empty($object->webservices_url)) {
588 if (strpos($object->webservices_url,
"http") ===
false) {
589 $object->webservices_url =
"http://".$object->webservices_url;
592 $langs->load(
"errors");
593 $error++; $errors[] = $langs->trans(
"ErrorBadUrl", $object->webservices_url);
598 $object->country_id =
GETPOST(
'country_id',
'int') !=
'' ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
599 if ($object->country_id) {
600 $tmparray =
getCountry($object->country_id,
'all');
601 $object->country_code = $tmparray[
'code'];
602 $object->country = $tmparray[
'label'];
608 if ($action ==
'add') {
613 if (empty($object->client)) {
614 $object->code_client =
'';
616 if (empty($object->fournisseur)) {
617 $object->code_fournisseur =
'';
620 $result = $object->create($user);
622 if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email) && $object->no_email == 1) {
624 $result = $object->setNoEmail($object->no_email);
627 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
633 if ($object->particulier) {
634 dol_syslog(
"We ask to create a contact/address too", LOG_DEBUG);
635 $contcats =
GETPOST(
'contcats',
'array');
636 $no_email =
GETPOST(
'contact_no_email',
'int');
637 $result = $object->create_individual($user, $no_email, $contcats);
645 $salesreps =
GETPOST(
'commercial',
'array');
646 $result = $object->setSalesRep($salesreps,
true);
653 $custcats =
GETPOST(
'custcats',
'array');
654 $result = $object->setCategories($custcats,
'customer');
661 $suppcats =
GETPOST(
'suppcats',
'array');
662 $result = $object->setCategories($suppcats,
'supplier');
669 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos/";
670 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
679 if (!($result > 0)) {
680 $errors[] =
"ErrorFailedToSaveFile";
683 $object->addThumbs($newfile);
688 switch ($_FILES[
'photo'][
'error']) {
691 $errors[] =
"ErrorFileSizeTooLarge";
694 $errors[] =
"ErrorFilePartiallyUploaded";
699 if ($result == -3 && in_array(
'ErrorCustomerCodeAlreadyUsed', $object->errors)) {
700 $duplicate_code_error =
true;
701 $object->code_client =
null;
704 if ($result == -3 && in_array(
'ErrorSupplierCodeAlreadyUsed', $object->errors)) {
705 $duplicate_code_error =
true;
706 $object->code_fournisseur =
null;
709 if ($db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
710 $duplicate_code_error =
true;
717 if ($result >= 0 && !$error) {
720 if ($backtopagejsfields) {
723 $tmpbacktopagejsfields = explode(
':', $backtopagejsfields);
724 $dol_openinpopup = $tmpbacktopagejsfields[0];
726 $retstring =
'<script>';
727 $retstring .=
'jQuery(document).ready(function() {
728 console.log(\'We execute action to create. We save id and go back - '.$dol_openinpopup.
'\');
729 console.log(\
'id = '.$object->id.
'\');
730 $(\
'#varforreturndialogid'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->id.
'\');
731 $(\
'#varforreturndialoglabel'.$dol_openinpopup.
'\', window.parent.document).text(\
''.$object->name.
'\');
732 window.parent.jQuery(\
'#idfordialog'.$dol_openinpopup.
'\').dialog(\
'close\');
734 $retstring .=
'</script>';
741 if (!empty($backtopage)) {
742 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
743 if (preg_match(
'/\?/', $backtopage)) {
744 $backtopage .=
'&socid='.$object->id;
746 header(
"Location: ".$backtopage);
749 $url = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
750 if (($object->client == 1 || $object->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
751 $url = DOL_URL_ROOT.
"/comm/card.php?socid=".$object->id;
752 } elseif ($object->fournisseur == 1) {
753 $url = DOL_URL_ROOT.
"/fourn/card.php?socid=".$object->id;
756 header(
"Location: ".$url);
765 if ($action ==
'update') {
768 if (
GETPOST(
'cancel',
'alpha')) {
769 if (!empty($backtopage)) {
770 header(
"Location: ".$backtopage);
773 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
779 if (empty($object->client) && empty($object->oldcopy->code_client)) {
780 $object->code_client =
'';
782 if (empty($object->fournisseur) && empty($object->oldcopy->code_fournisseur)) {
783 $object->code_fournisseur =
'';
787 $result = $object->update($socid, $user, 1, $object->oldcopy->codeclient_modifiable(), $object->oldcopy->codefournisseur_modifiable(),
'update', 0);
792 $no_email =
GETPOST(
'no_email',
'int');
793 $result = $object->setNoEmail($no_email);
812 $salesreps =
GETPOST(
'commercial',
'array');
813 $result = $object->setSalesRep($salesreps);
820 if (!$error && !empty($user->rights->categorie->lire)) {
822 $categories =
GETPOST(
'custcats',
'array');
823 $result = $object->setCategories($categories,
'customer');
830 $categories =
GETPOST(
'suppcats',
'array');
831 $result = $object->setCategories($categories,
'supplier');
839 $dir = $conf->societe->multidir_output[$object->entity].
"/".$object->id.
"/logos";
840 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
841 if (
GETPOST(
'deletephoto') && $object->logo) {
842 $fileimg = $dir.
'/'.$object->logo;
843 $dirthumbs = $dir.
'/thumbs';
849 if ($current_logo != $object->logo) {
850 $fileimg = $dir.
'/'.$current_logo;
851 $dirthumbs = $dir.
'/thumbs';
862 if (!($result > 0)) {
863 $errors[] =
"ErrorFailedToSaveFile";
866 $object->addThumbs($newfile);
869 if (!empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) {
870 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
879 $errors[] =
"ErrorBadImageFormat";
882 switch ($_FILES[
'photo'][
'error']) {
885 $errors[] =
"ErrorFileSizeTooLarge";
888 $errors[] =
"ErrorFilePartiallyUploaded";
896 if (!$error && $object->fk_soc > 0) {
897 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"adherent";
898 $sql .=
" SET fk_soc = NULL WHERE fk_soc = ".((int) $socid);
899 if (!$object->db->query($sql)) {
901 $object->error .= $object->db->lasterror();
906 if (!$error && !count($errors)) {
907 if (!empty($backtopage)) {
908 header(
"Location: ".$backtopage);
911 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?socid=".$socid);
915 $object->id = $socid;
920 $action = ($action ==
'add' ?
'create' :
'edit');
925 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'supprimer')) {
926 $object->fetch($socid);
927 $object->oldcopy = clone $object;
928 $result = $object->delete($socid, $user);
931 header(
"Location: ".DOL_URL_ROOT.
"/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name));
934 $langs->load(
"errors");
942 if ($action ==
'set_thirdpartytype' && $user->rights->societe->creer) {
943 $object->fetch($socid);
944 $result = $object->setThirdpartyType(
GETPOST(
'typent_id',
'int'));
948 if ($action ==
'set_incoterms' && $user->rights->societe->creer &&
isModEnabled(
'incoterm')) {
949 $object->fetch($socid);
950 $result = $object->setIncoterms(
GETPOST(
'incoterm_id',
'int'),
GETPOST(
'location_incoterms',
'alpha'));
954 if ($action ==
'set_thirdparty' && $user->rights->societe->creer) {
955 $object->fetch($socid);
956 $result = $object->setParent(
GETPOST(
'parent_id',
'int'));
960 if ($action ==
'set_salesrepresentatives' && $user->rights->societe->creer) {
961 $object->fetch($socid);
962 $result = $object->setSalesRep(
GETPOST(
'commercial',
'array'));
966 if ($action ==
'setwarehouse' && $user->rights->societe->creer) {
967 $result = $object->setWarehouse(
GETPOST(
'fk_warehouse',
'int'));
971 $object->fetch($socid);
974 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
975 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
979 $triggersendname =
'COMPANY_SENTBYMAIL';
980 $paramname =
'socid';
981 $mode =
'emailfromthirdparty';
982 $trackid =
'thi'.$object->id;
983 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
987 $upload_dir = !empty($conf->societe->multidir_output[$object->entity])?$conf->societe->multidir_output[$object->entity]:$conf->societe->dir_output;
988 $permissiontoadd = $user->hasRight(
'societe',
'creer');
989 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1005 if ($socid > 0 && empty($object->id)) {
1006 $result = $object->fetch($socid);
1013 $title = $langs->trans(
"ThirdParty");
1014 if ($action ==
'create') {
1015 $title = $langs->trans(
"NewThirdParty");
1017 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
1018 $title = $object->name.
" - ".$langs->trans(
'Card');
1020 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas|DE:Modul_Geschäftspartner';
1024 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
1026 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
1030 $objcanvas->assign_values($action, $object->id, $object->ref);
1031 $objcanvas->display_canvas($action);
1036 if ($action ==
'create') {
1040 $private =
GETPOST(
"private",
"int");
1041 if (!empty($conf->global->THIRDPARTY_DEFAULT_CREATE_CONTACT) && !
GETPOSTISSET(
'private')) {
1044 if (empty($private)) {
1049 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1050 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1051 $module = substr($module, 0,
dol_strlen($module) - 4);
1053 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1054 foreach ($dirsociete as $dirroot) {
1060 $modCodeClient =
new $module;
1062 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1063 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1064 $module = substr($module, 0,
dol_strlen($module) - 4);
1066 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1067 foreach ($dirsociete as $dirroot) {
1073 $modCodeFournisseur =
new $module;
1076 if (
GETPOST(
"type",
'aZ') !=
'f') {
1077 $object->client = -1;
1078 if (!empty($conf->global->THIRDPARTY_CUSTOMERPROSPECT_BY_DEFAULT)) {
1079 $object->client = 3;
1083 if (
GETPOST(
"type",
'aZ') ==
'c') {
1084 if (!empty($conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT)) {
1085 $object->client = $conf->global->THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT;
1087 $object->client = 3;
1090 if (
GETPOST(
"type",
'aZ') ==
'p') {
1091 $object->client = 2;
1094 if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS) && $object->client == 3) {
1095 $object->client = 1;
1098 if (((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order") ||
isModEnabled(
"supplier_invoice")) && (
GETPOST(
"type") ==
'f' || (
GETPOST(
"type") ==
'' && !empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)))) {
1099 $object->fournisseur = 1;
1102 $object->name =
GETPOST(
'name',
'alphanohtml');
1103 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1104 $object->firstname =
GETPOST(
'firstname',
'alphanohtml');
1105 $object->particulier = $private;
1106 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1107 $object->client =
GETPOST(
'client',
'int') ?
GETPOST(
'client',
'int') : $object->client;
1109 if (empty($duplicate_code_error)) {
1110 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1111 $object->fournisseur =
GETPOST(
'fournisseur') ?
GETPOST(
'fournisseur',
'int') : $object->fournisseur;
1112 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1114 setEventMessages($langs->trans(
'NewCustomerSupplierCodeProposed'),
'',
'warnings');
1117 $object->address =
GETPOST(
'address',
'alphanohtml');
1118 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1119 $object->town =
GETPOST(
'town',
'alphanohtml');
1120 $object->state_id =
GETPOST(
'state_id',
'int');
1122 $object->socialnetworks = array();
1124 foreach ($socialnetworks as $key => $value) {
1126 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
1131 $object->phone =
GETPOST(
'phone',
'alpha');
1132 $object->fax =
GETPOST(
'fax',
'alpha');
1133 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
1134 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
1135 $object->capital =
GETPOST(
'capital',
'alphanohtml');
1136 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
1137 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
1138 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
1139 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
1140 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
1141 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
1142 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
1143 $object->typent_id =
GETPOST(
'typent_id',
'int');
1144 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
1145 $object->civility_id =
GETPOST(
'civility_id',
'alpha');
1147 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
1148 $object->status =
GETPOST(
'status',
'int');
1151 $object->localtax1_assuj =
GETPOST(
'localtax1assuj_value',
'int');
1152 $object->localtax2_assuj =
GETPOST(
'localtax2assuj_value',
'int');
1154 $object->localtax1_value =
GETPOST(
'lt1',
'int');
1155 $object->localtax2_value =
GETPOST(
'lt2',
'int');
1157 $object->tva_intra =
GETPOST(
'tva_intra',
'alphanohtml');
1159 $object->commercial_id =
GETPOST(
'commercial_id',
'int');
1160 $object->default_lang =
GETPOST(
'default_lang');
1163 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1165 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
1166 $object->accountancy_code_sell =
'';
1168 $object->accountancy_code_sell = $accountancy_code_sell;
1172 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1174 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
1175 $object->accountancy_code_buy =
'';
1177 $object->accountancy_code_buy = $accountancy_code_buy;
1181 $object->logo = (isset($_FILES[
'photo']) ?
dol_sanitizeFileName($_FILES[
'photo'][
'name']) :
'');
1184 $dir = $conf->societe->multidir_output[$conf->entity].
"/".$object->id.
"/logos";
1185 $file_OK = (isset($_FILES[
'photo']) ?is_uploaded_file($_FILES[
'photo'][
'tmp_name']) : false);
1190 if (@is_dir($dir)) {
1194 if (!($result > 0)) {
1195 $errors[] =
"ErrorFailedToSaveFile";
1198 $object->addThumbs($newfile);
1205 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $mysoc->country_id;
1206 if ($object->country_id) {
1207 $tmparray =
getCountry($object->country_id,
'all');
1208 $object->country_code = $tmparray[
'code'];
1209 $object->country = $tmparray[
'label'];
1211 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code');
1215 $object->multicurrency_code =
GETPOST(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : $conf->currency;
1220 print
load_fiche_titre($langs->trans(
"NewThirdParty"), $linkback,
'building');
1222 if (!empty($conf->use_javascript_ajax)) {
1223 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1224 print
"\n".
'<script type="text/javascript">';
1225 print
'$(document).ready(function () {
1228 is_private=' . $private.
';
1230 $(".individualline").show();
1232 $(".individualline").hide();
1234 $("#radiocompany").click(function() {
1235 $(".individualline").hide();
1236 $("#typent_id").val(0);
1237 $("#typent_id").change();
1238 $("#effectif_id").val(0);
1239 $("#effectif_id").change();
1240 $("#TypeName").html(document.formsoc.ThirdPartyName.value);
1241 document.formsoc.private.value=0;
1243 $("#radioprivate").click(function() {
1244 $(".individualline").show();
1245 $("#typent_id").val(id_te_private);
1246 $("#typent_id").change();
1247 $("#effectif_id").val(id_ef15);
1248 $("#effectif_id").change();
1249 /* Force to recompute the width of a select2 field when it was hidden and then shown programatically */
1250 if ($("#civility_id").data("select2")) {
1251 $("#civility_id").select2({width: "resolve"});
1253 $("#TypeName").html(document.formsoc.LastName.value);
1254 document.formsoc.private.value=1;
1257 var canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
1259 init_customer_categ();
1260 $("#customerprospect").change(function() {
1261 init_customer_categ();
1263 function init_customer_categ() {
1264 console.log("is customer or prospect = "+jQuery("#customerprospect").val());
1265 if (jQuery("#customerprospect").val() == 0 && !canHaveCategoryIfNotCustomerProspectSupplier)
1267 jQuery(".visibleifcustomer").hide();
1271 jQuery(".visibleifcustomer").show();
1275 init_supplier_categ();
1276 $("#fournisseur").change(function() {
1277 init_supplier_categ();
1279 function init_supplier_categ() {
1280 console.log("is supplier = "+jQuery("#fournisseur").val());
1281 if (jQuery("#fournisseur").val() == 0)
1283 jQuery(".visibleifsupplier").hide();
1287 jQuery(".visibleifsupplier").show();
1291 $("#selectcountry_id").change(function() {
1292 document.formsoc.action.value="create";
1293 document.formsoc.submit();
1295 if ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1297 function init_check_no_email(input) {
1298 if (input.val()!="") {
1299 $(".noemail").addClass("fieldrequired");
1301 $(".noemail").removeClass("fieldrequired");
1304 $("#email").keyup(function() {
1305 init_check_no_email($(this));
1307 init_check_no_email($("#email"));';
1310 print
'</script>'.
"\n";
1312 print
'<div id="selectthirdpartytype">';
1313 print
'<div class="hideonsmartphone float">';
1314 print $langs->trans(
"ThirdPartyType").
': ';
1316 print
'<label for="radiocompany" class="radiocompany">';
1317 print
'<input type="radio" id="radiocompany" class="flat" name="private" value="0"'.($private ?
'' :
' checked').
'>';
1319 print $langs->trans(
"CreateThirdPartyOnly");
1321 print
' ';
1322 print
'<label for="radioprivate" class="radioprivate">';
1323 $text =
'<input type="radio" id="radioprivate" class="flat" name="private" value="1"'.($private ?
' checked' :
'').
'>';
1325 $text .= $langs->trans(
"CreateThirdPartyAndContact");
1326 $htmltext = $langs->trans(
"ToCreateContactWithSameName");
1327 print
$form->textwithpicto($text, $htmltext, 1,
'help',
'', 0, 3);
1332 print
'<script type="text/javascript">';
1333 print
'$(document).ready(function () {
1334 $("#selectcountry_id").change(function() {
1335 document.formsoc.action.value="create";
1336 document.formsoc.submit();
1339 print
'</script>'.
"\n";
1345 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'" method="post" name="formsoc" autocomplete="off">';
1347 print
'<input type="hidden" name="action" value="add">';
1348 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1349 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1350 print
'<input type="hidden" name="backtopagejsfields" value="'.$backtopagejsfields.
'">';
1351 print
'<input type="hidden" name="dol_openinpopup" value="'.$dol_openinpopup.
'">';
1352 print
'<input type="hidden" name="private" value='.$object->particulier.
'>';
1353 print
'<input type="hidden" name="type" value='.GETPOST(
"type",
'alpha').
'>';
1354 print
'<input type="hidden" name="LastName" value="'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName').
'">';
1355 print
'<input type="hidden" name="ThirdPartyName" value="'.$langs->trans(
'ThirdPartyName').
'">';
1356 if ($modCodeClient->code_auto || $modCodeFournisseur->code_auto) {
1357 print
'<input type="hidden" name="code_auto" value="1">';
1362 print
'<table class="border centpercent">';
1365 print
'<tr class="tr-field-thirdparty-name"><td class="titlefieldcreate">';
1366 if ($object->particulier || $private) {
1367 print
'<span id="TypeName" class="fieldrequired">'.$langs->trans(
'ThirdPartyName').
' / '.$langs->trans(
'LastName',
'name').
'</span>';
1369 print
'<span id="TypeName" class="fieldrequired">'.$form->editfieldkey(
'ThirdPartyName',
'name',
'', $object, 0).
'</span>';
1371 print
'</td><td'.(empty($conf->global->SOCIETE_USEPREFIX) ?
' colspan="3"' :
'').
'>';
1373 print
'<input type="text" class="minwidth300" maxlength="128" name="name" id="name" value="'.dol_escape_htmltag($object->name).
'" autofocus="autofocus">';
1374 print
$form->widgetForTranslation(
"name", $object, $permissiontoadd,
'string',
'alpahnohtml',
'minwidth300');
1469 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
1470 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>';
1475 if ($conf->use_javascript_ajax) {
1476 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1478 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'FirstName',
'firstname',
'', $object, 0).
'</td>';
1479 print
'<td colspan="3"><input type="text" class="minwidth300" maxlength="128" name="firstname" id="firstname" value="'.dol_escape_htmltag($object->firstname).
'"></td>';
1483 print
'<tr class="individualline"><td>'.$form->editfieldkey(
'UserTitle',
'civility_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1484 print $formcompany->select_civility($object->civility_id,
'civility_id',
'maxwidth100').
'</td>';
1490 print
'<tr id="name_alias"><td><label for="name_alias_input">'.$langs->trans(
'AliasNames').
'</label></td>';
1491 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>';
1494 print
'<tr><td class="titlefieldcreate">'.$form->editfieldkey(
'ProspectCustomer',
'customerprospect',
'', $object, 0,
'string',
'', 1).
'</td>';
1495 print
'<td class="maxwidthonsmartphone">';
1497 print $formcompany->selectProspectCustomerType($selected);
1500 if ($conf->browser->layout ==
'phone') {
1504 print
'<td>'.$form->editfieldkey(
'CustomerCode',
'customer_code',
'', $object, 0).
'</td><td>';
1505 print
'<table class="nobordernopadding"><tr><td>';
1506 $tmpcode = $object->code_client;
1507 if (empty($tmpcode) && !empty($modCodeClient->code_auto)) {
1508 $tmpcode = $modCodeClient->getNextValue($object, 0);
1510 print
'<input type="text" name="customer_code" id="customer_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1512 $s = $modCodeClient->getToolTip($langs, $object, 0);
1513 print
$form->textwithpicto(
'', $s, 1);
1514 print
'</td></tr></table>';
1517 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))
1518 || (
isModEnabled(
'supplier_proposal') && !empty($user->rights->supplier_proposal->lire))) {
1521 print
'<td>'.$form->editfieldkey(
'Vendor',
'fournisseur',
'', $object, 0,
'string',
'', 1).
'</td><td>';
1523 if (!empty($conf->global->THIRDPARTY_SUPPLIER_BY_DEFAULT)) {
1526 print
$form->selectyesno(
"fournisseur", (
GETPOST(
'fournisseur',
'int') !=
'' ?
GETPOST(
'fournisseur',
'int') : (
GETPOST(
"type",
'alpha') ==
'' ? $default : $object->fournisseur)), 1, 0, (
GETPOST(
"type",
'alpha') ==
'' ? 1 : 0), 1);
1530 if ($conf->browser->layout ==
'phone') {
1535 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))) {
1536 print
$form->editfieldkey(
'SupplierCode',
'supplier_code',
'', $object, 0);
1539 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))) {
1540 print
'<table class="nobordernopadding"><tr><td>';
1541 $tmpcode = $object->code_fournisseur;
1542 if (empty($tmpcode) && !empty($modCodeFournisseur->code_auto)) {
1543 $tmpcode = $modCodeFournisseur->getNextValue($object, 1);
1545 print
'<input type="text" name="supplier_code" id="supplier_code" class="maxwidthonsmartphone" value="'.dol_escape_htmltag($tmpcode).
'" maxlength="24">';
1547 $s = $modCodeFournisseur->getToolTip($langs, $object, 1);
1548 print
$form->textwithpicto(
'', $s, 1);
1549 print
'</td></tr></table>';
1555 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0).
'</td><td colspan="3">';
1556 print
$form->selectarray(
'status', array(
'0'=>$langs->trans(
'ActivityCeased'),
'1'=>$langs->trans(
'InActivity')), 1, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth100', 1);
1561 print
'<tr><td>'.$form->editfieldkey(
'Gencod',
'barcode',
'', $object, 0).
'</td>';
1562 print
'<td colspan="3">';
1563 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1564 print
'<input type="text" name="barcode" id="barcode" value="'.dol_escape_htmltag($object->barcode).
'">';
1569 print
'<tr><td class="tdtop">';
1570 print
$form->editfieldkey(
'Address',
'address',
'', $object, 0);
1572 print
'<td colspan="3">';
1573 print
'<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_2.
'" wrap="soft">';
1575 print
'</textarea>';
1576 print
$form->widgetForTranslation(
"address", $object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
1580 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
1581 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
1583 if ($conf->browser->layout ==
'phone') {
1586 print
'<td class="tdtop">'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
1587 print $formcompany->select_ziptown($object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth150 quatrevingtpercent');
1588 print
$form->widgetForTranslation(
"town", $object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
1592 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1593 print
img_picto(
'',
'country',
'class="pictofixedwidth"');
1594 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 maxwidth500 widthcentpercentminusx');
1596 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1601 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1602 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)) {
1603 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1605 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
1608 if ($object->country_id) {
1609 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1610 print $formcompany->select_state($object->state_id, $object->country_code);
1612 print $countrynotdefined;
1618 print
'<tr><td>'.$form->editfieldkey(
'Phone',
'phone',
'', $object, 0).
'</td>';
1619 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>';
1620 if ($conf->browser->layout ==
'phone') {
1623 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
1624 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>';
1627 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'', empty($conf->global->SOCIETE_EMAIL_MANDATORY) ?
'' : $conf->global->SOCIETE_EMAIL_MANDATORY).
'</td>';
1628 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>';
1629 if (
isModEnabled(
'mailing') && !empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1630 if ($conf->browser->layout ==
'phone') {
1633 print
'<td class="individualline noemail">'.$form->editfieldkey($langs->trans(
'No_Email') .
' ('.$langs->trans(
'Contact').
')',
'contact_no_email',
'', $object, 0).
'</td>';
1634 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>';
1637 print
'<tr><td>'.$form->editfieldkey(
'Web',
'url',
'', $object, 0).
'</td>';
1638 print
'<td colspan="3">'.img_picto(
'',
'globe',
'class="pictofixedwidth"').
' <input type="text" class="maxwidth500 widthcentpercentminusx" name="url" id="url" value="'.$object->url.
'"></td></tr>';
1641 if (!empty($conf->mailing->enabled)) {
1642 if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1643 print
"\n".
'<script type="text/javascript">'.
"\n";
1644 print
'$(document).ready(function () {
1645 $("#email").keyup(function() {
1646 if ($(this).val()!="") {
1647 $(".noemail").addClass("fieldrequired");
1649 $(".noemail").removeClass("fieldrequired");
1653 print
'</script>'.
"\n";
1655 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
1656 $result = $object->getNoEmail();
1662 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1664 print
$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1,
false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
1671 foreach ($socialnetworks as $key => $value) {
1672 if ($value[
'active']) {
1674 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1675 print
'<td colspan="3">';
1676 if (!empty($value[
'icon'])) {
1677 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
1679 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth300 widthcentpercentminusx" maxlength="80" value="'.
dol_escape_htmltag(
GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : (empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key])).
'">';
1682 } elseif (!empty($object->socialnetworks[$key])) {
1683 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1689 $i = 1; $j = 0; $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
1691 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
1692 if ($idprof !=
'-') {
1695 if (($j % $NBCOLS) == 0) {
1699 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
1700 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', (empty($conf->global->$idprof_mandatory) ? 0 : 1)).
'</td><td>';
1702 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
1704 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
1711 if ($NBCOLS > 1 && ($j % 2 == 1)) {
1712 print
'<td colspan="2"></td></tr>';
1716 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td>';
1718 print
$form->selectyesno(
'assujtva_value',
GETPOSTISSET(
'assujtva_value') ?
GETPOST(
'assujtva_value',
'int') : 1, 1);
1720 if ($conf->browser->layout ==
'phone') {
1723 print
'<td class="nowrap">'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
1724 print
'<td class="nowrap">';
1725 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
1727 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
1730 if (!empty($conf->use_javascript_ajax)) {
1732 if (!empty($conf->dol_use_jmobile)) {
1737 print
'<script type="text/javascript">';
1738 print
"function CheckVAT(a) {\n";
1739 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
1743 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
1744 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
1746 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
1755 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
1756 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
1757 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1759 if ($conf->browser->layout ==
'phone') {
1762 print
'<td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
1763 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1765 } elseif ($mysoc->localtax1_assuj ==
"1") {
1766 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1767 print
$form->selectyesno(
'localtax1assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX1 : 0), 1);
1769 } elseif ($mysoc->localtax2_assuj ==
"1") {
1770 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td colspan="3">';
1771 print
$form->selectyesno(
'localtax2assuj_value', (isset($conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2) ? $conf->global->THIRDPARTY_DEFAULT_USELOCALTAX2 : 0), 1);
1776 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";
1777 $sortparam = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT);
1778 print
$form->selectarray(
"typent_id", $formcompany->typent_array(0), $object->typent_id, 1, 0, 0,
'', 0, 0, 0, $sortparam,
'', 1);
1780 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1782 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
1784 if ($conf->browser->layout ==
'phone') {
1787 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone"'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
1788 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
1790 print
' '.info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1793 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
1798 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td>';
1799 print
'<td colspan="3" class="maxwidthonsmartphone">';
1800 if ($object->country_id) {
1801 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
1803 print $countrynotdefined;
1808 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
1809 print
'<td colspan="3"><input type="text" name="capital" id="capital" class="maxwidth100" value="'.$object->capital.
'"> ';
1811 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
1813 print
'<span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
1816 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1817 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');
1825 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
1826 print
'<td colspan="3" class="maxwidthonsmartphone">';
1827 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
1832 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
1833 $langs->load(
'categories');
1836 print
'<tr class="visibleifcustomer"><td class="toptd">'.$form->editfieldkey(
'CustomersProspectsCategoriesShort',
'custcats',
'', $object, 0).
'</td><td colspan="3">';
1837 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
'parent',
null,
null, 1);
1838 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo,
GETPOST(
'custcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1841 if (!empty($conf->global->THIRDPARTY_SUGGEST_ALSO_ADDRESS_CREATION)) {
1842 print
'<tr class="individualline"><td class="toptd">'.$form->editfieldkey(
'ContactCategoriesShort',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
1843 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
1844 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1850 print
'<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td><td colspan="3">';
1851 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
'parent',
null,
null, 1);
1852 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo,
GETPOST(
'suppcats',
'array'),
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1860 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
1861 print
'<td colspan="3" class="maxwidthonsmartphone">';
1862 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
1863 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'',
false,
'maxwidth150 widthcentpercentminusx');
1868 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
1869 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
1872 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
1874 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
1875 print
'<td colspan="3" class="maxwidthonsmartphone">';
1876 print
img_picto(
'',
'company',
'class="paddingrightonly"');
1877 print
$form->select_company(
GETPOST(
'parent_company_id'),
'parent_company_id',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
1883 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
1884 print
'<td colspan="3" class="maxwidthonsmartphone">';
1885 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
1887 $selected = (count(
GETPOST(
'commercial',
'array')) > 0 ?
GETPOST(
'commercial',
'array') : (
GETPOST(
'commercial',
'int') > 0 ? array(
GETPOST(
'commercial',
'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array())));
1888 print
img_picto(
'',
'user').$form->multiselectarray(
'commercial', $userlist, $selected,
null,
null,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1892 print
'<tr class="hideonsmartphone">';
1893 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
1894 print
'<td colspan="3">';
1895 print
'<input class="flat" type="file" name="photo" id="photoinput" />';
1899 print
'</table>'.
"\n";
1902 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
1903 print
'<table class="border centpercent">';
1907 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1909 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
1910 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'');
1914 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1916 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
1917 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'');
1921 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1922 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1926 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1927 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1936 print
$form->buttonsSaveCancel(
"AddThirdParty",
'Cancel',
null, 0,
'', $dol_openinpopup);
1938 print
'</form>'.
"\n";
1939 } elseif ($action ==
'edit') {
1943 $res = $object->fetch_optionals();
1949 $module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON :
'mod_codeclient_leopard');
1950 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1951 $module = substr($module, 0,
dol_strlen($module) - 4);
1953 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1954 foreach ($dirsociete as $dirroot) {
1960 $modCodeClient =
new $module($db);
1962 if ($modCodeClient->code_auto) {
1963 $prefixCustomerIsUsed = $modCodeClient->verif_prefixIsUsed();
1965 $module = $conf->global->SOCIETE_CODECLIENT_ADDON;
1966 if (substr($module, 0, 15) ==
'mod_codeclient_' && substr($module, -3) ==
'php') {
1967 $module = substr($module, 0,
dol_strlen($module) - 4);
1969 $dirsociete = array_merge(array(
'/core/modules/societe/'), $conf->modules_parts[
'societe']);
1970 foreach ($dirsociete as $dirroot) {
1976 $modCodeFournisseur =
new $module($db);
1978 if ($modCodeFournisseur->code_auto) {
1979 $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
1982 $object->oldcopy = clone $object;
1986 $object->name =
GETPOST(
'name',
'alphanohtml');
1987 $object->name_alias =
GETPOST(
'name_alias',
'alphanohtml');
1988 $object->prefix_comm =
GETPOST(
'prefix_comm',
'alphanohtml');
1989 $object->client =
GETPOST(
'client',
'int');
1990 $object->code_client =
GETPOST(
'customer_code',
'alpha');
1991 $object->fournisseur =
GETPOST(
'fournisseur',
'int');
1992 $object->code_fournisseur =
GETPOST(
'supplier_code',
'alpha');
1993 $object->address =
GETPOST(
'address',
'alphanohtml');
1994 $object->zip =
GETPOST(
'zipcode',
'alphanohtml');
1995 $object->town =
GETPOST(
'town',
'alphanohtml');
1996 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id',
'int') : $mysoc->country_id;
1997 $object->state_id =
GETPOST(
'state_id',
'int');
1998 $object->parent =
GETPOST(
'parent_company_id',
'int');
2000 $object->socialnetworks = array();
2002 foreach ($socialnetworks as $key => $value) {
2004 $object->socialnetworks[$key] =
GETPOST($key,
'alphanohtml');
2009 $object->phone =
GETPOST(
'phone',
'alpha');
2010 $object->fax =
GETPOST(
'fax',
'alpha');
2011 $object->email =
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
2012 $object->no_email =
GETPOST(
"no_email",
"int");
2013 $object->url =
GETPOST(
'url',
'custom', 0, FILTER_SANITIZE_URL);
2014 $object->capital =
GETPOST(
'capital',
'alphanohtml');
2015 $object->idprof1 =
GETPOST(
'idprof1',
'alphanohtml');
2016 $object->idprof2 =
GETPOST(
'idprof2',
'alphanohtml');
2017 $object->idprof3 =
GETPOST(
'idprof3',
'alphanohtml');
2018 $object->idprof4 =
GETPOST(
'idprof4',
'alphanohtml');
2019 $object->idprof5 =
GETPOST(
'idprof5',
'alphanohtml');
2020 $object->idprof6 =
GETPOST(
'idprof6',
'alphanohtml');
2021 $object->typent_id =
GETPOST(
'typent_id',
'int');
2022 $object->effectif_id =
GETPOST(
'effectif_id',
'int');
2023 $object->barcode =
GETPOST(
'barcode',
'alphanohtml');
2024 $object->forme_juridique_code =
GETPOST(
'forme_juridique_code',
'int');
2025 $object->default_lang =
GETPOST(
'default_lang',
'alpha');
2027 $object->tva_assuj =
GETPOST(
'assujtva_value',
'int');
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');
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;
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;
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'];
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 canHaveCategoryIfNotCustomerProspectSupplier = ' . (empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT) ?
'0' :
'1') .
';
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 && !canHaveCategoryIfNotCustomerProspectSupplier)
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>';
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 (!empty($conf->mailing->enabled)) {
2367 if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->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 = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->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);
2403 foreach ($socialnetworks as $key => $value) {
2404 if ($value[
'active']) {
2406 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
2407 print
'<td colspan="3">';
2408 if (!empty($value[
'icon'])) {
2409 print
'<span class="fa '.$value[
'icon'].
' pictofixedwidth"></span>';
2411 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth500 widthcentpercentminusx" maxlength="80" value="'.(empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key]).
'">';
2414 } elseif (!empty($object->socialnetworks[$key])) {
2415 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
2423 $NBCOLS = ($conf->browser->layout ==
'phone' ? 1 : 2);
2425 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2426 if ($idprof !=
'-') {
2429 if (($j % $NBCOLS) == 0) {
2433 $idprof_mandatory =
'SOCIETE_IDPROF'.($i).
'_MANDATORY';
2434 print
'<td>'.$form->editfieldkey($idprof, $key,
'', $object, 0,
'string',
'', !(empty($conf->global->$idprof_mandatory) || !$object->isACompany())).
'</td><td>';
2435 print $formcompany->get_input_id_prof($i, $key, $object->$key, $object->country_code);
2437 if (($j % $NBCOLS) == ($NBCOLS - 1)) {
2444 if ($NBCOLS > 0 && $j % 2 == 1) {
2445 print
'<td colspan="2"></td></tr>';
2449 print
'<tr><td>'.$form->editfieldkey(
'VATIsUsed',
'assujtva_value',
'', $object, 0).
'</td><td colspan="3">';
2450 print
$form->selectyesno(
'assujtva_value', $object->tva_assuj, 1);
2455 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2456 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td>';
2457 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2459 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2460 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2465 print
'<td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td>';
2466 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2468 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2469 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2473 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2474 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code),
'localtax1assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2475 print
$form->selectyesno(
'localtax1assuj_value', $object->localtax1_assuj, 1);
2477 print
'<span class="cblt1"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2478 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2482 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2483 print
'<tr><td>'.$form->editfieldkey($langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code),
'localtax2assuj_value',
'', $object, 0).
'</td><td colspan="3">';
2484 print
$form->selectyesno(
'localtax2assuj_value', $object->localtax2_assuj, 1);
2486 print
'<span class="cblt2"> '.$langs->transcountry(
"Type", $mysoc->country_code).
': ';
2487 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2494 print
'<tr><td>'.$form->editfieldkey(
'VATIntra',
'intra_vat',
'', $object, 0).
'</td>';
2495 print
'<td colspan="3">';
2496 $s =
'<input type="text" class="flat maxwidthonsmartphone" name="tva_intra" id="intra_vat" maxlength="20" value="'.$object->tva_intra.
'">';
2498 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2501 if ($conf->use_javascript_ajax) {
2503 if (!empty($conf->dol_use_jmobile)) {
2508 print
'<script type="text/javascript">';
2509 print
"function CheckVAT(a) {\n";
2510 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2514 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans(
"VATIntraCheck").
'</a>';
2515 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2517 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2525 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"' :
'').
'>';
2526 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);
2528 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2530 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
2532 if ($conf->browser->layout ==
'phone') {
2535 print
'<td>'.$form->editfieldkey(
'Workforce',
'effectif_id',
'', $object, 0).
'</td><td class="maxwidthonsmartphone">';
2536 print
$form->selectarray(
"effectif_id", $formcompany->effectif_array(0), $object->effectif_id, 0, 0, 0,
'', 0, 0, 0,
'',
'', 1);
2538 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2541 print
'<input type="hidden" name="effectif_id" id="effectif_id" value="'.$object->effectif_id.
'">';
2546 print
'<tr><td>'.$form->editfieldkey(
'JuridicalStatus',
'forme_juridique_code',
'', $object, 0).
'</td><td class="maxwidthonsmartphone" colspan="3">';
2547 print $formcompany->select_juridicalstatus($object->forme_juridique_code, $object->country_code,
'',
'forme_juridique_code');
2551 print
'<tr><td>'.$form->editfieldkey(
'Capital',
'capital',
'', $object, 0).
'</td>';
2552 print
'<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="';
2555 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$object->multicurrency_code).
'</span></td></tr>';
2557 print
'"> <span class="hideonsmartphone">'.$langs->trans(
"Currency".$conf->currency).
'</span></td></tr>';
2562 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3">'.
"\n";
2563 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language($object->default_lang,
'default_lang', 0,
null,
'1', 0, 0,
'maxwidth300 widthcentpercentminusx');
2571 print
'<td>'.$form->editfieldkey(
'IncotermLabel',
'incoterm_id',
'', $object, 0).
'</td>';
2572 print
'<td colspan="3" class="maxwidthonsmartphone">';
2573 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''));
2578 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
2580 print
'<tr class="visibleifcustomer"><td>'.$form->editfieldkey(
'CustomersCategoriesShort',
'custcats',
'', $object, 0).
'</td>';
2581 print
'<td colspan="3">';
2582 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
null,
null,
null,
null, 1);
2584 $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER);
2585 $arrayselected = array();
2586 foreach ($cats as $cat) {
2587 $arrayselected[] = $cat->id;
2589 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'custcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2593 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))) {
2594 print
'<tr class="visibleifsupplier"><td>'.$form->editfieldkey(
'SuppliersCategoriesShort',
'suppcats',
'', $object, 0).
'</td>';
2595 print
'<td colspan="3">';
2596 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_SUPPLIER,
null,
null,
null,
null, 1);
2598 $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER);
2599 $arrayselected = array();
2600 foreach ($cats as $cat) {
2601 $arrayselected[] = $cat->id;
2603 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'suppcats', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2611 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
2612 print
'<td colspan="3" class="maxwidthonsmartphone">';
2613 print
img_picto(
'',
'currency',
'class="pictofixedwidth"');
2614 print
$form->selectMultiCurrency((
GETPOSTISSET(
'multicurrency_code') ?
GETPOST(
'multicurrency_code') : ($object->multicurrency_code ? $object->multicurrency_code : $conf->currency)),
'multicurrency_code', 1,
'',
false,
'maxwidth150 widthcentpercentminusx');
2619 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
2620 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
2623 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
2625 print
'<td>'.$langs->trans(
'ParentCompany').
'</td>';
2626 print
'<td colspan="3" class="maxwidthonsmartphone">';
2627 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
2628 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');
2633 if (!empty($conf->syncsupplierwebservices->enabled)) {
2634 print
'<tr><td>'.$form->editfieldkey(
'WebServiceURL',
'webservices_url',
'', $object, 0).
'</td>';
2635 print
'<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="'.$object->webservices_url.
'"></td>';
2636 print
'<td>'.$form->editfieldkey(
'WebServiceKey',
'webservices_key',
'', $object, 0).
'</td>';
2637 print
'<td><input type="text" name="webservices_key" id="webservices_key" size="32" value="'.$object->webservices_key.
'"></td></tr>';
2641 print
'<tr class="hideonsmartphone">';
2642 print
'<td>'.$form->editfieldkey(
'Logo',
'photoinput',
'', $object, 0).
'</td>';
2643 print
'<td colspan="3">';
2644 if ($object->logo) {
2645 print
$form->showphoto(
'societe', $object);
2648 if ($caneditfield) {
2649 if ($object->logo) {
2652 print
'<table class="nobordernopadding">';
2653 if ($object->logo) {
2654 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
2659 $maxmin = $maxfilesizearray[
'maxmin'];
2661 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
2663 print
'<input type="file" class="flat" name="photo" id="photoinput">';
2672 print
'<td>'.$form->editfieldkey(
'AllocateCommercial',
'commercial_id',
'', $object, 0).
'</td>';
2673 print
'<td colspan="3" class="maxwidthonsmartphone">';
2674 $userlist =
$form->select_dolusers(
'',
'', 0,
null, 0,
'',
'', 0, 0, 0,
'AND u.statut = 1', 0,
'',
'', 0, 1);
2675 $arrayselected =
GETPOST(
'commercial',
'array');
2676 if (empty($arrayselected)) {
2677 $arrayselected = $object->getSalesRepresentatives($user, 1);
2679 print
img_picto(
'',
'user',
'class="pictofixedwidth"').$form->multiselectarray(
'commercial', $userlist, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0,
'',
'',
'', 1);
2684 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
2686 print
'<table class="border centpercent">';
2690 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2692 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
2696 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2698 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
2702 print
'<tr><td class="titlefield">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2703 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2707 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2708 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2718 print
$form->buttonsSaveCancel();
2727 if (!empty($object->id)) {
2728 $res = $object->fetch_optionals();
2740 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
2741 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"DeleteACompany"), $langs->trans(
"ConfirmDeleteCompany"),
"confirm_delete",
'', 0,
"action-delete");
2744 if ($action ==
'merge') {
2745 $formquestion = array(
2747 'name' =>
'soc_origin',
2748 'label' => $langs->trans(
'MergeOriginThirdparty'),
2750 'value' =>
$form->select_company(
'',
'soc_origin',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth200',
'',
'', 1,
null,
false, array($object->id))
2754 $formconfirm .=
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?socid=".$object->id, $langs->trans(
"MergeThirdparties"), $langs->trans(
"ConfirmMergeThirdparties"),
"confirm_merge", $formquestion,
'no', 1, 250);
2759 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2760 if (empty($reshook)) {
2762 } elseif ($reshook > 0) {
2771 $linkback =
'<a href="'.DOL_URL_ROOT.
'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
2773 dol_banner_tab($object,
'socid', $linkback, ($user->socid ? 0 : 1),
'rowid',
'nom');
2776 print
'<div class="fichecenter">';
2777 print
'<div class="fichehalfleft">';
2779 print
'<div class="underbanner clearboth"></div>';
2780 print
'<table class="border tableforfield centpercent">';
2783 print
'<tr><td class="titlefield">'.$langs->trans(
'NatureOfThirdParty').
'</td><td>';
2784 print $object->getTypeUrl(1);
2788 if (!empty($conf->global->SOCIETE_USEPREFIX)) {
2789 print
'<tr><td>'.$langs->trans(
'Prefix').
'</td><td>'.
dol_escape_htmltag($object->prefix_comm).
'</td>';
2794 if ($object->client) {
2796 print $langs->trans(
'CustomerCode');
2800 $tmpcheck = $object->check_codeclient();
2801 if ($tmpcheck != 0 && $tmpcheck != -5) {
2802 print
' <span class="error">('.$langs->trans(
"WrongCustomerCode").
')</span>';
2809 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) {
2811 print $langs->trans(
'SupplierCode').
'</td><td>';
2813 $tmpcheck = $object->check_codefournisseur();
2814 if ($tmpcheck != 0 && $tmpcheck != -5) {
2815 print
' <span class="error">('.$langs->trans(
"WrongSupplierCode").
')</span>';
2832 $idprof = $langs->transcountry(
'ProfId'.$i, $object->country_code);
2833 if ($idprof !=
'-') {
2836 print
'<td>'.$idprof.
'</td><td>';
2839 if ($object->$key) {
2840 if ($object->id_prof_check($i, $object) > 0) {
2841 if (!empty($object->id_prof_url($i, $object))) {
2842 print
' '.$object->id_prof_url($i, $object);
2845 print
' <span class="error">('.$langs->trans(
"ErrorWrongValue").
')</span>';
2862 if ($object->fournisseur) {
2865 print
$form->textwithpicto($langs->trans(
'VATIsUsed'), $langs->trans(
'VATIsUsedWhenSelling'));
2867 print
yn($object->tva_assuj);
2873 if ($object->fournisseur || $mysoc->country_code ==
'ES') {
2874 if ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj ==
"1") {
2875 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2876 print
yn($object->localtax1_assuj);
2877 print
'</td></tr><tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2878 print
yn($object->localtax2_assuj);
2882 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2883 print
'<input type="hidden" name="action" value="set_localtax1">';
2884 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2885 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>';
2886 if ($action ==
'editRE') {
2887 print
'<td class="left">';
2888 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2889 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2891 print
'<td>'.$object->localtax1_value.
'</td>';
2893 print
'</tr></form>';
2896 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2897 print
'<input type="hidden" name="action" value="set_localtax2">';
2898 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2899 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>';
2900 if ($action ==
'editIRPF') {
2901 print
'<td class="left">';
2902 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2903 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2905 print
'<td>'.$object->localtax2_value.
'</td>';
2907 print
'</tr></form>';
2909 } elseif ($mysoc->localtax1_assuj ==
"1" && $mysoc->localtax2_assuj !=
"1") {
2910 print
'<tr><td>'.$langs->transcountry(
"LocalTax1IsUsed", $mysoc->country_code).
'</td><td>';
2911 print
yn($object->localtax1_assuj);
2914 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2915 print
'<input type="hidden" name="action" value="set_localtax1">';
2916 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2917 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>';
2918 if ($action ==
'editRE') {
2919 print
'<td class="left">';
2920 $formcompany->select_localtax(1, $object->localtax1_value,
"lt1");
2921 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2923 print
'<td>'.$object->localtax1_value.
'</td>';
2925 print
'</tr></form>';
2927 } elseif ($mysoc->localtax2_assuj ==
"1" && $mysoc->localtax1_assuj !=
"1") {
2928 print
'<tr><td>'.$langs->transcountry(
"LocalTax2IsUsed", $mysoc->country_code).
'</td><td>';
2929 print
yn($object->localtax2_assuj);
2932 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?socid='.$object->id.
'">';
2933 print
'<input type="hidden" name="action" value="set_localtax2">';
2934 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2935 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>';
2936 if ($action ==
'editIRPF') {
2937 print
'<td class="left">';
2938 $formcompany->select_localtax(2, $object->localtax2_value,
"lt2");
2939 print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
2941 print
'<td>'.$object->localtax2_value.
'</td>';
2943 print
'</tr></form>';
2950 print
'<td class="nowrap">'.$langs->trans(
'VATIntra').
'</td><td>';
2951 if ($object->tva_intra) {
2954 $s .=
'<input type="hidden" id="tva_intra" name="tva_intra" maxlength="20" value="'.$object->tva_intra.
'">';
2956 if (empty($conf->global->MAIN_DISABLEVATCHECK) &&
isInEEC($object)) {
2959 if ($conf->use_javascript_ajax) {
2961 if (!empty($conf->dol_use_jmobile)) {
2966 print
'<script type="text/javascript">';
2967 print
"function CheckVAT(a) {\n";
2968 print
"newpopup('".DOL_URL_ROOT.
"/societe/checkvat/checkVatPopup.php?vatNumber='+a, '".
dol_escape_js($langs->trans(
"VATIntraCheckableOnEUSite")).
"', ".$widthpopup.
", ".$heightpopup.
");\n";
2972 $s .=
'<a href="#" class="hideonsmartphone" onclick="javascript: CheckVAT( $(\'#tva_intra\').val() );">'.$langs->trans(
"VATIntraCheck").
'</a>';
2973 $s =
$form->textwithpicto($s, $langs->trans(
"VATIntraCheckDesc", $langs->transnoentitiesnoconv(
"VATIntraCheck")), 1);
2975 $s .=
'<a href="'.$langs->transcountry(
"VATIntraCheckURL", $object->country_id).
'" class="hideonsmartphone" target="_blank" rel="noopener noreferrer">'.
img_picto($langs->trans(
"VATIntraCheckableOnEUSite"),
'help').
'</a>';
2985 if (
isModEnabled(
'stock') && !empty($conf->global->SOCIETE_ASK_FOR_WAREHOUSE)) {
2986 $langs->load(
'stocks');
2987 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
2989 print
'<tr class="nowrap">';
2991 print
$form->editfieldkey(
"Warehouse",
'warehouse',
'', $object, $user->rights->societe->creer);
2993 if ($action ==
'editwarehouse') {
2994 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'fk_warehouse', 1);
2996 if ($object->fk_warehouse > 0) {
2997 print
img_picto(
'',
'stock',
'class="paddingrightonly"');
2999 $formproduct->formSelectWarehouses($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_warehouse,
'none');
3008 print
'<div class="fichehalfright">';
3010 print
'<div class="underbanner clearboth"></div>';
3011 print
'<table class="border tableforfield centpercent">';
3014 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
3016 if ($object->prospect || $object->client || !empty($conf->global->THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT)) {
3017 print
'<tr><td>'.$langs->trans(
"CustomersCategoriesShort").
'</td>';
3019 print
$form->showCategories($object->id, Categorie::TYPE_CUSTOMER, 1);
3024 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) {
3025 print
'<tr><td>'.$langs->trans(
"SuppliersCategoriesShort").
'</td>';
3027 print
$form->showCategories($object->id, Categorie::TYPE_SUPPLIER, 1);
3035 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ThirdPartyType').
'</td>';
3036 if ($action !=
'editthirdpartytype' && $user->hasRight(
'societe',
'creer')) {
3037 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>';
3039 print
'</tr></table>';
3041 $html_name = ($action ==
'editthirdpartytype') ?
'typent_id' :
'none';
3042 $formcompany->formThirdpartyType($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->typent_id, $html_name,
'');
3046 if (empty($conf->global->SOCIETE_DISABLE_WORKFORCE)) {
3047 print
'<tr><td>'.$langs->trans(
"Workforce").
'</td><td>'.$object->effectif.
'</td></tr>';
3051 print
'<tr><td class="titlefield">'.$langs->trans(
'JuridicalStatus').
'</td><td>'.$object->forme_juridique.
'</td></tr>';
3054 print
'<tr><td>'.$langs->trans(
'Capital').
'</td><td>';
3055 if ($object->capital) {
3056 if (
isModEnabled(
"multicurrency") && !empty($object->multicurrency_code)) {
3057 print
price($object->capital,
'', $langs, 0, -1, -1, $object->multicurrency_code);
3059 print
price($object->capital,
'', $langs, 0, -1, -1, $conf->currency);
3067 if (!empty($conf->mailing->enabled)) {
3068 $result = $object->getNoEmail();
3072 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
3073 if ($object->email) {
3074 print
yn($object->no_email);
3076 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
3079 $langs->load(
"mails");
3080 print
' <span class="badge badge-secondary" title="'.dol_escape_htmltag($langs->trans(
"NbOfEMailingsSend")).
'">'.$object->getNbOfEMailings().
'</span>';
3087 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
3088 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
3091 $langs->load(
"languages");
3092 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
3093 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
3101 print
'<table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans(
'IncotermLabel').
'</td>';
3102 if ($action !=
'editincoterm' && $user->hasRight(
'societe',
'creer')) {
3103 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=editincoterm&token='.
newToken().
'">'.
img_edit(
'', 1).
'</a></td>';
3105 print
'</tr></table>';
3106 print
'</td><td colspan="3">';
3107 if ($action !=
'editincoterm') {
3108 print
$form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1);
3110 print
$form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms :
''), (!empty($object->location_incoterms) ? $object->location_incoterms :
''), $_SERVER[
'PHP_SELF'].
'?socid='.$object->id);
3118 print
'<td>'.$form->editfieldkey(
'Currency',
'multicurrency_code',
'', $object, 0).
'</td>';
3120 print !empty($object->multicurrency_code) ?
currency_name($object->multicurrency_code, 1) :
'';
3124 if (!empty($conf->global->ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY)) {
3126 print
'<tr><td class="nowrap">';
3127 print $langs->trans(
"ProductAccountancySellCode");
3128 print
'</td><td colspan="2">';
3130 if (!empty($object->accountancy_code_sell)) {
3132 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
3134 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
3137 print $object->accountancy_code_sell;
3142 print
'<tr><td class="nowrap">';
3143 print $langs->trans(
"ProductAccountancyBuyCode");
3144 print
'</td><td colspan="2">';
3146 if (!empty($object->accountancy_code_buy)) {
3148 $accountingaccount2->fetch(
'', $object->accountancy_code_buy, 1);
3150 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
3153 print $object->accountancy_code_buy;
3159 $parameters = array(
'socid'=>$socid,
'colspan' =>
' colspan="3"',
'colspanvalue' =>
'3');
3160 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3163 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) {
3165 print
'<table class="nobordernopadding" width="100%"><tr><td>'.$langs->trans(
'ParentCompany').
'</td>';
3166 if ($action !=
'editparentcompany' && $user->hasRight(
'societe',
'creer')) {
3167 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>';
3169 print
'</tr></table>';
3171 $html_name = ($action ==
'editparentcompany') ?
'parent_id' :
'none';
3172 $form->form_thirdparty($_SERVER[
'PHP_SELF'].
'?socid='.$object->id, $object->parent, $html_name,
'', 1, 0, 0,
null, 0, array($object->id));
3177 include DOL_DOCUMENT_ROOT.
'/societe/tpl/linesalesrepresentative.tpl.php';
3181 $langs->load(
"members");
3182 print
'<tr><td>'.$langs->trans(
"LinkedToDolibarrMember").
'</td>';
3185 $result = $adh->fetch(
'',
'', $object->id);
3187 $adh->ref = $adh->getFullName($langs);
3188 print $adh->getNomUrl(-1);
3190 print
'<span class="opacitymedium">'.$langs->trans(
"ThirdpartyNotLinkedToMember").
'</span>';
3192 print
"</td></tr>\n";
3212 if (!empty($conf->syncsupplierwebservices->enabled)) {
3213 print
'<tr><td>'.$langs->trans(
"WebServiceURL").
'</td><td>'.
dol_print_url($object->webservices_url).
'</td>';
3214 print
'<td class="nowrap">'.$langs->trans(
'WebServiceKey').
'</td><td>'.$object->webservices_key.
'</td></tr>';
3221 print
'<div style="clear:both"></div>';
3229 if ($action !=
'presend') {
3230 print
'<div class="tabsAction">'.
"\n";
3233 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
3234 if (empty($reshook)) {
3235 $at_least_one_email_contact =
false;
3236 $TContact = $object->contact_array_objects();
3237 foreach ($TContact as &$contact) {
3238 if (!empty($contact->email)) {
3239 $at_least_one_email_contact =
true;
3244 if (empty($user->socid)) {
3245 $langs->load(
"mails");
3247 if (empty($object->email) && !$at_least_one_email_contact) { $title = $langs->trans(
'NoEMail'); }
3248 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);
3251 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
3255 $result = $adh->fetch(
'',
'', $object->id);
3256 if ($result == 0 && ($object->client == 1 || $object->client == 3) && !empty($conf->global->MEMBER_CAN_CONVERT_CUSTOMERS_TO_MEMBERS)) {
3257 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";
3261 print
dolGetButtonAction($langs->trans(
'MergeThirdparties'), $langs->trans(
'Merge'),
'danger', $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=merge&token='.
newToken(),
'', $permissiontodelete);
3263 if ($user->hasRight(
'societe',
'supprimer')) {
3264 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?socid='.$object->id.
'&action=delete&token='.
newToken();
3265 $buttonId =
'action-delete-no-ajax';
3266 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
3268 $buttonId =
'action-delete';
3270 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $deleteUrl, $buttonId, $permissiontodelete);
3274 print
'</div>'.
"\n";
3278 if (
GETPOST(
'modelselected')) {
3279 $action =
'presend';
3282 if ($action !=
'presend') {
3283 print
'<div class="fichecenter"><div class="fichehalfleft">';
3285 if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) {
3286 print
'<a name="builddoc"></a>';
3291 $filedir = $conf->societe->multidir_output[$object->entity].
'/'.$object->id;
3292 $urlsource = $_SERVER[
"PHP_SELF"].
"?socid=".$object->id;
3293 $genallowed = $user->hasRight(
'societe',
'lire');
3294 $delallowed = $user->hasRight(
'societe',
'creer');
3296 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);
3300 if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY) && empty($conf->global->SOCIETE_DISABLE_SHOW_SUBSIDIARIES)) {
3304 print
'</div><div class="fichehalfright">';
3308 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/societe/agenda.php?socid='.$object->id);
3311 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3313 $somethingshown =
$formactions->showactions($object,
'', $socid, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3315 print
'</div></div>';
3317 if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD)) {
3319 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
3320 $result =
show_contacts($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3324 if (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) {
3325 $result = show_addresses($conf, $langs, $db, $object, $_SERVER[
"PHP_SELF"].
'?socid='.$object->id);
3331 $modelmail =
'thirdparty';
3332 $defaulttopic =
'Information';
3333 $diroutput = $conf->societe->multidir_output[$object->entity];
3334 $trackid =
'thi'.$object->id;
3336 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage members of a foundation.
Class to manage categories.
Class to manage third parties objects (customers, suppliers, prospects...)
show_contacts($conf, $langs, $db, $object, $backtopage='', $showuserlogin=0)
Show html area for list of contacts.
currency_name($code_iso, $withcode='', $outputlangs=null)
Return label of currency or code+label.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
show_subsidiaries($conf, $langs, $db, $object)
Show html area for list of subsidiaries.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
isInEEC($object)
Return if a country of an object is inside the EEC (European Economic Community)
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0, $object=null)
Add a file into database index.
deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded')
Delete files into database index using search criterias.
isValidUrl($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0)
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
isOnlyOneLocalTax($local)
Return true if LocalTax (1 or 2) is unique.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0)
Show Url link.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_print_profids($profID, $profIDtype, $countrycode='', $addcpButton=1, $separ=' ')
Format profIDs according to country.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
$formconfirm
if ($action == 'delbookkeepingyear') {
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.