New #23494 : add birthday to thirdparty contact list

This commit is contained in:
hystepik 2023-01-17 12:16:03 +01:00
parent 4cf4da973c
commit fc8aed1a6d

View File

@ -957,7 +957,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$search_poste = GETPOST("search_poste", 'alpha');
$search_note_private = GETPOST('search_note_private', 'alphanohtml');
$search_roles = GETPOST("search_roles", 'array');
$search_birthday_dtstart = GETPOST("search_birthday_dtstart", 'alpha');
$search_birthday_dtend = GETPOST("search_birthday_dtend", 'alpha');
if ($search_birthday_dtstart != '' || $search_birthday_dtend != '') {
$search_birthday_dtstart = dol_mktime(0, 0, 0, GETPOST('search_birthday_dtstartmonth', 'int'), GETPOST('search_birthday_dtstartday', 'int'), GETPOST('search_birthday_dtstartyear', 'int'));
$search_birthday_dtend = dol_mktime(23, 59, 59, GETPOST('search_birthday_dtendmonth', 'int'), GETPOST('search_birthday_dtendday', 'int'), GETPOST('search_birthday_dtendyear', 'int'));
}
$socialnetworks = getArrayOfSocialNetworks();
$searchAddressPhoneDBFields = array(
@ -1007,6 +1013,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>3, 'index'=>1, 'position'=>30),
'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>(!getDolGlobalInt('MAIN_LIST_HIDE_PRIVATE_NOTES')), 'visible'=>3, 'position'=>35),
'role' =>array('type'=>'checkbox', 'label'=>'Role', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>4, 'index'=>1, 'position'=>40),
'birthday' =>array('type'=>'date', 'label'=>'Birthday', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 0, 'position'=>45),
'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>50, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0, 1), 1=>$contactstatic->LibStatut(1, 1))),
);
@ -1018,6 +1025,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30),
't.note_private' => array('label' => 'NotePrivate', 'checked' => 0, 'position'=>35),
'sc.role'=>array('label'=>"ContactByDefaultFor", 'checked'=>1, 'position'=>40),
't.birthday'=>array('label'=>"Birthday", 'checked'=>0, 'position'=>45),
't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'),
);
// Extra fields
@ -1052,6 +1060,8 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$search_address = '';
$search_poste = '';
$search_note_private = '';
$search_birthday_dtstart = '';
$search_birthday_dtend = '';
$search = array();
$search_array_options = array();
@ -1111,6 +1121,9 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
if ($search_note_private != '') {
$param .= '&search_note_private='.urlencode($search_note_private);
}
if ($search_birthday != '') {
$param .= '&search_birthday='.urlencode($search_birthday);
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
}
@ -1120,7 +1133,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
$sql = "SELECT t.rowid, t.entity, t.lastname, t.firstname, t.fk_pays as country_id, t.civility, t.poste, t.phone as phone_pro, t.phone_mobile, t.phone_perso, t.fax, t.email, t.socialnetworks, t.statut, t.photo,";
$sql .= " t.civility as civility_id, t.address, t.zip, t.town";
$sql .= " t.civility as civility_id, t.address, t.zip, t.town, t.birthday";
$sql .= ", t.note_private";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople_extrafields as ef on (t.rowid = ef.fk_object)";
@ -1144,6 +1157,12 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
if ($search_note_private) {
$sql .= natural_search('t.note_private', $search_note_private);
}
if ($search_birthday_dtstart != '') {
$sql .= " AND t.birthday >= '".$db->idate($search_birthday_dtstart)."'";
}
if ($search_birthday_dtend != '') {
$sql .= " AND t.birthday <= '".$db->idate($search_birthday_dtend)."'";
}
if (count($search_roles) > 0) {
$sql .= " AND t.rowid IN (SELECT sc.fk_socpeople FROM ".MAIN_DB_PREFIX."societe_contacts as sc WHERE sc.fk_c_type_contact IN (".$db->sanitize(implode(',', $search_roles))."))";
}
@ -1188,6 +1207,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage');
} elseif (in_array($key, array('role'))) {
print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles, 'minwidth200 maxwidth300');
} elseif (in_array($key, array('birthday'))) {
print '<div class="nowrap">';
print $form->selectDate($search_birthday_dtstart ? $search_birthday_dtstart : '', "search_birthday_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_birthday_dtend ? $search_birthday_dtend : '', "search_birthday_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
print '</div>';
} else {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.(!empty($search[$key]) ? dol_escape_htmltag($search[$key]) : '').'">';
}
@ -1342,6 +1368,13 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
print '</td>';
}
// Birthday
if (!empty($arrayfields['t.birthday']['checked'])) {
print '<td>';
print dol_print_date($obj->birthday);
print '</td>';
}
// Status
if (!empty($arrayfields['t.statut']['checked'])) {
print '<td class="center">'.$contactstatic->getLibStatut(5).'</td>';
@ -1384,7 +1417,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserl
$i++;
}
} else {
$colspan = 1;
$colspan = 2;
foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;