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';
54$langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
60$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
61$confirm =
GETPOST(
'confirm',
'alpha');
62$backtopage =
GETPOST(
'backtopage',
'alpha');
63$cancel =
GETPOST(
'cancel',
'alpha');
72$extrafields->fetch_name_optionals_label(
$object->table_element);
81 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
82 $objcanvas =
new Canvas($db, $action);
83 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
87$hookmanager->initHooks(array(
'contactcard',
'globalcard'));
94if (!(
$object->id > 0) && $action ==
'view') {
95 $langs->load(
"errors");
96 print($langs->trans(
'ErrorRecordNotFound'));
100$triggermodname =
'CONTACT_MODIFY';
101$permissiontoadd = $user->hasRight(
'societe',
'contact',
'creer');
105 $socid = $user->socid;
110$result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
117$parameters = array(
'id' => $id,
'objcanvas' => $objcanvas);
118$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
123if (empty($reshook)) {
124 $backurlforlist = DOL_URL_ROOT.
'/contact/list.php';
126 if (empty($backtopage) || ($cancel && empty($id))) {
127 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
128 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
129 $backtopage = $backurlforlist;
131 $backtopage = DOL_URL_ROOT.
'/contact/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
137 if (!empty($backtopageforcancel)) {
138 header(
"Location: ".$backtopageforcancel);
140 } elseif (!empty($backtopage)) {
141 header(
"Location: ".$backtopage);
148 if ($action ==
'confirm_create_user' && $confirm ==
'yes' && $user->hasRight(
'user',
'user',
'creer')) {
156 $nuser =
new User($db);
160 $result2 = $nuser->setPassword($user,
GETPOST(
"password"), 0, 0, 1);
161 if (is_int($result2) && $result2 < 0) {
162 $error = $nuser->error;
163 $errors = $nuser->errors;
169 $error = $nuser->error;
170 $errors = $nuser->errors;
181 if ($action ==
'disable' && $permissiontoadd) {
183 if (
$object->setstatus(0) < 0) {
186 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
192 if ($action ==
'enable' && $permissiontoadd) {
194 if (
$object->setstatus(1) < 0) {
197 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$id);
203 if ($action ==
'add' && $permissiontoadd) {
214 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
221 $object->socialnetworks = array();
222 if (isModEnabled(
'socialnetworks')) {
223 foreach ($socialnetworks as $key => $value) {
224 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
225 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
229 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
233 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
236 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
237 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
250 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
256 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
$object->no_email == -1 && !empty(
$object->email)) {
258 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
263 $langs->load(
"errors");
265 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
269 if (empty(
$object->lastname)) {
271 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
286 $contcats =
GETPOST(
'contcats',
'array');
287 if (count($contcats) > 0) {
288 $result =
$object->setCategories($contcats);
297 if (empty($error) && isModEnabled(
'mailing') && !empty(
$object->email)) {
307 if (empty($error) && $id > 0) {
309 if (!empty($backtopage)) {
310 $url = str_replace(
'__ID__', (
string) $id, $backtopage);
312 $url =
'card.php?id='.$id;
314 header(
"Location: ".$url);
321 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->hasRight(
'societe',
'contact',
'supprimer')) {
325 $result =
$object->delete($user);
328 if ($backurlforlist) {
329 header(
"Location: ".$backurlforlist);
332 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
340 if ($action ==
'update' && empty($cancel) && $permissiontoadd) {
341 if (!
GETPOST(
"lastname",
'alpha')) {
343 $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
347 if (isModEnabled(
'mailing') &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2 &&
GETPOSTINT(
"no_email") == -1 && !empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
349 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"No_Email"));
353 if (!empty(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL)) && !
isValidEmail(
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL))) {
354 $langs->load(
"errors");
356 $errors[] = $langs->trans(
"ErrorBadEMail",
GETPOST(
'email',
'alpha'));
366 $dir = $conf->societe->multidir_output[
$object->entity].
"/contact/".
$object->id.
"/photos";
367 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
369 $fileimg = $dir.
'/'.
$object->photo;
370 $dirthumbs = $dir.
'/thumbs';
383 if (!($result > 0)) {
384 $errors[] =
"ErrorFailedToSaveFile";
393 $errors[] =
"ErrorBadImageFormat";
396 switch ($_FILES[
'photo'][
'error']) {
399 $errors[] =
"ErrorFileSizeTooLarge";
402 $errors[] =
"ErrorFilePartiallyUploaded";
412 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
421 $object->email = (string)
GETPOST(
'email',
'custom', 0, FILTER_SANITIZE_EMAIL);
423 $object->socialnetworks = array();
424 if (isModEnabled(
'socialnetworks')) {
425 foreach ($socialnetworks as $key => $value) {
426 if (GETPOSTISSET($key) &&
GETPOST($key,
'alphanohtml') !=
'') {
427 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
433 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
436 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
437 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
445 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
451 $result =
$object->update($contactid, $user);
455 $categories =
GETPOST(
'contcats',
'array');
456 $object->setCategories($categories);
459 if (GETPOSTISSET(
'no_email') &&
$object->email) {
461 $result =
$object->setNoEmail($no_email);
474 if (!$error && empty($errors)) {
475 if (!empty($backtopage)) {
476 header(
"Location: ".$backtopage);
485 if ($action ==
'setprospectcontactlevel' && $permissiontoadd) {
487 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
495 if ($action ==
'setstcomm' && $permissiontoadd) {
505 if ($action ==
"update_extras" && $permissiontoadd) {
508 $attributekey =
GETPOST(
'attribute',
'alpha');
509 $attributekeylong =
'options_'.$attributekey;
511 if (GETPOSTISSET($attributekeylong.
'day') && GETPOSTISSET($attributekeylong.
'month') && GETPOSTISSET($attributekeylong.
'year')) {
516 $object->array_options[
'options_'.$attributekey] =
GETPOST($attributekeylong,
'alpha');
519 $result =
$object->insertExtraFields(empty($triggermodname) ?
'' : $triggermodname, $user);
525 $action =
'edit_extras';
530 if ($action ==
'update_extras' && $user->hasRight(
'societe',
'contact',
'creer')) {
534 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
540 $result =
$object->insertExtraFields(
'CONTACT_MODIFY');
548 $action =
'edit_extras';
553 $triggersendname =
'CONTACT_SENTBYMAIL';
555 $mode =
'emailfromcontact';
556 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
564$form =
new Form($db);
570 $objsoc->fetch($socid);
573$title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
578 $title = (
getDolGlobalString(
'SOCIETE_ADDRESSES_MANAGEMENT') ? $langs->trans(
"NewContact") : $langs->trans(
"NewContactAddress"));
580$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
584$countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
586if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
590 if (empty(
$object->error) && $id) {
598 $objcanvas->display_canvas($action);
605 if ($user->hasRight(
'societe',
'contact',
'supprimer')) {
606 if ($action ==
'delete') {
607 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
618 $res =
$object->fetch($id, $user);
629 if ($user->hasRight(
'societe',
'contact',
'creer')) {
630 if ($action ==
'create') {
639 $object->country_id =
GETPOST(
"country_id") ?
GETPOSTINT(
"country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
642 $object->country_code = $tmparray[
'code'];
643 $object->country = $tmparray[
'label'];
653 if ($conf->use_javascript_ajax) {
654 print
"\n".
'<script type="text/javascript">'.
"\n";
655 print
'jQuery(document).ready(function () {
656 jQuery("#selectcountry_id").change(function() {
657 document.formsoc.action.value="create";
658 document.formsoc.submit();
661 $("#copyaddressfromsoc").click(function() {
662 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
663 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
664 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
665 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
666 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
667 /* set country at end because it will trigger page refresh */
668 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
669 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
672 print
'</script>'.
"\n";
675 print
'<form method="post" name="formsoc" action="'.$_SERVER[
"PHP_SELF"].
'">';
676 print
'<input type="hidden" name="token" value="'.newToken().
'">';
677 print
'<input type="hidden" name="action" value="add">';
678 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
679 if (!empty($objsoc)) {
680 print
'<input type="hidden" name="entity" value="'.$objsoc->entity.
'">';
685 print
'<table class="border centpercent">';
688 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
689 print
'<td colspan="3"><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(
GETPOST(
"lastname",
'alpha') ?
GETPOST(
"lastname",
'alpha') :
$object->lastname).
'" autofocus="autofocus"></td>';
694 print
'<td><label for="firstname">';
695 print $form->textwithpicto($langs->trans(
"Firstname"), $langs->trans(
"KeepEmptyIfGenericAddress")).
'</label></td>';
696 print
'<td colspan="3"><input name="firstname" id="firstname"type="text" class="maxwidth100onsmartphone" maxlength="80" value="'.dol_escape_htmltag(
GETPOST(
"firstname",
'alpha') ?
GETPOST(
"firstname",
'alpha') :
$object->firstname).
'"></td>';
702 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
703 print
'<td colspan="3" class="maxwidthonsmartphone">';
704 print $objsoc->getNomUrl(1,
'contact');
706 print
'<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.
'">';
709 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
710 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($socid,
'socid',
'',
'SelectThirdParty', 0, 0,
null, 0,
'minwidth300 maxwidth500 widthcentpercentminusxx');
716 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
717 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'alpha') :
$object->civility_code,
'civility_code');
721 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
722 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>';
725 if ($conf->use_javascript_ajax && $socid > 0) {
730 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->address)) == 0) {
731 $object->address = $objsoc->address;
733 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
734 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>';
736 if ($conf->use_javascript_ajax && $socid > 0) {
742 print
'<td class="valignmiddle center" rowspan="'.$rowspan.
'">';
743 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a>';
752 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->town)) == 0) {
755 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
756 print $formcompany->select_ziptown((
GETPOST(
"zipcode",
'alpha') ?
GETPOST(
"zipcode",
'alpha') :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
757 print $formcompany->select_ziptown((
GETPOST(
"town",
'alpha') ?
GETPOST(
"town",
'alpha') :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
761 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
762 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
763 print $form->select_country((
GETPOST(
"country_id",
'alpha') ?
GETPOST(
"country_id",
'alpha') :
$object->country_id),
'country_id');
765 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
772 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
774 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
778 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
779 print $formcompany->select_state(
GETPOST(
"state_id",
'alpha') ?
GETPOST(
"state_id",
'alpha') :
$object->state_id,
$object->country_code,
'state_id');
781 print $countrynotdefined;
786 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->phone_pro)) == 0) {
787 $object->phone_pro = $objsoc->phone;
794 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
'',
$object, 0).
'</td>';
796 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
797 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') :
$object->phone_pro).
'"></td>';
798 if ($conf->browser->layout ==
'phone') {
801 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'phone_perso',
'',
$object, 0).
'</td>';
803 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
804 print
'<input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_perso') ?
GETPOST(
'phone_perso',
'alpha') :
$object->phone_perso).
'"></td>';
807 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'',
$object, 0).
'</td>';
809 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
810 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') :
$object->phone_mobile).
'"></td>';
811 if ($conf->browser->layout ==
'phone') {
814 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'',
$object, 0).
'</td>';
816 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
817 print
'<input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') :
$object->fax).
'"></td>';
820 if (((isset($objsoc->typent_code) && $objsoc->typent_code ==
'TE_PRIVATE') ||
getDolGlobalString(
'CONTACT_USE_COMPANY_ADDRESS')) &&
dol_strlen(trim(
$object->email)) == 0) {
821 $object->email = $objsoc->email;
825 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'',
$object, 0,
'string',
'').
'</td>';
827 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
828 print
'<input type="text" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->email).
'"></td>';
832 if (isModEnabled(
'mailing')) {
833 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
834 print
"\n".
'<script type="text/javascript">'.
"\n";
835 print
'$(document).ready(function () {
836 $("#email").keyup(function() {
837 if ($(this).val()!="") {
838 $(".noemail").addClass("fieldrequired");
840 $(".noemail").removeClass("fieldrequired");
844 print
'</script>'.
"\n";
846 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
847 $result =
$object->getNoEmail();
853 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
856 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS')), 1, false, (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2));
862 if (isModEnabled(
'socialnetworks')) {
863 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
867 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
868 $selectarray = array(
'0' => $langs->trans(
"ContactPublic"),
'1' => $langs->trans(
"ContactPrivate"));
869 print $form->selectarray(
'priv', $selectarray, (
GETPOST(
"priv",
'alpha') ?
GETPOST(
"priv",
'alpha') :
$object->priv), 0);
874 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
875 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : (
$object->default_lang ?
$object->default_lang :
''),
'default_lang', 0, 0, 1, 0, 0,
'maxwidth200onsmartphone');
881 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
882 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'',
$object, 0).
'</td><td colspan="3">';
883 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
'',
'parent', 64, 0, 3);
884 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'),
null,
null,
null,
null,
'90%');
889 if (!empty($socid)) {
890 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
891 print
'<td colspan="3">';
892 $contactType =
$object->listeTypeContacts(
'external',
'', 1);
893 print
img_picto(
'',
'contact',
'class="pictofixedwidth"').$form->multiselectarray(
'roles', $contactType, array(), 0, 0,
'', 0,
'90%');
898 $parameters = array(
'socid' => $socid,
'objsoc' => $objsoc,
'colspan' =>
' colspan="3"',
'cols' => 3,
'colspanvalue' => 3);
899 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
901 print
"</table><br>";
903 print
'<hr style="margin-bottom: 20px">';
906 print
load_fiche_titre(
'<div class="comboperso">'.$langs->trans(
"PersonalInformations").
'</div>',
'',
'');
908 print
'<table class="border centpercent">';
911 print
'<tr><td><label for="birthday">'.$langs->trans(
"DateOfBirth").
'</label></td><td>';
912 $form =
new Form($db);
914 print $form->selectDate(
$object->birthday,
'birthday', 0, 0, 0,
"perso", 1, 0);
916 print $form->selectDate(
'',
'birthday', 0, 0, 1,
"perso", 1, 0);
920 print
'<td><label for="birthday_alert">'.$langs->trans(
"Alert").
'</label>: ';
921 if (!empty(
$object->birthday_alert)) {
922 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
924 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert">';
933 print $form->buttonsSaveCancel(
"Add");
936 } elseif ($action ==
'edit' && !empty($id)) {
942 if (GETPOSTISSET(
"country_id") ||
$object->country_id) {
944 $object->country_code = $tmparray[
'code'];
945 $object->country = $tmparray[
'label'];
949 $objsoc->fetch(
$object->socid);
954 if ($conf->use_javascript_ajax) {
955 print
"\n".
'<script type="text/javascript">'.
"\n";
956 print
'jQuery(document).ready(function () {
957 jQuery("#selectcountry_id").change(function() {
958 document.formsoc.action.value="edit";
959 document.formsoc.submit();
962 $("#copyaddressfromsoc").click(function() {
963 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
964 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
965 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
966 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
967 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
968 /* set country at end because it will trigger page refresh */
969 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
970 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
973 print
'</script>'.
"\n";
976 print
'<form enctype="multipart/form-data" method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" name="formsoc">';
977 print
'<input type="hidden" name="token" value="'.newToken().
'">';
978 print
'<input type="hidden" name="id" value="'.$id.
'">';
979 print
'<input type="hidden" name="action" value="update">';
980 print
'<input type="hidden" name="contactid" value="'.$object->id.
'">';
981 if (!empty($backtopage)) {
982 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
987 print
'<table class="border centpercent">';
991 print
'<tr><td>'.$langs->trans(
"ID").
'</td><td colspan="3">';
997 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
998 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>';
1002 print
'<td><label for="firstname">'.$langs->trans(
"Firstname").
'</label></td>';
1003 print
'<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"firstname") ?
GETPOST(
"firstname") :
$object->firstname).
'"></td>';
1008 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
1009 print
'<td colspan="3" class="maxwidthonsmartphone">';
1010 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
GETPOSTINT(
'socid') ?
GETPOSTINT(
'socid') : (
$object->socid ?
$object->socid : -1),
'socid',
'', $langs->trans(
"SelectThirdParty"));
1016 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
1017 print $formcompany->select_civility(GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
"aZ09") :
$object->civility_code,
'civility_code');
1021 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
1022 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>';
1025 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
1026 print
'<td colspan="3">';
1027 print
'<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
1028 print
'<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET(
"address") ?
GETPOST(
"address",
'alphanohtml') :
$object->address).
'</textarea>';
1029 print
'</div><div class="paddingrightonly valignmiddle inline-block">';
1030 if (!empty($conf->use_javascript_ajax)) {
1031 print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a><br>';
1037 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1038 print $formcompany->select_ziptown((GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") :
$object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
1039 print $formcompany->select_ziptown((GETPOSTISSET(
"town") ?
GETPOST(
"town") :
$object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1043 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1044 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1045 print $form->select_country(GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id") :
$object->country_id,
'country_id');
1047 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1054 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1056 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1059 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1060 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'alpha') :
$object->state_id,
$object->country_code,
'state_id');
1065 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
GETPOST(
'phone_pro',
'alpha'),
$object, 0).
'</td>';
1067 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1068 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>';
1069 if ($conf->browser->layout ==
'phone') {
1072 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'fax',
GETPOST(
'phone_perso',
'alpha'),
$object, 0).
'</td>';
1074 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
1075 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>';
1077 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'),
$object, 0,
'string',
'').
'</td>';
1079 print
img_picto(
'',
'object_phoning_mobile',
'class="pictofixedwidth"');
1080 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>';
1081 if ($conf->browser->layout ==
'phone') {
1084 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'),
$object, 0).
'</td>';
1086 print
img_picto(
'',
'object_phoning_fax',
'class="pictofixedwidth"');
1087 print
'<input type="text" name="fax" id="fax" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_fax') ?
GETPOST(
'phone_fax',
'alpha') :
$object->fax).
'"></td></tr>';
1090 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'),
$object, 0,
'string',
'', (
getDolGlobalString(
'SOCIETE_EMAIL_MANDATORY'))).
'</td>';
1092 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
1093 print
'<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->email).
'"></td>';
1094 if (isModEnabled(
'mailing')) {
1095 if ($conf->browser->layout ==
'phone') {
1098 $langs->load(
"mails");
1099 print
'<td class="nowrap">'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1100 print
'<td>'.$object->getNbOfEMailings().
'</td>';
1102 print
'<td colspan="2"></td>';
1107 if (isModEnabled(
'mailing')) {
1108 if ($conf->use_javascript_ajax &&
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2) {
1109 print
"\n".
'<script type="text/javascript">'.
"\n";
1112 jQuery(document).ready(function () {
1113 function init_check_no_email(input) {
1114 if (input.val()!="") {
1115 $(".noemail").addClass("fieldrequired");
1117 $(".noemail").removeClass("fieldrequired");
1120 $("#email").keyup(function() {
1121 init_check_no_email($(this));
1123 init_check_no_email($("#email"));
1125 print
'</script>'.
"\n";
1127 if (!GETPOSTISSET(
"no_email") && !empty(
$object->email)) {
1128 $result =
$object->getNoEmail();
1134 print
'<td class="noemail"><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1136 $useempty = (
getDolGlobalInt(
'MAILING_CONTACT_DEFAULT_BULK_STATUS') == 2);
1137 print $form->selectyesno(
'no_email', (GETPOSTISSET(
"no_email") ?
GETPOSTINT(
"no_email") :
$object->no_email), 1, false, $useempty);
1143 if (isModEnabled(
'socialnetworks')) {
1144 $object->showSocialNetwork($socialnetworks, ($conf->browser->layout ==
'phone' ? 2 : 4));
1148 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
1149 $selectarray = array(
'0' => $langs->trans(
"ContactPublic"),
'1' => $langs->trans(
"ContactPrivate"));
1150 print $form->selectarray(
'priv', $selectarray,
$object->priv, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth150');
1155 print
'<tr><td>'.$form->editfieldkey(
'DefaultLang',
'default_lang',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">'.
"\n";
1156 print
img_picto(
'',
'language',
'class="pictofixedwidth"').$formadmin->select_language(
GETPOST(
'default_lang',
'alpha') ?
GETPOST(
'default_lang',
'alpha') : (
$object->default_lang ?
$object->default_lang :
''),
'default_lang', 0, 0, 1, 0, 0,
'maxwidth200onsmartphone');
1162 print
'<tr><td class="tdtop"><label for="note_public">'.$langs->trans(
"NotePublic").
'</label></td><td colspan="3">';
1163 $doleditor =
new DolEditor(
'note_public',
$object->note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_3,
'90%');
1164 print $doleditor->Create(1);
1168 print
'<tr><td class="tdtop"><label for="note_private">'.$langs->trans(
"NotePrivate").
'</label></td><td colspan="3">';
1169 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false, !
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_3,
'90%');
1170 print $doleditor->Create(1);
1174 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
1175 print
'<td colspan="3">';
1176 print
$object->getLibStatut(4);
1180 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
1181 $arrayselected = array();
1182 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'',
$object, 0).
'</td>';
1183 print
'<td colspan="3">';
1184 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT,
'',
'', 64, 0, 3);
1186 $cats = $c->containing(
$object->id,
'contact');
1187 foreach ($cats as $cat) {
1188 $arrayselected[] = $cat->id;
1190 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'contcats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
1196 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1197 print
'<td colspan="3">';
1198 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$formcompany->showRoles(
"roles",
$object,
'edit',
$object->roles,
'');
1203 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' =>
'3',
'colspanvalue' =>
'3');
1204 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
1208 if (isModEnabled(
'order')) {
1209 print
'<tr><td>'.$langs->trans(
"ContactForOrders").
'</td><td colspan="3">';
1210 print
$object->ref_commande ?
$object->ref_commande : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>');
1214 if (isModEnabled(
"propal")) {
1215 print
'<tr><td>'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1216 print
$object->ref_propal ?
$object->ref_propal : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'</span>');
1220 if (isModEnabled(
'contract')) {
1221 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1222 print
$object->ref_contrat ?
$object->ref_contrat : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>');
1226 if (isModEnabled(
'invoice')) {
1227 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1228 print
$object->ref_facturation ?
$object->ref_facturation : (
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>');
1233 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1235 $dolibarr_user =
new User($db);
1236 $result = $dolibarr_user->fetch(
$object->user_id);
1237 print $dolibarr_user->getLoginUrl(1);
1239 print
'<span class="opacitymedium">'.$langs->trans(
"NoDolibarrAccess").
'</span>';
1245 print
'<td>'.$langs->trans(
"PhotoFile").
'</td>';
1246 print
'<td colspan="3">';
1248 print $form->showphoto(
'contact',
$object);
1251 print
'<table class="nobordernopadding">';
1253 print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
1258 $maxmin = $maxfilesizearray[
'maxmin'];
1260 print
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
1262 print
'<input type="file" class="flat maxwidth200" name="photo" id="photoinput">';
1273 print $form->buttonsSaveCancel();
1280 if (
GETPOST(
'modelselected',
'alpha')) {
1281 $action =
'presend';
1285 if (!empty($id) && $action !=
'edit' && $action !=
'create') {
1293 if ($action ==
'create_user') {
1295 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1298 $generated_password =
'';
1299 if (empty($ldap_sid)) {
1300 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1303 $password = $generated_password;
1306 $formquestion = array(
1307 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
1308 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password),
1311 $text = $langs->trans(
"ConfirmCreateContact").
'<br>';
1312 if (isModEnabled(
"societe")) {
1314 $text .= $langs->trans(
"UserWillBeExternalUser");
1316 $text .= $langs->trans(
"UserWillBeInternalUser");
1319 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"CreateDolibarrLogin"), $text,
"confirm_create_user", $formquestion,
'yes');
1322 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1324 $morehtmlref =
'<a href="'.DOL_URL_ROOT.
'/contact/vcard.php?id='.
$object->id.
'" class="refid">';
1325 $morehtmlref .=
img_picto($langs->trans(
"Download").
' '.$langs->trans(
"VCard"),
'vcard.png',
'class="valignmiddle marginleftonly paddingrightonly"');
1326 $morehtmlref .=
'</a>';
1328 $morehtmlref .=
'<div class="refidno">';
1330 $objsoc->fetch(
$object->socid);
1332 if ($objsoc->id > 0) {
1333 $morehtmlref .= $objsoc->getNomUrl(1,
'contact');
1335 $morehtmlref .=
'<span class="opacitymedium">'.$langs->trans(
"ContactNotLinkedToCompany").
'</span>';
1338 $morehtmlref .=
'</div>';
1340 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
1343 print
'<div class="fichecenter">';
1344 print
'<div class="fichehalfleft">';
1346 print
'<div class="underbanner clearboth"></div>';
1347 print
'<table class="border tableforfield" width="100%">';
1350 print
'<tr><td class="titlefield">'.$langs->trans(
"UserTitle").
'</td><td>';
1351 print
$object->getCivilityLabel();
1355 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td><td>'.
$object->poste.
'</td></tr>';
1358 if (isModEnabled(
'mailing')) {
1359 $langs->load(
"mails");
1360 print
'<tr><td>'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1361 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?filteremail='.urlencode(
$object->email).
'">'.
$object->getNbOfEMailings().
'</a></td></tr>';
1365 if (isModEnabled(
'mailing')) {
1366 $result =
$object->getNoEmail();
1370 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>';
1374 print
'<span class="opacitymedium">'.$langs->trans(
"EMailNotDefined").
'</span>';
1381 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1382 print
'<tr><td>'.$langs->trans(
"DefaultLang").
'</td><td>';
1385 $langs->load(
"languages");
1386 $labellang = (
$object->default_lang ? $langs->trans(
'Language_'.
$object->default_lang) :
'');
1392 print
'<tr><td>'.$langs->trans(
"ContactVisibility").
'</td><td>';
1402 print
'<div class="fichehalfright">';
1404 print
'<div class="underbanner clearboth"></div>';
1405 print
'<table class="border tableforfield centpercent">';
1409 if (
$object->thirdparty->client == 2 ||
$object->thirdparty->client == 3) {
1411 print
'<tr><td class="titlefield">';
1412 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1413 print $langs->trans(
'ProspectLevel');
1415 if ($action !=
'editlevel' && $user->hasRight(
'societe',
'contact',
'creer')) {
1416 print
'<td align="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
1418 print
'</tr></table>';
1420 if ($action ==
'editlevel') {
1421 $formcompany->formProspectContactLevel($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_prospectlevel,
'prospect_contact_level_id', 1);
1423 print
$object->getLibProspLevel();
1429 $object->loadCacheOfProspStatus();
1430 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.
$object->getLibProspCommStatut(4,
$object->cacheprospectstatus[
$object->stcomm_id][
'label']);
1431 print
' ';
1432 print
'<div class="floatright">';
1433 foreach (
$object->cacheprospectstatus as $key => $val) {
1434 $titlealt =
'default';
1435 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) {
1436 $titlealt = $val[
'label'];
1438 if (
$object->stcomm_id != $val[
'id']) {
1439 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>';
1442 print
'</div></td></tr>';
1447 if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire')) {
1448 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1450 print $form->showCategories(
$object->id, Categorie::TYPE_CONTACT, 1);
1456 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1458 print $formcompany->showRoles(
"roles",
$object,
'view',
$object->roles,
'');
1463 $parameters = array(
'socid' => $socid);
1464 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1468 if (isModEnabled(
"propal")) {
1469 print
'<tr><td class="titlefield tdoverflow">'.$langs->trans(
"ContactForProposals").
'</td><td>';
1470 print
$object->ref_propal ?
$object->ref_propal :
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyProposal").
'<span>';
1474 if (isModEnabled(
'order') || isModEnabled(
"shipping")) {
1475 print
'<tr><td class="titlefield tdoverflow">';
1476 if (isModEnabled(
"shipping")) {
1477 print $langs->trans(
"ContactForOrdersOrShipments");
1479 print $langs->trans(
"ContactForOrders");
1482 $none =
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrder").
'</span>';
1483 if (isModEnabled(
"shipping")) {
1484 $none =
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyOrderOrShipments").
'</span>';
1490 if (isModEnabled(
'contract')) {
1491 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForContracts").
'</td><td>';
1492 print
$object->ref_contrat ?
$object->ref_contrat :
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyContract").
'</span>';
1496 if (isModEnabled(
'invoice')) {
1497 print
'<tr><td class="tdoverflow">'.$langs->trans(
"ContactForInvoices").
'</td><td>';
1498 print
$object->ref_facturation ?
$object->ref_facturation :
'<span class="opacitymedium">'.$langs->trans(
"NoContactForAnyInvoice").
'</span>';
1502 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td>';
1504 $dolibarr_user =
new User($db);
1505 $result = $dolibarr_user->fetch(
$object->user_id);
1506 print $dolibarr_user->getLoginUrl(-1);
1509 if (!
$object->user_id && $user->hasRight(
'user',
'user',
'creer')) {
1510 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>';
1517 print
'</div></div>';
1518 print
'<div class="clearboth"></div>';
1525 print
'<div class="tabsAction">';
1527 $parameters = array();
1528 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
1529 if (empty($reshook) && $action !=
'presend') {
1530 if (empty($user->socid)) {
1532 $langs->load(
"mails");
1533 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>';
1535 $langs->load(
"mails");
1536 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a></div>';
1540 if ($user->hasRight(
'societe',
'contact',
'creer')) {
1541 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=edit&token='.
newToken().
'">'.$langs->trans(
'Modify').
'</a>';
1545 if (
$object->statut == 0 && $user->hasRight(
'societe',
'contact',
'creer')) {
1546 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=enable&token='.
newToken().
'">'.$langs->trans(
"Reactivate").
'</a>';
1549 if (
$object->statut == 1 && $user->hasRight(
'societe',
'contact',
'creer')) {
1550 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=disable&id='.
$object->id.
'&token='.
newToken().
'">'.$langs->trans(
"DisableUser").
'</a>';
1554 if ($user->hasRight(
'societe',
'contact',
'supprimer')) {
1555 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'));
1562 if (
GETPOST(
'modelselected')) {
1563 $action =
'presend';
1566 if ($action !=
'presend') {
1567 print
'<div class="fichecenter"><div class="fichehalfleft">';
1569 print
'</div><div class="fichehalfright">';
1573 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/contact/agenda.php?id='.
$object->id);
1576 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1578 $somethingshown = $formactions->showactions(
$object,
'contact',
$object->socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
1580 print
'</div></div>';
1584 $modelmail =
'contact';
1585 $defaulttopic =
'Information';
1586 $diroutput = $conf->societe->dir_output.
'/contact/';
1587 $trackid =
'ctc'.$object->id;
1589 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage categories.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0, $indexdatabase=1, $nolog=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories)
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles='addedfile', $upload_dir='')
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
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.
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.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.
getDolGlobalString($key, $default='')
Return 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)
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
getMaxFileSizeArray()
Return the max allowed for file upload.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.