38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/contact.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
63$langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
69$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
70$confirm =
GETPOST(
'confirm',
'alpha');
71$backtopage =
GETPOST(
'backtopage',
'alpha');
72$cancel =
GETPOST(
'cancel',
'alpha');
81$extrafields->fetch_name_optionals_label(
$object->table_element);
90 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
91 $objcanvas =
new Canvas($db, $action);
92 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
96$hookmanager->initHooks(array(
'contactcard',
'globalcard'));
103if (!(
$object->id > 0) && $action ==
'view') {
104 $langs->load(
"errors");
105 print($langs->trans(
'ErrorRecordNotFound'));
109$triggermodname =
'CONTACT_MODIFY';
110$permissiontoadd = $user->hasRight(
'societe',
'contact',
'creer');
111$permissiontoeditextra = $permissiontoadd;
112if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
114 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
119 $socid = $user->socid;
124$result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
131$parameters = array(
'id' => $id,
'objcanvas' => $objcanvas);
132$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
137if (empty($reshook)) {
138 $backurlforlist = DOL_URL_ROOT.
'/contact/list.php';
140 if (empty($backtopage) || ($cancel && empty($id))) {
141 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
142 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
143 $backtopage = $backurlforlist;
145 $backtopage = DOL_URL_ROOT.
'/contact/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
151 if (!empty($backtopageforcancel)) {
152 header(
"Location: ".$backtopageforcancel);
154 } elseif (!empty($backtopage)) {
155 header(
"Location: ".$backtopage);
162 if ($action ==
'confirm_create_user' && $confirm ==
'yes' && $user->hasRight(
'user',
'user',
'creer')) {
170 $nuser =
new User($db);
174 $result2 = $nuser->setPassword($user,
GETPOST(
"password"), 0, 0, 1);
175 if (is_int($result2) && $result2 < 0) {
176 $error = $nuser->error;
177 $errors = $nuser->errors;
183 $error = $nuser->error;
184 $errors = $nuser->errors;
195 if ($action ==
'disable' && $permissiontoadd) {
197 if (
$object->setstatus(0) < 0) {
200 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
206 if ($action ==
'enable' && $permissiontoadd) {
208 if (
$object->setstatus(1) < 0) {
211 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
217 if ($action ==
'add' && $permissiontoadd) {
228 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
235 $object->socialnetworks = array();
236 if (isModEnabled(
'socialnetworks')) {
237 foreach ($socialnetworks as $key => $value) {
238 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
239 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
247 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
250 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
251 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
258 $object->birthday_alert = (
GETPOST(
'birthday_alert',
'alpha') ==
"on" ? 1 : 0);
264 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
270 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
$object->no_email == -1 && !empty(
$object->email)) {
272 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
277 $langs->load(
"errors");
279 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
283 if (empty(
$object->lastname)) {
285 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
300 $contcats =
GETPOST(
'contcats',
'array');
301 if (count($contcats) > 0) {
302 $result =
$object->setCategories($contcats);
311 if (empty($error) && isModEnabled(
'mailing') && !empty(
$object->email)) {
321 if (empty($error) && $id > 0) {
323 if (!empty($backtopage)) {
324 $url = str_replace(
'__ID__', (
string) $id, $backtopage);
326 $url =
'card.php?id='.$id;
328 header(
"Location: ".$url);
335 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'contact',
'supprimer')) {
339 $result =
$object->delete($user);
342 if ($backurlforlist) {
343 header(
"Location: ".$backurlforlist);
346 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
354 if ($action ==
'update' && empty($cancel) && $permissiontoadd) {
355 if (!
GETPOST(
"lastname",
'alpha')) {
357 $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
361 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOSTINT(
"no_email") == -1 && !empty(
GETPOST(
'email',
'email'))) {
363 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
368 $langs->load(
"errors");
370 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
381 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
383 $fileimg = $dir.
'/'.
$object->photo;
384 $dirthumbs = $dir.
'/thumbs';
398 if (!is_numeric($result) || $result <= 0) {
399 $errors[] =
"ErrorFailedToSaveFile";
408 $errors[] =
"ErrorBadImageFormat";
411 switch ($_FILES[
'photo'][
'error']) {
414 $errors[] =
"ErrorFileSizeTooLarge";
417 $errors[] =
"ErrorFilePartiallyUploaded";
427 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
436 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
438 $object->socialnetworks = array();
439 if (isModEnabled(
'socialnetworks')) {
440 foreach ($socialnetworks as $key => $value) {
441 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
442 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
448 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
451 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
452 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
460 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
466 $result =
$object->update($contactid, $user);
470 $categories =
GETPOST(
'contcats',
'array');
471 $object->setCategories($categories);
474 if (GETPOSTISSET(
'no_email') &&
$object->email) {
476 $result =
$object->setNoEmail($no_email);
489 if (!$error && empty($errors)) {
490 if (!empty($backtopage)) {
491 header(
"Location: ".$backtopage);
500 if ($action ==
'setprospectcontactlevel' && $permissiontoadd) {
502 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
510 if ($action ==
'setstcomm' && $permissiontoadd) {
520 if ($action ==
'update_extras' && $permissiontoeditextra) {
523 $attribute_name =
GETPOST(
'attribute',
'aZ09');
526 $ret = $extrafields->setOptionalsFromPost(
null,
$object, $attribute_name);
532 $result =
$object->updateExtraField($attribute_name,
'CONTACT_MODIFY');
540 $action =
'edit_extras';
545 $triggersendname =
'CONTACT_SENTBYMAIL';
547 $mode =
'emailfromcontact';
548 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
556$form =
new Form($db);
562 $objsoc->fetch($socid);
565$title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
570 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
572$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
574llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-societe page-contact-card');
576$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
578if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
582 if (empty(
$object->error) && $id) {
590 $objcanvas->display_canvas($action);
597 if ($user->hasRight(
'societe',
'contact',
'supprimer')) {
598 if ($action ==
'delete') {
599 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
610 $res =
$object->fetch($id, $user);
621 if ($user->hasRight(
'societe',
'contact',
'creer')) {
622 if ($action ==
'create') {
631 $object->country_id =
GETPOST(
"country_id") ?
GETPOSTINT(
"country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
634 $object->country_code = $tmparray[
'code'];
635 $object->country = $tmparray[
'label'];
645 if (
$conf->use_javascript_ajax) {
646 print
"\n".
'<script type="text/javascript">'.
"\n";
647 print
'jQuery(document).ready(function () {
648 jQuery("#selectcountry_id").change(function() {
649 document.formsoc.action.value="create";
650 document.formsoc.submit();
653 $("#copyaddressfromsoc").click(function() {
654 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
655 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
656 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
657 console.log("Set state_id to '.
dol_escape_js((
string) $objsoc->state_id).
'");
658 $(\'select[name="state_id"]\').val("'.
dol_escape_js((
string) $objsoc->state_id).
'").trigger("change");
659 /* set country at end because it will trigger page refresh */
660 console.log("Set country id to '.
dol_escape_js((
string) $objsoc->country_id).
'");
661 $(\'select[name="country_id"]\').val("'.
dol_escape_js((
string) $objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
664 print
'</script>'.
"\n";
667 print
'<form method="post" name="formsoc" action="'.$_SERVER[
"PHP_SELF"].
'">';
668 print
'<input type="hidden" name="token" value="'.newToken().
'">';
669 print
'<input type="hidden" name="action" value="add">';
670 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
671 if (!empty($objsoc)) {
672 print
'<input type="hidden" name="entity" value="'.$objsoc->entity.
'">';
677 print
'<table class="border centpercent">';
680 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
681 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>';
686 print
'<td><label for="firstname">';
687 print $form->textwithpicto($langs->trans(
"Firstname"), $langs->trans(
"KeepEmptyIfGenericAddress")).
'</label></td>';
688 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>';
694 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
695 print
'<td colspan="3" class="maxwidthonsmartphone">';
696 print $objsoc->getNomUrl(1,
'contact');
698 print
'<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.
'">';
701 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
702 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($socid,
'socid',
'',
'SelectThirdParty', 0, 0, array(), 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
708 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
709 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'alpha') :
$object->civility_code,
'civility_code');
713 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
714 print
'<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="255" value="'.dol_escape_htmltag(GETPOSTISSET(
"poste") ?
GETPOST(
"poste",
'alphanohtml') :
$object->poste).
'"></td>';
716 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
717 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'><hr></td></tr>';
720 if (
$conf->use_javascript_ajax && $socid > 0) {
725 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->address)) == 0) {
726 $object->address = $objsoc->address;
728 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
729 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>';
731 if (
$conf->use_javascript_ajax && $socid > 0) {
737 print
'<td class="valignmiddle center" rowspan="'.$rowspan.
'">';
738 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a>';
747 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->town)) == 0) {
750 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
751 print $formcompany->select_ziptown((
GETPOST(
"zipcode",
'alpha') ?
GETPOST(
"zipcode",
'alpha') :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
752 print $formcompany->select_ziptown((
GETPOST(
"town",
'alpha') ?
GETPOST(
"town",
'alpha') :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
756 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
757 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
758 print $form->select_country((GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id",
'alpha') :
$object->country_id),
'country_id');
760 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
767 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
769 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
773 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
774 print $formcompany->select_state(
GETPOST(
"state_id",
'alpha') ?
GETPOST(
"state_id",
'alpha') :
$object->state_id,
$object->country_code,
'state_id');
776 print $countrynotdefined;
781 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->phone_pro)) == 0) {
782 $object->phone_pro = $objsoc->phone;
789 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
'',
$object, 0).
'</td>';
791 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
792 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth250 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') :
$object->phone_pro).
'"></td>';
793 if (
$conf->browser->layout ==
'phone') {
796 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'phone_perso',
'',
$object, 0).
'</td>';
798 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
799 print
'<input type="text" name="phone_perso" id="phone_perso" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_perso') ?
GETPOST(
'phone_perso',
'alpha') :
$object->phone_perso).
'"></td>';
802 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'',
$object, 0).
'</td>';
804 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
805 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'"></td>';
806 if (
$conf->browser->layout ==
'phone') {
809 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'',
$object, 0).
'</td>';
811 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
812 print
'<input type="text" name="fax" id="fax" class="maxwidth200 widthcentpercentminusx" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') :
$object->fax).
'"></td>';
815 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->email)) == 0) {
816 $object->email = $objsoc->email;
820 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'',
$object, 0,
'string',
'').
'</td>';
822 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
823 print
'<input class="maxwidth200 widthcentpercentminusx" type="text" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->
email).
'"></td>';
827 if (isModEnabled(
'mailing')) {
828 if (
$conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
829 print
"\n".
'<script type="text/javascript">'.
"\n";
830 print
'$(document).ready(function () {
831 $("#email").keyup(function() {
832 if ($(this).val()!="") {
833 $(".noemail").addClass("fieldrequired");
835 $(".noemail").removeClass("fieldrequired");
839 print
'</script>'.
"\n";
841 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
842 $result =
$object->getNoEmail();
848 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
851 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));
857 if (isModEnabled(
'socialnetworks')) {
858 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
860 $object->showSocialNetwork($socialnetworks, $colspan);
862 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'><hr></td></tr>';
866 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
867 $selectarray = array(
'0' => $langs->trans(
"ContactPublic"),
'1' => $langs->trans(
"ContactPrivate"));
868 print $form->selectarray(
'priv', $selectarray, (
GETPOST(
"priv",
'alpha') ?
GETPOST(
"priv",
'alpha') :
$object->priv), 0);
873 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
874 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');
880 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
881 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'',
$object, 0).
'</td><td colspan="3">';
882 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
'',
'parent', 64, 0, 3);
883 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'), 0, 0,
'', 0,
'90%');
889 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
890 print
'<td colspan="3">';
891 $contactType =
$object->listeTypeContacts(
'external', 0, 1);
892 print
img_picto(
'',
'contact',
'class="pictofixedwidth"').$form->multiselectarray(
'roles', $contactType, array(), 0, 0,
'', 0,
'90%');
897 $parameters = array(
'socid' => $socid,
'objsoc' => $objsoc,
'colspan' =>
' colspan="3"',
'cols' => 3,
'colspanvalue' => 3);
898 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
900 print
"</table><br>";
902 print
'<hr style="margin-bottom: 20px">';
905 print
load_fiche_titre(
'<div class="comboperso">'.$langs->trans(
"PersonalInformations").
'</div>',
'',
'');
907 print
'<table class="border centpercent">';
910 print
'<tr><td class="titlefieldcreate"><label for="birthday">'.$langs->trans(
"DateOfBirth").
'</label></td><td colspan="3">';
911 $form =
new Form($db);
913 print $form->selectDate(
$object->birthday,
'birthday', 0, 0, 0,
"perso", 1, 0);
915 print $form->selectDate(
'',
'birthday', 0, 0, 1,
"perso", 1, 0);
918 print
' <label for="birthday_alert">'.$langs->trans(
"Alert").
'</label> ';
919 if (!empty(
$object->birthday_alert)) {
920 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
922 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert">';
931 print $form->buttonsSaveCancel(
"Add");
934 } elseif ($action ==
'edit' && !empty($id)) {
940 if (GETPOSTISSET(
"country_id") ||
$object->country_id) {
942 $object->country_code = $tmparray[
'code'];
943 $object->country = $tmparray[
'label'];
947 $objsoc->fetch(
$object->socid);
952 if (
$conf->use_javascript_ajax) {
953 print
"\n".
'<script type="text/javascript">'.
"\n";
954 print
'jQuery(document).ready(function () {
955 jQuery("#selectcountry_id").change(function() {
956 document.formsoc.action.value="edit";
957 document.formsoc.submit();
960 $("#copyaddressfromsoc").click(function() {
961 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
962 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
963 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
964 console.log("Set state_id to '.
dol_escape_js((
string) $objsoc->state_id).
'");
965 $(\'select[name="state_id"]\').val("'.
dol_escape_js((
string) $objsoc->state_id).
'").trigger("change");
966 /* set country at end because it will trigger page refresh */
967 console.log("Set country id to '.
dol_escape_js((
string) $objsoc->country_id).
'");
968 $(\'select[name="country_id"]\').val("'.
dol_escape_js((
string) $objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
971 print
'</script>'.
"\n";
974 print
'<form enctype="multipart/form-data" method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'" name="formsoc">';
975 print
'<input type="hidden" name="token" value="'.newToken().
'">';
976 print
'<input type="hidden" name="id" value="'.$id.
'">';
977 print
'<input type="hidden" name="action" value="update">';
978 print
'<input type="hidden" name="contactid" value="'.$object->id.
'">';
979 if (!empty($backtopage)) {
980 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
985 print
'<table class="border centpercent">';
989 print
'<tr><td>'.$langs->trans(
"ID").
'</td><td colspan="3">';
995 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
996 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>';
1000 print
'<td><label for="firstname">'.$langs->trans(
"Firstname").
'</label></td>';
1001 print
'<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"firstname") ?
GETPOST(
"firstname") :
$object->firstname).
'"></td>';
1006 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
1007 print
'<td colspan="3" class="maxwidthonsmartphone">';
1008 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOSTINT(
'socid') ?
GETPOSTINT(
'socid') : (
$object->socid ?
$object->socid : -1),
'socid',
'', $langs->trans(
"SelectThirdParty"));
1014 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
1015 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
"aZ09") :
$object->civility_code,
'civility_code');
1019 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
1020 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>';
1022 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
1023 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'><hr></td></tr>';
1026 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
1027 print
'<td colspan="3">';
1028 print
'<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
1029 print
'<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET(
"address") ?
GETPOST(
"address",
'alphanohtml') :
$object->
address).
'</textarea>';
1030 print
'</div><div class="paddingrightonly valignmiddle inline-block">';
1031 if (!empty(
$conf->use_javascript_ajax)) {
1032 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a><br>';
1038 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1039 print $formcompany->select_ziptown((GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
1040 print $formcompany->select_ziptown((GETPOSTISSET(
"town") ?
GETPOST(
"town") :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1044 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1045 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1046 print $form->select_country(GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id") :
$object->country_id,
'country_id');
1048 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1055 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1057 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1060 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1061 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'alpha') :
$object->state_id,
$object->country_code,
'state_id');
1066 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
GETPOST(
'phone_pro',
'alpha'),
$object, 0).
'</td>';
1068 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1069 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') :
$object->phone_pro).
'"></td>';
1070 if (
$conf->browser->layout ==
'phone') {
1073 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'fax',
GETPOST(
'phone_perso',
'alpha'),
$object, 0).
'</td>';
1075 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1076 print
'<input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_perso') ?
GETPOST(
'phone_perso',
'alpha') :
$object->phone_perso).
'"></td></tr>';
1078 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'),
$object, 0,
'string',
'').
'</td>';
1080 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1081 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'"></td>';
1082 if (
$conf->browser->layout ==
'phone') {
1085 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'),
$object, 0).
'</td>';
1087 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1088 print
'<input type="text" name="fax" id="fax" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_fax') ?
GETPOST(
'phone_fax',
'alpha') :
$object->fax).
'"></td></tr>';
1091 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'),
$object, 0,
'string',
'', (
int) (
getDolGlobalInt(
'SOCIETE_EMAIL_MANDATORY'))).
'</td>';
1093 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1094 print
'<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->
email).
'"></td>';
1095 if (isModEnabled(
'mailing')) {
1096 if (
$conf->browser->layout ==
'phone') {
1099 $langs->load(
"mails");
1100 print
'<td class="nowrap">'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1101 print
'<td>'.$object->getNbOfEMailings().
'</td>';
1103 print
'<td colspan="2"></td>';
1108 if (isModEnabled(
'mailing')) {
1109 if (
$conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1110 print
"\n".
'<script type="text/javascript">'.
"\n";
1113 jQuery(document).ready(function () {
1114 function init_check_no_email(input) {
1115 if (input.val()!="") {
1116 $(".noemail").addClass("fieldrequired");
1118 $(".noemail").removeClass("fieldrequired");
1121 $("#email").keyup(function() {
1122 init_check_no_email($(this));
1124 init_check_no_email($("#email"));
1126 print
'</script>'.
"\n";
1128 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
1129 $result =
$object->getNoEmail();
1135 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1137 $useempty = (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
1138 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
$object->no_email), 1, false, (int) $useempty);
1144 if (isModEnabled(
'socialnetworks')) {
1145 $colspan = (
$conf->browser->layout ==
'phone' ? 2 : 4);
1147 $object->showSocialNetwork($socialnetworks, $colspan);
1149 print
'<tr><td'.($colspan ?
' colspan="'.$colspan.
'"' :
'').
'><hr></td></tr>';
1153 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
1154 $selectarray = array(
'0' => $langs->trans(
"ContactPublic"),
'1' => $langs->trans(
"ContactPrivate"));
1155 print $form->selectarray(
'priv', $selectarray,
$object->priv, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth150');
1160 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1161 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');
1167 print
'<tr><td class="tdtop"><label for="note_public">'.$langs->trans(
"NotePublic").
'</label></td><td colspan="3">';
1168 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1169 print $doleditor->Create(1);
1173 print
'<tr><td class="tdtop"><label for="note_private">'.$langs->trans(
"NotePrivate").
'</label></td><td colspan="3">';
1174 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 80,
'dolibarr_notes',
'In',
false,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1175 print $doleditor->Create(1);
1179 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
1180 print
'<td colspan="3">';
1181 print
$object->getLibStatut(4);
1185 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
1186 $arrayselected = array();
1187 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'',
$object, 0).
'</td>';
1188 print
'<td colspan="3">';
1189 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
'',
'', 64, 0, 3);
1191 $cats =
$c->containing(
$object->id,
'contact');
1192 foreach ($cats as $cat) {
1193 $arrayselected[] = $cat->id;
1195 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo, $arrayselected, 0, 0,
'', 0,
'90%');
1201 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1202 print
'<td colspan="3">';
1203 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$formcompany->showRoles(
"roles",
$object,
'edit',
$object->roles,
'');
1208 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'colspanvalue' =>
'3');
1209 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
1213 if (isModEnabled(
'order')) {
1214 print
'<tr><td>'.$langs->trans(
"ContactForOrders").
'</td><td colspan="3">';
1215 print
$object->ref_commande ?
$object->ref_commande : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>');
1219 if (isModEnabled(
"propal")) {
1220 print
'<tr><td>'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1221 print
$object->ref_propal ?
$object->ref_propal : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'</span>');
1225 if (isModEnabled(
'contract')) {
1226 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1227 print
$object->ref_contrat ?
$object->ref_contrat : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>');
1231 if (isModEnabled(
'invoice')) {
1232 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1233 print
$object->ref_facturation ?
$object->ref_facturation : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>');
1238 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1240 $dolibarr_user =
new User($db);
1241 $result = $dolibarr_user->fetch(
$object->user_id);
1242 print $dolibarr_user->getLoginUrl(1);
1244 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
1250 print
'<td>'.$langs->trans(
"PhotoFile").
'</td>';
1251 print
'<td colspan="3">';
1253 print $form->showphoto(
'contact',
$object);
1256 print
'<table class="nobordernopadding">';
1258 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
1263 $maxmin = $maxfilesizearray[
'maxmin'];
1265 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1267 print
'<input type="file" class="flat maxwidth200" name="photo" id="photoinput">';
1278 print $form->buttonsSaveCancel();
1285 if (
GETPOST(
'modelselected',
'alpha')) {
1286 $action =
'presend';
1290 if (!empty($id) && $action !=
'edit' && $action !=
'create') {
1298 if ($action ==
'create_user') {
1300 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1303 $generated_password =
'';
1304 if (empty($ldap_sid)) {
1305 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1308 $password = $generated_password;
1311 $formquestion = array(
1312 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
1313 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password),
1316 $text = $langs->trans(
"ConfirmCreateContact").
'<br>';
1317 if (isModEnabled(
"societe")) {
1319 $text .= $langs->trans(
"UserWillBeExternalUser");
1321 $text .= $langs->trans(
"UserWillBeInternalUser");
1324 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"CreateDolibarrLogin"), $text,
"confirm_create_user", $formquestion,
'yes');
1327 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1329 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/contact/vcard.php?id='.
$object->id.
'" class="refid">';
1330 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1331 $morehtmlref .=
'</a>';
1333 $morehtmlref .=
'<div class="refidno">';
1335 $objsoc->fetch(
$object->socid);
1337 if ($objsoc->id > 0) {
1338 $morehtmlref .= $objsoc->getNomUrl(1,
'contact');
1340 $morehtmlref .=
'<span class="opacitymedium">'.$langs->trans(
"ContactNotLinkedToCompany").
'</span>';
1343 $morehtmlref .=
'</div>';
1345 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
1348 print
'<div class="fichecenter">';
1349 print
'<div class="fichehalfleft">';
1351 print
'<div class="underbanner clearboth"></div>';
1352 print
'<table class="border tableforfield" width="100%">';
1355 print
'<tr><td class="titlefield">'.$langs->trans(
"UserTitle").
'</td><td>';
1356 print
$object->getCivilityLabel();
1360 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td><td>'.
$object->poste.
'</td></tr>';
1363 if (isModEnabled(
'mailing')) {
1364 $langs->load(
"mails");
1365 print
'<tr><td>'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1366 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?filteremail='.urlencode(
$object->email).
'">'.
$object->getNbOfEMailings().
'</a></td></tr>';
1370 if (isModEnabled(
'mailing')) {
1371 $result =
$object->getNoEmail();
1375 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
1379 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
1386 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1387 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
1390 $langs->load(
"languages");
1391 $labellang = (
$object->default_lang ? $langs->trans(
'Language_'.
$object->default_lang) :
'');
1397 print
'<tr><td>'.$langs->trans(
"ContactVisibility").
'</td><td>';
1407 print
'<div class="fichehalfright">';
1409 print
'<div class="underbanner clearboth"></div>';
1410 print
'<table class="border tableforfield centpercent">';
1414 if (
$object->thirdparty->client == 2 ||
$object->thirdparty->client == 3) {
1416 print
'<tr><td class="titlefield">';
1417 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1418 print $langs->trans(
'ProspectLevel');
1420 if ($action !=
'editlevel' && $user->hasRight(
'societe',
'contact',
'creer')) {
1421 print
'<td align="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
1423 print
'</tr></table>';
1425 if ($action ==
'editlevel') {
1426 $formcompany->formProspectContactLevel($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
int)
$object->fk_prospectlevel,
'prospect_contact_level_id', 1);
1428 print
$object->getLibProspLevel();
1434 $object->loadCacheOfProspStatus();
1435 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
1436 print
' ';
1437 print
'<div class="floatright">';
1438 foreach (
$object->cacheprospectstatus as $key => $val) {
1439 $titlealt =
'default';
1440 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1441 $titlealt = $val[
'label'];
1443 if (
$object->stcomm_id != $val[
'id']) {
1444 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>';
1447 print
'</div></td></tr>';
1452 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
1453 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1455 print $form->showCategories(
$object->id, Categorie::TYPE_CONTACT, 1);
1461 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1463 print $formcompany->showRoles(
"roles",
$object,
'view',
$object->roles,
'');
1468 $parameters = array(
'socid' => $socid);
1469 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1473 if (isModEnabled(
"propal")) {
1474 print
'<tr><td class="titlefield tdoverflow">'.$langs->trans(
"ContactForProposals").
'</td><td>';
1475 print
$object->ref_propal ?
$object->ref_propal :
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'<span>';
1479 if (isModEnabled(
'order') || isModEnabled(
"shipping")) {
1480 print
'<tr><td class="titlefield tdoverflow">';
1481 if (isModEnabled(
"shipping")) {
1482 print $langs->trans(
"ContactForOrdersOrShipments");
1484 print $langs->trans(
"ContactForOrders");
1487 $none =
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>';
1488 if (isModEnabled(
"shipping")) {
1489 $none =
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrderOrShipments").
'</span>';
1495 if (isModEnabled(
'contract')) {
1496 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForContracts").
'</td><td>';
1497 print
$object->ref_contrat ?
$object->ref_contrat :
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>';
1501 if (isModEnabled(
'invoice')) {
1502 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForInvoices").
'</td><td>';
1503 print
$object->ref_facturation ?
$object->ref_facturation :
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>';
1507 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td>';
1509 $dolibarr_user =
new User($db);
1510 $result = $dolibarr_user->fetch(
$object->user_id);
1511 print $dolibarr_user->getLoginUrl(-1);
1514 if (!
$object->user_id && $user->hasRight(
'user',
'user',
'creer')) {
1515 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>';
1522 print
'</div></div>';
1523 print
'<div class="clearboth"></div>';
1530 print
'<div class="tabsAction">';
1532 $parameters = array();
1533 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1534 if (empty($reshook) && $action !=
'presend') {
1535 if (empty($user->socid)) {
1537 $langs->load(
"mails");
1538 print
'<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans(
'SendMail').
'</a></div>';
1540 $langs->load(
"mails");
1541 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a></div>';
1545 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1546 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
1550 if (
$object->statut == 0 && $user->hasRight(
'societe',
'contact',
'creer')) {
1551 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Reactivate").
'</a>';
1554 if (
$object->statut == 1 && $user->hasRight(
'societe',
'contact',
'creer')) {
1555 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=disable&id='.
$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"DisableUser").
'</a>';
1559 if ($user->hasRight(
'societe',
'contact',
'supprimer')) {
1560 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().($backtopage ?
'&backtopage='.urlencode($backtopage) :
''),
'delete', $user->hasRight(
'societe',
'contact',
'supprimer'));
1567 if (
GETPOST(
'modelselected')) {
1568 $action =
'presend';
1571 if ($action !=
'presend') {
1572 print
'<div class="fichecenter"><div class="fichehalfleft">';
1574 print
'</div><div class="fichehalfright">';
1578 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contact/agenda.php?id='.
$object->id);
1581 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1583 $somethingshown = $formactions->showactions(
$object,
'contact',
$object->socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
1585 print
'</div></div>';
1589 $modelmail =
'contact';
1590 $defaulttopic =
'Information';
1591 $diroutput =
$conf->societe->dir_output.
'/contact/';
1592 $trackid =
'ctc'.$object->id;
1594 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 categories.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=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_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
getArrayOfSocialNetworks()
Get array of social network dictionary.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_htmloutput_errors($mesgstring='', $mesgarray=array(), $keepembedded=0)
Print formatted error messages to output (Used to show messages on html output).
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
div refaddress div address
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.