From 6288ef5261fb9558173d9b5180e2c6a6c83159f9 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 20 Dec 2022 13:35:53 +0100 Subject: [PATCH 1/2] Add View mode to Contact adress --- htdocs/contact/class/contact.class.php | 44 +++ htdocs/contact/list.php | 491 +++++++++++++------------ 2 files changed, 303 insertions(+), 232 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d535da76199..c028c80b07b 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -2115,4 +2115,48 @@ class Contact extends CommonObject } return 0; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + //var_dump($this->photo);exit; + if (property_exists($this, 'photo') && !is_null($this->photo)) { + $return.= Form::showphoto('contact', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + } else { + $return .= img_picto('', $this->picto); + } + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'socid') && !is_null($this->socid)) { + $return .= '
'.$this->socid.''; + } else { + if (property_exists($this, 'phone_pro')) { + $return .= '
'.$langs->trans("Phone").''; + $return .= ' : '.$this->phone_pro.''; + } + } + + if (method_exists($this, 'LibPubPriv')) { + $return .= '
'.$langs->trans("Visibility").''; + $return .= ' : '.$this->LibPubPriv($this->priv).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e8c4174af71..59f504ec886 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -53,6 +53,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist'; +$mode = GETPOST('mode', 'alpha'); // Security check $id = GETPOST('id', 'int'); @@ -680,6 +681,9 @@ $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -789,7 +793,10 @@ if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); print '
'; if ($optioncss != '') { @@ -802,6 +809,8 @@ print ''; //print ''; print ''; print ''; +print 'fk_prospectlevel = $obj->fk_prospectcontactlevel; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + $contactstatic->photo = $obj->photo; + $soc = new Societe($db); + $soc->fetch($obj->socid); + if ($obj->socid) { + $contactstatic->socid = $soc->getNomUrl(1); + } + print $contactstatic->getKanbanView(''); + if ($i == min($num, $limit) - 1) { + print '
'; + print ''; + } + } else { + print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''; } - print ''; - } - // ID - if (!empty($arrayfields['p.rowid']['checked'])) { - print ''; - print dol_escape_htmltag($obj->rowid); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // ID + if (!empty($arrayfields['p.rowid']['checked'])) { + print ''; + print dol_escape_htmltag($obj->rowid); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Name - if (!empty($arrayfields['p.lastname']['checked'])) { - print ''; - print $contactstatic->getNomUrl(1); - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Name + if (!empty($arrayfields['p.lastname']['checked'])) { + print ''; + print $contactstatic->getNomUrl(1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Firstname - if (!empty($arrayfields['p.firstname']['checked'])) { - print ''.dol_escape_htmltag($obj->firstname).''; - if (!$i) { - $totalarray['nbfield']++; + // Firstname + if (!empty($arrayfields['p.firstname']['checked'])) { + print ''.dol_escape_htmltag($obj->firstname).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Job position - if (!empty($arrayfields['p.poste']['checked'])) { - print ''.dol_escape_htmltag($obj->poste).''; - if (!$i) { - $totalarray['nbfield']++; + // Job position + if (!empty($arrayfields['p.poste']['checked'])) { + print ''.dol_escape_htmltag($obj->poste).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Address - if (!empty($arrayfields['p.address']['checked'])) { - print ''.dol_escape_htmltag($obj->address).''; - if (!$i) { - $totalarray['nbfield']++; + // Address + if (!empty($arrayfields['p.address']['checked'])) { + print ''.dol_escape_htmltag($obj->address).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Zip - if (!empty($arrayfields['p.zip']['checked'])) { - print ''.dol_escape_htmltag($obj->zip).''; - if (!$i) { - $totalarray['nbfield']++; + // Zip + if (!empty($arrayfields['p.zip']['checked'])) { + print ''.dol_escape_htmltag($obj->zip).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Town - if (!empty($arrayfields['p.town']['checked'])) { - print ''.dol_escape_htmltag($obj->town).''; - if (!$i) { - $totalarray['nbfield']++; + // Town + if (!empty($arrayfields['p.town']['checked'])) { + print ''.dol_escape_htmltag($obj->town).''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // State - /*if (!empty($arrayfields['state.nom']['checked'])) - { - print "".$obj->state_name."\n"; - if (! $i) $totalarray['nbfield']++; - } - // Region - if (!empty($arrayfields['region.nom']['checked'])) - { - print "".$obj->region_name."\n"; - if (! $i) $totalarray['nbfield']++; - }*/ - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - $tmparray = getCountry($obj->fk_pays, 'all'); - print dol_escape_htmltag($tmparray['label']); - print ''; - if (!$i) { - $totalarray['nbfield']++; + // State + /*if (!empty($arrayfields['state.nom']['checked'])) + { + print "".$obj->state_name."\n"; + if (! $i) $totalarray['nbfield']++; } - } - // Phone - if (!empty($arrayfields['p.phone']['checked'])) { - print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; - if (!$i) { - $totalarray['nbfield']++; + // Region + if (!empty($arrayfields['region.nom']['checked'])) + { + print "".$obj->region_name."\n"; + if (! $i) $totalarray['nbfield']++; + }*/ + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + $tmparray = getCountry($obj->fk_pays, 'all'); + print dol_escape_htmltag($tmparray['label']); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Phone perso - if (!empty($arrayfields['p.phone_perso']['checked'])) { - print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; - if (!$i) { - $totalarray['nbfield']++; + // Phone + if (!empty($arrayfields['p.phone']['checked'])) { + print ''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Phone mobile - if (!empty($arrayfields['p.phone_mobile']['checked'])) { - print ''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''; - if (!$i) { - $totalarray['nbfield']++; + // Phone perso + if (!empty($arrayfields['p.phone_perso']['checked'])) { + print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Fax - if (!empty($arrayfields['p.fax']['checked'])) { - print ''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; - if (!$i) { - $totalarray['nbfield']++; + // Phone mobile + if (!empty($arrayfields['p.phone_mobile']['checked'])) { + print ''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // EMail - if (!empty($arrayfields['p.email']['checked'])) { - print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; - if (!$i) { - $totalarray['nbfield']++; + // Fax + if (!empty($arrayfields['p.fax']['checked'])) { + print ''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // No EMail - if (!empty($arrayfields['unsubscribed']['checked'])) { - print ''; - if (empty($obj->email)) { - //print ''.$langs->trans("NoEmail").''; - } else { - print yn(($obj->unsubscribed > 0) ? 1 : 0); + // EMail + if (!empty($arrayfields['p.email']['checked'])) { + print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // No EMail + if (!empty($arrayfields['unsubscribed']['checked'])) { + print ''; + if (empty($obj->email)) { + //print ''.$langs->trans("NoEmail").''; + } else { + print yn(($obj->unsubscribed > 0) ? 1 : 0); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { - print ''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).''; - if (!$i) { - $totalarray['nbfield']++; + if (isModEnabled('socialnetworks')) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { + print ''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).''; + if (!$i) { + $totalarray['nbfield']++; + } } } } - } - // Company - if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { - print ''; - if ($obj->socid) { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); - } else { - print ' '; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Private/Public - if (!empty($arrayfields['p.priv']['checked'])) { - print ''.$contactstatic->LibPubPriv($obj->priv).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { - // Prospect level - print ''; - print $contactstatic->getLibProspLevel(); - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { - // Prospect status - print '
'; - print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); - print '
-
'; - foreach ($contactstatic->cacheprospectstatus as $key => $val) { - $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { - $titlealt = $val['label']; + // Company + if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { + print ''; + if ($obj->socid) { + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1); + } else { + print ' '; } - if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print '
'; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.statut']['checked'])) { - print ''.$contactstatic->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Import key - if (!empty($arrayfields['p.import_key']['checked'])) { - print ''; - print dol_escape_htmltag($obj->import_key); - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { - $selected = 1; + // Private/Public + if (!empty($arrayfields['p.priv']['checked'])) { + print ''.$contactstatic->LibPubPriv($obj->priv).''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { + // Prospect level + print ''; + print $contactstatic->getLibProspLevel(); + print ""; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { + // Prospect status + print '
'; + print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
-
'; + foreach ($contactstatic->cacheprospectstatus as $key => $val) { + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($obj->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } + } + print '
'; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['p.statut']['checked'])) { + print ''.$contactstatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Import key + if (!empty($arrayfields['p.import_key']['checked'])) { + print ''; + print dol_escape_htmltag($obj->import_key); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } From c142a79a46cba5ed8b121a63f702fff2048546c4 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 20 Dec 2022 15:00:54 +0100 Subject: [PATCH 2/2] close input field --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 59f504ec886..3a53fad67a8 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -809,7 +809,7 @@ print ''; //print ''; print ''; print ''; -print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1);