37 require
'../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contact.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
53 $langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
55 $mesg =
''; $error = 0; $errors = array();
58 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
59 $confirm =
GETPOST(
'confirm',
'alpha');
60 $backtopage =
GETPOST(
'backtopage',
'alpha');
61 $cancel =
GETPOST(
'cancel',
'alpha');
63 $socid =
GETPOST(
'socid',
'int');
70 $extrafields->fetch_name_optionals_label($object->table_element);
75 $object->getCanvas($id);
77 $canvas = (!empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas"));
78 if (!empty($canvas)) {
79 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
80 $objcanvas =
new Canvas($db, $action);
81 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
85 $hookmanager->initHooks(array(
'contactcard',
'globalcard'));
92 if (!($object->id > 0) && $action ==
'view') {
93 $langs->load(
"errors");
94 print($langs->trans(
'ErrorRecordNotFound'));
98 $triggermodname =
'CONTACT_MODIFY';
99 $permissiontoadd = $user->hasRight(
'societe',
'contact',
'creer');
103 $socid = $user->socid;
105 if ($object->priv && $object->user_creation->id != $user->id) {
108 $result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
115 $parameters = array(
'id'=>$id,
'objcanvas'=>$objcanvas);
116 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
121 if (empty($reshook)) {
122 $backurlforlist = DOL_URL_ROOT.
'/contact/list.php';
124 if (empty($backtopage) || ($cancel && empty($id))) {
125 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
126 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
127 $backtopage = $backurlforlist;
129 $backtopage = DOL_URL_ROOT.
'/contact/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
135 if (!empty($backtopageforcancel)) {
136 header(
"Location: ".$backtopageforcancel);
138 } elseif (!empty($backtopage)) {
139 header(
"Location: ".$backtopage);
146 if ($action ==
'confirm_create_user' && $confirm ==
'yes' && $user->hasRight(
'user',
'user',
'creer')) {
148 $result = $object->fetch($id);
154 $nuser =
new User($db);
155 $result = $nuser->create_from_contact($object,
GETPOST(
"login"));
158 $result2 = $nuser->setPassword($user,
GETPOST(
"password"), 0, 0, 1);
162 $error = $nuser->error; $errors = $nuser->errors;
166 $error = $nuser->error; $errors = $nuser->errors;
170 $error = $object->error; $errors = $object->errors;
176 if ($action ==
'disable' && !empty($permissiontoadd)) {
178 if ($object->setstatus(0) < 0) {
181 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
187 if ($action ==
'enable' && !empty($permissiontoadd)) {
189 if ($object->setstatus(1) < 0) {
192 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
198 if ($action ==
'add' && !empty($permissiontoadd)) {
202 $object->canvas = $canvas;
206 $object->socid =
GETPOST(
"socid",
'int');
207 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
208 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
209 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
210 $object->poste = (string)
GETPOST(
"poste",
'alpha');
211 $object->address = (string)
GETPOST(
"address",
'alpha');
212 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
213 $object->town = (string)
GETPOST(
"town",
'alpha');
214 $object->country_id = (int)
GETPOST(
"country_id",
'int');
215 $object->state_id = (int)
GETPOST(
"state_id",
'int');
216 $object->socialnetworks = array();
218 foreach ($socialnetworks as $key => $value) {
220 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
224 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
225 $object->no_email =
GETPOST(
"no_email",
"int");
226 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
227 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
228 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
229 $object->fax = (string)
GETPOST(
"fax",
'alpha');
230 $object->priv =
GETPOST(
"priv",
'int');
231 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
232 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
233 $object->roles =
GETPOST(
"roles",
'array');
239 $object->birthday_alert =
GETPOST(
"birthday_alert",
'alpha');
242 $object->default_lang =
GETPOST(
'default_lang');
245 $ret = $extrafields->setOptionalsFromPost(
null, $object);
251 if (
isModEnabled(
'mailing') && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && $object->no_email == -1 && !empty($object->email)) {
253 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
257 if (!empty($object->email) && !isValidEMail($object->email)) {
258 $langs->load(
"errors");
260 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
264 if (empty($object->lastname)) {
266 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
271 $id = $object->create($user);
274 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
281 $contcats =
GETPOST(
'contcats',
'array');
282 if (count($contcats) > 0) {
283 $result = $object->setCategories($contcats);
286 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
292 if (empty($error) &&
isModEnabled(
'mailing') && !empty($object->email)) {
294 $result = $object->setNoEmail($object->no_email);
297 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
302 if (empty($error) && $id > 0) {
304 if (!empty($backtopage)) {
305 $url = str_replace(
'__ID__', $id, $backtopage);
307 $url =
'card.php?id='.$id;
309 header(
"Location: ".$url);
316 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'contact',
'supprimer')) {
317 $result = $object->fetch($id);
318 $object->oldcopy = clone $object;
320 $result = $object->delete();
323 if ($backurlforlist) {
324 header(
"Location: ".$backurlforlist);
327 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
335 if ($action ==
'update' && empty($cancel) && !empty($permissiontoadd)) {
336 if (!
GETPOST(
"lastname",
'alpha')) {
337 $error++; $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
341 if (
isModEnabled(
'mailing') && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
"no_email",
"int") == -1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
343 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
347 if (!empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
348 $langs->load(
"errors");
350 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
355 $contactid =
GETPOST(
"contactid",
'int');
356 $object->fetch($contactid);
357 $object->fetchRoles();
360 $dir = $conf->societe->multidir_output[$object->entity].
"/contact/".$object->id.
"/photos";
361 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
362 if (
GETPOST(
'deletephoto') && $object->photo) {
363 $fileimg = $dir.
'/'.$object->photo;
364 $dirthumbs = $dir.
'/thumbs';
377 if (!($result > 0)) {
378 $errors[] =
"ErrorFailedToSaveFile";
383 $object->addThumbs($newfile);
387 $errors[] =
"ErrorBadImageFormat";
390 switch ($_FILES[
'photo'][
'error']) {
393 $errors[] =
"ErrorFileSizeTooLarge";
396 $errors[] =
"ErrorFilePartiallyUploaded";
401 $object->oldcopy = clone $object;
403 $object->socid =
GETPOST(
"socid",
'int');
404 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
405 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
406 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
407 $object->poste = (string)
GETPOST(
"poste",
'alpha');
409 $object->address = (string)
GETPOST(
"address",
'alpha');
410 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
411 $object->town = (string)
GETPOST(
"town",
'alpha');
412 $object->state_id =
GETPOST(
"state_id",
'int');
413 $object->country_id =
GETPOST(
"country_id",
'int');
415 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
416 $object->no_email =
GETPOST(
"no_email",
"int");
417 $object->socialnetworks = array();
419 foreach ($socialnetworks as $key => $value) {
421 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
425 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
426 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
427 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
428 $object->fax = (string)
GETPOST(
"fax",
'alpha');
429 $object->priv = (string)
GETPOST(
"priv",
'int');
430 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
431 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
433 $object->roles =
GETPOST(
"roles",
'array');
436 $object->default_lang =
GETPOST(
'default_lang');
439 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
445 $result = $object->update($contactid, $user);
449 $categories =
GETPOST(
'contcats',
'array');
450 $object->setCategories($categories);
454 $no_email =
GETPOST(
'no_email',
'int');
455 $result = $object->setNoEmail($no_email);
470 if (!$error && empty($errors)) {
471 if (!empty($backtopage)) {
472 header(
"Location: ".$backtopage);
478 if ($action ==
'setprospectcontactlevel' && !empty($permissiontoadd)) {
480 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
481 $result = $object->update($object->id, $user);
488 if ($action ==
'setstcomm' && !empty($permissiontoadd)) {
491 $result = $object->update($object->id, $user);
498 if ($action ==
"update_extras" && !empty($permissiontoadd)) {
499 $object->fetch(
GETPOST(
'id',
'int'));
501 $attributekey =
GETPOST(
'attribute',
'alpha');
502 $attributekeylong =
'options_'.$attributekey;
506 $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'));
509 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
512 $result = $object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
518 $action =
'edit_extras';
523 if ($action ==
'update_extras' && !empty($user->rights->societe->contact->creer)) {
527 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
533 $result = $object->insertExtraFields(
'CONTACT_MODIFY');
541 $action =
'edit_extras';
546 $triggersendname =
'CONTACT_SENTBYMAIL';
548 $mode =
'emailfromcontact';
549 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
563 $objsoc->fetch($socid);
566 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
567 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
568 $title = $object->lastname;
570 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
571 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
575 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
577 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
581 if (empty($object->error) && $id) {
583 $result = $object->fetch($id);
588 $objcanvas->assign_values($action, $object->id, $object->ref);
589 $objcanvas->display_canvas($action);
596 if ($user->rights->societe->contact->supprimer) {
597 if ($action ==
'delete') {
598 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
609 $res = $object->fetch($id, $user);
614 $object->fetchRoles();
620 if ($user->rights->societe->contact->creer) {
621 if ($action ==
'create') {
625 $object->canvas = $canvas;
627 $object->state_id =
GETPOST(
"state_id",
"int");
630 $object->country_id =
GETPOST(
"country_id") ?
GETPOST(
"country_id",
"int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
631 if ($object->country_id) {
632 $tmparray =
getCountry($object->country_id,
'all');
633 $object->country_code = $tmparray[
'code'];
634 $object->country = $tmparray[
'label'];
644 if ($conf->use_javascript_ajax) {
645 print
"\n".
'<script type="text/javascript">'.
"\n";
646 print
'jQuery(document).ready(function () {
647 jQuery("#selectcountry_id").change(function() {
648 document.formsoc.action.value="create";
649 document.formsoc.submit();
652 $("#copyaddressfromsoc").click(function() {
653 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
654 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
655 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
656 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
657 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
658 /* set country at end because it will trigger page refresh */
659 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
660 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
663 print
'</script>'.
"\n";
666 print
'<form method="post" name="formsoc" action="'.$_SERVER[
"PHP_SELF"].
'">';
667 print
'<input type="hidden" name="token" value="'.newToken().
'">';
668 print
'<input type="hidden" name="action" value="add">';
669 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
670 if (!empty($objsoc)) {
671 print
'<input type="hidden" name="entity" value="'.$objsoc->entity.
'">';
676 print
'<table class="border centpercent">';
679 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
680 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>';
685 print
'<td><label for="firstname">';
686 print
$form->textwithpicto($langs->trans(
"Firstname"), $langs->trans(
"KeepEmptyIfGenericAddress")).
'</label></td>';
687 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>';
691 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
693 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
694 print
'<td colspan="3" class="maxwidthonsmartphone">';
695 print $objsoc->getNomUrl(1,
'contact');
697 print
'<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.
'">';
700 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
701 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($socid,
'socid',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
707 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
708 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'alpha') : $object->civility_code,
'civility_code');
712 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
713 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>';
716 if ($conf->use_javascript_ajax && $socid > 0) {
721 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->address)) == 0) {
722 $object->address = $objsoc->address;
724 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
725 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>';
727 if ($conf->use_javascript_ajax && $socid > 0) {
729 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
733 print
'<td class="valignmiddle center" rowspan="'.$rowspan.
'">';
734 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a>';
740 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->zip)) == 0) {
741 $object->zip = $objsoc->zip;
743 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->town)) == 0) {
744 $object->town = $objsoc->town;
746 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
747 print $formcompany->select_ziptown((
GETPOST(
"zipcode",
'alpha') ?
GETPOST(
"zipcode",
'alpha') : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
748 print $formcompany->select_ziptown((
GETPOST(
"town",
'alpha') ?
GETPOST(
"town",
'alpha') : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
752 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
753 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
754 print
$form->select_country((
GETPOST(
"country_id",
'alpha') ?
GETPOST(
"country_id",
'alpha') : $object->country_id),
'country_id');
756 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
761 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
762 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)) {
763 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
765 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
768 if ($object->country_id) {
769 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
770 print $formcompany->select_state(
GETPOST(
"state_id",
'alpha') ?
GETPOST(
"state_id",
'alpha') : $object->state_id, $object->country_code,
'state_id');
772 print $countrynotdefined;
777 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->phone_pro)) == 0) {
778 $object->phone_pro = $objsoc->phone;
780 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->fax)) == 0) {
781 $object->fax = $objsoc->fax;
785 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
'', $object, 0).
'</td>';
787 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
788 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') : $object->phone_pro).
'"></td>';
789 if ($conf->browser->layout ==
'phone') {
792 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'phone_perso',
'', $object, 0).
'</td>';
794 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
795 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>';
797 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'', $object, 0).
'</td>';
799 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
800 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') : $object->phone_mobile).
'"></td>';
801 if ($conf->browser->layout ==
'phone') {
804 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
806 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
807 print
'<input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') : $object->fax).
'"></td>';
810 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->email)) == 0) {
811 $object->email = $objsoc->email;
815 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'').
'</td>';
817 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
818 print
'<input type="text" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
823 if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
824 print
"\n".
'<script type="text/javascript">'.
"\n";
825 print
'$(document).ready(function () {
826 $("#email").keyup(function() {
827 if ($(this).val()!="") {
828 $(".noemail").addClass("fieldrequired");
830 $(".noemail").removeClass("fieldrequired");
834 print
'</script>'.
"\n";
836 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
837 $result = $object->getNoEmail();
843 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
845 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));
852 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
856 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
857 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
858 print
$form->selectarray(
'priv', $selectarray, (
GETPOST(
"priv",
'alpha') ?
GETPOST(
"priv",
'alpha') : $object->priv), 0);
863 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
864 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');
870 if (
isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
871 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
872 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
873 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
null,
null,
'90%');
878 if (!empty($socid)) {
879 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
880 print
'<td colspan="3">';
881 $contactType = $object->listeTypeContacts(
'external',
'', 1);
882 print
$form->multiselectarray(
'roles', $contactType, array(), 0, 0,
'minwidth500');
887 $parameters = array(
'socid' => $socid,
'objsoc' => $objsoc,
'colspan' =>
' colspan="3"',
'cols' => 3,
'colspanvalue' => 3);
888 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
890 print
"</table><br>";
892 print
'<hr style="margin-bottom: 20px">';
895 print
load_fiche_titre(
'<div class="comboperso">'.$langs->trans(
"PersonalInformations").
'</div>',
'',
'');
897 print
'<table class="border centpercent">';
900 print
'<tr><td><label for="birthday">'.$langs->trans(
"DateOfBirth").
'</label></td><td>';
902 if ($object->birthday) {
903 print
$form->selectDate($object->birthday,
'birthday', 0, 0, 0,
"perso", 1, 0);
905 print
$form->selectDate(
'',
'birthday', 0, 0, 1,
"perso", 1, 0);
909 print
'<td><label for="birthday_alert">'.$langs->trans(
"Alert").
'</label>: ';
910 if (!empty($object->birthday_alert)) {
911 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
913 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert">';
922 print
$form->buttonsSaveCancel(
"Add");
925 } elseif ($action ==
'edit' && !empty($id)) {
931 if (
GETPOSTISSET(
"country_id") || $object->country_id) {
932 $tmparray =
getCountry($object->country_id,
'all');
933 $object->country_code = $tmparray[
'code'];
934 $object->country = $tmparray[
'label'];
938 $objsoc->fetch($object->socid);
943 if ($conf->use_javascript_ajax) {
944 print
"\n".
'<script type="text/javascript">'.
"\n";
945 print
'jQuery(document).ready(function () {
946 jQuery("#selectcountry_id").change(function() {
947 document.formsoc.action.value="edit";
948 document.formsoc.submit();
951 $("#copyaddressfromsoc").click(function() {
952 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
953 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
954 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
955 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
956 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
957 /* set country at end because it will trigger page refresh */
958 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
959 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
962 print
'</script>'.
"\n";
965 print
'<form enctype="multipart/form-data" method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" name="formsoc">';
966 print
'<input type="hidden" name="token" value="'.newToken().
'">';
967 print
'<input type="hidden" name="id" value="'.$id.
'">';
968 print
'<input type="hidden" name="action" value="update">';
969 print
'<input type="hidden" name="contactid" value="'.$object->id.
'">';
970 if (!empty($backtopage)) {
971 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
976 print
'<table class="border centpercent">';
979 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
980 print
'<tr><td>'.$langs->trans(
"ID").
'</td><td colspan="3">';
986 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
987 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>';
991 print
'<td><label for="firstname">'.$langs->trans(
"Firstname").
'</label></td>';
992 print
'<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"firstname") ?
GETPOST(
"firstname") : $object->firstname).
'"></td>';
996 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
997 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
998 print
'<td colspan="3" class="maxwidthonsmartphone">';
999 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOST(
'socid',
'int') ?
GETPOST(
'socid',
'int') : ($object->socid ? $object->socid : -1),
'socid',
'', $langs->trans(
"SelectThirdParty"));
1005 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
1006 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
"aZ09") : $object->civility_code,
'civility_code');
1010 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
1011 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>';
1014 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
1015 print
'<td colspan="3">';
1016 print
'<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
1017 print
'<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET(
"address") ?
GETPOST(
"address",
'alphanohtml') : $object->address).
'</textarea>';
1018 print
'</div><div class="paddingrightonly valignmiddle inline-block">';
1019 if (!empty($conf->use_javascript_ajax)) {
1020 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a><br>';
1026 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1027 print $formcompany->select_ziptown((
GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
1028 print $formcompany->select_ziptown((
GETPOSTISSET(
"town") ?
GETPOST(
"town") : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1032 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1033 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1034 print
$form->select_country(
GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id") : $object->country_id,
'country_id');
1036 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1041 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1042 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)) {
1043 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1045 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1048 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1049 print $formcompany->select_state(
GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'alpha') : $object->state_id, $object->country_code,
'state_id');
1054 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
GETPOST(
'phone_pro',
'alpha'), $object, 0).
'</td>';
1056 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1057 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>';
1058 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'fax',
GETPOST(
'phone_perso',
'alpha'), $object, 0).
'</td>';
1060 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1061 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>';
1063 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'), $object, 0,
'string',
'').
'</td>';
1065 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1066 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>';
1067 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
1069 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1070 print
'<input type="text" name="fax" id="fax" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_fax') ?
GETPOST(
'phone_fax',
'alpha') : $object->fax).
'"></td></tr>';
1073 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
1075 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1076 print
'<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
1078 $langs->load(
"mails");
1079 print
'<td class="nowrap">'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1080 print
'<td>'.$object->getNbOfEMailings().
'</td>';
1082 print
'<td colspan="2"></td>';
1088 if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1089 print
"\n".
'<script type="text/javascript">'.
"\n";
1092 jQuery(document).ready(function () {
1093 function init_check_no_email(input) {
1094 if (input.val()!="") {
1095 $(".noemail").addClass("fieldrequired");
1097 $(".noemail").removeClass("fieldrequired");
1100 $("#email").keyup(function() {
1101 init_check_no_email($(this));
1103 init_check_no_email($("#email"));
1105 print
'</script>'.
"\n";
1107 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
1108 $result = $object->getNoEmail();
1114 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1116 $useempty = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
1117 print
$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $object->no_email), 1, false, $useempty);
1124 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
1128 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
1129 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1130 print
$form->selectarray(
'priv', $selectarray, $object->priv, 0);
1135 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1136 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');
1142 print
'<tr><td class="tdtop"><label for="note_public">'.$langs->trans(
"NotePublic").
'</label></td><td colspan="3">';
1143 $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%');
1144 print $doleditor->Create(1);
1148 print
'<tr><td class="tdtop"><label for="note_private">'.$langs->trans(
"NotePrivate").
'</label></td><td colspan="3">';
1149 $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%');
1150 print $doleditor->Create(1);
1154 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
1155 print
'<td colspan="3">';
1156 print $object->getLibStatut(4);
1160 if (
isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
1161 $arrayselected = array();
1162 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td>';
1163 print
'<td colspan="3">';
1164 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
null,
null,
null, 1);
1166 $cats = $c->containing($object->id,
'contact');
1167 foreach ($cats as $cat) {
1168 $arrayselected[] = $cat->id;
1170 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
1175 if (!empty($object->socid)) {
1176 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1177 print
'<td colspan="3">';
1178 print $formcompany->showRoles(
"roles", $object,
'edit', $object->roles);
1183 $parameters = array(
'colspan' =>
' colspan="3"',
'cols'=>
'3',
'colspanvalue'=>
'3');
1184 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
1186 $object->load_ref_elements();
1189 print
'<tr><td>'.$langs->trans(
"ContactForOrders").
'</td><td colspan="3">';
1190 print $object->ref_commande ? $object->ref_commande : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>');
1195 print
'<tr><td>'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1196 print $object->ref_propal ? $object->ref_propal : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'</span>');
1201 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1202 print $object->ref_contrat ? $object->ref_contrat : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>');
1207 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1208 print $object->ref_facturation ? $object->ref_facturation : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>');
1213 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1214 if ($object->user_id) {
1215 $dolibarr_user =
new User($db);
1216 $result = $dolibarr_user->fetch($object->user_id);
1217 print $dolibarr_user->getLoginUrl(1);
1219 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
1225 print
'<td>'.$langs->trans(
"PhotoFile").
'</td>';
1226 print
'<td colspan="3">';
1227 if ($object->photo) {
1228 print
$form->showphoto(
'contact', $object);
1231 print
'<table class="nobordernopadding">';
1232 if ($object->photo) {
1233 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
1238 $maxmin = $maxfilesizearray[
'maxmin'];
1240 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1242 print
'<input type="file" class="flat" name="photo" id="photoinput">';
1253 print
$form->buttonsSaveCancel();
1260 if (
GETPOST(
'modelselected',
'alpha')) {
1261 $action =
'presend';
1265 if (!empty($id) && $action !=
'edit' && $action !=
'create') {
1273 if ($action ==
'create_user') {
1275 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1278 $generated_password =
'';
1279 if (empty($ldap_sid)) {
1280 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1283 $password = $generated_password;
1286 $formquestion = array(
1287 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
1288 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password),
1291 $text = $langs->trans(
"ConfirmCreateContact").
'<br>';
1293 if ($object->socid > 0) {
1294 $text .= $langs->trans(
"UserWillBeExternalUser");
1296 $text .= $langs->trans(
"UserWillBeInternalUser");
1299 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"CreateDolibarrLogin"), $text,
"confirm_create_user", $formquestion,
'yes');
1302 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1304 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/contact/vcard.php?id='.$object->id.
'" class="refid">';
1305 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1306 $morehtmlref .=
'</a>';
1308 $morehtmlref .=
'<div class="refidno">';
1309 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
1310 $objsoc->fetch($object->socid);
1312 if ($objsoc->id > 0) {
1313 $morehtmlref .= $objsoc->getNomUrl(1,
'contact');
1315 $morehtmlref .=
'<span class="opacitymedium">'.$langs->trans(
"ContactNotLinkedToCompany").
'</span>';
1318 $morehtmlref .=
'</div>';
1320 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
1323 print
'<div class="fichecenter">';
1324 print
'<div class="fichehalfleft">';
1326 print
'<div class="underbanner clearboth"></div>';
1327 print
'<table class="border tableforfield" width="100%">';
1330 print
'<tr><td class="titlefield">'.$langs->trans(
"UserTitle").
'</td><td>';
1331 print $object->getCivilityLabel();
1335 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td><td>'.$object->poste.
'</td></tr>';
1339 $langs->load(
"mails");
1340 print
'<tr><td>'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1341 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?filteremail='.urlencode($object->email).
'">'.$object->getNbOfEMailings().
'</a></td></tr>';
1346 $result = $object->getNoEmail();
1350 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
1351 if ($object->email) {
1352 print
yn($object->no_email);
1354 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
1361 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1362 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
1365 $langs->load(
"languages");
1366 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
1367 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
1372 print
'<tr><td>'.$langs->trans(
"ContactVisibility").
'</td><td>';
1373 print $object->LibPubPriv($object->priv);
1379 $object->fetch_thirdparty();
1381 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
1382 if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
1385 print
'<div class="underbanner clearboth"></div>';
1386 print
'<table class="border" width="100%">';
1389 print
'<tr><td class="titlefield nowrap">';
1390 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1391 print $langs->trans(
'ProspectLevel');
1393 if ($action !=
'editlevel' && $user->hasRight(
'societe',
'contact',
'creer')) {
1394 print
'<td align="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
1396 print
'</tr></table>';
1398 if ($action ==
'editlevel') {
1399 $formcompany->formProspectContactLevel($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_prospectlevel,
'prospect_contact_level_id', 1);
1401 print $object->getLibProspLevel();
1407 $object->loadCacheOfProspStatus();
1408 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id][
'label']);
1409 print
' ';
1410 print
'<div class="floatright">';
1411 foreach ($object->cacheprospectstatus as $key => $val) {
1412 $titlealt =
'default';
1413 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1414 $titlealt = $val[
'label'];
1416 if ($object->stcomm_id != $val[
'id']) {
1417 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>';
1420 print
'</div></td></tr>';
1427 print
'<div class="fichehalfright">';
1429 print
'<div class="underbanner clearboth"></div>';
1430 print
'<table class="border tableforfield centpercent">';
1433 if (
isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire')) {
1434 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1436 print
$form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
1440 if (!empty($object->socid)) {
1441 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1443 print $formcompany->showRoles(
"roles", $object,
'view', $object->roles);
1449 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1451 $object->load_ref_elements();
1454 print
'<tr><td class="titlefield tdoverflow">'.$langs->trans(
"ContactForProposals").
'</td><td>';
1455 print $object->ref_propal ? $object->ref_propal : $langs->trans(
"NoContactForAnyProposal");
1460 print
'<tr><td class="titlefield tdoverflow">';
1462 print $langs->trans(
"ContactForOrdersOrShipments");
1464 print $langs->trans(
"ContactForOrders");
1467 $none = $langs->trans(
"NoContactForAnyOrder");
1469 $none = $langs->trans(
"NoContactForAnyOrderOrShipments");
1471 print $object->ref_commande ? $object->ref_commande : $none;
1476 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForContracts").
'</td><td>';
1477 print $object->ref_contrat ? $object->ref_contrat : $langs->trans(
"NoContactForAnyContract");
1482 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForInvoices").
'</td><td>';
1483 print $object->ref_facturation ? $object->ref_facturation : $langs->trans(
"NoContactForAnyInvoice");
1487 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td>';
1488 if ($object->user_id) {
1489 $dolibarr_user =
new User($db);
1490 $result = $dolibarr_user->fetch($object->user_id);
1491 print $dolibarr_user->getLoginUrl(-1);
1494 if (!$object->user_id && $user->hasRight(
'user',
'user',
'creer')) {
1495 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>';
1502 print
'</div></div>';
1503 print
'<div class="clearboth"></div>';
1510 print
'<div class="tabsAction">';
1513 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
1514 if (empty($reshook) && $action !=
'presend') {
1515 if (empty($user->socid)) {
1516 if (!empty($object->email)) {
1517 $langs->load(
"mails");
1518 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>';
1520 $langs->load(
"mails");
1521 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a></div>';
1525 if ($user->rights->societe->contact->creer) {
1526 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
1530 if ($object->statut == 0 && $user->hasRight(
'societe',
'contact',
'creer')) {
1531 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Reactivate").
'</a>';
1534 if ($object->statut == 1 && $user->hasRight(
'societe',
'contact',
'creer')) {
1535 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=disable&id='.$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"DisableUser").
'</a>';
1539 if ($user->rights->societe->contact->supprimer) {
1540 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().($backtopage ?
'&backtopage='.urlencode($backtopage) :
''),
'delete', $user->rights->societe->contact->supprimer);
1547 if (
GETPOST(
'modelselected')) {
1548 $action =
'presend';
1551 if ($action !=
'presend') {
1552 print
'<div class="fichecenter"><div class="fichehalfleft">';
1554 print
'</div><div class="fichehalfright">';
1558 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contact/agenda.php?id='.$object->id);
1561 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1563 $somethingshown =
$formactions->showactions($object,
'contact', $object->socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
1565 print
'</div></div>';
1569 $modelmail =
'contact';
1570 $defaulttopic =
'Information';
1571 $diroutput = $conf->societe->dir_output.
'/contact/';
1572 $trackid =
'ctc'.$object->id;
1574 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';