diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 14c3a5c51ec..aa9f86c8efe 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -42,11 +42,11 @@ $langs->loadLangs(array("companies", "members")); // Security check $result = restrictedArea($user, 'adherent'); -if (!isset($form) || !is_object($form)) { - $form = new Form($db); -} -// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) -$resultboxes = FormOther::getBoxesArea($user, "2"); + + +/* + * Actions + */ if (GETPOST('addbox')) { // Add box (when submit is done from a form when ajax disabled) @@ -61,10 +61,16 @@ if (GETPOST('addbox')) { } } + /* * View */ +$form = new Form($db); + +// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) +$resultboxes = FormOther::getBoxesArea($user, "2"); + llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); $staticmember = new Adherent($db); @@ -238,22 +244,259 @@ if ($conf->use_javascript_ajax) { print '
'; print '
'; -$boxlist = '
'; +print '
'; -$boxlist .= '
'; -$boxlist .= $searchbox; -$boxlist .= $boxgraph; -$boxlist .= $resultboxes['boxlista']; -$boxlist .= '
'."\n"; +print '
'; +print $searchbox; +print $boxgraph; -$boxlist .= '
'; -$boxlist .= $resultboxes['boxlistb']; -$boxlist .= '
'."\n"; +// List of subscription by year +$Total = array(); +$Number = array(); +$tot = 0; +$numb = 0; -$boxlist .= '
'; +$sql = "SELECT c.subscription, c.dateadh as dateh"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; +$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; +$sql .= " AND d.rowid = c.fk_adherent"; -print $boxlist; +$result = $db->query($sql); +if ($result) { + $num = $db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($result); + $year = dol_print_date($db->jdate($objp->dateh), "%Y"); + $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; + $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; + $tot += $objp->subscription; + $numb += 1; + $i++; + } +} + +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +krsort($Total); +$i = 0; +foreach ($Total as $key=>$value) { + if ($i >= 8) { + print ''; + print ""; + print ""; + print ""; + print ""; + print "\n"; + break; + } + print ''; + print ""; + print ""; + print ""; + print ""; + print "\n"; + $i++; +} + +// Total +print ''; +print ''; +print ""; +print '"; +print ""; +print "\n"; +print "
'.$langs->trans("Year").''.$langs->trans("Subscriptions").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
...
$key".$Number[$key]."".price($value)."".price(price2num($value / $Number[$key], 'MT'))."
'.$langs->trans("Total").'".$numb."'.price($tot)."".price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT'))."
"; + +print "
\n"; + + +print $resultboxes['boxlista']; +print '
'."\n"; + +print '
'; + +/* + * Latest modified members + */ +$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + +$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " a.gender, a.email, a.photo, a.morphy,"; +$sql .= " a.tms as datem, a.datefin as date_end_subscription,"; +$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; +$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; +$sql .= " AND a.fk_adherent_type = ta.rowid"; +$sql .= $db->order("a.tms", "DESC"); +$sql .= $db->plimit($max, 0); + +$resql = $db->query($sql); +if ($resql) { + print '
'; + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) { + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; + $staticmember->lastname = $obj->lastname; + $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; + $staticmember->statut = $obj->status; + $staticmember->need_subscription = $obj->need_subscription; + $staticmember->datefin = $db->jdate($obj->date_end_subscription); + if (!empty($obj->fk_soc)) { + $staticmember->fk_soc = $obj->fk_soc; + $staticmember->fetch_thirdparty(); + $staticmember->name = $staticmember->thirdparty->name; + } else { + $staticmember->name = $obj->company; + } + + $statictype->id = $obj->typeid; + $statictype->label = $obj->label; + $statictype->subscription = $obj->need_subscription; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } + print "
'.$langs->trans("LastMembersModified", $max).'
'.$staticmember->getNomUrl(-1, 32).''.$statictype->getNomUrl(1, 32).''.dol_print_date($db->jdate($obj->datem), 'dayhour').''.$staticmember->getLibStatut(3).'
"; + print "
"; +} else { + dol_print_error($db); +} + + +/* + * Last modified subscriptions + */ +$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; + +$sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; +$sql .= " a.gender, a.email, a.photo, a.morphy,"; +$sql .= " a.datefin as date_end_subscription,"; +$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription,"; +$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta, ".MAIN_DB_PREFIX."subscription as c"; +$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; +$sql .= " AND a.fk_adherent_type = ta.rowid"; +$sql .= " AND c.fk_adherent = a.rowid"; +$sql .= $db->order("c.tms", "DESC"); +$sql .= $db->plimit($max, 0); + +$resql = $db->query($sql); +if ($resql) { + print '
'; + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) { + $i = 0; + while ($i < $num) { + $obj = $db->fetch_object($resql); + + $staticmember->id = $obj->rowid; + $staticmember->ref = $obj->rowid; + $staticmember->lastname = $obj->lastname; + $staticmember->firstname = $obj->firstname; + $staticmember->gender = $obj->gender; + $staticmember->email = $obj->email; + $staticmember->photo = $obj->photo; + $staticmember->morphy = $obj->morphy; + $staticmember->statut = $obj->status; + $staticmember->need_subscription = $obj->need_subscription; + $staticmember->datefin = $db->jdate($obj->date_end_subscription); + if (!empty($obj->fk_soc)) { + $staticmember->fk_soc = $obj->fk_soc; + $staticmember->fetch_thirdparty(); + $staticmember->name = $staticmember->thirdparty->name; + } else { + $staticmember->name = $obj->company; + } + + $subscriptionstatic->id = $obj->cid; + $subscriptionstatic->ref = $obj->cid; + + print ''; + print ''; + print ''; + print ''; + print ''; + //print ''; + print ''; + print ''; + $i++; + } + } + print "
'.$langs->trans("LastSubscriptionsModified", $max).'
'.$subscriptionstatic->getNomUrl(1).''.$staticmember->getNomUrl(-1, 32, 'subscription').''.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).''.price($obj->subscription).''.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).''.dol_print_date($db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour').'
"; + print "
"; +} else { + dol_print_error($db); +} + + +// Summary of members by type +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +foreach ($AdherentType as $key => $adhtype) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; +} +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print "
'.$langs->trans("MembersTypes").''.$langs->trans("MembersStatusToValid").''.$langs->trans("OutOfDate").''.$langs->trans("UpToDate").''.$langs->trans("MembersStatusResiliated").'
'.$adhtype->getNomUrl(1, dol_size(32)).''.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).''.(isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).''.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).''.(isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'
'.$langs->trans("Total").''.$SommeA.' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).''.$SommeB.' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).''.$SommeC.' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).''.$SommeD.' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'
\n"; +print "
"; + +print $resultboxes['boxlistb']; + +print '
'."\n"; + +print '
'; print '
'; $parameters = array('user' => $user);