NEW Add hooks on list of members to allow an external module to add more
fields into list view.
This commit is contained in:
parent
5a8e763099
commit
cac7b1f49f
@ -73,6 +73,10 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
|
|||||||
$sall="";
|
$sall="";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
|
$hookmanager->initHooks(array('memberlist'));
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -91,6 +95,12 @@ $sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.societe as company,
|
|||||||
$sql.= " d.datefin,";
|
$sql.= " d.datefin,";
|
||||||
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
|
$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
|
||||||
$sql.= " t.libelle as type, t.cotisation";
|
$sql.= " t.libelle as type, t.cotisation";
|
||||||
|
// Add fields for extrafields
|
||||||
|
foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
|
||||||
|
// Add fields from hooks
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
$sql.=$hookmanager->resPrint;
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||||
if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
|
if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
|
$sql.= ", ".MAIN_DB_PREFIX."adherent_type as t";
|
||||||
@ -100,52 +110,23 @@ if ($catid == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
|||||||
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
|
if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_categ);
|
||||||
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
|
||||||
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")";
|
$sql.= " AND d.entity IN (".getEntity('adherent', 1).")";
|
||||||
if ($sall)
|
if ($sall) $sql.=natural_search(array("d.rowid", "d.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
|
||||||
{
|
if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type);
|
||||||
// For natural search
|
if (isset($_GET["statut"]) || isset($_POST["statut"])) $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
|
||||||
$scrit = explode(' ', $sall);
|
|
||||||
foreach ($scrit as $crit)
|
|
||||||
{
|
|
||||||
$sql.=" AND (";
|
|
||||||
if (is_numeric($sall)) $sql.= "d.rowid = ".$db->escape($sall)." OR ";
|
|
||||||
$sql.=" d.firstname LIKE '%".$db->escape($sall)."%' OR d.lastname LIKE '%".$db->escape($sall)."%' OR d.societe LIKE '%".$db->escape($sall)."%'";
|
|
||||||
$sql.=" OR d.email LIKE '%".$db->escape($sall)."%' OR d.login LIKE '%".$db->escape($sall)."%' OR d.address LIKE '%".$db->escape($sall)."%'";
|
|
||||||
$sql.=" OR d.town LIKE '%".$db->escape($sall)."%' OR d.note_public LIKE '%".$db->escape($sall)."%' OR d.note_private LIKE '%".$db->escape($sall)."%')";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($type > 0)
|
|
||||||
{
|
|
||||||
$sql.=" AND t.rowid=".$db->escape($type);
|
|
||||||
}
|
|
||||||
if (isset($_GET["statut"]) || isset($_POST["statut"]))
|
|
||||||
{
|
|
||||||
$sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
|
|
||||||
}
|
|
||||||
if ($search_ref)
|
if ($search_ref)
|
||||||
{
|
{
|
||||||
if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")";
|
if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$db->escape($search_ref).")";
|
||||||
else $sql.=" AND 1 = 2"; // Always wrong
|
else $sql.=" AND 1 = 2"; // Always wrong
|
||||||
}
|
}
|
||||||
if ($search_lastname)
|
if ($search_lastname) $sql.= natural_search(array("d.firstname", "d.lastname", "d.societe"), $search_lastname);
|
||||||
{
|
if ($search_login) $sql.= natural_search("d.login", $search_login);
|
||||||
$sql.= " AND (d.firstname LIKE '%".$db->escape($search_lastname)."%' OR d.lastname LIKE '%".$db->escape($search_lastname)."%' OR d.societe LIKE '%".$db->escape($search_lastname)."%')";
|
if ($search_email) $sql.= natural_search("d.email", $search_email);
|
||||||
}
|
if ($filter == 'uptodate') $sql.=" AND datefin >= '".$db->idate($now)."'";
|
||||||
if ($search_login)
|
if ($filter == 'outofdate') $sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')";
|
||||||
{
|
// Add where from hooks
|
||||||
$sql.= " AND d.login LIKE '%".$db->escape($search_login)."%'";
|
$parameters=array();
|
||||||
}
|
$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
if ($search_email)
|
$sql.=$hookmanager->resPrint;
|
||||||
{
|
|
||||||
$sql.= " AND (d.email LIKE '%".$db->escape($search_email)."%')";
|
|
||||||
}
|
|
||||||
if ($filter == 'uptodate')
|
|
||||||
{
|
|
||||||
$sql.=" AND datefin >= '".$db->idate($now)."'";
|
|
||||||
}
|
|
||||||
if ($filter == 'outofdate')
|
|
||||||
{
|
|
||||||
$sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count total nb of records with no order and no limits
|
// Count total nb of records with no order and no limits
|
||||||
$nbtotalofrecords = 0;
|
$nbtotalofrecords = 0;
|
||||||
@ -204,7 +185,7 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].($param?'?'.$param:'').'">';
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].($param?'?'.$param:'').'">';
|
||||||
print "<table class=\"noborder\" width=\"100%\">";
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
|
||||||
// Filter on categories
|
// Filter on categories
|
||||||
$moreforfilter='';
|
$moreforfilter='';
|
||||||
@ -215,14 +196,17 @@ if ($resql)
|
|||||||
$moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1);
|
$moreforfilter.=$formother->select_categories(Categorie::TYPE_MEMBER,$search_categ,'search_categ',1);
|
||||||
$moreforfilter.=' ';
|
$moreforfilter.=' ';
|
||||||
}
|
}
|
||||||
if ($moreforfilter)
|
if (! empty($moreforfilter))
|
||||||
{
|
{
|
||||||
print '<tr class="liste_titre">';
|
print '<div class="liste_titre">';
|
||||||
print '<td class="liste_titre" colspan="9">';
|
|
||||||
print $moreforfilter;
|
print $moreforfilter;
|
||||||
print '</td></tr>';
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
print '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print "<table class=\"noborder\" width=\"100%\">";
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.lastname",$param,"","",$sortfield,$sortorder);
|
||||||
@ -230,6 +214,11 @@ if ($resql)
|
|||||||
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"t.libelle",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"t.libelle",$param,"","",$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
|
||||||
|
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
|
||||||
@ -257,6 +246,11 @@ if ($resql)
|
|||||||
print '<td class="liste_titre" align="left">';
|
print '<td class="liste_titre" align="left">';
|
||||||
print '<input class="flat" type="text" name="search_email" value="'.$search_email.'" size="12"></td>';
|
print '<input class="flat" type="text" name="search_email" value="'.$search_email.'" size="12"></td>';
|
||||||
|
|
||||||
|
$parameters=array();
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
|
// Status
|
||||||
print '<td class="liste_titre"> </td>';
|
print '<td class="liste_titre"> </td>';
|
||||||
|
|
||||||
print '<td align="right" colspan="2" class="liste_titre">';
|
print '<td align="right" colspan="2" class="liste_titre">';
|
||||||
@ -317,6 +311,10 @@ if ($resql)
|
|||||||
// EMail
|
// EMail
|
||||||
print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
|
print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
|
||||||
|
|
||||||
|
$parameters=array('obj' => $obj);
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
// Statut
|
// Statut
|
||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2);
|
print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2);
|
||||||
@ -366,6 +364,12 @@ if ($resql)
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$db->free($resql);
|
||||||
|
|
||||||
|
$parameters=array('sql' => $sql);
|
||||||
|
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print '</form>';
|
print '</form>';
|
||||||
|
|
||||||
|
|||||||
@ -199,7 +199,8 @@ Entreprises=Companies
|
|||||||
DOLIBARRFOUNDATION_PAYMENT_FORM=To make your subscription payment using a bank transfer, see page <a target="_blank" href="http://wiki.dolibarr.org/index.php/Subscribe#To_subscribe_making_a_bank_transfer">http://wiki.dolibarr.org/index.php/Subscribe</a>.<br>To pay using a Credit Card or Paypal, click on button at bottom of this page.<br>
|
DOLIBARRFOUNDATION_PAYMENT_FORM=To make your subscription payment using a bank transfer, see page <a target="_blank" href="http://wiki.dolibarr.org/index.php/Subscribe#To_subscribe_making_a_bank_transfer">http://wiki.dolibarr.org/index.php/Subscribe</a>.<br>To pay using a Credit Card or Paypal, click on button at bottom of this page.<br>
|
||||||
ByProperties=By characteristics
|
ByProperties=By characteristics
|
||||||
MembersStatisticsByProperties=Members statistics by characteristics
|
MembersStatisticsByProperties=Members statistics by characteristics
|
||||||
MembersByNature=Members by nature
|
MembersByNature=This screen show you statistics on members by nature.
|
||||||
|
MembersByRegion=This screen show you statistics on members by region.
|
||||||
VATToUseForSubscriptions=VAT rate to use for subscriptions
|
VATToUseForSubscriptions=VAT rate to use for subscriptions
|
||||||
NoVatOnSubscription=No TVA for subscriptions
|
NoVatOnSubscription=No TVA for subscriptions
|
||||||
MEMBER_PAYONLINE_SENDEMAIL=Email to warn when Dolibarr receive a confirmation of a validated payment for subscription
|
MEMBER_PAYONLINE_SENDEMAIL=Email to warn when Dolibarr receive a confirmation of a validated payment for subscription
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user