38require
'../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/lib/contact.lib.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
62$langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
68$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$backtopage =
GETPOST(
'backtopage',
'alpha');
71$cancel =
GETPOST(
'cancel',
'alpha');
79$extrafields->fetch_name_optionals_label(
$object->table_element);
88 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
89 $objcanvas =
new Canvas($db, $action);
90 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
94$hookmanager->initHooks(array(
'contactcard',
'globalcard'));
101if (!(
$object->id > 0) && $action ==
'view') {
102 $langs->load(
"errors");
103 print($langs->trans(
'ErrorRecordNotFound'));
107$triggermodname =
'CONTACT_MODIFY';
108$permissiontoadd = $user->hasRight(
'societe',
'contact',
'creer');
109$permissiontoeditextra = $permissiontoadd;
110if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
112 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
117 $socid = $user->socid;
122$result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
129$parameters = array(
'id' => $id,
'objcanvas' => $objcanvas);
130$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
132 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
135if (empty($reshook)) {
136 $backurlforlist = DOL_URL_ROOT.
'/contact/list.php';
138 if (empty($backtopage) || ($cancel && empty($id))) {
139 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
140 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
141 $backtopage = $backurlforlist;
143 $backtopage = DOL_URL_ROOT.
'/contact/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
149 if (!empty($backtopageforcancel)) {
150 header(
"Location: ".$backtopageforcancel);
152 } elseif (!empty($backtopage)) {
153 header(
"Location: ".$backtopage);
160 if ($action ==
'confirm_create_user' && $confirm ==
'yes' && $user->hasRight(
'user',
'user',
'creer')) {
168 $nuser =
new User($db);
169 $result = $nuser->create_from_contact($object,
GETPOST(
"login"));
172 $result2 = $nuser->setPassword($user,
GETPOST(
"password"), 0, 0, 1);
173 if (is_int($result2) && $result2 < 0) {
174 $error = $nuser->error;
175 $errors = $nuser->errors;
181 $error = $nuser->error;
182 $errors = $nuser->errors;
186 setEventMessage($langs->trans(
'ImpossibleToCreateUserFromContact').
' : '.$nuser->errorsToString(),
'errors');
196 if ($action ==
'disable' && $permissiontoadd) {
198 if (
$object->setstatus(0) < 0) {
201 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
207 if ($action ==
'enable' && $permissiontoadd) {
209 if (
$object->setstatus(1) < 0) {
212 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
218 if ($action ==
'add' && $permissiontoadd) {
230 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
238 $object->socialnetworks = array();
240 foreach ($socialnetworks as $key => $value) {
242 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
250 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
253 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
254 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
262 $object->birthday_alert = (
GETPOST(
'birthday_alert',
'alpha') ==
"on" ? 1 : 0);
268 $ret = $extrafields->setOptionalsFromPost(
null, $object);
276 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
281 $langs->load(
"errors");
283 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
287 if (empty(
$object->lastname)) {
289 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
304 $contcats =
GETPOST(
'contcats',
'array');
305 if (count($contcats) > 0) {
306 $result =
$object->setCategories($contcats);
325 if (empty($error) && $id > 0) {
327 if (!empty($backtopage)) {
328 $url = str_replace(
'__ID__', (
string) $id, $backtopage);
330 $url =
'card.php?id='.$id;
332 header(
"Location: ".$url);
339 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'contact',
'supprimer')) {
343 $result =
$object->delete($user);
345 setEventMessages(
"RecordDeleted",
null,
'mesgs');
346 if ($backurlforlist) {
347 header(
"Location: ".$backurlforlist);
350 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
361 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $permissiontoadd && $user->hasRight(
'societe',
'contact',
'supprimer')) {
362 $contact_origin_id =
GETPOSTINT(
'contact_origin');
364 if ($contact_origin_id <= 0) {
365 $langs->load(
'errors');
366 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'MergeOriginContact')),
null,
'errors');
372 $langs->load(
'errors');
373 setEventMessages($langs->trans(
'ErrorRecordNotFound'),
null,
'errors');
374 } elseif ($result != $id) {
375 $langs->load(
'errors');
376 setEventMessages(
$object->error ?
$object->error : $langs->trans(
'ErrorBadParameters'),
$object->errors,
'errors');
377 } elseif (
$object->mergeContact($contact_origin_id) < 0) {
380 setEventMessages($langs->trans(
'ContactsMergeSuccess'),
null,
'mesgs');
382 if (!empty(
$object->warnings)) {
383 setEventMessages(
null,
$object->warnings,
'warnings');
385 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
391 if ($action ==
'update' && empty($cancel) && $permissiontoadd) {
392 if (!
GETPOST(
"lastname",
'alpha')) {
394 $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
400 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
405 $langs->load(
"errors");
407 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
418 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
420 $fileimg = $dir.
'/'.
$object->photo;
421 $dirthumbs = $dir.
'/thumbs';
435 if (!is_numeric($result) || $result <= 0) {
436 $errors[] =
"ErrorFailedToSaveFile";
445 $errors[] =
"ErrorBadImageFormat";
448 switch ($_FILES[
'photo'][
'error']) {
451 $errors[] =
"ErrorFileSizeTooLarge";
454 $errors[] =
"ErrorFilePartiallyUploaded";
465 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
475 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
477 $object->socialnetworks = array();
479 foreach ($socialnetworks as $key => $value) {
481 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
487 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
490 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
491 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
500 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
506 $result =
$object->update($contactid, $user);
511 $tmpuser =
new User($db);
512 if ($tmpuser->fetch(
$object->user_id) > 0 && $tmpuser->socid !=
$object->socid) {
513 setEventMessages($langs->trans(
"WarningUserDifferentContactSocid"),
null,
'warnings');
518 $categories =
GETPOST(
'contcats',
'array');
519 $object->setCategories($categories);
524 $result =
$object->setNoEmail($no_email);
537 if (!$error && empty($errors)) {
538 if (!empty($backtopage)) {
539 header(
"Location: ".$backtopage);
548 if ($action ==
'setprospectcontactlevel' && $permissiontoadd) {
550 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
558 if ($action ==
'setstcomm' && $permissiontoadd) {
568 if ($action ==
'update_extras' && $permissiontoeditextra) {
571 $attribute_name =
GETPOST(
'attribute',
'aZ09');
574 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
580 $result =
$object->updateExtraField($attribute_name,
'CONTACT_MODIFY');
588 $action =
'edit_extras';
593 $triggersendname =
'CONTACT_SENTBYMAIL';
595 $mode =
'emailfromcontact';
596 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
604$form =
new Form($db);
610 $objsoc->fetch($socid);
613$title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
618 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
620$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
622llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-societe page-contact-card');
624$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
626if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
630 if (empty(
$object->error) && $id) {
634 dol_print_error(
null,
$object->error);
638 $objcanvas->display_canvas($action);
645 if ($user->hasRight(
'societe',
'contact',
'supprimer')) {
646 if ($action ==
'delete') {
647 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
652 if ($action ==
'merge' && $permissiontoadd && $user->hasRight(
'societe',
'contact',
'supprimer')) {
658 $formquestion = array(
660 'name' =>
'contact_origin',
661 'label' => $langs->trans(
"MergeOriginContact"),
663 'value' => $form->select_contact(0,
'',
'contact_origin', 1,
'',
'', 1,
'minwidth200',
false, 1, 0, array(),
'',
'',
'',
'(sp.rowid:!=:'.((
int) $id).
')')
667 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"MergeContacts"), $langs->trans(
"ConfirmMergeContacts"),
"confirm_merge", $formquestion,
'no', 1, 300);
677 $res =
$object->fetch($id, $user);
688 if ($user->hasRight(
'societe',
'contact',
'creer')) {
689 if ($action ==
'create') {
701 $object->country_code = $tmparray[
'code'];
702 $object->country = $tmparray[
'label'];
712 if (
$conf->use_javascript_ajax) {
713 print
"\n".
'<script type="text/javascript">'.
"\n";
714 print
'jQuery(document).ready(function () {
715 jQuery("#selectcountry_id").change(function() {
716 document.formsoc.action.value="create";
717 document.formsoc.submit();
720 $("#copyaddressfromsoc").click(function() {
721 $(\'textarea[name="address"]\').val(\''.dol_escape_js($objsoc->address).
'\');
722 $(\
'input[name="zipcode"]\').val(\''.
dol_escape_js($objsoc->zip).
'\');
723 $(\
'input[name="town"]\').val(\''.
dol_escape_js($objsoc->town).
'\');
724 console.log(\
'Set state_id to '.
dol_escape_js((
string) $objsoc->state_id).
'\');
725 $(\
'select[name="state_id"]\').val(\''.
dol_escape_js((
string) $objsoc->state_id).
'\').trigger(
"change");
727 console.log(\
'Set country id to '.
dol_escape_js((
string) $objsoc->country_id).
'\');
728 $(\
'select[name="country_id"]\').val(\''.
dol_escape_js((
string) $objsoc->country_id).
'\').trigger(
"change");
731 print '</script>
'."\n";
734 print '<form method=
"post" name=
"formsoc" action=
"'.dolBuildUrl($_SERVER["PHP_SELF
"]).'">
';
735 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
736 print '<input
type=
"hidden" name=
"action" value=
"add">
';
737 print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
738 if (!empty($objsoc)) {
739 print '<input
type=
"hidden" name=
"entity" value=
"'.$objsoc->entity.'">
';
742 print dol_get_fiche_head($head, 'card
', '', 0, '');
744 print '<
table class=
"border centpercent">
';
747 print '<tr><td
class=
"titlefieldcreate fieldrequired"><label
for=
"lastname">
'.$langs->trans("Lastname").' /
'.$langs->trans("Label").'</label></td>
';
748 print '<td colspan=
"3"><input
name=
"lastname" id=
"lastname" type=
"text" class=
"minwidth200" maxlength=
"80" value=
"'.dol_escape_htmltag(GETPOST("lastname
", 'alpha') ? GETPOST("lastname
", 'alpha') : $object->lastname).'" autofocus=
"autofocus"></td>
';
753 print '<td><label
for=
"firstname">
';
754 print $form->textwithpicto($langs->trans("Firstname"), $langs->trans("KeepEmptyIfGenericAddress")).'</label></td>
';
755 print '<td colspan=
"3"><input
name=
"firstname" id=
"firstname"type=
"text" class=
"minwidth200" maxlength=
"80" value=
"'.dol_escape_htmltag(GETPOST("firstname
", 'alpha') ? GETPOST("firstname
", 'alpha') : $object->firstname).'"></td>
';
759 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS
')) {
761 print '<tr><td><label
for=
"socid">
'.$langs->trans("ThirdParty").'</label></td>
';
762 print '<td colspan=
"3" class=
"maxwidthonsmartphone">
';
763 print $objsoc->getNomUrl(1, 'contact
');
765 print '<input
type=
"hidden" name=
"socid" id=
"socid" value=
"'.$objsoc->id.'">
';
768 print '<tr><td><label
for=
"socid">
'.$langs->trans("ThirdParty").'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
769 print img_picto('', 'company
', 'class=
"pictofixedwidth"').$form->select_company($socid, 'socid
', '', 'SelectThirdParty
', 0, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx
');
775 if (getDolGlobalString('MAIN_USE_TITLE_FOR_CONTACT
')) {
776 print '<tr><td><label
for=
"civility_code">
'.$langs->trans("UserTitle").'</label></td><td colspan=
"3">
';
777 print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09
') : $object->civility_code, 'civility_code
');
782 print '<tr><td><label
for=
"title">
'.$langs->trans("PostOrFunction").'</label></td>
';
783 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>
';
785 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
786 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
789 if ($conf->use_javascript_ajax && $socid > 0) {
794 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->address)) == 0) {
795 $object->address = $objsoc->address; // Predefined with third party
797 print '<tr><td><label
for=
"address">
'.$langs->trans("Address").'</label></td>
';
798 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>
';
800 if ($conf->use_javascript_ajax && $socid > 0) {
802 if (!getDolGlobalString('SOCIETE_DISABLE_STATE
')) {
806 print '<td
class=
"valignmiddle center" rowspan=
"'.$rowspan.'">
';
807 print '<a href=
"#" id=
"copyaddressfromsoc">
'.$langs->trans('CopyAddressFromSoc
').'</a>
';
813 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->zip)) == 0) {
814 $object->zip = $objsoc->zip; // Predefined with third party
816 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->town)) == 0) {
817 $object->town = $objsoc->town; // Predefined with third party
819 print '<tr><td><label
for=
"zipcode">
'.$langs->trans("Zip").'</label> / <label
for=
"town">
'.$langs->trans("Town").'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
820 print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha
') ? GETPOST("zipcode", 'alpha
') : $object->zip), 'zipcode
', array('town
', 'selectcountry_id
', 'state_id
'), 6).'
';
821 print $formcompany->select_ziptown((GETPOST("town", 'alpha
') ? GETPOST("town", 'alpha
') : $object->town), 'town
', array('zipcode
', 'selectcountry_id
', 'state_id
'));
825 print '<tr><td><label
for=
"selectcountry_id">
'.$langs->trans("Country").'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
826 print img_picto('', 'globe-americas
', 'class=
"pictofixedwidth"');
827 print $form->select_country((GETPOSTISSET("country_id") ? GETPOST("country_id", 'alpha
') : $object->country_id), 'country_id
');
829 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
834 if (!getDolGlobalString('SOCIETE_DISABLE_STATE
')) {
835 if (getDolGlobalString('MAIN_SHOW_REGION_IN_STATE_SELECT
') && (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 2)) {
836 print '<tr><td><label
for=
"state_id">
'.$langs->trans('Region-State
').'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
838 print '<tr><td><label
for=
"state_id">
'.$langs->trans('State
').'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
841 if ($object->country_id) {
842 print img_picto('', 'state
', 'class=
"pictofixedwidth"');
843 print $formcompany->select_state(GETPOST("state_id", 'alpha
') ? GETPOST("state_id", 'alpha
') : $object->state_id, $object->country_code, 'state_id
');
845 print $countrynotdefined;
850 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->phone_pro)) == 0) {
851 $object->phone_pro = $objsoc->phone; // Predefined with third party
853 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->fax)) == 0) {
854 $object->fax = $objsoc->fax; // Predefined with third party
858 print '<tr><td>
'.$form->editfieldkey('PhonePro
', 'phone_pro
', '', $object, 0).'</td>
';
860 print $form->showPhoneInput($object->phone_pro, 'phone_pro
', $object->country_id, 'object_phoning
', 'maxwidth150 widthcentpercentminusx
');
862 if ($conf->browser->layout == 'phone
') {
866 print '<td>
'.$form->editfieldkey('PhonePerso
', 'phone_perso
', '', $object, 0).'</td>
';
868 print $form->showPhoneInput($object->phone_perso, 'phone_perso
', $object->country_id, 'object_phoning
', 'maxwidth150 widthcentpercentminusx
');
872 print '<tr><td>
'.$form->editfieldkey('PhoneMobile
', 'phone_mobile
', '', $object, 0).'</td>
';
874 print $form->showPhoneInput($object->phone_mobile, 'phone_mobile
', $object->country_id, 'object_phoning_mobile
', 'maxwidth150 widthcentpercentminusx
');
876 if ($conf->browser->layout == 'phone
') {
880 print '<td>
'.$form->editfieldkey('Fax
', 'fax
', '', $object, 0).'</td>
';
882 print $form->showPhoneInput($object->fax, 'fax
', $object->country_id, 'object_phoning_fax
', 'maxwidth150 widthcentpercentminusx
');
886 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->email)) == 0) {
887 $object->email = $objsoc->email; // Predefined with third party
891 print '<tr><td>
'.$form->editfieldkey('EMail
', 'email', '', $object, 0, 'string', '').'</td>
';
893 print img_picto('', 'object_email
', 'class=
"pictofixedwidth"');
894 print '<input
class=
"maxwidth200 widthcentpercentminusx" type=
"text" name=
"email" id=
"email" value=
"'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>
';
898 if (isModEnabled('mailing
')) {
899 if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2) {
900 print "\n".'<script
type=
"text/javascript">
'."\n";
901 print '$(document).ready(
function () {
902 $(
"#email").keyup(
function() {
903 if ($(
this).val()!=
"") {
904 $(
".noemail").addClass(
"fieldrequired");
906 $(
".noemail").removeClass(
"fieldrequired");
910 print '</script>
'."\n";
912 if (!GETPOSTISSET("no_email") && !empty($object->email)) {
913 $result = $object->getNoEmail();
915 setEventMessages($object->error, $object->errors, 'errors
');
919 print '<td
class=
"noemail"><label
for=
"no_email">
'.$langs->trans("No_Email").'</label></td>
';
921 // Default value is in MAILING_CONTACT_DEFAULT_BULK_STATUS that you can modify in setup of module emailing
922 print $form->selectyesno('no_email
', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
')), 1, false, (int) (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2));
928 if (isModEnabled('socialnetworks
')) {
929 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
931 $object->showSocialNetwork($socialnetworks, $colspan);
933 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
937 print '<tr><td><label
for=
"priv">
'.$langs->trans("ContactVisibility").'</label></td><td colspan=
"3">
';
938 $selectarray = array('0
' => $langs->trans("ContactPublic"), '1
' => $langs->trans("ContactPrivate"));
939 print $form->selectarray('priv
', $selectarray, (GETPOST("priv", 'alpha
') ? GETPOST("priv", 'alpha
') : $object->priv), 0);
943 if (getDolGlobalInt('MAIN_MULTILANGS
')) {
944 print '<tr><td>
'.$form->editfieldkey('DefaultLang
', 'default_lang
', '', $object, 0).'</td><td colspan=
"3" class=
"maxwidthonsmartphone">
'."\n";
945 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, array(), 1, 0, 0, 'maxwidth200 widthcentpercentminusx
');
951 if (isModEnabled('category
') && $user->hasRight('categorie
', 'lire
')) {
952 print '<tr><td>
'.$form->editfieldkey('Categories', 'contcats
', '', $object, 0).'</td><td colspan=
"3">
';
953 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, '', 'parent
', 64, 0, 3);
954 print img_picto('', 'category
', 'class=
"pictofixedwidth"').$form->multiselectarray('contcats
', $cate_arbo, GETPOST('contcats
', 'array
'), 0, 0, '', 0, '90%
');
958 // Contact by default
960 print '<tr><td>
'.$langs->trans("ContactByDefaultFor").'</td>
';
961 print '<td colspan=
"3">
';
962 $contactType = $object->listeTypeContacts('external
', 0, 1);
963 print img_picto('', 'contact
', 'class=
"pictofixedwidth"').$form->multiselectarray('roles
', $contactType, array(), 0, 0, '', 0, '90%
');
968 $parameters = array('socid
' => $socid, 'objsoc
' => $objsoc, 'colspan
' => ' colspan=
"3"', 'cols
' => 3, 'colspanvalue
' => 3);
969 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php
';
971 print "</table><br>";
973 print '<hr style=
"margin-bottom: 20px">
';
975 // Add personal information
976 print load_fiche_titre('<div
class=
"comboperso">
'.$langs->trans("PersonalInformations").'</div>
', '', '');
978 print '<
table class=
"border centpercent">
';
981 print '<tr><td
class=
"titlefieldcreate"><label
for=
"birthday">
'.$langs->trans("DateOfBirth").'</label></td><td colspan=
"3">
';
982 $form = new Form($db);
983 if ($object->birthday) {
984 print $form->selectDate($object->birthday, 'birthday
', 0, 0, 0, "perso", 1, 0);
986 print $form->selectDate('', 'birthday
', 0, 0, 1, "perso", 1, 0);
989 print ' <label
for=
"birthday_alert">
'.$langs->trans("Alert").'</label>
';
990 if (!empty($object->birthday_alert)) {
991 print '<input
type=
"checkbox" name=
"birthday_alert" id=
"birthday_alert" checked>
';
993 print '<input
type=
"checkbox" name=
"birthday_alert" id=
"birthday_alert">
';
1000 print dol_get_fiche_end();
1002 print $form->buttonsSaveCancel("Add");
1005 } elseif ($action == 'edit
' && !empty($id)) {
1010 // We set country_id, and country_code label of the chosen country
1011 if (GETPOSTISSET("country_id") || $object->country_id) {
1012 $tmparray = getCountry($object->country_id, 'all
');
1013 $object->country_code = $tmparray['code
'];
1014 $object->country = $tmparray['label
'];
1017 $objsoc = new Societe($db);
1018 $objsoc->fetch($object->socid);
1021 dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
1023 if ($conf->use_javascript_ajax) {
1024 print "\n".'<script
type=
"text/javascript">
'."\n";
1025 print 'jQuery(document).ready(
function () {
1026 jQuery(
"#selectcountry_id").change(
function() {
1027 document.formsoc.action.value=
"edit";
1028 document.formsoc.submit();
1031 $(
"#copyaddressfromsoc").click(
function() {
1032 $(\
'textarea[name="address"]\').val(\''.
dol_escape_js($objsoc->address).
'\');
1033 $(\
'input[name="zipcode"]\').val(\''.
dol_escape_js($objsoc->zip).
'\');
1034 $(\
'input[name="town"]\').val(\''.
dol_escape_js($objsoc->town).
'\');
1035 console.log(\
'Set state_id to '.
dol_escape_js((
string) $objsoc->state_id).
'\');
1036 $(\
'select[name="state_id"]\').val(\''.
dol_escape_js((
string) $objsoc->state_id).
'\').trigger(
"change");
1038 console.log(\
'Set country id to '.
dol_escape_js((
string) $objsoc->country_id).
'\');
1039 $(\
'select[name="country_id"]\').val(\''.
dol_escape_js((
string) $objsoc->country_id).
'\').trigger(
"change");
1042 print '</script>
'."\n";
1045 print '<form enctype=
"multipart/form-data" method=
"post" action=
"'.$_SERVER["PHP_SELF
"].'?id='.$id.'" name=
"formsoc">
';
1046 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
1047 print '<input
type=
"hidden" name=
"id" value=
"'.$id.'">
';
1048 print '<input
type=
"hidden" name=
"action" value=
"update">
';
1049 print '<input
type=
"hidden" name=
"contactid" value=
"'.$object->id.'">
';
1050 if (!empty($backtopage)) {
1051 print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
1054 print dol_get_fiche_head($head, 'card
', $title, 0, 'contact
');
1056 print '<
table class=
"border centpercent">
';
1059 if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID
')) {
1060 print '<tr><td>
'.$langs->trans("ID").'</td><td colspan=
"3">
';
1066 print '<tr><td
class=
"titlefieldcreate fieldrequired"><label
for=
"lastname">
'.$langs->trans("Lastname").' /
'.$langs->trans("Label").'</label></td>
';
1067 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>
';
1071 print '<td><label
for=
"firstname">
'.$langs->trans("Firstname").'</label></td>
';
1072 print '<td colspan=
"3"><input
name=
"firstname" id=
"firstname" type=
"text" class=
"minwidth200" maxlength=
"80" value=
"'.(GETPOSTISSET("firstname
") ? GETPOST("firstname
") : $object->firstname).'"></td>
';
1076 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS
')) {
1077 print '<tr><td><label
for=
"socid">
'.$langs->trans("ThirdParty").'</label></td>
';
1078 print '<td colspan=
"3" class=
"maxwidthonsmartphone">
';
1079 print img_picto('', 'company
', 'class=
"pictofixedwidth"').$form->select_company(GETPOSTINT('socid
') ? GETPOSTINT('socid
') : ($object->socid ? $object->socid : -1), 'socid
', '', $langs->trans("SelectThirdParty"));
1085 if (getDolGlobalString('MAIN_USE_TITLE_FOR_CONTACT
')) {
1086 print '<tr><td><label
for=
"civility_code">
'.$langs->trans("UserTitle").'</label></td><td colspan=
"3">
';
1087 print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code
');
1092 print '<tr><td><label
for=
"title">
'.$langs->trans("PostOrFunction").'</label></td>
';
1093 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>
';
1095 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
1096 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
1099 print '<tr><td><label
for=
"address">
'.$langs->trans("Address").'</label></td>
';
1100 print '<td colspan=
"3">
';
1101 print '<div
class=
"paddingrightonly valignmiddle inline-block quatrevingtpercent">
';
1102 print '<textarea
class=
"flat minwidth200 centpercent" name=
"address" id=
"address">
'.(GETPOSTISSET("address") ? GETPOST("address", 'alphanohtml
') : $object->address).'</textarea>
';
1103 print '</div><div
class=
"paddingrightonly valignmiddle inline-block">
';
1104 if (!empty($conf->use_javascript_ajax)) {
1105 print '<a href=
"#" id=
"copyaddressfromsoc">
'.$langs->trans('CopyAddressFromSoc
').'</a><br>
';
1111 print '<tr><td><label
for=
"zipcode">
'.$langs->trans("Zip").'</label> / <label
for=
"town">
'.$langs->trans("Town").'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1112 print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode
', array('town
', 'selectcountry_id
', 'state_id
'), 6).'
';
1113 print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town
', array('zipcode
', 'selectcountry_id
', 'state_id
'));
1117 print '<tr><td><label
for=
"selectcountry_id">
'.$langs->trans("Country").'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1118 print img_picto('', 'globe-americas
', 'class=
"pictofixedwidth"');
1119 print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id
');
1121 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1126 if (!getDolGlobalString('SOCIETE_DISABLE_STATE
')) {
1127 if (getDolGlobalString('MAIN_SHOW_REGION_IN_STATE_SELECT
') && (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 2)) {
1128 print '<tr><td><label
for=
"state_id">
'.$langs->trans('Region-State
').'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1130 print '<tr><td><label
for=
"state_id">
'.$langs->trans('State
').'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1133 print img_picto('', 'state
', 'class=
"pictofixedwidth"');
1134 print $formcompany->select_state(GETPOSTISSET('state_id
') ? GETPOST('state_id
', 'alpha
') : $object->state_id, $object->country_code, 'state_id
');
1139 print '<tr><td>
'.$form->editfieldkey('PhonePro
', 'phone_pro
', GETPOST('phone_pro
', 'alpha
'), $object, 0).'</td>
';
1141 print $form->showPhoneInput($object->phone_pro, 'phone_pro
', $object->country_id, 'object_phoning
', 'maxwidth150
', 80);
1143 if ($conf->browser->layout == 'phone
') {
1147 print '<td>
'.$form->editfieldkey('PhonePerso
', 'phone_perso
', GETPOST('phone_perso
', 'alpha
'), $object, 0).'</td>
';
1149 print $form->showPhoneInput($object->phone_perso, 'phone_perso
', $object->country_id, 'object_phoning
', 'maxwidth150
', 80);
1152 print '<tr><td>
'.$form->editfieldkey('PhoneMobile
', 'phone_mobile
', GETPOST('phone_mobile
', 'alpha
'), $object, 0, 'string', '').'</td>
';
1154 print $form->showPhoneInput($object->phone_mobile, 'phone_mobile
', $object->country_id, 'object_phoning_mobile
', 'maxwidth150
', 80);
1156 if ($conf->browser->layout == 'phone
') {
1160 print '<td>
'.$form->editfieldkey('Fax
', 'fax
', GETPOST('fax
', 'alpha
'), $object, 0).'</td>
';
1162 print $form->showPhoneInput($object->fax, 'fax
', $object->country_id, 'object_phoning_fax
', 'maxwidth150
', 80);
1166 print '<tr><td>
'.$form->editfieldkey('EMail
', 'email', GETPOST('email', 'alpha
'), $object, 0, 'string', '', (int) (getDolGlobalInt('SOCIETE_EMAIL_MANDATORY
'))).'</td>
';
1168 print img_picto('', 'object_email
', 'class=
"pictofixedwidth"');
1169 print '<input
type=
"text" name=
"email" id=
"email" class=
"maxwidth100onsmartphone quatrevingtpercent" value=
"'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>
';
1170 if (isModEnabled('mailing
')) {
1171 if ($conf->browser->layout == 'phone
') {
1174 $langs->load("mails");
1175 print '<td
class=
"nowrap">
'.$langs->trans("NbOfEMailingsSend").'</td>
';
1176 print '<td>
'.$object->getNbOfEMailings().'</td>
';
1178 print '<td colspan=
"2"></td>
';
1183 if (isModEnabled('mailing
')) {
1184 if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2) {
1185 print "\n".'<script
type=
"text/javascript">
'."\n";
1188 jQuery(document).ready(
function () {
1189 function init_check_no_email(input) {
1190 if (input.val()!=
"") {
1191 $(
".noemail").addClass(
"fieldrequired");
1193 $(
".noemail").removeClass(
"fieldrequired");
1196 $(
"#email").keyup(
function() {
1197 init_check_no_email($(
this));
1199 init_check_no_email($(
"#email"));
1201 print '</script>
'."\n";
1203 if (!GETPOSTISSET("no_email") && !empty($object->email)) {
1204 $result = $object->getNoEmail();
1206 setEventMessages($object->error, $object->errors, 'errors
');
1210 print '<td
class=
"noemail"><label
for=
"no_email">
'.$langs->trans("No_Email").'</label></td>
';
1212 $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2);
1213 print $form->selectyesno('no_email
', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, false, (int) $useempty);
1219 if (isModEnabled('socialnetworks
')) {
1220 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
1222 $object->showSocialNetwork($socialnetworks, $colspan);
1224 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
1228 print '<tr><td><label
for=
"priv">
'.$langs->trans("ContactVisibility").'</label></td><td colspan=
"3">
';
1229 $selectarray = array('0
' => $langs->trans("ContactPublic"), '1
' => $langs->trans("ContactPrivate"));
1230 print $form->selectarray('priv
', $selectarray, $object->priv, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth150
');
1234 if (getDolGlobalInt('MAIN_MULTILANGS
')) {
1235 print '<tr><td>
'.$form->editfieldkey('DefaultLang
', 'default_lang
', '', $object, 0).'</td><td colspan=
"3" class=
"maxwidthonsmartphone">
'."\n";
1236 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, array(), 1, 0, 0, 'maxwidth200onsmartphone
');
1242 print '<tr><td
class=
"tdtop"><label
for=
"note_public">
'.$langs->trans("NotePublic").'</label></td><td colspan=
"3">
';
1243 $doleditor = new DolEditor('note_public
', $object->note_public, '', 80, 'dolibarr_notes
', 'In
', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC
') ? 0 : 1, ROWS_3, '90%
');
1244 print $doleditor->Create(1);
1248 print '<tr><td
class=
"tdtop"><label
for=
"note_private">
'.$langs->trans("NotePrivate").'</label></td><td colspan=
"3">
';
1249 $doleditor = new DolEditor('note_private
', $object->note_private, '', 80, 'dolibarr_notes
', 'In
', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE
') ? 0 : 1, ROWS_3, '90%
');
1250 print $doleditor->Create(1);
1254 print '<tr><td>
'.$langs->trans("Status").'</td>
';
1255 print '<td colspan=
"3">
';
1256 print $object->getLibStatut(4);
1260 if (isModEnabled('category
') && $user->hasRight('categorie
', 'lire
')) {
1261 $arrayselected = array();
1262 print '<tr><td>
'.$form->editfieldkey('Categories', 'contcats
', '', $object, 0).'</td>
';
1263 print '<td colspan=
"3">
';
1264 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, '', '', 64, 0, 3);
1265 $c = new Categorie($db);
1266 $cats = $c->containing($object->id, 'contact
');
1267 foreach ($cats as $cat) {
1268 $arrayselected[] = $cat->id;
1270 print img_picto('', 'category
', 'class=
"pictofixedwidth"').$form->multiselectarray('contcats
', $cate_arbo, $arrayselected, 0, 0, '', 0, '90%
');
1274 // Contact by default
1275 if (!empty($object->socid)) {
1276 print '<tr><td>
'.$langs->trans("ContactByDefaultFor").'</td>
';
1277 print '<td colspan=
"3">
';
1278 print img_picto('', 'category
', 'class=
"pictofixedwidth"').$formcompany->showRoles("roles", $object, 'edit
', $object->roles, '');
1283 $parameters = array('colspan
' => ' colspan=
"3"', 'cols
' => '3
', 'colspanvalue
' => '3
');
1284 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php
';
1286 $object->load_ref_elements();
1288 if (isModEnabled('order
')) {
1289 print '<tr><td>
'.$langs->trans("ContactForOrders").'</td><td colspan=
"3">
';
1290 print $object->ref_commande ? $object->ref_commande : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyOrder").'</span>
');
1294 if (isModEnabled("propal")) {
1295 print '<tr><td>
'.$langs->trans("ContactForProposals").'</td><td colspan=
"3">
';
1296 print $object->ref_propal ? $object->ref_propal : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyProposal").'</span>
');
1300 if (isModEnabled('contract
')) {
1301 print '<tr><td>
'.$langs->trans("ContactForContracts").'</td><td colspan=
"3">
';
1302 print $object->ref_contrat ? $object->ref_contrat : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyContract").'</span>
');
1306 if (isModEnabled('invoice
')) {
1307 print '<tr><td>
'.$langs->trans("ContactForInvoices").'</td><td colspan=
"3">
';
1308 print $object->ref_facturation ? $object->ref_facturation : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyInvoice").'</span>
');
1313 print '<tr><td>
'.$langs->trans("DolibarrLogin").'</td><td colspan=
"3">
';
1314 if ($object->user_id) {
1315 $dolibarr_user = new User($db);
1316 $result = $dolibarr_user->fetch($object->user_id);
1317 print $dolibarr_user->getLoginUrl(1);
1319 print '<span
class=
"opacitymedium">
'.$langs->trans("NoDolibarrAccess").'</span>
';
1325 print '<td>
'.$langs->trans("PhotoFile").'</td>
';
1326 print '<td colspan=
"3">
';
1327 if ($object->photo) {
1328 print $form->showphoto('contact
', $object);
1331 print '<
table class=
"nobordernopadding">
';
1332 if ($object->photo) {
1333 print '<tr><td><input
type=
"checkbox" class=
"flat photodelete" name=
"deletephoto" id=
"photodelete">
'.$langs->trans("Delete").'<br><br></td></tr>
';
1335 //print '<tr><td>
'.$langs->trans("PhotoFile").'</td></tr>
';
1337 $maxfilesizearray = getMaxFileSizeArray();
1338 $maxmin = $maxfilesizearray['maxmin
'];
1340 print '<input
type=
"hidden" name=
"MAX_FILE_SIZE" value=
"'.($maxmin * 1024).'">
'; // MAX_FILE_SIZE must precede the field type=file
1342 print '<input
type=
"file" class=
"flat maxwidth200" name=
"photo" id=
"photoinput">
';
1351 print dol_get_fiche_end();
1353 print $form->buttonsSaveCancel();
1359 // Select mail models is same action as presend
1360 if (GETPOST('modelselected
', 'alpha
')) {
1361 $action = 'presend
';
1365 if (!empty($id) && $action != 'edit
' && $action != 'create
') {
1366 $objsoc = new Societe($db);
1369 dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
1371 print dol_get_fiche_head($head, 'card
', $title, -1, 'contact
', 0, '', '', 0, '', 1);
1373 if ($action == 'create_user
') {
1374 // Full firstname and lastname separated with a dot : firstname.lastname
1375 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
1376 $login = dol_buildlogin($object->lastname, $object->firstname);
1378 $generated_password = '';
1379 if (empty($ldap_sid)) { // TODO ldap_sid ?
1380 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php
';
1381 $generated_password = getRandomPassword(false);
1383 $password = $generated_password;
1385 // Create a form array
1386 $formquestion = array(
1387 array('label
' => $langs->trans("LoginToCreate"), 'type' => 'text
', 'name' => 'login
', 'value
' => $login),
1388 array('label
' => $langs->trans("Password"), 'type' => 'text
', 'name' => 'password
', 'value
' => $password),
1389 //array('label
' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select
', 'name' => 'intern
', 'default' => 1, 'values
' => array(0=>$langs->trans('Internal
'),1=>$langs->trans('External
')))
1391 $text = $langs->trans("ConfirmCreateContact").'<br>
';
1392 if (isModEnabled("societe")) {
1393 if ($object->socid > 0) {
1394 $text .= $langs->trans("UserWillBeExternalUser");
1396 $text .= $langs->trans("UserWillBeInternalUser");
1399 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes
');
1402 $linkback = '<a href=
"'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">
'.$langs->trans("BackToList").'</a>
';
1404 $morehtmlref = '<a href=
"'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class=
"refid" tabindex=
"-1">
';
1405 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard
', 'class=
"valignmiddle marginleftonly paddingrightonly"');
1406 $morehtmlref .= '</a>
';
1408 $morehtmlref .= '<div
class=
"refidno">
';
1409 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS
')) {
1410 $objsoc->fetch($object->socid);
1412 if ($objsoc->id > 0) {
1413 $morehtmlref .= $objsoc->getNomUrl(1, 'contact
');
1415 $morehtmlref .= '<span
class=
"opacitymedium">
'.$langs->trans("ContactNotLinkedToCompany").'</span>
';
1418 $morehtmlref .= '</div>
';
1420 dol_banner_tab($object, 'id', $linkback, 1, 'rowid
', 'ref', $morehtmlref);
1423 print '<div
class=
"fichecenter">
';
1424 print '<div
class=
"fichehalfleft">
';
1426 print '<div
class=
"underbanner clearboth"></div>
';
1427 print '<
table class=
"border tableforfield" width=
"100%">
';
1430 if (getDolGlobalString('MAIN_USE_TITLE_FOR_CONTACT
')) {
1431 print '<tr><td
class=
"titlefield">
'.$langs->trans("UserTitle").'</td><td>
';
1432 print $object->getCivilityLabel();
1437 print '<tr><td>
'.$langs->trans("PostOrFunction").'</td><td>
'.$object->poste.'</td></tr>
';
1440 if (isModEnabled('mailing
')) {
1441 $langs->load("mails");
1442 print '<tr><td>
'.$langs->trans("NbOfEMailingsSend").'</td>
';
1443 print '<td><a
class=
"badge badge-info" href=
"'.DOL_URL_ROOT.'/comm/mailing/list.php?filteremail='.urlencode($object->email).'">
'.$object->getNbOfEMailings().'</a></td></tr>
';
1446 // Unsubscribe opt-out
1447 if (isModEnabled('mailing
')) {
1448 $result = $object->getNoEmail();
1450 setEventMessages($object->error, $object->errors, 'errors
');
1452 print '<tr><td>
'.$langs->trans("No_Email").'</td><td>
';
1453 if ($object->email) {
1454 print yn($object->no_email);
1456 print '<span
class=
"opacitymedium">
'.$langs->trans("EMailNotDefined").'</span>
';
1462 if (getDolGlobalInt('MAIN_MULTILANGS
')) {
1463 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
1464 print '<tr><td>
'.$langs->trans("DefaultLang").'</td><td>
';
1465 //$s=picto_from_langcode($object->default_lang);
1466 //print ($s?$s.' ':'');
1467 $langs->load("languages");
1468 $labellang = ($object->default_lang ? $langs->trans('Language_
'.$object->default_lang) : '');
1469 print picto_from_langcode($object->default_lang, 'class=
"paddingrightonly saturatemedium opacitylow"');
1474 print '<tr><td>
'.$langs->trans("ContactVisibility").'</td><td>
';
1475 print $object->LibPubPriv($object->priv, 1);
1481 $object->fetch_thirdparty();
1484 print '<div
class=
"fichehalfright">
';
1486 print '<div
class=
"underbanner clearboth"></div>
';
1487 print '<
table class=
"border tableforfield centpercent">
';
1490 if (getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES
')) {
1491 if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
1492 // Level of prospect
1493 print '<tr><td
class=
"">
';
1494 print '<
table class=
"nobordernopadding centpercent"><tr><td
class=
"nowrap">
';
1495 print $langs->trans('ProspectLevel
');
1497 if ($action != 'editlevel
' && $user->hasRight('societe
', 'contact
', 'creer
')) {
1498 print '<td align=
"right"><a href=
"'.$_SERVER["PHP_SELF
"].'?action=editlevel&token='.newToken().'&id='.$object->id.'">
'.img_edit($langs->trans('Modify
'), 1).'</a></td>
';
1500 print '</tr></
table>
';
1502 if ($action == 'editlevel
') {
1503 $formcompany->formProspectContactLevel($_SERVER['PHP_SELF
'].'?
id=
'.$object->id, (int) $object->fk_prospectlevel, 'prospect_contact_level_id
', 1);
1505 print $object->getLibProspLevel();
1510 // Status of prospection
1511 $object->loadCacheOfProspStatus();
1512 print '<tr><td>
'.$langs->trans("StatusProsp").'</td><td>
'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label
']);
1513 print '
';
1514 print '<div
class=
"floatright">
';
1515 foreach ($object->cacheprospectstatus as $key => $val) {
1516 $titlealt = 'default';
1517 if (!empty($val['code
']) && !in_array($val['code
'], array('ST_NO
', 'ST_NEVER
', 'ST_TODO
', 'ST_PEND
', 'ST_DONE
'))) {
1518 $titlealt = $val['label
'];
1520 if ($object->stcomm_id != $val['id']) {
1521 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>
';
1524 print '</div></td></tr>
';
1529 if (isModEnabled('category
') && $user->hasRight('categorie
', 'lire
')) {
1530 print '<tr><td
class=
"">
'.$langs->trans("Categories").'</td>
';
1532 print $form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
1536 // Contact by default for
1537 if (!empty($object->socid)) {
1538 print '<tr><td
class=
"">
'.$langs->trans("ContactByDefaultFor").'</td>
';
1540 print $formcompany->showRoles("roles", $object, 'view
', $object->roles, '');
1545 $parameters = array('socid
' => $socid);
1546 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
1548 $object->load_ref_elements();
1550 if (isModEnabled("propal")) {
1551 print '<tr><td
class=
"">
'.$langs->trans("ContactForProposals").'</td><td>
';
1552 print $object->ref_propal ? $object->ref_propal : '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyProposal").'<span>
';
1556 if (isModEnabled('order
') || isModEnabled("shipping")) {
1557 print '<tr><td
class=
"">
';
1558 if (isModEnabled("shipping")) {
1559 print $langs->trans("ContactForOrdersOrShipments");
1561 print $langs->trans("ContactForOrders");
1564 $none = '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyOrder").'</span>
';
1565 if (isModEnabled("shipping")) {
1566 $none = '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyOrderOrShipments").'</span>
';
1568 print $object->ref_commande ? $object->ref_commande : $none;
1572 if (isModEnabled('contract
')) {
1573 print '<tr><td
class=
"">
'.$langs->trans("ContactForContracts").'</td><td>
';
1574 print $object->ref_contrat ? $object->ref_contrat : '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyContract").'</span>
';
1578 if (isModEnabled('invoice
')) {
1579 print '<tr><td
class=
"">
'.$langs->trans("ContactForInvoices").'</td><td>
';
1580 print $object->ref_facturation ? $object->ref_facturation : '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyInvoice").'</span>
';
1584 print '<tr><td>
'.$langs->trans("DolibarrLogin").'</td><td>
';
1585 if ($object->user_id) {
1586 $dolibarr_user = new User($db);
1587 $result = $dolibarr_user->fetch($object->user_id);
1588 print $dolibarr_user->getLoginUrl(-1);
1590 //print '<span
class=
"opacitymedium">
'.$langs->trans("NoDolibarrAccess").'</span>
';
1591 if (!$object->user_id && $user->hasRight('user', 'user', 'creer
')) {
1592 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>
';
1599 print '</div></div>
';
1600 print '<div
class=
"clearboth"></div>
';
1602 print dol_get_fiche_end();
1608 print '<div
class=
"tabsAction">
';
1610 $parameters = array();
1611 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1612 if (empty($reshook) && $action != 'presend
') {
1613 if (empty($user->socid)) {
1614 if (!empty($object->email)) {
1615 $langs->load("mails");
1616 print dolGetButtonAction('', $langs->trans('SendMail
'), 'email', dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action
' => 'presend
', 'mode
' => 'init
'], true).'#formmailbeforetitle
', '');
1618 $langs->load("mails");
1619 print dolGetButtonAction('', $langs->trans('SendMail
'), 'email', '#
', '', false);
1623 if ($user->hasRight('societe
', 'contact
', 'creer
')) {
1624 print '<a
class=
"butAction" href=
"'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">
'.$langs->trans('Modify
').'</a>
';
1628 if ($object->status == 0 && $user->hasRight('societe
', 'contact
', 'creer
')) {
1629 print '<a
class=
"butAction" href=
"'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken().'">
'.$langs->trans("Reactivate").'</a>
';
1632 if ($object->status == 1 && $user->hasRight('societe
', 'contact
', 'creer
')) {
1633 print '<a
class=
"butActionDelete" href=
"'.$_SERVER['PHP_SELF'].'?action=disable&id='.$object->id.'&token='.newToken().'">
'.$langs->trans("DisableUser").'</a>
';
1637 if ($permissiontoadd && $user->hasRight('societe
', 'contact
', 'supprimer
')) {
1638 print dolGetButtonAction($langs->trans("MergeContacts"), $langs->trans("Merge"), 'default', $_SERVER["PHP_SELF"].'?
id=
'.$object->id.'&action=merge&token=
'.newToken(), '', $user->hasRight('societe
', 'contact
', 'supprimer
'), array('attr
' => array('classOverride
' => 'butAction butActionDanger
')))."\n";
1642 if ($user->hasRight('societe
', 'contact
', 'supprimer
')) {
1643 print dolGetButtonAction($langs->trans("Delete"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?
id=
'.$object->id.'&action=
delete&token=
'.newToken().($backtopage ? '&backtopage=
'.urlencode($backtopage) : ''), 'delete', $user->hasRight('societe
', 'contact
', 'supprimer
'), array('attr
' => array('class' => 'reposition
')))."\n";
1649 //Select mail models is same action as presend
1650 if (GETPOST('modelselected
')) {
1651 $action = 'presend
';
1654 if ($action != 'presend
') {
1655 print '<div
class=
"fichecenter"><div
class=
"fichehalfleft">
';
1657 print '</div><div
class=
"fichehalfright">
';
1661 $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll
'), '', 'fa fa-bars imgforviewmode
', DOL_URL_ROOT.'/contact/agenda.php?
id=
'.$object->id);
1663 // List of actions on element
1664 include_once DOL_DOCUMENT_ROOT.'/core/
class/html.formactions.class.php
';
1665 $formactions = new FormActions($db);
1666 $somethingshown = $formactions->showactions($object, 'contact
', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty
1668 print '</div></div>
';
1672 $modelmail = 'contact
';
1673 $defaulttopic = 'Information
';
1674 $diroutput = $conf->societe->dir_output.'/contact/
';
1675 $trackid = 'ctc
'.$object->id;
1677 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php
';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
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_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0, $level=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $keyforsourcefile='addedfile', $upload_dir='', $mode=0)
Check validity of a file upload from an GUI page, and move it to its final destination.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
$conf db user
Active Directory does not allow anonymous connections.
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
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.
treeview li table
No Email.