35 require
'../main.inc.php';
36 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/contact.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
50 $langs->loadLangs(array(
'companies',
'users',
'other',
'commercial'));
52 $mesg =
''; $error = 0; $errors = array();
54 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
55 $confirm =
GETPOST(
'confirm',
'alpha');
56 $backtopage =
GETPOST(
'backtopage',
'alpha');
57 $cancel =
GETPOST(
'cancel',
'alpha');
60 $socid =
GETPOST(
'socid',
'int');
66 $extrafields->fetch_name_optionals_label($object->table_element);
71 $object->getCanvas($id);
73 $canvas = (!empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas"));
76 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
77 $objcanvas =
new Canvas($db, $action);
78 $objcanvas->getCanvas(
'contact',
'contactcard', $canvas);
82 if ($user->socid) $socid = $user->socid;
83 $result =
restrictedArea($user,
'contact', $id,
'socpeople&societe',
'',
'',
'rowid', 0);
86 $hookmanager->initHooks(array(
'contactcard',
'globalcard'));
88 if ($id > 0) $object->fetch($id);
90 if (!($object->id > 0) && $action ==
'view')
92 $langs->load(
"errors");
93 print($langs->trans(
'ErrorRecordNotFound'));
101 $parameters = array(
'id'=>$id,
'objcanvas'=>$objcanvas);
102 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
103 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
108 if (
GETPOST(
'cancel',
'alpha') && !empty($backtopage))
110 header(
"Location: ".$backtopage);
115 if ($action ==
'confirm_create_user' && $confirm ==
'yes' && $user->rights->user->user->creer)
118 $result = $object->fetch($id);
125 $nuser =
new User($db);
126 $result = $nuser->create_from_contact($object,
GETPOST(
"login"));
130 $result2 = $nuser->setPassword($user,
GETPOST(
"password"), 0, 0, 1);
135 $error = $nuser->error; $errors = $nuser->errors;
139 $error = $nuser->error; $errors = $nuser->errors;
143 $error = $object->error; $errors = $object->errors;
149 if ($action ==
'disable')
152 if ($object->setstatus(0) < 0)
156 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?id='.$id);
162 if ($action ==
'enable')
165 if ($object->setstatus(1) < 0)
169 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?id='.$id);
175 if ($action ==
'add' && $user->rights->societe->contact->creer)
179 if ($canvas) $object->canvas = $canvas;
182 $object->socid =
GETPOST(
"socid",
'int');
183 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
184 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
185 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
186 $object->poste = (string)
GETPOST(
"poste",
'alpha');
187 $object->address = (string)
GETPOST(
"address",
'alpha');
188 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
189 $object->town = (string)
GETPOST(
"town",
'alpha');
190 $object->country_id = (int)
GETPOST(
"country_id",
'int');
191 $object->state_id = (int)
GETPOST(
"state_id",
'int');
197 $object->socialnetworks = array();
198 if (!empty($conf->socialnetworks->enabled)) {
199 foreach ($socialnetworks as $key => $value) {
201 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
205 $object->email = (string)
GETPOST(
"email",
'alpha');
206 $object->no_email =
GETPOST(
"no_email",
"int");
207 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
208 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
209 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
210 $object->fax = (string)
GETPOST(
"fax",
'alpha');
211 $object->priv =
GETPOST(
"priv",
'int');
212 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
213 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
214 $object->roles =
GETPOST(
"roles",
'array');
220 $object->birthday_alert =
GETPOST(
"birthday_alert",
'alpha');
223 $ret = $extrafields->setOptionalsFromPost(null, $object);
232 $errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Lastname").
' / '.$langs->transnoentities(
"Label"));
238 $id = $object->create($user);
242 $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors));
246 $contcats =
GETPOST(
'contcats',
'array');
247 $object->setCategories($contcats);
250 if (
GETPOST(
'no_email',
'int') && $object->email)
252 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing', 0).
") AND email = '".$db->escape($object->email).
"'";
253 $resql = $db->query($sql);
256 $obj = $db->fetch_object(
$resql);
259 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email).
"', ".$db->escape(
getEntity(
'mailing', 0)).
", '".$db->idate(
dol_now()).
"')";
260 $resql = $db->query($sql);
267 if (!$error && $id > 0)
270 if (!empty($backtopage)) $url = $backtopage;
271 else $url =
'card.php?id='.$id;
272 header(
"Location: ".$url);
279 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $user->rights->societe->contact->supprimer)
281 $result = $object->fetch($id);
282 $object->oldcopy = clone $object;
284 $object->old_lastname = (string)
GETPOST(
"old_lastname",
'alpha');
285 $object->old_firstname = (string)
GETPOST(
"old_firstname",
'alpha');
287 $result = $object->delete();
290 header(
"Location: ".$backtopage);
293 header(
"Location: ".DOL_URL_ROOT.
'/contact/list.php');
301 if ($action ==
'update' && empty($cancel) && $user->rights->societe->contact->creer)
303 if (!
GETPOST(
"lastname",
'alpha'))
305 $error++; $errors = array($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name").
' / '.$langs->transnoentities(
"Label")));
311 $contactid =
GETPOST(
"contactid",
'int');
312 $object->fetch($contactid);
313 $object->fetchRoles($contactid);
316 $dir = $conf->societe->multidir_output[$object->entity].
"/contact/".$object->id.
"/photos";
317 $file_OK = is_uploaded_file($_FILES[
'photo'][
'tmp_name']);
318 if (
GETPOST(
'deletephoto') && $object->photo)
320 $fileimg = $dir.
'/'.$object->photo;
321 $dirthumbs = $dir.
'/thumbs';
339 $errors[] =
"ErrorFailedToSaveFile";
344 $object->addThumbs($newfile);
348 $errors[] =
"ErrorBadImageFormat";
351 switch ($_FILES[
'photo'][
'error'])
355 $errors[] =
"ErrorFileSizeTooLarge";
358 $errors[] =
"ErrorFilePartiallyUploaded";
363 $object->oldcopy = clone $object;
365 $object->old_lastname = (string)
GETPOST(
"old_lastname",
'alpha');
366 $object->old_firstname = (string)
GETPOST(
"old_firstname",
'alpha');
368 $object->socid =
GETPOST(
"socid",
'int');
369 $object->lastname = (string)
GETPOST(
"lastname",
'alpha');
370 $object->firstname = (string)
GETPOST(
"firstname",
'alpha');
371 $object->civility_code = (string)
GETPOST(
"civility_code",
'alpha');
372 $object->poste = (string)
GETPOST(
"poste",
'alpha');
374 $object->address = (string)
GETPOST(
"address",
'alpha');
375 $object->zip = (string)
GETPOST(
"zipcode",
'alpha');
376 $object->town = (string)
GETPOST(
"town",
'alpha');
377 $object->state_id =
GETPOST(
"state_id",
'int');
378 $object->country_id =
GETPOST(
"country_id",
'int');
380 $object->email = (string)
GETPOST(
"email",
'alpha');
381 $object->no_email =
GETPOST(
"no_email",
"int");
387 $object->socialnetworks = array();
388 if (!empty($conf->socialnetworks->enabled)) {
389 foreach ($socialnetworks as $key => $value) {
391 $object->socialnetworks[$key] = (string)
GETPOST($key,
'alphanohtml');
395 $object->phone_pro = (string)
GETPOST(
"phone_pro",
'alpha');
396 $object->phone_perso = (string)
GETPOST(
"phone_perso",
'alpha');
397 $object->phone_mobile = (string)
GETPOST(
"phone_mobile",
'alpha');
398 $object->fax = (string)
GETPOST(
"fax",
'alpha');
399 $object->priv = (string)
GETPOST(
"priv",
'int');
400 $object->note_public = (string)
GETPOST(
"note_public",
'restricthtml');
401 $object->note_private = (string)
GETPOST(
"note_private",
'restricthtml');
403 $object->roles =
GETPOST(
"roles",
'array');
406 $ret = $extrafields->setOptionalsFromPost(null, $object);
407 if ($ret < 0) $error++;
411 $result = $object->update($contactid, $user);
415 $categories =
GETPOST(
'contcats',
'array');
416 $object->setCategories($categories);
418 $no_email =
GETPOST(
'no_email',
'int');
425 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing', 0).
") AND email = '".$db->escape($object->email).
"'";
426 $resql = $db->query($sql);
429 $obj = $db->fetch_object(
$resql);
433 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"mailing_unsubscribe(email, entity, date_creat) VALUES ('".$db->escape($object->email).
"', ".$db->escape(
getEntity(
'mailing', 0)).
", '".$db->idate(
dol_now()).
"')";
434 $resql = $db->query($sql);
438 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE email = '".$db->escape($object->email).
"' AND entity = ".$db->escape(
getEntity(
'mailing', 0));
439 $resql = $db->query($sql);
442 $object->no_email = $no_email;
445 $object->old_lastname =
'';
446 $object->old_firstname =
'';
455 if (!$error && empty($errors))
457 if (!empty($backtopage))
459 header(
"Location: ".$backtopage);
465 if ($action ==
'setprospectcontactlevel' && $user->rights->societe->contact->creer)
468 $object->fk_prospectlevel =
GETPOST(
'prospect_contact_level_id',
'alpha');
469 $result = $object->update($object->id, $user);
470 if ($result < 0)
setEventMessages($object->error, $object->errors,
'errors');
474 if ($action ==
'setstcomm')
478 $result = $object->update($object->id, $user);
479 if ($result < 0)
setEventMessages($object->error, $object->errors,
'errors');
483 $triggersendname =
'CONTACT_SENTBYMAIL';
485 $mode =
'emailfromcontact';
486 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
495 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
496 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) $title = $object->lastname;
497 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
500 $form =
new Form($db);
503 $countrynotdefined = $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
508 $objsoc->fetch($socid);
511 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
516 if (empty($object->error) && $id)
519 $result = $object->fetch($id);
522 $objcanvas->assign_values($action, $object->id, $object->ref);
523 $objcanvas->display_canvas($action);
530 if ($user->rights->societe->contact->supprimer)
532 if ($action ==
'delete')
534 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$id.($backtopage ?
'&backtopage='.$backtopage :
''), $langs->trans(
"DeleteContact"), $langs->trans(
"ConfirmDeleteContact"),
"confirm_delete",
'', 0, 1);
546 $res = $object->fetch($id, $user);
551 $object->fetchRoles();
556 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"Contacts") : $langs->trans(
"ContactsAddresses"));
559 if ($user->rights->societe->contact->creer)
561 if ($action ==
'create')
566 $object->canvas = $canvas;
568 $object->state_id =
GETPOST(
"state_id");
571 $object->country_id = $_POST[
"country_id"] ?
GETPOST(
"country_id") : (empty($objsoc->country_id) ? $mysoc->country_id : $objsoc->country_id);
572 if ($object->country_id)
574 $tmparray =
getCountry($object->country_id,
'all');
575 $object->country_code = $tmparray[
'code'];
576 $object->country = $tmparray[
'label'];
579 $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans(
"AddContact") : $langs->trans(
"AddContactAddress"));
586 if ($conf->use_javascript_ajax)
588 print "\n".
'<script type="text/javascript" language="javascript">'.
"\n";
589 print 'jQuery(document).ready(function () {
590 jQuery("#selectcountry_id").change(function() {
591 document.formsoc.action.value="create";
592 document.formsoc.submit();
595 $("#copyaddressfromsoc").click(function() {
596 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
597 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
598 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
599 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
600 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
601 /* set country at end because it will trigger page refresh */
602 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
603 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
606 print '</script>'.
"\n";
609 print '<form method="post" name="formsoc" action="'.$_SERVER[
"PHP_SELF"].
'">';
610 print '<input type="hidden" name="token" value="'.newToken().
'">';
611 print '<input type="hidden" name="action" value="add">';
612 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
613 if (!empty($objsoc)) {
614 print '<input type="hidden" name="entity" value="'.$objsoc->entity.
'">';
619 print '<table class="border centpercent">';
622 print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
623 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>';
627 print '<td><label for="firstname">';
628 print $form->textwithpicto($langs->trans(
"Firstname"), $langs->trans(
"KeepEmptyIfGenericAddress")).
'</label></td>';
629 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>';
633 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
637 print '<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
638 print '<td colspan="3" class="maxwidthonsmartphone">';
639 print $objsoc->getNomUrl(1,
'contact');
641 print '<input type="hidden" name="socid" id="socid" value="'.$objsoc->id.
'">';
644 print '<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
645 print img_picto(
'',
'company').$form->select_company($socid,
'socid',
'',
'SelectThirdParty');
651 print '<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
652 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
'alpha') : $object->civility_code,
'civility_code');
655 print '<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
656 print '<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="80" value="'.dol_escape_htmltag(
GETPOST(
"poste",
'alpha') ?
GETPOST(
"poste",
'alpha') : $object->poste).
'"></td>';
659 if ($conf->use_javascript_ajax && $socid > 0) $colspan = 2;
662 if (($objsoc->typent_code ==
'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->address)) == 0) $object->address = $objsoc->address;
663 print '<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
664 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>';
666 if ($conf->use_javascript_ajax && $socid > 0)
669 if (empty($conf->global->SOCIETE_DISABLE_STATE)) $rowspan++;
671 print '<td class="valignmiddle center" rowspan="'.$rowspan.
'">';
672 print '<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a>';
678 if (($objsoc->typent_code ==
'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip;
679 if (($objsoc->typent_code ==
'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town;
680 print '<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
681 print $formcompany->select_ziptown((
GETPOST(
"zipcode",
'alpha') ?
GETPOST(
"zipcode",
'alpha') : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
682 print $formcompany->select_ziptown((
GETPOST(
"town",
'alpha') ?
GETPOST(
"town",
'alpha') : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
686 print '<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
687 print img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
688 print $form->select_country((
GETPOST(
"country_id",
'alpha') ?
GETPOST(
"country_id",
'alpha') : $object->country_id),
'country_id');
689 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
693 if (empty($conf->global->SOCIETE_DISABLE_STATE))
695 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
697 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
699 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="'.$colspan.
'" class="maxwidthonsmartphone">';
702 if ($object->country_id)
704 print $formcompany->select_state(
GETPOST(
"state_id",
'alpha') ?
GETPOST(
"state_id",
'alpha') : $object->state_id, $object->country_code,
'state_id');
706 print $countrynotdefined;
711 if (($objsoc->typent_code ==
'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->phone_pro)) == 0) $object->phone_pro = $objsoc->phone;
712 if (($objsoc->typent_code ==
'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->fax)) == 0) $object->fax = $objsoc->fax;
715 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
'', $object, 0).
'</td>';
718 print
'<input type="text" name="phone_pro" id="phone_pro" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_pro') ?
GETPOST(
'phone_pro',
'alpha') : $object->phone_pro).
'"></td>';
719 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
720 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'phone_perso',
'', $object, 0).
'</td>';
723 print
'<input type="text" name="phone_perso" id="phone_perso" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_perso') ?
GETPOST(
'phone_perso',
'alpha') : $object->phone_perso).
'"></td></tr>';
725 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
'', $object, 0).
'</td>';
727 print
img_picto(
'',
'object_phoning_mobile');
728 print
'<input type="text" name="phone_mobile" id="phone_mobile" class="maxwidth200" value="'.(GETPOSTISSET(
'phone_mobile') ?
GETPOST(
'phone_mobile',
'alpha') : $object->phone_mobile).
'"></td>';
729 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
730 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
'', $object, 0).
'</td>';
732 print
img_picto(
'',
'object_phoning_fax');
733 print
'<input type="text" name="fax" id="fax" class="maxwidth200" value="'.(GETPOSTISSET(
'fax') ?
GETPOST(
'fax',
'alpha') : $object->fax).
'"></td>';
736 if (($objsoc->typent_code ==
'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) &&
dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email;
739 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'', $object, 0,
'string',
'').
'</td>';
742 print
'<input type="text" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
745 if (!empty($conf->mailing->enabled))
748 if (empty($noemail) && !empty($object->email))
750 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$db->escape($object->email).
"'";
752 $resql = $db->query($sql);
755 $obj = $db->fetch_object(
$resql);
761 print
'<td><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
762 print
'<td>'.$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'alpha') : $noemail), 1).
'</td>';
767 if (!empty($conf->socialnetworks->enabled)) {
768 foreach ($socialnetworks as $key => $value) {
769 if ($value[
'active']) {
771 print
'<td><label for="'.$value[
'label'].
'">'.$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
772 print
'<td colspan="3">';
773 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100" maxlength="80" value="'.
dol_escape_htmltag(
GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : $object->socialnetworks[$key]).
'">';
776 } elseif (!empty($object->socialnetworks[$key])) {
777 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
816 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
817 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
818 print $form->selectarray(
'priv', $selectarray, (
GETPOST(
"priv",
'alpha') ?
GETPOST(
"priv",
'alpha') : $object->priv), 0);
822 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
823 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td><td colspan="3">';
824 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null,
'parent', null, null, 1);
825 print
img_picto(
'',
'category').$form->multiselectarray(
'contcats', $cate_arbo,
GETPOST(
'contcats',
'array'), null, null, null, null,
'90%');
830 if (!empty($socid)) {
831 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
832 print
'<td colspan="3">';
833 $contactType = $object->listeTypeContacts(
'external',
'', 1);
834 print $form->multiselectarray(
'roles', $contactType, array(), 0, 0,
'minwidth500');
839 $parameters = array(
'socid' => $socid,
'objsoc' => $objsoc,
'colspan' =>
' colspan="3"',
'cols' => 3);
840 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
841 print $hookmanager->resPrint;
844 print $object->showOptionals($extrafields,
'edit', $parameters);
847 print
"</table><br>";
849 print
'<hr style="margin-bottom: 20px">';
852 print
load_fiche_titre(
'<div class="comboperso">'.$langs->trans(
"PersonalInformations").
'</div>',
'',
'');
854 print
'<table class="border centpercent">';
857 print
'<tr><td><label for="birthday">'.$langs->trans(
"DateOfBirth").
'</label></td><td>';
858 $form =
new Form($db);
859 if ($object->birthday)
861 print $form->selectDate($object->birthday,
'birthday', 0, 0, 0,
"perso", 1, 0);
863 print $form->selectDate(
'',
'birthday', 0, 0, 1,
"perso", 1, 0);
867 print
'<td><label for="birthday_alert">'.$langs->trans(
"Alert").
'</label>: ';
868 if ($object->birthday_alert)
870 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert" checked>';
872 print
'<input type="checkbox" name="birthday_alert" id="birthday_alert">';
881 print
'<div class="center">';
882 print
'<input type="submit" class="button" name="add" value="'.$langs->trans(
"Add").
'">';
883 if (!empty($backtopage))
885 print
' ';
886 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
888 print
' ';
889 print
'<input type="button" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" onClick="javascript:history.go(-1)">';
894 } elseif ($action ==
'edit' && !empty($id)) {
902 $tmparray =
getCountry($object->country_id,
'all');
903 $object->country_code = $tmparray[
'code'];
904 $object->country = $tmparray[
'label'];
908 $objsoc->fetch($object->socid);
913 if ($conf->use_javascript_ajax)
915 print
"\n".
'<script type="text/javascript" language="javascript">'.
"\n";
916 print
'jQuery(document).ready(function () {
917 jQuery("#selectcountry_id").change(function() {
918 document.formsoc.action.value="edit";
919 document.formsoc.submit();
922 $("#copyaddressfromsoc").click(function() {
923 $(\'textarea[name="address"]\').val("'.dol_escape_js($objsoc->address).
'");
924 $(\'input[name="zipcode"]\').val("'.
dol_escape_js($objsoc->zip).
'");
925 $(\'input[name="town"]\').val("'.
dol_escape_js($objsoc->town).
'");
926 console.log("Set state_id to '.
dol_escape_js($objsoc->state_id).
'");
927 $(\'select[name="state_id"]\').val("'.
dol_escape_js($objsoc->state_id).
'").trigger("change");
928 /* set country at end because it will trigger page refresh */
929 console.log("Set country id to '.
dol_escape_js($objsoc->country_id).
'");
930 $(\'select[name="country_id"]\').val("'.
dol_escape_js($objsoc->country_id).
'").trigger("change"); /* trigger required to update select2 components */
933 print
'</script>'.
"\n";
936 print
'<form enctype="multipart/form-data" method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" name="formsoc">';
937 print
'<input type="hidden" name="token" value="'.newToken().
'">';
938 print
'<input type="hidden" name="id" value="'.$id.
'">';
939 print
'<input type="hidden" name="action" value="update">';
940 print
'<input type="hidden" name="contactid" value="'.$object->id.
'">';
941 print
'<input type="hidden" name="old_lastname" value="'.$object->lastname.
'">';
942 print
'<input type="hidden" name="old_firstname" value="'.$object->firstname.
'">';
943 if (!empty($backtopage)) print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
947 print
'<table class="border centpercent">';
950 if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID))
952 print
'<tr><td>'.$langs->trans(
"ID").
'</td><td colspan="3">';
958 print
'<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">'.$langs->trans(
"Lastname").
' / '.$langs->trans(
"Label").
'</label></td>';
959 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>';
963 print
'<td><label for="firstname">'.$langs->trans(
"Firstname").
'</label></td>';
964 print
'<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="'.(GETPOSTISSET(
"firstname") ?
GETPOST(
"firstname") : $object->firstname).
'"></td>';
968 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
970 print
'<tr><td><label for="socid">'.$langs->trans(
"ThirdParty").
'</label></td>';
971 print
'<td colspan="3" class="maxwidthonsmartphone">';
972 print
img_picto(
'',
'company').$form->select_company(
GETPOST(
'socid',
'int') ?
GETPOST(
'socid',
'int') : ($object->socid ? $object->socid : -1),
'socid',
'', $langs->trans(
"SelectThirdParty"));
978 print
'<tr><td><label for="civility_code">'.$langs->trans(
"UserTitle").
'</label></td><td colspan="3">';
979 print $formcompany->select_civility(
GETPOSTISSET(
"civility_code") ?
GETPOST(
"civility_code",
"aZ09") : $object->civility_code,
'civility_code');
982 print
'<tr><td><label for="title">'.$langs->trans(
"PostOrFunction").
'</label></td>';
983 print
'<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="80" value="'.(GETPOSTISSET(
"poste") ?
GETPOST(
"poste") : $object->poste).
'"></td></tr>';
986 print
'<tr><td><label for="address">'.$langs->trans(
"Address").
'</label></td>';
987 print
'<td colspan="3">';
988 print
'<div class="paddingrightonly valignmiddle inline-block quatrevingtpercent">';
989 print
'<textarea class="flat minwidth200 centpercent" name="address" id="address">'.(GETPOSTISSET(
"address") ?
GETPOST(
"address",
'nohtml') : $object->address).
'</textarea>';
990 print
'</div><div class="paddingrightonly valignmiddle inline-block">';
991 if ($conf->use_javascript_ajax) print
'<a href="#" id="copyaddressfromsoc">'.$langs->trans(
'CopyAddressFromSoc').
'</a><br>';
996 print
'<tr><td><label for="zipcode">'.$langs->trans(
"Zip").
'</label> / <label for="town">'.$langs->trans(
"Town").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
997 print $formcompany->select_ziptown((
GETPOSTISSET(
"zipcode") ?
GETPOST(
"zipcode") : $object->zip),
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 6).
' ';
998 print $formcompany->select_ziptown((
GETPOSTISSET(
"town") ?
GETPOST(
"town") : $object->town),
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
1002 print
'<tr><td><label for="selectcountry_id">'.$langs->trans(
"Country").
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1003 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1004 print $form->select_country(
GETPOSTISSET(
"country_id") ?
GETPOST(
"country_id") : $object->country_id,
'country_id');
1005 if ($user->admin) print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1009 if (empty($conf->global->SOCIETE_DISABLE_STATE))
1011 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1013 print
'<tr><td><label for="state_id">'.$langs->trans(
'Region-State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1015 print
'<tr><td><label for="state_id">'.$langs->trans(
'State').
'</label></td><td colspan="3" class="maxwidthonsmartphone">';
1018 print $formcompany->select_state(
GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'alpha') : $object->state_id, $object->country_code,
'state_id');
1023 print
'<tr><td>'.$form->editfieldkey(
'PhonePro',
'phone_pro',
GETPOST(
'phone_pro',
'alpha'), $object, 0).
'</td>';
1026 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>';
1027 print
'<td>'.$form->editfieldkey(
'PhonePerso',
'fax',
GETPOST(
'phone_perso',
'alpha'), $object, 0).
'</td>';
1030 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>';
1032 print
'<tr><td>'.$form->editfieldkey(
'PhoneMobile',
'phone_mobile',
GETPOST(
'phone_mobile',
'alpha'), $object, 0,
'string',
'').
'</td>';
1034 print
img_picto(
'',
'object_phoning_mobile');
1035 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>';
1036 print
'<td>'.$form->editfieldkey(
'Fax',
'fax',
GETPOST(
'fax',
'alpha'), $object, 0).
'</td>';
1038 print
img_picto(
'',
'object_phoning_fax');
1039 print
'<input type="text" name="fax" id="fax" class="maxwidth200" maxlength="80" value="'.(GETPOSTISSET(
'phone_fax') ?
GETPOST(
'phone_fax',
'alpha') : $object->fax).
'"></td></tr>';
1042 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
GETPOST(
'email',
'alpha'), $object, 0,
'string',
'', (!empty($conf->global->SOCIETE_EMAIL_MANDATORY))).
'</td>';
1045 print
'<input type="text" name="email" id="email" class="maxwidth100onsmartphone quatrevingtpercent" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') : $object->email).
'"></td>';
1046 if (!empty($conf->mailing->enabled))
1048 $langs->load(
"mails");
1049 print
'<td class="nowrap">'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1050 print
'<td>'.$object->getNbOfEMailings().
'</td>';
1052 print
'<td colspan="2"></td>';
1058 if (!empty($conf->mailing->enabled))
1061 if (empty($noemail) && !empty($object->email))
1063 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$db->escape($object->email).
"'";
1065 $resql = $db->query($sql);
1068 $obj = $db->fetch_object(
$resql);
1069 $noemail = $obj->nb;
1073 print
'<td><label for="no_email">'.$langs->trans(
"No_Email").
'</label></td>';
1074 print
'<td>'.$form->selectyesno(
'no_email', (
GETPOSTISSET(
"no_email") ?
GETPOST(
"no_email",
'alpha') : $noemail), 1).
'</td>';
1076 print
'<td colspan="2"></td>';
1080 if (!empty($conf->socialnetworks->enabled)) {
1081 foreach ($socialnetworks as $key => $value) {
1082 if ($value[
'active']) {
1084 print
'<td><label for="'.$value[
'label'].
'">'.$form->editfieldkey($value[
'label'], $key,
'', $object, 0).
'</label></td>';
1085 print
'<td colspan="3">';
1086 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100" maxlength="80" value="'.
dol_escape_htmltag(
GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : $object->socialnetworks[$key]).
'">';
1089 } elseif (!empty($object->socialnetworks[$key])) {
1090 print
'<input type="hidden" name="'.$key.
'" value="'.$object->socialnetworks[$key].
'">';
1096 print
'<tr><td><label for="priv">'.$langs->trans(
"ContactVisibility").
'</label></td><td colspan="3">';
1097 $selectarray = array(
'0'=>$langs->trans(
"ContactPublic"),
'1'=>$langs->trans(
"ContactPrivate"));
1098 print $form->selectarray(
'priv', $selectarray, $object->priv, 0);
1102 print
'<tr><td class="tdtop"><label for="note_public">'.$langs->trans(
"NotePublic").
'</label></td><td colspan="3">';
1103 $doleditor =
new DolEditor(
'note_public', $object->note_public,
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
1104 print $doleditor->Create(1);
1108 print
'<tr><td class="tdtop"><label for="note_private">'.$langs->trans(
"NotePrivate").
'</label></td><td colspan="3">';
1109 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 80,
'dolibarr_notes',
'In', 0,
false,
true, ROWS_3,
'90%');
1110 print $doleditor->Create(1);
1114 print
'<tr><td>'.$langs->trans(
"Status").
'</td>';
1115 print
'<td colspan="3">';
1116 print $object->getLibStatut(4);
1120 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1121 print
'<tr><td>'.$form->editfieldkey(
'Categories',
'contcats',
'', $object, 0).
'</td>';
1122 print
'<td colspan="3">';
1123 $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, null, null, null, 1);
1125 $cats = $c->containing($object->id,
'contact');
1126 foreach ($cats as $cat) {
1127 $arrayselected[] = $cat->id;
1129 print
img_picto(
'',
'category').$form->multiselectarray(
'contcats', $cate_arbo, $arrayselected,
'', 0,
'', 0,
'90%');
1134 if (!empty($object->socid)) {
1135 print
'<tr><td>'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1136 print
'<td colspan="3">';
1137 print $formcompany->showRoles(
"roles", $object,
'edit', $object->roles);
1142 $parameters = array(
'colspan' =>
' colspan="3"',
'cols'=>
'3');
1143 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1144 print $hookmanager->resPrint;
1145 if (empty($reshook))
1147 print $object->showOptionals($extrafields,
'edit', $parameters);
1150 $object->load_ref_elements();
1152 if (!empty($conf->commande->enabled))
1154 print
'<tr><td>'.$langs->trans(
"ContactForOrders").
'</td><td colspan="3">';
1155 print $object->ref_commande ? $object->ref_commande : $langs->trans(
"NoContactForAnyOrder");
1159 if (!empty($conf->propal->enabled))
1161 print
'<tr><td>'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1162 print $object->ref_propal ? $object->ref_propal : $langs->trans(
"NoContactForAnyProposal");
1166 if (!empty($conf->contrat->enabled))
1168 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1169 print $object->ref_contrat ? $object->ref_contrat : $langs->trans(
"NoContactForAnyContract");
1173 if (!empty($conf->facture->enabled))
1175 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1176 print $object->ref_facturation ? $object->ref_facturation : $langs->trans(
"NoContactForAnyInvoice");
1181 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1182 if ($object->user_id)
1184 $dolibarr_user =
new User($db);
1185 $result = $dolibarr_user->fetch($object->user_id);
1186 print $dolibarr_user->getLoginUrl(1);
1187 }
else print $langs->trans(
"NoDolibarrAccess");
1192 print
'<td>'.$langs->trans(
"PhotoFile").
'</td>';
1193 print
'<td colspan="3">';
1194 if ($object->photo) {
1195 print $form->showphoto(
'contact', $object);
1198 print
'<table class="nobordernopadding">';
1199 if ($object->photo) print
'<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans(
"Delete").
'<br><br></td></tr>';
1201 print
'<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
1211 print
'<div class="center">';
1212 print
'<input type="submit" class="button button-save" name="save" value="'.$langs->trans(
"Save").
'">';
1213 print
' ';
1214 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1222 if (
GETPOST(
'modelselected',
'alpha')) {
1223 $action =
'presend';
1226 if (!empty($id) && $action !=
'edit' && $action !=
'create')
1237 if ($action ==
'create_user')
1240 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1243 $generated_password =
'';
1246 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
1249 $password = $generated_password;
1252 $formquestion = array(
1253 array(
'label' => $langs->trans(
"LoginToCreate"),
'type' =>
'text',
'name' =>
'login',
'value' => $login),
1254 array(
'label' => $langs->trans(
"Password"),
'type' =>
'text',
'name' =>
'password',
'value' => $password),
1257 $text = $langs->trans(
"ConfirmCreateContact").
'<br>';
1258 if (!empty($conf->societe->enabled))
1260 if ($object->socid > 0) $text .= $langs->trans(
"UserWillBeExternalUser");
1261 else $text .= $langs->trans(
"UserWillBeInternalUser");
1263 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"CreateDolibarrLogin"), $text,
"confirm_create_user", $formquestion,
'yes');
1266 $linkback =
'<a href="'.DOL_URL_ROOT.
'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1268 $morehtmlref =
'<div class="refidno">';
1269 if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
1271 $objsoc->fetch($object->socid);
1273 $morehtmlref .= $langs->trans(
'ThirdParty').
' : ';
1274 if ($objsoc->id > 0) $morehtmlref .= $objsoc->getNomUrl(1,
'contact');
1275 else $morehtmlref .= $langs->trans(
"ContactNotLinkedToCompany");
1277 $morehtmlref .=
'</div>';
1279 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'ref', $morehtmlref);
1282 print
'<div class="fichecenter">';
1283 print
'<div class="fichehalfleft">';
1285 print
'<div class="underbanner clearboth"></div>';
1286 print
'<table class="border tableforfield" width="100%">';
1289 print
'<tr><td class="titlefield">'.$langs->trans(
"UserTitle").
'</td><td>';
1290 print $object->getCivilityLabel();
1294 print
'<tr><td>'.$langs->trans(
"PostOrFunction").
'</td><td>'.$object->poste.
'</td></tr>';
1297 if (!empty($conf->mailing->enabled))
1299 $langs->load(
"mails");
1300 print
'<tr><td>'.$langs->trans(
"NbOfEMailingsSend").
'</td>';
1301 print
'<td><a href="'.DOL_URL_ROOT.
'/comm/mailing/list.php?filteremail='.urlencode($object->email).
'">'.$object->getNbOfEMailings().
'</a></td></tr>';
1305 if (!empty($conf->mailing->enabled))
1308 $noemail = $object->no_email;
1309 if (empty($noemail) && !empty($object->email))
1311 $sql =
"SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe WHERE entity IN (".
getEntity(
'mailing').
") AND email = '".$db->escape($object->email).
"'";
1313 $resql = $db->query($sql);
1316 $obj = $db->fetch_object(
$resql);
1317 $noemail = $obj->nb;
1320 print
'<tr><td>'.$langs->trans(
"No_Email").
'</td><td>'.
yn($noemail).
'</td></tr>';
1323 print
'<tr><td>'.$langs->trans(
"ContactVisibility").
'</td><td>';
1324 print $object->LibPubPriv($object->priv);
1330 $object->fetch_thirdparty();
1332 if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
1333 if ($object->thirdparty->client == 2 || $object->thirdparty->client == 3)
1337 print
'<div class="underbanner clearboth"></div>';
1338 print
'<table class="border" width="100%">';
1341 print
'<tr><td class="titlefield nowrap">';
1342 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1343 print $langs->trans(
'ProspectLevel');
1345 if ($action !=
'editlevel' && $user->rights->societe->contact->creer) print
'<td align="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editlevel&id='.$object->id.
'">'.
img_edit($langs->trans(
'Modify'), 1).
'</a></td>';
1346 print
'</tr></table>';
1348 if ($action ==
'editlevel') {
1349 $formcompany->formProspectContactLevel(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->fk_prospectlevel,
'prospect_contact_level_id', 1);
1351 print $object->getLibProspLevel();
1357 $object->loadCacheOfProspStatus();
1358 print
'<tr><td>'.$langs->trans(
"StatusProsp").
'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id][
'label']);
1359 print
' ';
1360 print
'<div class="floatright">';
1361 foreach ($object->cacheprospectstatus as $key => $val) {
1362 $titlealt =
'default';
1363 if (!empty($val[
'code']) && !in_array($val[
'code'], array(
'ST_NO',
'ST_NEVER',
'ST_TODO',
'ST_PEND',
'ST_DONE'))) $titlealt = $val[
'label'];
1364 if ($object->stcomm_id != $val[
'id']) print
'<a class="pictosubstatus" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&stcomm='.$val[
'code'].
'&action=setstcomm&token='.
newToken().
'">'.
img_action($titlealt, $val[
'code'], $val[
'picto']).
'</a>';
1366 print
'</div></td></tr>';
1373 print
'<div class="fichehalfright"><div class="ficheaddleft">';
1375 print
'<div class="underbanner clearboth"></div>';
1376 print
'<table class="border tableforfield" width="100%">';
1379 if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) {
1380 print
'<tr><td class="titlefield">'.$langs->trans(
"Categories").
'</td>';
1381 print
'<td colspan="3">';
1382 print $form->showCategories($object->id, Categorie::TYPE_CONTACT, 1);
1386 if (!empty($object->socid)) {
1387 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactByDefaultFor").
'</td>';
1388 print
'<td colspan="3">';
1389 print $formcompany->showRoles(
"roles", $object,
'view');
1395 $parameters = array(
'socid'=>$socid);
1396 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
1398 $object->load_ref_elements();
1400 if (!empty($conf->propal->enabled))
1402 print
'<tr><td class="titlefield">'.$langs->trans(
"ContactForProposals").
'</td><td colspan="3">';
1403 print $object->ref_propal ? $object->ref_propal : $langs->trans(
"NoContactForAnyProposal");
1407 if (!empty($conf->commande->enabled) || !empty($conf->expedition->enabled))
1410 if (!empty($conf->expedition->enabled)) { print $langs->trans(
"ContactForOrdersOrShipments"); }
else print $langs->trans(
"ContactForOrders");
1411 print
'</td><td colspan="3">';
1412 $none = $langs->trans(
"NoContactForAnyOrder");
1413 if (!empty($conf->expedition->enabled)) { $none = $langs->trans(
"NoContactForAnyOrderOrShipments"); }
1414 print $object->ref_commande ? $object->ref_commande : $none;
1418 if (!empty($conf->contrat->enabled))
1420 print
'<tr><td>'.$langs->trans(
"ContactForContracts").
'</td><td colspan="3">';
1421 print $object->ref_contrat ? $object->ref_contrat : $langs->trans(
"NoContactForAnyContract");
1425 if (!empty($conf->facture->enabled))
1427 print
'<tr><td>'.$langs->trans(
"ContactForInvoices").
'</td><td colspan="3">';
1428 print $object->ref_facturation ? $object->ref_facturation : $langs->trans(
"NoContactForAnyInvoice");
1432 print
'<tr><td>'.$langs->trans(
"DolibarrLogin").
'</td><td colspan="3">';
1433 if ($object->user_id)
1435 $dolibarr_user =
new User($db);
1436 $result = $dolibarr_user->fetch($object->user_id);
1437 print $dolibarr_user->getLoginUrl(1);
1438 }
else print $langs->trans(
"NoDolibarrAccess");
1442 print $langs->trans(
"VCard").
'</td><td colspan="3">';
1443 print
'<a href="'.DOL_URL_ROOT.
'/contact/vcard.php?id='.$object->id.
'">';
1444 print
img_picto($langs->trans(
"Download"),
'vcard.png',
'class="paddingrightonly"');
1445 print $langs->trans(
"Download");
1451 print
'</div></div></div>';
1452 print
'<div style="clear:both"></div>';
1457 print
'<div class="tabsAction">';
1459 $parameters = array();
1460 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
1461 if (empty($reshook) && $action !=
'presend')
1463 if (empty($user->socid)) {
1464 if (!empty($object->email))
1466 $langs->load(
"mails");
1467 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>';
1469 $langs->load(
"mails");
1470 print
'<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans(
"NoEMail")).
'">'.$langs->trans(
'SendMail').
'</a></div>';
1474 if ($user->rights->societe->contact->creer)
1476 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit">'.$langs->trans(
'Modify').
'</a>';
1479 if (!$object->user_id && $user->rights->user->user->creer)
1481 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=create_user">'.$langs->trans(
"CreateDolibarrLogin").
'</a>';
1485 if ($object->statut == 0 && $user->rights->societe->contact->creer)
1487 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=enable">'.$langs->trans(
"Reactivate").
'</a>';
1490 if ($object->statut == 1 && $user->rights->societe->contact->creer)
1492 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=disable&id='.$object->id.
'">'.$langs->trans(
"DisableUser").
'</a>';
1496 if ($user->rights->societe->contact->supprimer)
1498 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.
newToken().
''.($backtopage ?
'&backtopage='.urlencode($backtopage) :
'').
'">'.$langs->trans(
'Delete').
'</a>';
1505 if (
GETPOST(
'modelselected')) {
1506 $action =
'presend';
1509 if ($action !=
'presend')
1511 print
'<div class="fichecenter"><div class="fichehalfleft">';
1513 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
1517 $morehtmlright =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.
'/contact/agenda.php?id='.$object->id);
1520 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
1522 $somethingshown =
$formactions->showactions($object,
'contact', $object->socid, 1,
'', $MAXEVENT,
'', $morehtmlright);
1524 print
'</div></div></div>';
1528 $modelmail =
'contact';
1529 $defaulttopic =
'Information';
1530 $diroutput = $conf->contact->dir_output;
1531 $trackid =
'ctc'.$object->id;
1533 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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.
getArrayOfSocialNetworks()
Get array of social network dictionary.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
dol_buildlogin($lastname, $firstname)
Build a login from lastname, firstname.
img_action($titlealt, $numaction, $picto= '')
Show logo action.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=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)
Remove a file or several files with a mask.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $nohook=0, $varfiles= 'addedfile', $upload_dir= '')
Make control on an uploaded file from an GUI page and move it to final destination.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_htmloutput_errors($mesgstring= '', $mesgarray=array(), $keepembedded=0)
Print formated error messages to output (Used to show messages on html output).
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...