35 require
'../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contact.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51 $langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
53 $mesg =
''; $error = 0; $errors = array();
55 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
56 $confirm =
GETPOST(
'confirm',
'alpha');
57 $backtopage =
GETPOST(
'backtopage',
'alpha');
58 $cancel =
GETPOST(
'cancel',
'alpha');
61 $socid =
GETPOST(
'socid',
'int');
67 $extrafields->fetch_name_optionals_label($object->table_element);
72 $object->getCanvas($id);
74 $canvas = (!empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas"));
75 if (!empty($canvas)) {
76 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
77 $objcanvas =
new Canvas($db, $action);
78 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
82 $hookmanager->initHooks(array(
'contactcard',
'globalcard'));
88 if (!($object->id > 0) && $action ==
'view') {
89 $langs->load(
"errors");
90 print($langs->trans(
'ErrorRecordNotFound'));
94 $triggermodname =
'CONTACT_MODIFY';
95 $permissiontoadd = $user->rights->societe->contact->creer;
99 $socid = $user->socid;
101 $result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
108 $parameters = array(
'id'=>$id,
'objcanvas'=>$objcanvas);
109 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
114 if (empty($reshook)) {
115 $backurlforlist = DOL_URL_ROOT.
'/contact/list.php';
117 if (empty($backtopage) || ($cancel && empty($id))) {
118 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
119 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
120 $backtopage = $backurlforlist;
122 $backtopage = DOL_URL_ROOT.
'/contact/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
128 if (!empty($backtopageforcancel)) {
129 header(
"Location: ".$backtopageforcancel);
131 } elseif (!empty($backtopage)) {
132 header(
"Location: ".$backtopage);
139 if ($action ==
'confirm_create_user' && $confirm ==
'yes' && $user->rights->user->user->creer) {
141 $result = $object->fetch($id);
147 $nuser =
new User($db);
148 $result = $nuser->create_from_contact($object,
GETPOST(
"login"));
151 $result2 = $nuser->setPassword($user,
GETPOST(
"password"), 0, 0, 1);
155 $error = $nuser->error; $errors = $nuser->errors;
159 $error = $nuser->error; $errors = $nuser->errors;
163 $error = $object->error; $errors = $object->errors;
169 if ($action ==
'disable' && !empty($permissiontoadd)) {
171 if ($object->setstatus(0) < 0) {
174 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
180 if ($action ==
'enable' && !empty($permissiontoadd)) {
182 if ($object->setstatus(1) < 0) {
185 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
191 if ($action ==
'add' && !empty($permissiontoadd)) {
195 $object->canvas = $canvas;
199 $object->socid =
GETPOST(
"socid",
'int');
200 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
201 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
202 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
203 $object->poste = (string)
GETPOST(
"poste",
'alpha');
204 $object->address = (string)
GETPOST(
"address",
'alpha');
205 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
206 $object->town = (string)
GETPOST(
"town",
'alpha');
207 $object->country_id = (int)
GETPOST(
"country_id",
'int');
208 $object->state_id = (int)
GETPOST(
"state_id",
'int');
214 $object->socialnetworks = array();
215 if (!empty($conf->socialnetworks->enabled)) {
216 foreach ($socialnetworks as $key => $value) {
218 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
222 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
223 $object->no_email =
GETPOST(
"no_email",
"int");
224 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
225 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
226 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
227 $object->fax = (string)
GETPOST(
"fax",
'alpha');
228 $object->priv =
GETPOST(
"priv",
'int');
229 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
230 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
231 $object->roles =
GETPOST(
"roles",
'array');
237 $object->birthday_alert =
GETPOST(
"birthday_alert",
'alpha');
240 $object->default_lang =
GETPOST(
'default_lang');
243 $ret = $extrafields->setOptionalsFromPost(
null, $object);
249 if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && $object->no_email == -1 && !empty($object->email)) {
251 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
255 if (!empty($object->email) && !isValidEMail($object->email)) {
256 $langs->load(
"errors");
258 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
262 if (empty($object->lastname)) {
264 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
269 $id = $object->create($user);
272 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
279 $contcats =
GETPOST(
'contcats',
'array');
280 if (count($contcats) > 0) {
281 $result = $object->setCategories($contcats);
284 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
290 if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email)) {
292 $result = $object->setNoEmail($object->no_email);
295 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
300 if (empty($error) && $id > 0) {
302 if (!empty($backtopage)) {
303 $url = str_replace(
'__ID__', $id, $backtopage);
305 $url =
'card.php?id='.$id;
307 header(
"Location: ".$url);
314 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->societe->contact->supprimer) {
315 $result = $object->fetch($id);
316 $object->oldcopy = clone $object;
318 $object->old_lastname = (string)
GETPOST(
"old_lastname",
'alpha');
319 $object->old_firstname = (string)
GETPOST(
"old_firstname",
'alpha');
321 $result = $object->delete();
324 if ($backurlforlist) {
325 header(
"Location: ".$backurlforlist);
328 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
336 if ($action ==
'update' && empty($cancel) && !empty($permissiontoadd)) {
337 if (!
GETPOST(
"lastname",
'alpha')) {
338 $error++; $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
342 if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
"no_email",
"int") == -1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
344 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
348 if (!empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
349 $langs->load(
"errors");
351 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
356 $contactid =
GETPOST(
"contactid",
'int');
357 $object->fetch($contactid);
358 $object->fetchRoles($contactid);
361 $dir = $conf->societe->multidir_output[$object->entity].
"/contact/".$object->id.
"/photos";
362 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
363 if (
GETPOST(
'deletephoto') && $object->photo) {
364 $fileimg = $dir.
'/'.$object->photo;
365 $dirthumbs = $dir.
'/thumbs';
378 if (!($result > 0)) {
379 $errors[] =
"ErrorFailedToSaveFile";
384 $object->addThumbs($newfile);
388 $errors[] =
"ErrorBadImageFormat";
391 switch ($_FILES[
'photo'][
'error']) {
394 $errors[] =
"ErrorFileSizeTooLarge";
397 $errors[] =
"ErrorFilePartiallyUploaded";
402 $object->oldcopy = clone $object;
404 $object->old_lastname = (string)
GETPOST(
"old_lastname",
'alpha');
405 $object->old_firstname = (string)
GETPOST(
"old_firstname",
'alpha');
407 $object->socid =
GETPOST(
"socid",
'int');
408 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
409 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
410 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
411 $object->poste = (string)
GETPOST(
"poste",
'alpha');
413 $object->address = (string)
GETPOST(
"address",
'alpha');
414 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
415 $object->town = (string)
GETPOST(
"town",
'alpha');
416 $object->state_id =
GETPOST(
"state_id",
'int');
417 $object->country_id =
GETPOST(
"country_id",
'int');
419 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
420 $object->no_email =
GETPOST(
"no_email",
"int");
426 $object->socialnetworks = array();
427 if (!empty($conf->socialnetworks->enabled)) {
428 foreach ($socialnetworks as $key => $value) {
430 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
434 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
435 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
436 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
437 $object->fax = (string)
GETPOST(
"fax",
'alpha');
438 $object->priv = (string)
GETPOST(
"priv",
'int');
439 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
440 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
442 $object->roles =
GETPOST(
"roles",
'array');
445 $object->default_lang =
GETPOST(
'default_lang');
448 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
454 $result = $object->update($contactid, $user);
458 $categories =
GETPOST(
'contcats',
'array');
459 $object->setCategories($categories);
463 $no_email =
GETPOST(
'no_email',
'int');
464 $result = $object->setNoEmail($no_email);
479 if (!$error && empty($errors)) {
480 if (!empty($backtopage)) {
481 header(
"Location: ".$backtopage);
487 if ($action ==
'setprospectcontactlevel' && !empty($permissiontoadd)) {
489 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
490 $result = $object->update($object->id, $user);
497 if ($action ==
'setstcomm' && !empty($permissiontoadd)) {
500 $result = $object->update($object->id, $user);
507 if ($action ==
"update_extras" && !empty($permissiontoadd)) {
508 $object->fetch(
GETPOST(
'id',
'int'));
510 $attributekey =
GETPOST(
'attribute',
'alpha');
511 $attributekeylong =
'options_'.$attributekey;
515 $object->array_options[
'options_'.$attributekey] =
dol_mktime(
GETPOST($attributekeylong.
'hour',
'int'),
GETPOST($attributekeylong.
'min',
'int'),
GETPOST($attributekeylong.
'sec',
'int'),
GETPOST($attributekeylong.
'month',
'int'),
GETPOST($attributekeylong.
'day',
'int'),
GETPOST($attributekeylong.
'year',
'int'));
518 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
521 $result = $object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
527 $action =
'edit_extras';
532 if ($action ==
'update_extras' && ! empty($user->rights->societe->contact->creer)) {
536 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
542 $result = $object->insertExtraFields(
'CONTACT_MODIFY');
550 $action =
'edit_extras';
555 $triggersendname =
'CONTACT_SENTBYMAIL';
557 $mode =
'emailfromcontact';
558 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
570 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
571 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
572 $title = $object->lastname;
574 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
577 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
581 $objsoc->fetch($socid);
584 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
588 if (empty($object->error) && $id) {
590 $result = $object->fetch($id);
595 $objcanvas->assign_values($action, $object->id, $object->ref);
596 $objcanvas->display_canvas($action);
603 if ($user->rights->societe->contact->supprimer) {
604 if ($action ==
'delete') {
605 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
616 $res = $object->fetch($id, $user);
621 $object->fetchRoles();
626 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
629 if ($user->rights->societe->contact->creer) {
630 if ($action ==
'create') {
634 $object->canvas = $canvas;
636 $object->state_id =
GETPOST(
"state_id",
"int");
639 $object->country_id =
GETPOST(
"country_id") ?
GETPOST(
"country_id",
"int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
640 if ($object->country_id) {
641 $tmparray =
getCountry($object->country_id,
'all');
642 $object->country_code = $tmparray[
'code'];
643 $object->country = $tmparray[
'label'];
646 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
653 if ($conf->use_javascript_ajax) {
654 print
"\n".
'<script type="text/javascript">'.
"\n";
655 print
'jQuery(document).ready(function () {
656 jQuery("#selectcountry_id").change(function() {
657 document.formsoc.action.value="create";
658 document.formsoc.submit();
661 $("#copyaddressfromsoc").click(function() {
662 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
663 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
664 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
665 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
666 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
667 /* set country at end because it will trigger page refresh */
668 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
669 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
672 print
'</script>'.
"\n";
675 print
'<form method="post" name="formsoc" action="'.$_SERVER[
"PHP_SELF"].
'">';
676 print
'<input type="hidden" name="token" value="'.newToken().
'">';
677 print
'<input type="hidden" name="action" value="add">';
678 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
679 if (!empty($objsoc)) {
680 print
'<input type="hidden" name="entity" value="'.$objsoc->entity.
'">';
685 print
'<table class="border centpercent">';
688 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
689 print
'<td colspan="3"><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(
GETPOST(
"lastname",
'alpha') ?
GETPOST(
"lastname",
'alpha') : $object->lastname).
'" autofocus="autofocus"></td>';
693 print
'<td><label for="firstname">';
694 print
$form->textwithpicto($langs->trans(
"Firstname"), $langs->trans(
"KeepEmptyIfGenericAddress")).
'</label></td>';
695 print
'<td colspan="3"><input name="firstname" id="firstname"type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(
GETPOST(
"firstname",
'alpha') ?
GETPOST(
"firstname",
'alpha') : $object->firstname).
'"></td>';
699 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
701 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
702 print
'<td colspan="3" class="maxwidthonsmartphone">';
703 print $objsoc->getNomUrl(1,
'contact');
705 print
'<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.
'">';
708 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
709 print
img_picto(
'',
'company').$form->select_company($socid,
'socid',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
715 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
716 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'alpha') : $object->civility_code,
'civility_code');
720 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
721 print
'<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="255" value="'.dol_escape_htmltag(
GETPOSTISSET(
"poste") ?
GETPOST(
"poste",
'alphanohtml') : $object->poste).
'"></td>';
724 if ($conf->use_javascript_ajax && $socid > 0) {
729 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->address)) == 0) {
730 $object->address = $objsoc->address;
732 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
733 print
'<td colspan="'.$colspan.
'"><textarea class="flat quatrevingtpercent" name="address" id="address" rows="'.ROWS_2.
'">'.(
GETPOST(
"address",
'alpha') ?
GETPOST(
"address",
'alpha') : $object->address).
'</textarea></td>';
735 if ($conf->use_javascript_ajax && $socid > 0) {
737 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
741 print
'<td class="valignmiddle center" rowspan="'.$rowspan.
'">';
742 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a>';
748 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->zip)) == 0) {
749 $object->zip = $objsoc->zip;
751 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->town)) == 0) {
752 $object->town = $objsoc->town;
754 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
755 print $formcompany->select_ziptown((
GETPOST(
"zipcode",
'alpha') ?
GETPOST(
"zipcode",
'alpha') : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
756 print $formcompany->select_ziptown((
GETPOST(
"town",
'alpha') ?
GETPOST(
"town",
'alpha') : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
760 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
761 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
762 print
$form->select_country((
GETPOST(
"country_id",
'alpha') ?
GETPOST(
"country_id",
'alpha') : $object->country_id),
'country_id');
764 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
769 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
770 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)) {
771 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
773 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
776 if ($object->country_id) {
777 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
778 print $formcompany->select_state(
GETPOST(
"state_id",
'alpha') ?
GETPOST(
"state_id",
'alpha') : $object->state_id, $object->country_code,
'state_id');
780 print $countrynotdefined;
785 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->phone_pro)) == 0) {
786 $object->phone_pro = $objsoc->phone;
788 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->fax)) == 0) {
789 $object->fax = $objsoc->fax;
793 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
'', $object, 0).
'</td>';
796 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') : $object->phone_pro).
'"></td>';
797 if ($conf->browser->layout ==
'phone') {
800 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'phone_perso',
'', $object, 0).
'</td>';
803 print
'<input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_perso') ?
GETPOST(
'phone_perso',
'alpha') : $object->phone_perso).
'"></td></tr>';
805 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'', $object, 0).
'</td>';
807 print
img_picto(
'',
'object_phoning_mobile');
808 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') : $object->phone_mobile).
'"></td>';
809 if ($conf->browser->layout ==
'phone') {
812 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
814 print
img_picto(
'',
'object_phoning_fax');
815 print
'<input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') : $object->fax).
'"></td>';
818 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->email)) == 0) {
819 $object->email = $objsoc->email;
823 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'').
'</td>';
826 print
'<input type="text" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
830 if (!empty($conf->mailing->enabled)) {
831 if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
832 print
"\n".
'<script type="text/javascript">'.
"\n";
833 print
'$(document).ready(function () {
834 $("#email").keyup(function() {
835 if ($(this).val()!="") {
836 $(".noemail").addClass("fieldrequired");
838 $(".noemail").removeClass("fieldrequired");
842 print
'</script>'.
"\n";
844 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
845 $result = $object->getNoEmail();
851 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
853 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));
859 if (!empty($conf->socialnetworks->enabled)) {
860 foreach ($socialnetworks as $key => $value) {
861 if ($value[
'active']) {
863 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
864 print
'<td colspan="3">';
865 if (!empty($value[
'icon'])) {
866 print
'<span class="fa '.$value[
'icon'].
'"></span>';
868 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100" maxlength="80" value="'.
dol_escape_htmltag(
GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : (!empty($object->socialnetworks[$key]) ? $object->socialnetworks[$key] :
"")).
'">';
871 } elseif (!empty($object->socialnetworks[$key])) {
872 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
878 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
879 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
880 print
$form->selectarray(
'priv', $selectarray, (
GETPOST(
"priv",
'alpha') ?
GETPOST(
"priv",
'alpha') : $object->priv), 0);
884 if (!empty($conf->global->MAIN_MULTILANGS)) {
885 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
886 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');
892 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
893 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
894 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
895 print
img_picto(
'',
'category').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
null,
null,
'90%');
900 if (!empty($socid)) {
901 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
902 print
'<td colspan="3">';
903 $contactType = $object->listeTypeContacts(
'external',
'', 1);
904 print
$form->multiselectarray(
'roles', $contactType, array(), 0, 0,
'minwidth500');
909 $parameters = array(
'socid' => $socid,
'objsoc' => $objsoc,
'colspan' =>
' colspan="3"',
'cols' => 3,
'colspanvalue' => 3);
910 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
912 print
"</table><br>";
914 print
'<hr style="margin-bottom: 20px">';
917 print
load_fiche_titre(
'<div class="comboperso">'.$langs->trans(
"PersonalInformations").
'</div>',
'',
'');
919 print
'<table class="border centpercent">';
922 print
'<tr><td><label for="birthday">'.$langs->trans(
"DateOfBirth").
'</label></td><td>';
924 if ($object->birthday) {
925 print
$form->selectDate($object->birthday,
'birthday', 0, 0, 0,
"perso", 1, 0);
927 print
$form->selectDate(
'',
'birthday', 0, 0, 1,
"perso", 1, 0);
931 print
'<td><label for="birthday_alert">'.$langs->trans(
"Alert").
'</label>: ';
932 if (!empty($object->birthday_alert)) {
933 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
935 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert">';
944 print
$form->buttonsSaveCancel(
"Add");
947 } elseif ($action ==
'edit' && !empty($id)) {
953 if (
GETPOSTISSET(
"country_id") || $object->country_id) {
954 $tmparray =
getCountry($object->country_id,
'all');
955 $object->country_code = $tmparray[
'code'];
956 $object->country = $tmparray[
'label'];
960 $objsoc->fetch($object->socid);
965 if ($conf->use_javascript_ajax) {
966 print
"\n".
'<script type="text/javascript">'.
"\n";
967 print
'jQuery(document).ready(function () {
968 jQuery("#selectcountry_id").change(function() {
969 document.formsoc.action.value="edit";
970 document.formsoc.submit();
973 $("#copyaddressfromsoc").click(function() {
974 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
975 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
976 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
977 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
978 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
979 /* set country at end because it will trigger page refresh */
980 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
981 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
984 print
'</script>'.
"\n";
987 print
'<form enctype="multipart/form-data" method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" name="formsoc">';
988 print
'<input type="hidden" name="token" value="'.newToken().
'">';
989 print
'<input type="hidden" name="id" value="'.$id.
'">';
990 print
'<input type="hidden" name="action" value="update">';
991 print
'<input type="hidden" name="contactid" value="'.$object->id.
'">';
992 print
'<input type="hidden" name="old_lastname" value="'.$object->lastname.
'">';
993 print
'<input type="hidden" name="old_firstname" value="'.$object->firstname.
'">';
994 if (!empty($backtopage)) {
995 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1000 print
'<table class="border centpercent">';
1003 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
1004 print
'<tr><td>'.$langs->trans(
"ID").
'</td><td colspan="3">';
1010 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
1011 print
'<td colspan="3"><input name="lastname" id="lastname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"lastname") ?
GETPOST(
"lastname") : $object->lastname).
'" autofocus="autofocus"></td>';
1015 print
'<td><label for="firstname">'.$langs->trans(
"Firstname").
'</label></td>';
1016 print
'<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"firstname") ?
GETPOST(
"firstname") : $object->firstname).
'"></td>';
1020 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
1021 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
1022 print
'<td colspan="3" class="maxwidthonsmartphone">';
1023 print
img_picto(
'',
'company').$form->select_company(
GETPOST(
'socid',
'int') ?
GETPOST(
'socid',
'int') : ($object->socid ? $object->socid : -1),
'socid',
'', $langs->trans(
"SelectThirdParty"));
1029 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
1030 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
"aZ09") : $object->civility_code,
'civility_code');
1034 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
1035 print
'<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="255" value="'.dol_escape_htmltag(
GETPOSTISSET(
"poste") ?
GETPOST(
"poste",
'alphanohtml') : $object->poste).
'"></td></tr>';
1038 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
1039 print
'<td colspan="3">';
1040 print
'<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
1041 print
'<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET(
"address") ?
GETPOST(
"address",
'alphanohtml') : $object->address).
'</textarea>';
1042 print
'</div><div class="paddingrightonly valignmiddle inline-block">';
1043 if ($conf->use_javascript_ajax) {
1044 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a><br>';
1050 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1051 print $formcompany->select_ziptown((
GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
1052 print $formcompany->select_ziptown((
GETPOSTISSET(
"town") ?
GETPOST(
"town") : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1056 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1057 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1058 print
$form->select_country(
GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id") : $object->country_id,
'country_id');
1060 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1065 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1066 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)) {
1067 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1069 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1072 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1073 print $formcompany->select_state(
GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'alpha') : $object->state_id, $object->country_code,
'state_id');
1078 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
GETPOST(
'phone_pro',
'alpha'), $object, 0).
'</td>';
1081 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') : $object->phone_pro).
'"></td>';
1082 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'fax',
GETPOST(
'phone_perso',
'alpha'), $object, 0).
'</td>';
1085 print
'<input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_perso') ?
GETPOST(
'phone_perso',
'alpha') : $object->phone_perso).
'"></td></tr>';
1087 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'), $object, 0,
'string',
'').
'</td>';
1089 print
img_picto(
'',
'object_phoning_mobile');
1090 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') : $object->phone_mobile).
'"></td>';
1091 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
1093 print
img_picto(
'',
'object_phoning_fax');
1094 print
'<input type="text" name="fax" id="fax" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_fax') ?
GETPOST(
'phone_fax',
'alpha') : $object->fax).
'"></td></tr>';
1097 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
1100 print
'<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
1101 if (!empty($conf->mailing->enabled)) {
1102 $langs->load(
"mails");
1103 print
'<td class="nowrap">'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1104 print
'<td>'.$object->getNbOfEMailings().
'</td>';
1106 print
'<td colspan="2"></td>';
1111 if (!empty($conf->mailing->enabled)) {
1112 if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1113 print
"\n".
'<script type="text/javascript">'.
"\n";
1116 jQuery(document).ready(function () {
1117 function init_check_no_email(input) {
1118 if (input.val()!="") {
1119 $(".noemail").addClass("fieldrequired");
1121 $(".noemail").removeClass("fieldrequired");
1124 $("#email").keyup(function() {
1125 init_check_no_email($(this));
1127 init_check_no_email($("#email"));
1129 print
'</script>'.
"\n";
1131 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
1132 $result = $object->getNoEmail();
1138 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1140 $useempty = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
1141 print
$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $object->no_email), 1, false, $useempty);
1146 if (!empty($conf->socialnetworks->enabled)) {
1147 foreach ($socialnetworks as $key => $value) {
1148 if ($value[
'active']) {
1150 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1151 print
'<td colspan="3">';
1152 if (!empty($value[
'icon'])) {
1153 print
'<span class="fa '.$value[
'icon'].
'"></span>';
1155 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100" maxlength="80" value="'.
dol_escape_htmltag(
GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : (empty($object->socialnetworks[$key]) ?
'' : $object->socialnetworks[$key])).
'">';
1158 } elseif (!empty($object->socialnetworks[$key])) {
1159 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1165 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
1166 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1167 print
$form->selectarray(
'priv', $selectarray, $object->priv, 0);
1171 if (!empty($conf->global->MAIN_MULTILANGS)) {
1172 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1173 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');
1179 print
'<tr><td class="tdtop"><label for="note_public">'.$langs->trans(
"NotePublic").
'</label></td><td colspan="3">';
1180 $doleditor =
new DolEditor(
'note_public', $object->note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3,
'90%');
1181 print $doleditor->Create(1);
1185 print
'<tr><td class="tdtop"><label for="note_private">'.$langs->trans(
"NotePrivate").
'</label></td><td colspan="3">';
1186 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3,
'90%');
1187 print $doleditor->Create(1);
1191 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
1192 print
'<td colspan="3">';
1193 print $object->getLibStatut(4);
1197 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1198 $arrayselected = array();
1199 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td>';
1200 print
'<td colspan="3">';
1201 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
null,
null,
null, 1);
1203 $cats = $c->containing($object->id,
'contact');
1204 foreach ($cats as $cat) {
1205 $arrayselected[] = $cat->id;
1207 print
img_picto(
'',
'category').$form->multiselectarray(
'contcats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
1212 if (!empty($object->socid)) {
1213 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1214 print
'<td colspan="3">';
1215 print $formcompany->showRoles(
"roles", $object,
'edit', $object->roles);
1220 $parameters = array(
'colspan' =>
' colspan="3"',
'cols'=>
'3',
'colspanvalue'=>
'3');
1221 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
1223 $object->load_ref_elements();
1225 if (!empty($conf->commande->enabled)) {
1226 print
'<tr><td>'.$langs->trans(
"ContactForOrders").
'</td><td colspan="3">';
1227 print $object->ref_commande ? $object->ref_commande : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>');
1231 if (!empty($conf->propal->enabled)) {
1232 print
'<tr><td>'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1233 print $object->ref_propal ? $object->ref_propal : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'</span>');
1237 if (!empty($conf->contrat->enabled)) {
1238 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1239 print $object->ref_contrat ? $object->ref_contrat : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>');
1244 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1245 print $object->ref_facturation ? $object->ref_facturation : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>');
1250 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1251 if ($object->user_id) {
1252 $dolibarr_user =
new User($db);
1253 $result = $dolibarr_user->fetch($object->user_id);
1254 print $dolibarr_user->getLoginUrl(1);
1256 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
1262 print
'<td>'.$langs->trans(
"PhotoFile").
'</td>';
1263 print
'<td colspan="3">';
1264 if ($object->photo) {
1265 print
$form->showphoto(
'contact', $object);
1268 print
'<table class="nobordernopadding">';
1269 if ($object->photo) {
1270 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
1275 $maxmin = $maxfilesizearray[
'maxmin'];
1277 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1279 print
'<input type="file" class="flat" name="photo" id="photoinput">';
1290 print
$form->buttonsSaveCancel();
1297 if (
GETPOST(
'modelselected',
'alpha')) {
1298 $action =
'presend';
1302 if (!empty($id) && $action !=
'edit' && $action !=
'create') {
1310 if ($action ==
'create_user') {
1312 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1315 $generated_password =
'';
1317 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1320 $password = $generated_password;
1323 $formquestion = array(
1324 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
1325 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password),
1328 $text = $langs->trans(
"ConfirmCreateContact").
'<br>';
1329 if (!empty($conf->societe->enabled)) {
1330 if ($object->socid > 0) {
1331 $text .= $langs->trans(
"UserWillBeExternalUser");
1333 $text .= $langs->trans(
"UserWillBeInternalUser");
1336 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"CreateDolibarrLogin"), $text,
"confirm_create_user", $formquestion,
'yes');
1339 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1341 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/contact/vcard.php?id='.$object->id.
'" class="refid">';
1342 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1343 $morehtmlref .=
'</a>';
1345 $morehtmlref .=
'<div class="refidno">';
1346 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
1347 $objsoc->fetch($object->socid);
1349 $morehtmlref .= $langs->trans(
'ThirdParty').
' : ';
1350 if ($objsoc->id > 0) {
1351 $morehtmlref .= $objsoc->getNomUrl(1,
'contact');
1353 $morehtmlref .=
'<span class="opacitymedium">'.$langs->trans(
"ContactNotLinkedToCompany").
'</span>';
1356 $morehtmlref .=
'</div>';
1358 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
1361 print
'<div class="fichecenter">';
1362 print
'<div class="fichehalfleft">';
1364 print
'<div class="underbanner clearboth"></div>';
1365 print
'<table class="border tableforfield" width="100%">';
1368 print
'<tr><td class="titlefield">'.$langs->trans(
"UserTitle").
'</td><td>';
1369 print $object->getCivilityLabel();
1373 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td><td>'.$object->poste.
'</td></tr>';
1376 if (!empty($conf->mailing->enabled)) {
1377 $langs->load(
"mails");
1378 print
'<tr><td>'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1379 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?filteremail='.urlencode($object->email).
'">'.$object->getNbOfEMailings().
'</a></td></tr>';
1383 if (!empty($conf->mailing->enabled)) {
1384 $result = $object->getNoEmail();
1388 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
1389 if ($object->email) {
1390 print
yn($object->no_email);
1392 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
1398 if (!empty($conf->global->MAIN_MULTILANGS)) {
1399 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1400 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
1403 $langs->load(
"languages");
1404 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
1405 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
1410 print
'<tr><td>'.$langs->trans(
"ContactVisibility").
'</td><td>';
1411 print $object->LibPubPriv($object->priv);
1417 $object->fetch_thirdparty();
1419 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
1420 if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
1423 print
'<div class="underbanner clearboth"></div>';
1424 print
'<table class="border" width="100%">';
1427 print
'<tr><td class="titlefield nowrap">';
1428 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1429 print $langs->trans(
'ProspectLevel');
1431 if ($action !=
'editlevel' && $user->rights->societe->contact->creer) {
1432 print
'<td align="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
1434 print
'</tr></table>';
1436 if ($action ==
'editlevel') {
1437 $formcompany->formProspectContactLevel($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_prospectlevel,
'prospect_contact_level_id', 1);
1439 print $object->getLibProspLevel();
1445 $object->loadCacheOfProspStatus();
1446 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id][
'label']);
1447 print
' ';
1448 print
'<div class="floatright">';
1449 foreach ($object->cacheprospectstatus as $key => $val) {
1450 $titlealt =
'default';
1451 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1452 $titlealt = $val[
'label'];
1454 if ($object->stcomm_id != $val[
'id']) {
1455 print
'<a class="pictosubstatus" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&stcomm='.urlencode($val[
'code']).
'&action=setstcomm&token='.
newToken().
'">'.
img_action($titlealt, $val[
'code'], $val[
'picto']).
'</a>';
1458 print
'</div></td></tr>';
1465 print
'<div class="fichehalfright">';
1467 print
'<div class="underbanner clearboth"></div>';
1468 print
'<table class="border tableforfield centpercent">';
1471 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1472 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1473 print
'<td colspan="3">';
1474 print
$form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
1478 if (!empty($object->socid)) {
1479 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1480 print
'<td colspan="3">';
1481 print $formcompany->showRoles(
"roles", $object,
'view', $object->roles);
1488 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1490 $object->load_ref_elements();
1492 if (!empty($conf->propal->enabled)) {
1493 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1494 print $object->ref_propal ? $object->ref_propal : $langs->trans(
"NoContactForAnyProposal");
1498 if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled)) {
1500 if (!empty($conf->expedition->enabled)) {
1501 print $langs->trans(
"ContactForOrdersOrShipments");
1503 print $langs->trans(
"ContactForOrders");
1505 print
'</td><td colspan="3">';
1506 $none = $langs->trans(
"NoContactForAnyOrder");
1507 if (!empty($conf->expedition->enabled)) {
1508 $none = $langs->trans(
"NoContactForAnyOrderOrShipments");
1510 print $object->ref_commande ? $object->ref_commande : $none;
1514 if (!empty($conf->contrat->enabled)) {
1515 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1516 print $object->ref_contrat ? $object->ref_contrat : $langs->trans(
"NoContactForAnyContract");
1521 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1522 print $object->ref_facturation ? $object->ref_facturation : $langs->trans(
"NoContactForAnyInvoice");
1526 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1527 if ($object->user_id) {
1528 $dolibarr_user =
new User($db);
1529 $result = $dolibarr_user->fetch($object->user_id);
1530 print $dolibarr_user->getLoginUrl(-1);
1533 if (!$object->user_id && $user->rights->user->user->creer) {
1534 print
'<a class="aaa" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=create_user&token='.
newToken().
'">'.
img_picto($langs->trans(
"CreateDolibarrLogin"),
'add',
'class="pictofixedwidth"').$langs->trans(
"CreateDolibarrLogin").
'</a>';
1541 print
'</div></div>';
1542 print
'<div style="clear:both"></div>';
1549 print
'<div class="tabsAction">';
1552 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
1553 if (empty($reshook) && $action !=
'presend') {
1554 if (empty($user->socid)) {
1555 if (!empty($object->email)) {
1556 $langs->load(
"mails");
1557 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a></div>';
1559 $langs->load(
"mails");
1560 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a></div>';
1564 if ($user->rights->societe->contact->creer) {
1565 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
1569 if ($object->statut == 0 && $user->rights->societe->contact->creer) {
1570 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Reactivate").
'</a>';
1573 if ($object->statut == 1 && $user->rights->societe->contact->creer) {
1574 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=disable&id='.$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"DisableUser").
'</a>';
1578 if ($user->rights->societe->contact->supprimer) {
1579 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
''.($backtopage ?
'&backtopage='.urlencode($backtopage) :
'').
'">'.$langs->trans(
'Delete').
'</a>';
1586 if (
GETPOST(
'modelselected')) {
1587 $action =
'presend';
1590 if ($action !=
'presend') {
1591 print
'<div class="fichecenter"><div class="fichehalfleft">';
1593 print
'</div><div class="fichehalfright">';
1597 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contact/agenda.php?id='.$object->id);
1600 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1602 $somethingshown =
$formactions->showactions($object,
'contact', $object->socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
1604 print
'</div></div>';
1608 $modelmail =
'contact';
1609 $defaulttopic =
'Information';
1610 $diroutput = $conf->societe->dir_output.
'/contact/';
1611 $trackid =
'ctc'.$object->id;
1613 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';