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->rights->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->rights->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');
221 $object->socialnetworks = array();
223 foreach ($socialnetworks as $key => $value) {
225 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
229 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
230 $object->no_email =
GETPOST(
"no_email",
"int");
231 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
232 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
233 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
234 $object->fax = (string)
GETPOST(
"fax",
'alpha');
235 $object->priv =
GETPOST(
"priv",
'int');
236 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
237 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
238 $object->roles =
GETPOST(
"roles",
'array');
244 $object->birthday_alert =
GETPOST(
"birthday_alert",
'alpha');
247 $object->default_lang =
GETPOST(
'default_lang');
250 $ret = $extrafields->setOptionalsFromPost(
null, $object);
256 if (
isModEnabled(
'mailing') && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 && $object->no_email == -1 && !empty($object->email)) {
258 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
262 if (!empty($object->email) && !isValidEMail($object->email)) {
263 $langs->load(
"errors");
265 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
269 if (empty($object->lastname)) {
271 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
276 $id = $object->create($user);
279 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
286 $contcats =
GETPOST(
'contcats',
'array');
287 if (count($contcats) > 0) {
288 $result = $object->setCategories($contcats);
291 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
297 if (empty($error) &&
isModEnabled(
'mailing') && !empty($object->email)) {
299 $result = $object->setNoEmail($object->no_email);
302 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
307 if (empty($error) && $id > 0) {
309 if (!empty($backtopage)) {
310 $url = str_replace(
'__ID__', $id, $backtopage);
312 $url =
'card.php?id='.$id;
314 header(
"Location: ".$url);
321 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->societe->contact->supprimer) {
322 $result = $object->fetch($id);
323 $object->oldcopy = clone $object;
325 $object->old_lastname = (string)
GETPOST(
"old_lastname",
'alpha');
326 $object->old_firstname = (string)
GETPOST(
"old_firstname",
'alpha');
328 $result = $object->delete();
331 if ($backurlforlist) {
332 header(
"Location: ".$backurlforlist);
335 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
343 if ($action ==
'update' && empty($cancel) && !empty($permissiontoadd)) {
344 if (!
GETPOST(
"lastname",
'alpha')) {
345 $error++; $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
349 if (
isModEnabled(
'mailing') && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2 &&
GETPOST(
"no_email",
"int") == -1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
351 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
355 if (!empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL)) && !isValidEMail(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
356 $langs->load(
"errors");
358 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
363 $contactid =
GETPOST(
"contactid",
'int');
364 $object->fetch($contactid);
365 $object->fetchRoles();
368 $dir = $conf->societe->multidir_output[$object->entity].
"/contact/".$object->id.
"/photos";
369 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
370 if (
GETPOST(
'deletephoto') && $object->photo) {
371 $fileimg = $dir.
'/'.$object->photo;
372 $dirthumbs = $dir.
'/thumbs';
385 if (!($result > 0)) {
386 $errors[] =
"ErrorFailedToSaveFile";
391 $object->addThumbs($newfile);
395 $errors[] =
"ErrorBadImageFormat";
398 switch ($_FILES[
'photo'][
'error']) {
401 $errors[] =
"ErrorFileSizeTooLarge";
404 $errors[] =
"ErrorFilePartiallyUploaded";
409 $object->oldcopy = clone $object;
411 $object->old_lastname = (string)
GETPOST(
"old_lastname",
'alpha');
412 $object->old_firstname = (string)
GETPOST(
"old_firstname",
'alpha');
414 $object->socid =
GETPOST(
"socid",
'int');
415 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
416 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
417 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
418 $object->poste = (string)
GETPOST(
"poste",
'alpha');
420 $object->address = (string)
GETPOST(
"address",
'alpha');
421 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
422 $object->town = (string)
GETPOST(
"town",
'alpha');
423 $object->state_id =
GETPOST(
"state_id",
'int');
424 $object->country_id =
GETPOST(
"country_id",
'int');
426 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
427 $object->no_email =
GETPOST(
"no_email",
"int");
433 $object->socialnetworks = array();
435 foreach ($socialnetworks as $key => $value) {
437 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
441 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
442 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
443 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
444 $object->fax = (string)
GETPOST(
"fax",
'alpha');
445 $object->priv = (string)
GETPOST(
"priv",
'int');
446 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
447 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
449 $object->roles =
GETPOST(
"roles",
'array');
452 $object->default_lang =
GETPOST(
'default_lang');
455 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
461 $result = $object->update($contactid, $user);
465 $categories =
GETPOST(
'contcats',
'array');
466 $object->setCategories($categories);
470 $no_email =
GETPOST(
'no_email',
'int');
471 $result = $object->setNoEmail($no_email);
487 if (!$error && empty($errors)) {
488 if (!empty($backtopage)) {
489 header(
"Location: ".$backtopage);
495 if ($action ==
'setprospectcontactlevel' && !empty($permissiontoadd)) {
497 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
498 $result = $object->update($object->id, $user);
505 if ($action ==
'setstcomm' && !empty($permissiontoadd)) {
508 $result = $object->update($object->id, $user);
515 if ($action ==
"update_extras" && !empty($permissiontoadd)) {
516 $object->fetch(
GETPOST(
'id',
'int'));
518 $attributekey =
GETPOST(
'attribute',
'alpha');
519 $attributekeylong =
'options_'.$attributekey;
523 $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'));
526 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
529 $result = $object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
535 $action =
'edit_extras';
540 if ($action ==
'update_extras' && !empty($user->rights->societe->contact->creer)) {
544 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
550 $result = $object->insertExtraFields(
'CONTACT_MODIFY');
558 $action =
'edit_extras';
563 $triggersendname =
'CONTACT_SENTBYMAIL';
565 $mode =
'emailfromcontact';
566 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
580 $objsoc->fetch($socid);
583 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
584 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) {
585 $title = $object->lastname;
587 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
588 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
592 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
594 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
598 if (empty($object->error) && $id) {
600 $result = $object->fetch($id);
605 $objcanvas->assign_values($action, $object->id, $object->ref);
606 $objcanvas->display_canvas($action);
613 if ($user->rights->societe->contact->supprimer) {
614 if ($action ==
'delete') {
615 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
626 $res = $object->fetch($id, $user);
631 $object->fetchRoles();
637 if ($user->rights->societe->contact->creer) {
638 if ($action ==
'create') {
642 $object->canvas = $canvas;
644 $object->state_id =
GETPOST(
"state_id",
"int");
647 $object->country_id =
GETPOST(
"country_id") ?
GETPOST(
"country_id",
"int") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
648 if ($object->country_id) {
649 $tmparray =
getCountry($object->country_id,
'all');
650 $object->country_code = $tmparray[
'code'];
651 $object->country = $tmparray[
'label'];
661 if ($conf->use_javascript_ajax) {
662 print
"\n".
'<script type="text/javascript">'.
"\n";
663 print
'jQuery(document).ready(function () {
664 jQuery("#selectcountry_id").change(function() {
665 document.formsoc.action.value="create";
666 document.formsoc.submit();
669 $("#copyaddressfromsoc").click(function() {
670 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
671 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
672 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
673 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
674 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
675 /* set country at end because it will trigger page refresh */
676 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
677 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
680 print
'</script>'.
"\n";
683 print
'<form method="post" name="formsoc" action="'.$_SERVER[
"PHP_SELF"].
'">';
684 print
'<input type="hidden" name="token" value="'.newToken().
'">';
685 print
'<input type="hidden" name="action" value="add">';
686 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
687 if (!empty($objsoc)) {
688 print
'<input type="hidden" name="entity" value="'.$objsoc->entity.
'">';
693 print
'<table class="border centpercent">';
696 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
697 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>';
701 print
'<td><label for="firstname">';
702 print
$form->textwithpicto($langs->trans(
"Firstname"), $langs->trans(
"KeepEmptyIfGenericAddress")).
'</label></td>';
703 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>';
707 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
709 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
710 print
'<td colspan="3" class="maxwidthonsmartphone">';
711 print $objsoc->getNomUrl(1,
'contact');
713 print
'<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.
'">';
716 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
717 print
img_picto(
'',
'company').$form->select_company($socid,
'socid',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
723 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
724 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'alpha') : $object->civility_code,
'civility_code');
728 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
729 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>';
732 if ($conf->use_javascript_ajax && $socid > 0) {
737 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->address)) == 0) {
738 $object->address = $objsoc->address;
740 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
741 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>';
743 if ($conf->use_javascript_ajax && $socid > 0) {
745 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
749 print
'<td class="valignmiddle center" rowspan="'.$rowspan.
'">';
750 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a>';
756 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->zip)) == 0) {
757 $object->zip = $objsoc->zip;
759 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->town)) == 0) {
760 $object->town = $objsoc->town;
762 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
763 print $formcompany->select_ziptown((
GETPOST(
"zipcode",
'alpha') ?
GETPOST(
"zipcode",
'alpha') : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
764 print $formcompany->select_ziptown((
GETPOST(
"town",
'alpha') ?
GETPOST(
"town",
'alpha') : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
768 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
769 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
770 print
$form->select_country((
GETPOST(
"country_id",
'alpha') ?
GETPOST(
"country_id",
'alpha') : $object->country_id),
'country_id');
772 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
777 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
778 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)) {
779 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
781 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
784 if ($object->country_id) {
785 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
786 print $formcompany->select_state(
GETPOST(
"state_id",
'alpha') ?
GETPOST(
"state_id",
'alpha') : $object->state_id, $object->country_code,
'state_id');
788 print $countrynotdefined;
793 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->phone_pro)) == 0) {
794 $object->phone_pro = $objsoc->phone;
796 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->fax)) == 0) {
797 $object->fax = $objsoc->fax;
801 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
'', $object, 0).
'</td>';
804 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') : $object->phone_pro).
'"></td>';
805 if ($conf->browser->layout ==
'phone') {
808 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'phone_perso',
'', $object, 0).
'</td>';
811 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>';
813 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'', $object, 0).
'</td>';
815 print
img_picto(
'',
'object_phoning_mobile');
816 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') : $object->phone_mobile).
'"></td>';
817 if ($conf->browser->layout ==
'phone') {
820 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
822 print
img_picto(
'',
'object_phoning_fax');
823 print
'<input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') : $object->fax).
'"></td>';
826 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->email)) == 0) {
827 $object->email = $objsoc->email;
831 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'').
'</td>';
834 print
'<input type="text" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
839 if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
840 print
"\n".
'<script type="text/javascript">'.
"\n";
841 print
'$(document).ready(function () {
842 $("#email").keyup(function() {
843 if ($(this).val()!="") {
844 $(".noemail").addClass("fieldrequired");
846 $(".noemail").removeClass("fieldrequired");
850 print
'</script>'.
"\n";
852 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
853 $result = $object->getNoEmail();
859 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
861 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));
868 foreach ($socialnetworks as $key => $value) {
869 if ($value[
'active']) {
871 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
872 print
'<td colspan="3">';
873 if (!empty($value[
'icon'])) {
874 print
'<span class="fa '.$value[
'icon'].
'"></span>';
876 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] :
"")).
'">';
879 } elseif (!empty($object->socialnetworks[$key])) {
880 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
886 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
887 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
888 print
$form->selectarray(
'priv', $selectarray, (
GETPOST(
"priv",
'alpha') ?
GETPOST(
"priv",
'alpha') : $object->priv), 0);
893 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
894 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');
900 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
901 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
902 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
'parent',
null,
null, 1);
903 print
img_picto(
'',
'category').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
null,
null,
'90%');
908 if (!empty($socid)) {
909 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
910 print
'<td colspan="3">';
911 $contactType = $object->listeTypeContacts(
'external',
'', 1);
912 print
$form->multiselectarray(
'roles', $contactType, array(), 0, 0,
'minwidth500');
917 $parameters = array(
'socid' => $socid,
'objsoc' => $objsoc,
'colspan' =>
' colspan="3"',
'cols' => 3,
'colspanvalue' => 3);
918 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
920 print
"</table><br>";
922 print
'<hr style="margin-bottom: 20px">';
925 print
load_fiche_titre(
'<div class="comboperso">'.$langs->trans(
"PersonalInformations").
'</div>',
'',
'');
927 print
'<table class="border centpercent">';
930 print
'<tr><td><label for="birthday">'.$langs->trans(
"DateOfBirth").
'</label></td><td>';
932 if ($object->birthday) {
933 print
$form->selectDate($object->birthday,
'birthday', 0, 0, 0,
"perso", 1, 0);
935 print
$form->selectDate(
'',
'birthday', 0, 0, 1,
"perso", 1, 0);
939 print
'<td><label for="birthday_alert">'.$langs->trans(
"Alert").
'</label>: ';
940 if (!empty($object->birthday_alert)) {
941 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
943 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert">';
952 print
$form->buttonsSaveCancel(
"Add");
955 } elseif ($action ==
'edit' && !empty($id)) {
961 if (
GETPOSTISSET(
"country_id") || $object->country_id) {
962 $tmparray =
getCountry($object->country_id,
'all');
963 $object->country_code = $tmparray[
'code'];
964 $object->country = $tmparray[
'label'];
968 $objsoc->fetch($object->socid);
973 if ($conf->use_javascript_ajax) {
974 print
"\n".
'<script type="text/javascript">'.
"\n";
975 print
'jQuery(document).ready(function () {
976 jQuery("#selectcountry_id").change(function() {
977 document.formsoc.action.value="edit";
978 document.formsoc.submit();
981 $("#copyaddressfromsoc").click(function() {
982 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
983 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
984 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
985 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
986 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
987 /* set country at end because it will trigger page refresh */
988 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
989 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
992 print
'</script>'.
"\n";
995 print
'<form enctype="multipart/form-data" method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" name="formsoc">';
996 print
'<input type="hidden" name="token" value="'.newToken().
'">';
997 print
'<input type="hidden" name="id" value="'.$id.
'">';
998 print
'<input type="hidden" name="action" value="update">';
999 print
'<input type="hidden" name="contactid" value="'.$object->id.
'">';
1000 print
'<input type="hidden" name="old_lastname" value="'.$object->lastname.
'">';
1001 print
'<input type="hidden" name="old_firstname" value="'.$object->firstname.
'">';
1002 if (!empty($backtopage)) {
1003 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1008 print
'<table class="border centpercent">';
1011 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
1012 print
'<tr><td>'.$langs->trans(
"ID").
'</td><td colspan="3">';
1018 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
1019 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>';
1023 print
'<td><label for="firstname">'.$langs->trans(
"Firstname").
'</label></td>';
1024 print
'<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"firstname") ?
GETPOST(
"firstname") : $object->firstname).
'"></td>';
1028 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
1029 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
1030 print
'<td colspan="3" class="maxwidthonsmartphone">';
1031 print
img_picto(
'',
'company').$form->select_company(
GETPOST(
'socid',
'int') ?
GETPOST(
'socid',
'int') : ($object->socid ? $object->socid : -1),
'socid',
'', $langs->trans(
"SelectThirdParty"));
1037 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
1038 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
"aZ09") : $object->civility_code,
'civility_code');
1042 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
1043 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>';
1046 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
1047 print
'<td colspan="3">';
1048 print
'<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
1049 print
'<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET(
"address") ?
GETPOST(
"address",
'alphanohtml') : $object->address).
'</textarea>';
1050 print
'</div><div class="paddingrightonly valignmiddle inline-block">';
1051 if ($conf->use_javascript_ajax) {
1052 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a><br>';
1058 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1059 print $formcompany->select_ziptown((
GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
1060 print $formcompany->select_ziptown((
GETPOSTISSET(
"town") ?
GETPOST(
"town") : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1064 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1065 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1066 print
$form->select_country(
GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id") : $object->country_id,
'country_id');
1068 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1073 if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
1074 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)) {
1075 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1077 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1080 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1081 print $formcompany->select_state(
GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'alpha') : $object->state_id, $object->country_code,
'state_id');
1086 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
GETPOST(
'phone_pro',
'alpha'), $object, 0).
'</td>';
1089 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>';
1090 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'fax',
GETPOST(
'phone_perso',
'alpha'), $object, 0).
'</td>';
1093 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>';
1095 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'), $object, 0,
'string',
'').
'</td>';
1097 print
img_picto(
'',
'object_phoning_mobile');
1098 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>';
1099 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
1101 print
img_picto(
'',
'object_phoning_fax');
1102 print
'<input type="text" name="fax" id="fax" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_fax') ?
GETPOST(
'phone_fax',
'alpha') : $object->fax).
'"></td></tr>';
1105 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
1108 print
'<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
1110 $langs->load(
"mails");
1111 print
'<td class="nowrap">'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1112 print
'<td>'.$object->getNbOfEMailings().
'</td>';
1114 print
'<td colspan="2"></td>';
1120 if ($conf->use_javascript_ajax && isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2) {
1121 print
"\n".
'<script type="text/javascript">'.
"\n";
1124 jQuery(document).ready(function () {
1125 function init_check_no_email(input) {
1126 if (input.val()!="") {
1127 $(".noemail").addClass("fieldrequired");
1129 $(".noemail").removeClass("fieldrequired");
1132 $("#email").keyup(function() {
1133 init_check_no_email($(this));
1135 init_check_no_email($("#email"));
1137 print
'</script>'.
"\n";
1139 if (!
GETPOSTISSET(
"no_email") && !empty($object->email)) {
1140 $result = $object->getNoEmail();
1146 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1148 $useempty = (isset($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS) && ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == 2));
1149 print
$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'int') : $object->no_email), 1, false, $useempty);
1155 foreach ($socialnetworks as $key => $value) {
1156 if ($value[
'active']) {
1158 print
'<td><label for="'.$value[
'label'].
'">'.
$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1159 print
'<td colspan="3">';
1160 if (!empty($value[
'icon'])) {
1161 print
'<span class="fa '.$value[
'icon'].
'"></span>';
1163 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])).
'">';
1166 } elseif (!empty($object->socialnetworks[$key])) {
1167 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1173 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
1174 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1175 print
$form->selectarray(
'priv', $selectarray, $object->priv, 0);
1180 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'', $object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1181 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');
1187 print
'<tr><td class="tdtop"><label for="note_public">'.$langs->trans(
"NotePublic").
'</label></td><td colspan="3">';
1188 $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%');
1189 print $doleditor->Create(1);
1193 print
'<tr><td class="tdtop"><label for="note_private">'.$langs->trans(
"NotePrivate").
'</label></td><td colspan="3">';
1194 $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%');
1195 print $doleditor->Create(1);
1199 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
1200 print
'<td colspan="3">';
1201 print $object->getLibStatut(4);
1205 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
1206 $arrayselected = array();
1207 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td>';
1208 print
'<td colspan="3">';
1209 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_CONTACT,
null,
null,
null,
null, 1);
1211 $cats = $c->containing($object->id,
'contact');
1212 foreach ($cats as $cat) {
1213 $arrayselected[] = $cat->id;
1215 print
img_picto(
'',
'category').$form->multiselectarray(
'contcats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
1220 if (!empty($object->socid)) {
1221 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1222 print
'<td colspan="3">';
1223 print $formcompany->showRoles(
"roles", $object,
'edit', $object->roles);
1228 $parameters = array(
'colspan' =>
' colspan="3"',
'cols'=>
'3',
'colspanvalue'=>
'3');
1229 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
1231 $object->load_ref_elements();
1234 print
'<tr><td>'.$langs->trans(
"ContactForOrders").
'</td><td colspan="3">';
1235 print $object->ref_commande ? $object->ref_commande : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>');
1240 print
'<tr><td>'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1241 print $object->ref_propal ? $object->ref_propal : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'</span>');
1246 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1247 print $object->ref_contrat ? $object->ref_contrat : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>');
1252 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1253 print $object->ref_facturation ? $object->ref_facturation : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>');
1258 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1259 if ($object->user_id) {
1260 $dolibarr_user =
new User($db);
1261 $result = $dolibarr_user->fetch($object->user_id);
1262 print $dolibarr_user->getLoginUrl(1);
1264 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
1270 print
'<td>'.$langs->trans(
"PhotoFile").
'</td>';
1271 print
'<td colspan="3">';
1272 if ($object->photo) {
1273 print
$form->showphoto(
'contact', $object);
1276 print
'<table class="nobordernopadding">';
1277 if ($object->photo) {
1278 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
1283 $maxmin = $maxfilesizearray[
'maxmin'];
1285 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1287 print
'<input type="file" class="flat" name="photo" id="photoinput">';
1298 print
$form->buttonsSaveCancel();
1305 if (
GETPOST(
'modelselected',
'alpha')) {
1306 $action =
'presend';
1310 if (!empty($id) && $action !=
'edit' && $action !=
'create') {
1318 if ($action ==
'create_user') {
1320 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1323 $generated_password =
'';
1324 if (empty($ldap_sid)) {
1325 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1328 $password = $generated_password;
1331 $formquestion = array(
1332 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
1333 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password),
1336 $text = $langs->trans(
"ConfirmCreateContact").
'<br>';
1338 if ($object->socid > 0) {
1339 $text .= $langs->trans(
"UserWillBeExternalUser");
1341 $text .= $langs->trans(
"UserWillBeInternalUser");
1344 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"CreateDolibarrLogin"), $text,
"confirm_create_user", $formquestion,
'yes');
1347 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1349 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/contact/vcard.php?id='.$object->id.
'" class="refid">';
1350 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1351 $morehtmlref .=
'</a>';
1353 $morehtmlref .=
'<div class="refidno">';
1354 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
1355 $objsoc->fetch($object->socid);
1357 $morehtmlref .= $langs->trans(
'ThirdParty').
' : ';
1358 if ($objsoc->id > 0) {
1359 $morehtmlref .= $objsoc->getNomUrl(1,
'contact');
1361 $morehtmlref .=
'<span class="opacitymedium">'.$langs->trans(
"ContactNotLinkedToCompany").
'</span>';
1364 $morehtmlref .=
'</div>';
1366 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
1369 print
'<div class="fichecenter">';
1370 print
'<div class="fichehalfleft">';
1372 print
'<div class="underbanner clearboth"></div>';
1373 print
'<table class="border tableforfield" width="100%">';
1376 print
'<tr><td class="titlefield">'.$langs->trans(
"UserTitle").
'</td><td>';
1377 print $object->getCivilityLabel();
1381 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td><td>'.$object->poste.
'</td></tr>';
1385 $langs->load(
"mails");
1386 print
'<tr><td>'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1387 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?filteremail='.urlencode($object->email).
'">'.$object->getNbOfEMailings().
'</a></td></tr>';
1392 $result = $object->getNoEmail();
1396 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
1397 if ($object->email) {
1398 print
yn($object->no_email);
1400 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
1407 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1408 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
1411 $langs->load(
"languages");
1412 $labellang = ($object->default_lang ? $langs->trans(
'Language_'.$object->default_lang) :
'');
1413 print
picto_from_langcode($object->default_lang,
'class="paddingrightonly saturatemedium opacitylow"');
1418 print
'<tr><td>'.$langs->trans(
"ContactVisibility").
'</td><td>';
1419 print $object->LibPubPriv($object->priv);
1425 $object->fetch_thirdparty();
1428 print
'<div class="fichehalfright">';
1430 print
'<div class="underbanner clearboth"></div>';
1431 print
'<table class="border tableforfield centpercent">';
1434 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
1435 if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
1437 print
'<tr><td class="titlefield">';
1438 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1439 print $langs->trans(
'ProspectLevel');
1441 if ($action !=
'editlevel' && $user->rights->societe->contact->creer) {
1442 print
'<td align="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
1444 print
'</tr></table>';
1446 if ($action ==
'editlevel') {
1447 $formcompany->formProspectContactLevel($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_prospectlevel,
'prospect_contact_level_id', 1);
1449 print $object->getLibProspLevel();
1455 $object->loadCacheOfProspStatus();
1456 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id][
'label']);
1457 print
' ';
1458 print
'<div class="floatright">';
1459 foreach ($object->cacheprospectstatus as $key => $val) {
1460 $titlealt =
'default';
1461 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1462 $titlealt = $val[
'label'];
1464 if ($object->stcomm_id != $val[
'id']) {
1465 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>';
1468 print
'</div></td></tr>';
1473 if (
isModEnabled(
'categorie') && !empty($user->rights->categorie->lire)) {
1474 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1476 print
$form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
1480 if (!empty($object->socid)) {
1481 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1483 print $formcompany->showRoles(
"roles", $object,
'view', $object->roles);
1489 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1491 $object->load_ref_elements();
1494 print
'<tr><td class="titlefield tdoverflow">'.$langs->trans(
"ContactForProposals").
'</td><td>';
1495 print $object->ref_propal ? $object->ref_propal : $langs->trans(
"NoContactForAnyProposal");
1500 print
'<tr><td class="titlefield tdoverflow">';
1502 print $langs->trans(
"ContactForOrdersOrShipments");
1504 print $langs->trans(
"ContactForOrders");
1507 $none = $langs->trans(
"NoContactForAnyOrder");
1509 $none = $langs->trans(
"NoContactForAnyOrderOrShipments");
1511 print $object->ref_commande ? $object->ref_commande : $none;
1516 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForContracts").
'</td><td>';
1517 print $object->ref_contrat ? $object->ref_contrat : $langs->trans(
"NoContactForAnyContract");
1522 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForInvoices").
'</td><td>';
1523 print $object->ref_facturation ? $object->ref_facturation : $langs->trans(
"NoContactForAnyInvoice");
1527 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td>';
1528 if ($object->user_id) {
1529 $dolibarr_user =
new User($db);
1530 $result = $dolibarr_user->fetch($object->user_id);
1531 print $dolibarr_user->getLoginUrl(-1);
1534 if (!$object->user_id && $user->rights->user->user->creer) {
1535 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>';
1542 print
'</div></div>';
1543 print
'<div style="clear:both"></div>';
1550 print
'<div class="tabsAction">';
1553 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
1554 if (empty($reshook) && $action !=
'presend') {
1555 if (empty($user->socid)) {
1556 if (!empty($object->email)) {
1557 $langs->load(
"mails");
1558 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>';
1560 $langs->load(
"mails");
1561 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a></div>';
1565 if ($user->rights->societe->contact->creer) {
1566 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
1570 if ($object->statut == 0 && $user->rights->societe->contact->creer) {
1571 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Reactivate").
'</a>';
1574 if ($object->statut == 1 && $user->rights->societe->contact->creer) {
1575 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=disable&id='.$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"DisableUser").
'</a>';
1579 if ($user->rights->societe->contact->supprimer) {
1580 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);
1587 if (
GETPOST(
'modelselected')) {
1588 $action =
'presend';
1591 if ($action !=
'presend') {
1592 print
'<div class="fichecenter"><div class="fichehalfleft">';
1594 print
'</div><div class="fichehalfright">';
1598 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contact/agenda.php?id='.$object->id);
1601 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1603 $somethingshown =
$formactions->showactions($object,
'contact', $object->socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
1605 print
'</div></div>';
1609 $modelmail =
'contact';
1610 $defaulttopic =
'Information';
1611 $diroutput = $conf->societe->dir_output.
'/contact/';
1612 $trackid =
'ctc'.$object->id;
1614 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif($action=='specimen') elseif($action=='setmodel') elseif($action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
Make control on an uploaded file from an GUI page and move it to final destination.
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
img_action($titlealt, $numaction, $picto='')
Show logo action.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.