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) {
229 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
236 $object->socialnetworks = array();
238 foreach ($socialnetworks as $key => $value) {
240 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
248 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
251 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
252 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
260 $object->birthday_alert = (
GETPOST(
'birthday_alert',
'alpha') ==
"on" ? 1 : 0);
266 $ret = $extrafields->setOptionalsFromPost(
null, $object);
274 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
279 $langs->load(
"errors");
281 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
285 if (empty(
$object->lastname)) {
287 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
302 $contcats =
GETPOST(
'contcats',
'array');
303 if (count($contcats) > 0) {
304 $result =
$object->setCategories($contcats);
323 if (empty($error) && $id > 0) {
325 if (!empty($backtopage)) {
326 $url = str_replace(
'__ID__', (
string) $id, $backtopage);
328 $url =
'card.php?id='.$id;
330 header(
"Location: ".$url);
337 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'contact',
'supprimer')) {
341 $result =
$object->delete($user);
343 setEventMessages(
"RecordDeleted",
null,
'mesgs');
344 if ($backurlforlist) {
345 header(
"Location: ".$backurlforlist);
348 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
359 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $permissiontoadd && $user->hasRight(
'societe',
'contact',
'supprimer')) {
360 $contact_origin_id =
GETPOSTINT(
'contact_origin');
362 if ($contact_origin_id <= 0) {
363 $langs->load(
'errors');
364 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'MergeOriginContact')),
null,
'errors');
370 $langs->load(
'errors');
371 setEventMessages($langs->trans(
'ErrorRecordNotFound'),
null,
'errors');
372 } elseif ($result != $id) {
373 $langs->load(
'errors');
374 setEventMessages(
$object->error ?
$object->error : $langs->trans(
'ErrorBadParameters'),
$object->errors,
'errors');
375 } elseif (
$object->mergeContact($contact_origin_id) < 0) {
378 setEventMessages($langs->trans(
'ContactsMergeSuccess'),
null,
'mesgs');
380 if (!empty(
$object->warnings)) {
381 setEventMessages(
null,
$object->warnings,
'warnings');
383 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.
$object->id);
389 if ($action ==
'update' && empty($cancel) && $permissiontoadd) {
390 if (!
GETPOST(
"lastname",
'alpha')) {
392 $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
398 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
403 $langs->load(
"errors");
405 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
416 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
418 $fileimg = $dir.
'/'.
$object->photo;
419 $dirthumbs = $dir.
'/thumbs';
433 if (!is_numeric($result) || $result <= 0) {
434 $errors[] =
"ErrorFailedToSaveFile";
443 $errors[] =
"ErrorBadImageFormat";
446 switch ($_FILES[
'photo'][
'error']) {
449 $errors[] =
"ErrorFileSizeTooLarge";
452 $errors[] =
"ErrorFilePartiallyUploaded";
462 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
471 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
473 $object->socialnetworks = array();
475 foreach ($socialnetworks as $key => $value) {
477 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
483 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
486 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
487 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
496 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
502 $result =
$object->update($contactid, $user);
507 $tmpuser =
new User($db);
508 if ($tmpuser->fetch(
$object->user_id) > 0 && $tmpuser->socid !=
$object->socid) {
509 setEventMessages($langs->trans(
"WarningUserDifferentContactSocid"),
null,
'warnings');
514 $categories =
GETPOST(
'contcats',
'array');
515 $object->setCategories($categories);
520 $result =
$object->setNoEmail($no_email);
533 if (!$error && empty($errors)) {
534 if (!empty($backtopage)) {
535 header(
"Location: ".$backtopage);
544 if ($action ==
'setprospectcontactlevel' && $permissiontoadd) {
546 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
554 if ($action ==
'setstcomm' && $permissiontoadd) {
564 if ($action ==
'update_extras' && $permissiontoeditextra) {
567 $attribute_name =
GETPOST(
'attribute',
'aZ09');
570 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
576 $result =
$object->updateExtraField($attribute_name,
'CONTACT_MODIFY');
584 $action =
'edit_extras';
589 $triggersendname =
'CONTACT_SENTBYMAIL';
591 $mode =
'emailfromcontact';
592 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
600$form =
new Form($db);
606 $objsoc->fetch($socid);
609$title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
614 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
616$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
618llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-societe page-contact-card');
620$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
622if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
626 if (empty(
$object->error) && $id) {
630 dol_print_error(
null,
$object->error);
634 $objcanvas->display_canvas($action);
641 if ($user->hasRight(
'societe',
'contact',
'supprimer')) {
642 if ($action ==
'delete') {
643 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
648 if ($action ==
'merge' && $permissiontoadd && $user->hasRight(
'societe',
'contact',
'supprimer')) {
654 $formquestion = array(
656 'name' =>
'contact_origin',
657 'label' => $langs->trans(
"MergeOriginContact"),
659 'value' => $form->select_contact(0,
'',
'contact_origin', 1,
'',
'', 1,
'minwidth200',
false, 1, 0, array(),
'',
'',
'',
'(sp.rowid:!=:'.((
int) $id).
')')
663 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"MergeContacts"), $langs->trans(
"ConfirmMergeContacts"),
"confirm_merge", $formquestion,
'no', 1, 300);
673 $res =
$object->fetch($id, $user);
684 if ($user->hasRight(
'societe',
'contact',
'creer')) {
685 if ($action ==
'create') {
697 $object->country_code = $tmparray[
'code'];
698 $object->country = $tmparray[
'label'];
708 if (
$conf->use_javascript_ajax) {
709 print
"\n".
'<script type="text/javascript">'.
"\n";
710 print
'jQuery(document).ready(function () {
711 jQuery("#selectcountry_id").change(function() {
712 document.formsoc.action.value="create";
713 document.formsoc.submit();
716 $("#copyaddressfromsoc").click(function() {
717 $(\'textarea[name="address"]\').val(\''.dol_escape_js($objsoc->address).
'\');
718 $(\
'input[name="zipcode"]\').val(\''.
dol_escape_js($objsoc->zip).
'\');
719 $(\
'input[name="town"]\').val(\''.
dol_escape_js($objsoc->town).
'\');
720 console.log(\
'Set state_id to '.
dol_escape_js((
string) $objsoc->state_id).
'\');
721 $(\
'select[name="state_id"]\').val(\''.
dol_escape_js((
string) $objsoc->state_id).
'\').trigger(
"change");
723 console.log(\
'Set country id to '.
dol_escape_js((
string) $objsoc->country_id).
'\');
724 $(\
'select[name="country_id"]\').val(\''.
dol_escape_js((
string) $objsoc->country_id).
'\').trigger(
"change");
727 print '</script>
'."\n";
730 print '<form method=
"post" name=
"formsoc" action=
"'.dolBuildUrl($_SERVER["PHP_SELF
"]).'">
';
731 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
732 print '<input
type=
"hidden" name=
"action" value=
"add">
';
733 print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
734 if (!empty($objsoc)) {
735 print '<input
type=
"hidden" name=
"entity" value=
"'.$objsoc->entity.'">
';
738 print dol_get_fiche_head($head, 'card
', '', 0, '');
740 print '<
table class=
"border centpercent">
';
743 print '<tr><td
class=
"titlefieldcreate fieldrequired"><label
for=
"lastname">
'.$langs->trans("Lastname").' /
'.$langs->trans("Label").'</label></td>
';
744 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>
';
749 print '<td><label
for=
"firstname">
';
750 print $form->textwithpicto($langs->trans("Firstname"), $langs->trans("KeepEmptyIfGenericAddress")).'</label></td>
';
751 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>
';
755 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS
')) {
757 print '<tr><td><label
for=
"socid">
'.$langs->trans("ThirdParty").'</label></td>
';
758 print '<td colspan=
"3" class=
"maxwidthonsmartphone">
';
759 print $objsoc->getNomUrl(1, 'contact
');
761 print '<input
type=
"hidden" name=
"socid" id=
"socid" value=
"'.$objsoc->id.'">
';
764 print '<tr><td><label
for=
"socid">
'.$langs->trans("ThirdParty").'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
765 print img_picto('', 'company
', 'class=
"pictofixedwidth"').$form->select_company($socid, 'socid
', '', 'SelectThirdParty
', 0, 0, array(), 0, 'minwidth300 maxwidth500 widthcentpercentminusxx
');
771 if (getDolGlobalString('MAIN_USE_TITLE_FOR_CONTACT
')) {
772 print '<tr><td><label
for=
"civility_code">
'.$langs->trans("UserTitle").'</label></td><td colspan=
"3">
';
773 print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", 'aZ09
') : $object->civility_code, 'civility_code
');
778 print '<tr><td><label
for=
"title">
'.$langs->trans("PostOrFunction").'</label></td>
';
779 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>
';
781 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
782 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
785 if ($conf->use_javascript_ajax && $socid > 0) {
790 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->address)) == 0) {
791 $object->address = $objsoc->address; // Predefined with third party
793 print '<tr><td><label
for=
"address">
'.$langs->trans("Address").'</label></td>
';
794 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>
';
796 if ($conf->use_javascript_ajax && $socid > 0) {
798 if (!getDolGlobalString('SOCIETE_DISABLE_STATE
')) {
802 print '<td
class=
"valignmiddle center" rowspan=
"'.$rowspan.'">
';
803 print '<a href=
"#" id=
"copyaddressfromsoc">
'.$langs->trans('CopyAddressFromSoc
').'</a>
';
809 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->zip)) == 0) {
810 $object->zip = $objsoc->zip; // Predefined with third party
812 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->town)) == 0) {
813 $object->town = $objsoc->town; // Predefined with third party
815 print '<tr><td><label
for=
"zipcode">
'.$langs->trans("Zip").'</label> / <label
for=
"town">
'.$langs->trans("Town").'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
816 print $formcompany->select_ziptown((GETPOST("zipcode", 'alpha
') ? GETPOST("zipcode", 'alpha
') : $object->zip), 'zipcode
', array('town
', 'selectcountry_id
', 'state_id
'), 6).'
';
817 print $formcompany->select_ziptown((GETPOST("town", 'alpha
') ? GETPOST("town", 'alpha
') : $object->town), 'town
', array('zipcode
', 'selectcountry_id
', 'state_id
'));
821 print '<tr><td><label
for=
"selectcountry_id">
'.$langs->trans("Country").'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
822 print img_picto('', 'globe-americas
', 'class=
"pictofixedwidth"');
823 print $form->select_country((GETPOSTISSET("country_id") ? GETPOST("country_id", 'alpha
') : $object->country_id), 'country_id
');
825 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
830 if (!getDolGlobalString('SOCIETE_DISABLE_STATE
')) {
831 if (getDolGlobalString('MAIN_SHOW_REGION_IN_STATE_SELECT
') && (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 2)) {
832 print '<tr><td><label
for=
"state_id">
'.$langs->trans('Region-State
').'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
834 print '<tr><td><label
for=
"state_id">
'.$langs->trans('State
').'</label></td><td colspan=
"'.$colspan.'" class=
"maxwidthonsmartphone">
';
837 if ($object->country_id) {
838 print img_picto('', 'state
', 'class=
"pictofixedwidth"');
839 print $formcompany->select_state(GETPOST("state_id", 'alpha
') ? GETPOST("state_id", 'alpha
') : $object->state_id, $object->country_code, 'state_id
');
841 print $countrynotdefined;
846 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->phone_pro)) == 0) {
847 $object->phone_pro = $objsoc->phone; // Predefined with third party
849 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->fax)) == 0) {
850 $object->fax = $objsoc->fax; // Predefined with third party
854 print '<tr><td>
'.$form->editfieldkey('PhonePro
', 'phone_pro
', '', $object, 0).'</td>
';
856 print $form->showPhoneInput($object->phone_pro, 'phone_pro
', $object->country_id, 'object_phoning
', 'maxwidth150 widthcentpercentminusx
');
858 if ($conf->browser->layout == 'phone
') {
862 print '<td>
'.$form->editfieldkey('PhonePerso
', 'phone_perso
', '', $object, 0).'</td>
';
864 print $form->showPhoneInput($object->phone_perso, 'phone_perso
', $object->country_id, 'object_phoning
', 'maxwidth150 widthcentpercentminusx
');
868 print '<tr><td>
'.$form->editfieldkey('PhoneMobile
', 'phone_mobile
', '', $object, 0).'</td>
';
870 print $form->showPhoneInput($object->phone_mobile, 'phone_mobile
', $object->country_id, 'object_phoning_mobile
', 'maxwidth150 widthcentpercentminusx
');
872 if ($conf->browser->layout == 'phone
') {
876 print '<td>
'.$form->editfieldkey('Fax
', 'fax
', '', $object, 0).'</td>
';
878 print $form->showPhoneInput($object->fax, 'fax
', $object->country_id, 'object_phoning_fax
', 'maxwidth150 widthcentpercentminusx
');
882 if (((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE
') || getDolGlobalString('CONTACT_USE_COMPANY_ADDRESS
')) && dol_strlen(trim($object->email)) == 0) {
883 $object->email = $objsoc->email; // Predefined with third party
887 print '<tr><td>
'.$form->editfieldkey('EMail
', 'email', '', $object, 0, 'string', '').'</td>
';
889 print img_picto('', 'object_email
', 'class=
"pictofixedwidth"');
890 print '<input
class=
"maxwidth200 widthcentpercentminusx" type=
"text" name=
"email" id=
"email" value=
"'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>
';
894 if (isModEnabled('mailing
')) {
895 if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2) {
896 print "\n".'<script
type=
"text/javascript">
'."\n";
897 print '$(document).ready(
function () {
898 $(
"#email").keyup(
function() {
899 if ($(
this).val()!=
"") {
900 $(
".noemail").addClass(
"fieldrequired");
902 $(
".noemail").removeClass(
"fieldrequired");
906 print '</script>
'."\n";
908 if (!GETPOSTISSET("no_email") && !empty($object->email)) {
909 $result = $object->getNoEmail();
911 setEventMessages($object->error, $object->errors, 'errors
');
915 print '<td
class=
"noemail"><label
for=
"no_email">
'.$langs->trans("No_Email").'</label></td>
';
917 // Default value is in MAILING_CONTACT_DEFAULT_BULK_STATUS that you can modify in setup of module emailing
918 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));
924 if (isModEnabled('socialnetworks
')) {
925 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
927 $object->showSocialNetwork($socialnetworks, $colspan);
929 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
933 print '<tr><td><label
for=
"priv">
'.$langs->trans("ContactVisibility").'</label></td><td colspan=
"3">
';
934 $selectarray = array('0
' => $langs->trans("ContactPublic"), '1
' => $langs->trans("ContactPrivate"));
935 print $form->selectarray('priv
', $selectarray, (GETPOST("priv", 'alpha
') ? GETPOST("priv", 'alpha
') : $object->priv), 0);
939 if (getDolGlobalInt('MAIN_MULTILANGS
')) {
940 print '<tr><td>
'.$form->editfieldkey('DefaultLang
', 'default_lang
', '', $object, 0).'</td><td colspan=
"3" class=
"maxwidthonsmartphone">
'."\n";
941 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
');
947 if (isModEnabled('category
') && $user->hasRight('categorie
', 'lire
')) {
948 print '<tr><td>
'.$form->editfieldkey('Categories', 'contcats
', '', $object, 0).'</td><td colspan=
"3">
';
949 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, '', 'parent
', 64, 0, 3);
950 print img_picto('', 'category
', 'class=
"pictofixedwidth"').$form->multiselectarray('contcats
', $cate_arbo, GETPOST('contcats
', 'array
'), 0, 0, '', 0, '90%
');
954 // Contact by default
956 print '<tr><td>
'.$langs->trans("ContactByDefaultFor").'</td>
';
957 print '<td colspan=
"3">
';
958 $contactType = $object->listeTypeContacts('external
', 0, 1);
959 print img_picto('', 'contact
', 'class=
"pictofixedwidth"').$form->multiselectarray('roles
', $contactType, array(), 0, 0, '', 0, '90%
');
964 $parameters = array('socid
' => $socid, 'objsoc
' => $objsoc, 'colspan
' => ' colspan=
"3"', 'cols
' => 3, 'colspanvalue
' => 3);
965 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php
';
967 print "</table><br>";
969 print '<hr style=
"margin-bottom: 20px">
';
971 // Add personal information
972 print load_fiche_titre('<div
class=
"comboperso">
'.$langs->trans("PersonalInformations").'</div>
', '', '');
974 print '<
table class=
"border centpercent">
';
977 print '<tr><td
class=
"titlefieldcreate"><label
for=
"birthday">
'.$langs->trans("DateOfBirth").'</label></td><td colspan=
"3">
';
978 $form = new Form($db);
979 if ($object->birthday) {
980 print $form->selectDate($object->birthday, 'birthday
', 0, 0, 0, "perso", 1, 0);
982 print $form->selectDate('', 'birthday
', 0, 0, 1, "perso", 1, 0);
985 print ' <label
for=
"birthday_alert">
'.$langs->trans("Alert").'</label>
';
986 if (!empty($object->birthday_alert)) {
987 print '<input
type=
"checkbox" name=
"birthday_alert" id=
"birthday_alert" checked>
';
989 print '<input
type=
"checkbox" name=
"birthday_alert" id=
"birthday_alert">
';
996 print dol_get_fiche_end();
998 print $form->buttonsSaveCancel("Add");
1001 } elseif ($action == 'edit
' && !empty($id)) {
1006 // We set country_id, and country_code label of the chosen country
1007 if (GETPOSTISSET("country_id") || $object->country_id) {
1008 $tmparray = getCountry($object->country_id, 'all
');
1009 $object->country_code = $tmparray['code
'];
1010 $object->country = $tmparray['label
'];
1013 $objsoc = new Societe($db);
1014 $objsoc->fetch($object->socid);
1017 dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
1019 if ($conf->use_javascript_ajax) {
1020 print "\n".'<script
type=
"text/javascript">
'."\n";
1021 print 'jQuery(document).ready(
function () {
1022 jQuery(
"#selectcountry_id").change(
function() {
1023 document.formsoc.action.value=
"edit";
1024 document.formsoc.submit();
1027 $(
"#copyaddressfromsoc").click(
function() {
1028 $(\
'textarea[name="address"]\').val(\''.
dol_escape_js($objsoc->address).
'\');
1029 $(\
'input[name="zipcode"]\').val(\''.
dol_escape_js($objsoc->zip).
'\');
1030 $(\
'input[name="town"]\').val(\''.
dol_escape_js($objsoc->town).
'\');
1031 console.log(\
'Set state_id to '.
dol_escape_js((
string) $objsoc->state_id).
'\');
1032 $(\
'select[name="state_id"]\').val(\''.
dol_escape_js((
string) $objsoc->state_id).
'\').trigger(
"change");
1034 console.log(\
'Set country id to '.
dol_escape_js((
string) $objsoc->country_id).
'\');
1035 $(\
'select[name="country_id"]\').val(\''.
dol_escape_js((
string) $objsoc->country_id).
'\').trigger(
"change");
1038 print '</script>
'."\n";
1041 print '<form enctype=
"multipart/form-data" method=
"post" action=
"'.$_SERVER["PHP_SELF
"].'?id='.$id.'" name=
"formsoc">
';
1042 print '<input
type=
"hidden" name=
"token" value=
"'.newToken().'">
';
1043 print '<input
type=
"hidden" name=
"id" value=
"'.$id.'">
';
1044 print '<input
type=
"hidden" name=
"action" value=
"update">
';
1045 print '<input
type=
"hidden" name=
"contactid" value=
"'.$object->id.'">
';
1046 if (!empty($backtopage)) {
1047 print '<input
type=
"hidden" name=
"backtopage" value=
"'.$backtopage.'">
';
1050 print dol_get_fiche_head($head, 'card
', $title, 0, 'contact
');
1052 print '<
table class=
"border centpercent">
';
1055 if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID
')) {
1056 print '<tr><td>
'.$langs->trans("ID").'</td><td colspan=
"3">
';
1062 print '<tr><td
class=
"titlefieldcreate fieldrequired"><label
for=
"lastname">
'.$langs->trans("Lastname").' /
'.$langs->trans("Label").'</label></td>
';
1063 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>
';
1067 print '<td><label
for=
"firstname">
'.$langs->trans("Firstname").'</label></td>
';
1068 print '<td colspan=
"3"><input
name=
"firstname" id=
"firstname" type=
"text" class=
"minwidth200" maxlength=
"80" value=
"'.(GETPOSTISSET("firstname
") ? GETPOST("firstname
") : $object->firstname).'"></td>
';
1072 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS
')) {
1073 print '<tr><td><label
for=
"socid">
'.$langs->trans("ThirdParty").'</label></td>
';
1074 print '<td colspan=
"3" class=
"maxwidthonsmartphone">
';
1075 print img_picto('', 'company
', 'class=
"pictofixedwidth"').$form->select_company(GETPOSTINT('socid
') ? GETPOSTINT('socid
') : ($object->socid ? $object->socid : -1), 'socid
', '', $langs->trans("SelectThirdParty"));
1081 if (getDolGlobalString('MAIN_USE_TITLE_FOR_CONTACT
')) {
1082 print '<tr><td><label
for=
"civility_code">
'.$langs->trans("UserTitle").'</label></td><td colspan=
"3">
';
1083 print $formcompany->select_civility(GETPOSTISSET("civility_code") ? GETPOST("civility_code", "aZ09") : $object->civility_code, 'civility_code
');
1088 print '<tr><td><label
for=
"title">
'.$langs->trans("PostOrFunction").'</label></td>
';
1089 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>
';
1091 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
1092 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
1095 print '<tr><td><label
for=
"address">
'.$langs->trans("Address").'</label></td>
';
1096 print '<td colspan=
"3">
';
1097 print '<div
class=
"paddingrightonly valignmiddle inline-block quatrevingtpercent">
';
1098 print '<textarea
class=
"flat minwidth200 centpercent" name=
"address" id=
"address">
'.(GETPOSTISSET("address") ? GETPOST("address", 'alphanohtml
') : $object->address).'</textarea>
';
1099 print '</div><div
class=
"paddingrightonly valignmiddle inline-block">
';
1100 if (!empty($conf->use_javascript_ajax)) {
1101 print '<a href=
"#" id=
"copyaddressfromsoc">
'.$langs->trans('CopyAddressFromSoc
').'</a><br>
';
1107 print '<tr><td><label
for=
"zipcode">
'.$langs->trans("Zip").'</label> / <label
for=
"town">
'.$langs->trans("Town").'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1108 print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode
', array('town
', 'selectcountry_id
', 'state_id
'), 6).'
';
1109 print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town
', array('zipcode
', 'selectcountry_id
', 'state_id
'));
1113 print '<tr><td><label
for=
"selectcountry_id">
'.$langs->trans("Country").'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1114 print img_picto('', 'globe-americas
', 'class=
"pictofixedwidth"');
1115 print $form->select_country(GETPOSTISSET("country_id") ? GETPOST("country_id") : $object->country_id, 'country_id
');
1117 print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1122 if (!getDolGlobalString('SOCIETE_DISABLE_STATE
')) {
1123 if (getDolGlobalString('MAIN_SHOW_REGION_IN_STATE_SELECT
') && (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT
') == 2)) {
1124 print '<tr><td><label
for=
"state_id">
'.$langs->trans('Region-State
').'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1126 print '<tr><td><label
for=
"state_id">
'.$langs->trans('State
').'</label></td><td colspan=
"3" class=
"maxwidthonsmartphone">
';
1129 print img_picto('', 'state
', 'class=
"pictofixedwidth"');
1130 print $formcompany->select_state(GETPOSTISSET('state_id
') ? GETPOST('state_id
', 'alpha
') : $object->state_id, $object->country_code, 'state_id
');
1135 print '<tr><td>
'.$form->editfieldkey('PhonePro
', 'phone_pro
', GETPOST('phone_pro
', 'alpha
'), $object, 0).'</td>
';
1137 print $form->showPhoneInput($object->phone_pro, 'phone_pro
', $object->country_id, 'object_phoning
', 'maxwidth150
', 80);
1139 if ($conf->browser->layout == 'phone
') {
1143 print '<td>
'.$form->editfieldkey('PhonePerso
', 'phone_perso
', GETPOST('phone_perso
', 'alpha
'), $object, 0).'</td>
';
1145 print $form->showPhoneInput($object->phone_perso, 'phone_perso
', $object->country_id, 'object_phoning
', 'maxwidth150
', 80);
1148 print '<tr><td>
'.$form->editfieldkey('PhoneMobile
', 'phone_mobile
', GETPOST('phone_mobile
', 'alpha
'), $object, 0, 'string', '').'</td>
';
1150 print $form->showPhoneInput($object->phone_mobile, 'phone_mobile
', $object->country_id, 'object_phoning_mobile
', 'maxwidth150
', 80);
1152 if ($conf->browser->layout == 'phone
') {
1156 print '<td>
'.$form->editfieldkey('Fax
', 'fax
', GETPOST('fax
', 'alpha
'), $object, 0).'</td>
';
1158 print $form->showPhoneInput($object->fax, 'fax
', $object->country_id, 'object_phoning_fax
', 'maxwidth150
', 80);
1162 print '<tr><td>
'.$form->editfieldkey('EMail
', 'email', GETPOST('email', 'alpha
'), $object, 0, 'string', '', (int) (getDolGlobalInt('SOCIETE_EMAIL_MANDATORY
'))).'</td>
';
1164 print img_picto('', 'object_email
', 'class=
"pictofixedwidth"');
1165 print '<input
type=
"text" name=
"email" id=
"email" class=
"maxwidth100onsmartphone quatrevingtpercent" value=
"'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>
';
1166 if (isModEnabled('mailing
')) {
1167 if ($conf->browser->layout == 'phone
') {
1170 $langs->load("mails");
1171 print '<td
class=
"nowrap">
'.$langs->trans("NbOfEMailingsSend").'</td>
';
1172 print '<td>
'.$object->getNbOfEMailings().'</td>
';
1174 print '<td colspan=
"2"></td>
';
1179 if (isModEnabled('mailing
')) {
1180 if ($conf->use_javascript_ajax && getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2) {
1181 print "\n".'<script
type=
"text/javascript">
'."\n";
1184 jQuery(document).ready(
function () {
1185 function init_check_no_email(input) {
1186 if (input.val()!=
"") {
1187 $(
".noemail").addClass(
"fieldrequired");
1189 $(
".noemail").removeClass(
"fieldrequired");
1192 $(
"#email").keyup(
function() {
1193 init_check_no_email($(
this));
1195 init_check_no_email($(
"#email"));
1197 print '</script>
'."\n";
1199 if (!GETPOSTISSET("no_email") && !empty($object->email)) {
1200 $result = $object->getNoEmail();
1202 setEventMessages($object->error, $object->errors, 'errors
');
1206 print '<td
class=
"noemail"><label
for=
"no_email">
'.$langs->trans("No_Email").'</label></td>
';
1208 $useempty = (getDolGlobalInt('MAILING_CONTACT_DEFAULT_BULK_STATUS
') == 2);
1209 print $form->selectyesno('no_email
', (GETPOSTISSET("no_email") ? GETPOSTINT("no_email") : $object->no_email), 1, false, (int) $useempty);
1215 if (isModEnabled('socialnetworks
')) {
1216 $colspan = ($conf->browser->layout == 'phone
' ? 2 : 4);
1218 $object->showSocialNetwork($socialnetworks, $colspan);
1220 print '<tr><td
'.($colspan ? ' colspan=
"'.$colspan.'"' : '').'><hr></td></tr>
';
1224 print '<tr><td><label
for=
"priv">
'.$langs->trans("ContactVisibility").'</label></td><td colspan=
"3">
';
1225 $selectarray = array('0
' => $langs->trans("ContactPublic"), '1
' => $langs->trans("ContactPrivate"));
1226 print $form->selectarray('priv
', $selectarray, $object->priv, 0, 0, 0, '', 0, 0, 0, '', 'maxwidth150
');
1230 if (getDolGlobalInt('MAIN_MULTILANGS
')) {
1231 print '<tr><td>
'.$form->editfieldkey('DefaultLang
', 'default_lang
', '', $object, 0).'</td><td colspan=
"3" class=
"maxwidthonsmartphone">
'."\n";
1232 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
');
1238 print '<tr><td
class=
"tdtop"><label
for=
"note_public">
'.$langs->trans("NotePublic").'</label></td><td colspan=
"3">
';
1239 $doleditor = new DolEditor('note_public
', $object->note_public, '', 80, 'dolibarr_notes
', 'In
', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC
') ? 0 : 1, ROWS_3, '90%
');
1240 print $doleditor->Create(1);
1244 print '<tr><td
class=
"tdtop"><label
for=
"note_private">
'.$langs->trans("NotePrivate").'</label></td><td colspan=
"3">
';
1245 $doleditor = new DolEditor('note_private
', $object->note_private, '', 80, 'dolibarr_notes
', 'In
', false, false, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE
') ? 0 : 1, ROWS_3, '90%
');
1246 print $doleditor->Create(1);
1250 print '<tr><td>
'.$langs->trans("Status").'</td>
';
1251 print '<td colspan=
"3">
';
1252 print $object->getLibStatut(4);
1256 if (isModEnabled('category
') && $user->hasRight('categorie
', 'lire
')) {
1257 $arrayselected = array();
1258 print '<tr><td>
'.$form->editfieldkey('Categories', 'contcats
', '', $object, 0).'</td>
';
1259 print '<td colspan=
"3">
';
1260 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, '', '', 64, 0, 3);
1261 $c = new Categorie($db);
1262 $cats = $c->containing($object->id, 'contact
');
1263 foreach ($cats as $cat) {
1264 $arrayselected[] = $cat->id;
1266 print img_picto('', 'category
', 'class=
"pictofixedwidth"').$form->multiselectarray('contcats
', $cate_arbo, $arrayselected, 0, 0, '', 0, '90%
');
1270 // Contact by default
1271 if (!empty($object->socid)) {
1272 print '<tr><td>
'.$langs->trans("ContactByDefaultFor").'</td>
';
1273 print '<td colspan=
"3">
';
1274 print img_picto('', 'category
', 'class=
"pictofixedwidth"').$formcompany->showRoles("roles", $object, 'edit
', $object->roles, '');
1279 $parameters = array('colspan
' => ' colspan=
"3"', 'cols
' => '3
', 'colspanvalue
' => '3
');
1280 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php
';
1282 $object->load_ref_elements();
1284 if (isModEnabled('order
')) {
1285 print '<tr><td>
'.$langs->trans("ContactForOrders").'</td><td colspan=
"3">
';
1286 print $object->ref_commande ? $object->ref_commande : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyOrder").'</span>
');
1290 if (isModEnabled("propal")) {
1291 print '<tr><td>
'.$langs->trans("ContactForProposals").'</td><td colspan=
"3">
';
1292 print $object->ref_propal ? $object->ref_propal : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyProposal").'</span>
');
1296 if (isModEnabled('contract
')) {
1297 print '<tr><td>
'.$langs->trans("ContactForContracts").'</td><td colspan=
"3">
';
1298 print $object->ref_contrat ? $object->ref_contrat : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyContract").'</span>
');
1302 if (isModEnabled('invoice
')) {
1303 print '<tr><td>
'.$langs->trans("ContactForInvoices").'</td><td colspan=
"3">
';
1304 print $object->ref_facturation ? $object->ref_facturation : ('<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyInvoice").'</span>
');
1309 print '<tr><td>
'.$langs->trans("DolibarrLogin").'</td><td colspan=
"3">
';
1310 if ($object->user_id) {
1311 $dolibarr_user = new User($db);
1312 $result = $dolibarr_user->fetch($object->user_id);
1313 print $dolibarr_user->getLoginUrl(1);
1315 print '<span
class=
"opacitymedium">
'.$langs->trans("NoDolibarrAccess").'</span>
';
1321 print '<td>
'.$langs->trans("PhotoFile").'</td>
';
1322 print '<td colspan=
"3">
';
1323 if ($object->photo) {
1324 print $form->showphoto('contact
', $object);
1327 print '<
table class=
"nobordernopadding">
';
1328 if ($object->photo) {
1329 print '<tr><td><input
type=
"checkbox" class=
"flat photodelete" name=
"deletephoto" id=
"photodelete">
'.$langs->trans("Delete").'<br><br></td></tr>
';
1331 //print '<tr><td>
'.$langs->trans("PhotoFile").'</td></tr>
';
1333 $maxfilesizearray = getMaxFileSizeArray();
1334 $maxmin = $maxfilesizearray['maxmin
'];
1336 print '<input
type=
"hidden" name=
"MAX_FILE_SIZE" value=
"'.($maxmin * 1024).'">
'; // MAX_FILE_SIZE must precede the field type=file
1338 print '<input
type=
"file" class=
"flat maxwidth200" name=
"photo" id=
"photoinput">
';
1347 print dol_get_fiche_end();
1349 print $form->buttonsSaveCancel();
1355 // Select mail models is same action as presend
1356 if (GETPOST('modelselected
', 'alpha
')) {
1357 $action = 'presend
';
1361 if (!empty($id) && $action != 'edit
' && $action != 'create
') {
1362 $objsoc = new Societe($db);
1365 dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors);
1367 print dol_get_fiche_head($head, 'card
', $title, -1, 'contact
', 0, '', '', 0, '', 1);
1369 if ($action == 'create_user
') {
1370 // Full firstname and lastname separated with a dot : firstname.lastname
1371 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
1372 $login = dol_buildlogin($object->lastname, $object->firstname);
1374 $generated_password = '';
1375 if (empty($ldap_sid)) { // TODO ldap_sid ?
1376 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php
';
1377 $generated_password = getRandomPassword(false);
1379 $password = $generated_password;
1381 // Create a form array
1382 $formquestion = array(
1383 array('label
' => $langs->trans("LoginToCreate"), 'type' => 'text
', 'name' => 'login
', 'value
' => $login),
1384 array('label
' => $langs->trans("Password"), 'type' => 'text
', 'name' => 'password
', 'value
' => $password),
1385 //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
')))
1387 $text = $langs->trans("ConfirmCreateContact").'<br>
';
1388 if (isModEnabled("societe")) {
1389 if ($object->socid > 0) {
1390 $text .= $langs->trans("UserWillBeExternalUser");
1392 $text .= $langs->trans("UserWillBeInternalUser");
1395 print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CreateDolibarrLogin"), $text, "confirm_create_user", $formquestion, 'yes
');
1398 $linkback = '<a href=
"'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">
'.$langs->trans("BackToList").'</a>
';
1400 $morehtmlref = '<a href=
"'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class=
"refid">
';
1401 $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard
', 'class=
"valignmiddle marginleftonly paddingrightonly"');
1402 $morehtmlref .= '</a>
';
1404 $morehtmlref .= '<div
class=
"refidno">
';
1405 if (!getDolGlobalString('SOCIETE_DISABLE_CONTACTS
')) {
1406 $objsoc->fetch($object->socid);
1408 if ($objsoc->id > 0) {
1409 $morehtmlref .= $objsoc->getNomUrl(1, 'contact
');
1411 $morehtmlref .= '<span
class=
"opacitymedium">
'.$langs->trans("ContactNotLinkedToCompany").'</span>
';
1414 $morehtmlref .= '</div>
';
1416 dol_banner_tab($object, 'id', $linkback, 1, 'rowid
', 'ref', $morehtmlref);
1419 print '<div
class=
"fichecenter">
';
1420 print '<div
class=
"fichehalfleft">
';
1422 print '<div
class=
"underbanner clearboth"></div>
';
1423 print '<
table class=
"border tableforfield" width=
"100%">
';
1426 if (getDolGlobalString('MAIN_USE_TITLE_FOR_CONTACT
')) {
1427 print '<tr><td
class=
"titlefield">
'.$langs->trans("UserTitle").'</td><td>
';
1428 print $object->getCivilityLabel();
1433 print '<tr><td>
'.$langs->trans("PostOrFunction").'</td><td>
'.$object->poste.'</td></tr>
';
1436 if (isModEnabled('mailing
')) {
1437 $langs->load("mails");
1438 print '<tr><td>
'.$langs->trans("NbOfEMailingsSend").'</td>
';
1439 print '<td><a
class=
"badge badge-info" href=
"'.DOL_URL_ROOT.'/comm/mailing/list.php?filteremail='.urlencode($object->email).'">
'.$object->getNbOfEMailings().'</a></td></tr>
';
1442 // Unsubscribe opt-out
1443 if (isModEnabled('mailing
')) {
1444 $result = $object->getNoEmail();
1446 setEventMessages($object->error, $object->errors, 'errors
');
1448 print '<tr><td>
'.$langs->trans("No_Email").'</td><td>
';
1449 if ($object->email) {
1450 print yn($object->no_email);
1452 print '<span
class=
"opacitymedium">
'.$langs->trans("EMailNotDefined").'</span>
';
1458 if (getDolGlobalInt('MAIN_MULTILANGS
')) {
1459 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
1460 print '<tr><td>
'.$langs->trans("DefaultLang").'</td><td>
';
1461 //$s=picto_from_langcode($object->default_lang);
1462 //print ($s?$s.' ':'');
1463 $langs->load("languages");
1464 $labellang = ($object->default_lang ? $langs->trans('Language_
'.$object->default_lang) : '');
1465 print picto_from_langcode($object->default_lang, 'class=
"paddingrightonly saturatemedium opacitylow"');
1470 print '<tr><td>
'.$langs->trans("ContactVisibility").'</td><td>
';
1471 print $object->LibPubPriv($object->priv, 1);
1477 $object->fetch_thirdparty();
1480 print '<div
class=
"fichehalfright">
';
1482 print '<div
class=
"underbanner clearboth"></div>
';
1483 print '<
table class=
"border tableforfield centpercent">
';
1486 if (getDolGlobalString('THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES
')) {
1487 if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3) {
1488 // Level of prospect
1489 print '<tr><td
class=
"">
';
1490 print '<
table class=
"nobordernopadding centpercent"><tr><td
class=
"nowrap">
';
1491 print $langs->trans('ProspectLevel
');
1493 if ($action != 'editlevel
' && $user->hasRight('societe
', 'contact
', 'creer
')) {
1494 print '<td align=
"right"><a href=
"'.$_SERVER["PHP_SELF
"].'?action=editlevel&token='.newToken().'&id='.$object->id.'">
'.img_edit($langs->trans('Modify
'), 1).'</a></td>
';
1496 print '</tr></
table>
';
1498 if ($action == 'editlevel
') {
1499 $formcompany->formProspectContactLevel($_SERVER['PHP_SELF
'].'?
id=
'.$object->id, (int) $object->fk_prospectlevel, 'prospect_contact_level_id
', 1);
1501 print $object->getLibProspLevel();
1506 // Status of prospection
1507 $object->loadCacheOfProspStatus();
1508 print '<tr><td>
'.$langs->trans("StatusProsp").'</td><td>
'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label
']);
1509 print '
';
1510 print '<div
class=
"floatright">
';
1511 foreach ($object->cacheprospectstatus as $key => $val) {
1512 $titlealt = 'default';
1513 if (!empty($val['code
']) && !in_array($val['code
'], array('ST_NO
', 'ST_NEVER
', 'ST_TODO
', 'ST_PEND
', 'ST_DONE
'))) {
1514 $titlealt = $val['label
'];
1516 if ($object->stcomm_id != $val['id']) {
1517 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>
';
1520 print '</div></td></tr>
';
1525 if (isModEnabled('category
') && $user->hasRight('categorie
', 'lire
')) {
1526 print '<tr><td
class=
"">
'.$langs->trans("Categories").'</td>
';
1528 print $form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
1532 // Contact by default for
1533 if (!empty($object->socid)) {
1534 print '<tr><td
class=
"">
'.$langs->trans("ContactByDefaultFor").'</td>
';
1536 print $formcompany->showRoles("roles", $object, 'view
', $object->roles, '');
1541 $parameters = array('socid
' => $socid);
1542 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
1544 $object->load_ref_elements();
1546 if (isModEnabled("propal")) {
1547 print '<tr><td
class=
"">
'.$langs->trans("ContactForProposals").'</td><td>
';
1548 print $object->ref_propal ? $object->ref_propal : '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyProposal").'<span>
';
1552 if (isModEnabled('order
') || isModEnabled("shipping")) {
1553 print '<tr><td
class=
"">
';
1554 if (isModEnabled("shipping")) {
1555 print $langs->trans("ContactForOrdersOrShipments");
1557 print $langs->trans("ContactForOrders");
1560 $none = '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyOrder").'</span>
';
1561 if (isModEnabled("shipping")) {
1562 $none = '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyOrderOrShipments").'</span>
';
1564 print $object->ref_commande ? $object->ref_commande : $none;
1568 if (isModEnabled('contract
')) {
1569 print '<tr><td
class=
"">
'.$langs->trans("ContactForContracts").'</td><td>
';
1570 print $object->ref_contrat ? $object->ref_contrat : '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyContract").'</span>
';
1574 if (isModEnabled('invoice
')) {
1575 print '<tr><td
class=
"">
'.$langs->trans("ContactForInvoices").'</td><td>
';
1576 print $object->ref_facturation ? $object->ref_facturation : '<span
class=
"opacitymedium">
'.$langs->trans("NoContactForAnyInvoice").'</span>
';
1580 print '<tr><td>
'.$langs->trans("DolibarrLogin").'</td><td>
';
1581 if ($object->user_id) {
1582 $dolibarr_user = new User($db);
1583 $result = $dolibarr_user->fetch($object->user_id);
1584 print $dolibarr_user->getLoginUrl(-1);
1586 //print '<span
class=
"opacitymedium">
'.$langs->trans("NoDolibarrAccess").'</span>
';
1587 if (!$object->user_id && $user->hasRight('user', 'user', 'creer
')) {
1588 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>
';
1595 print '</div></div>
';
1596 print '<div
class=
"clearboth"></div>
';
1598 print dol_get_fiche_end();
1604 print '<div
class=
"tabsAction">
';
1606 $parameters = array();
1607 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1608 if (empty($reshook) && $action != 'presend
') {
1609 if (empty($user->socid)) {
1610 if (!empty($object->email)) {
1611 $langs->load("mails");
1612 print dolGetButtonAction('', $langs->trans('SendMail
'), 'email', dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id, 'action
' => 'presend
', 'mode
' => 'init
'], true).'#formmailbeforetitle
', '');
1614 $langs->load("mails");
1615 print dolGetButtonAction('', $langs->trans('SendMail
'), 'email', '#
', '', false);
1619 if ($user->hasRight('societe
', 'contact
', 'creer
')) {
1620 print '<a
class=
"butAction" href=
"'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit&token='.newToken().'">
'.$langs->trans('Modify
').'</a>
';
1624 if ($object->status == 0 && $user->hasRight('societe
', 'contact
', 'creer
')) {
1625 print '<a
class=
"butAction" href=
"'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken().'">
'.$langs->trans("Reactivate").'</a>
';
1628 if ($object->status == 1 && $user->hasRight('societe
', 'contact
', 'creer
')) {
1629 print '<a
class=
"butActionDelete" href=
"'.$_SERVER['PHP_SELF'].'?action=disable&id='.$object->id.'&token='.newToken().'">
'.$langs->trans("DisableUser").'</a>
';
1633 if ($permissiontoadd && $user->hasRight('societe
', 'contact
', 'supprimer
')) {
1634 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";
1638 if ($user->hasRight('societe
', 'contact
', 'supprimer
')) {
1639 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";
1645 //Select mail models is same action as presend
1646 if (GETPOST('modelselected
')) {
1647 $action = 'presend
';
1650 if ($action != 'presend
') {
1651 print '<div
class=
"fichecenter"><div
class=
"fichehalfleft">
';
1653 print '</div><div
class=
"fichehalfright">
';
1657 $morehtmlright = dolGetButtonTitle($langs->trans('SeeAll
'), '', 'fa fa-bars imgforviewmode
', DOL_URL_ROOT.'/contact/agenda.php?
id=
'.$object->id);
1659 // List of actions on element
1660 include_once DOL_DOCUMENT_ROOT.'/core/
class/html.formactions.class.php
';
1661 $formactions = new FormActions($db);
1662 $somethingshown = $formactions->showactions($object, 'contact
', $object->socid, 1, '', $MAXEVENT, '', $morehtmlright); // Show all action for thirdparty
1664 print '</div></div>
';
1668 $modelmail = 'contact
';
1669 $defaulttopic = 'Information
';
1670 $diroutput = $conf->societe->dir_output.'/contact/
';
1671 $trackid = 'ctc
'.$object->id;
1673 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.
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)
treeview li table
No Email.
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.