diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index ec55870e49f..14c3a5c51ec 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI + * Copyright (C) 2021 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $hookmanager = new HookManager($db); @@ -40,7 +42,24 @@ $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"); +if (GETPOST('addbox')) { + // Add box (when submit is done from a form when ajax disabled) + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) { + setEventMessages($langs->trans("BoxAdded"), null); + } +} /* * View @@ -52,7 +71,7 @@ $staticmember = new Adherent($db); $statictype = new AdherentType($db); $subscriptionstatic = new Subscription($db); -print load_fiche_titre($langs->trans("MembersArea"), '', 'member'); +print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members'); $Adherents = array(); $AdherentsAValider = array(); @@ -125,10 +144,7 @@ if ($result) { $db->free(); } - -print '
'; - - +$searchbox = ''; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo // Search contact/address if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { @@ -136,27 +152,27 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel } if (count($listofsearchfields)) { - print '
'; - print ''; - print '
'; - print ''; + $searchbox .=''; + $searchbox .=''; + $searchbox .='
'; + $searchbox .='
'; $i = 0; foreach ($listofsearchfields as $key => $value) { if ($i == 0) { - print ''; + $searchbox .=''; } - print ''; - print ''; + $searchbox .=''; + $searchbox .=''; if ($i == 0) { - print ''; + $searchbox .=''; } - print ''; + $searchbox .=''; $i++; } - print '
'.$langs->trans("Search").'
'.$langs->trans("Search").'
:
:
'; - print '
'; - print '
'; - print '
'; + $searchbox .=''; + $searchbox .='
'; + $searchbox .=''; + $searchbox .='
'; } } @@ -164,12 +180,12 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel /* * Statistics */ - +$boxgraph = ''; if ($conf->use_javascript_ajax) { - print '
'; - print ''; - print ''; - print ''; + $boxgraph .= ''; + $boxgraph .= '
'.$langs->trans("Statistics").'
'; + $boxgraph .='
'; + $boxgraph .=''; + $boxgraph .=''; + $boxgraph .=''; - print ''; - print '
'.$langs->trans("Statistics").'
'; $SommeA = 0; $SommeB = 0; @@ -207,257 +223,38 @@ if ($conf->use_javascript_ajax) { $dolgraph->SetType(array('pie')); $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($total ? 0 : 1); + $boxgraph .=$dolgraph->show($total ? 0 : 1); - print '
'.$langs->trans("Total").''; - print $SommeA + $SommeB + $SommeC + $SommeD; - print '
'; - print '
'; + $boxgraph .= '
'.$langs->trans("Total").''; + $boxgraph .= $SommeA + $SommeB + $SommeC + $SommeD; + $boxgraph .= '
'; + $boxgraph .= '
'; + $boxgraph .= '
'; } -print '
'; +// boxes +print '
'; +print '
'; -// 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"; +$boxlist .= '
'; +$boxlist .= $searchbox; +$boxlist .= $boxgraph; +$boxlist .= $resultboxes['boxlista']; +$boxlist .= '
'."\n"; +$boxlist .= '
'; +$boxlist .= $resultboxes['boxlistb']; +$boxlist .= '
'."\n"; -$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++; - } -} +$boxlist .= '
'; -print '
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; +print $boxlist; -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 '
'; - -/* - * Latest modified members - */ -$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; - -$sql = "SELECT a.rowid, a.ref, 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->ref; - $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 '
'; +print ''; $parameters = array('user' => $user); $reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 5c9aee97828..acd3773d2f0 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -92,7 +92,7 @@ class box_members extends ModeleBoxes $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql .= ' a.photo, a.email, a.gender, a.morphy,'; - $sql .= " t.subscription"; + $sql .= " t.subscription, t.libelle as label"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE a.entity IN (".getEntity('member').")"; $sql .= " AND a.fk_adherent_type = t.rowid"; diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php new file mode 100644 index 00000000000..5d32f9663d5 --- /dev/null +++ b/htdocs/core/boxes/box_members_by_type.php @@ -0,0 +1,277 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_members_by_type.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_members_by_type extends ModeleBoxes +{ + public $boxcode = "box_members_by_type"; + public $boximg = "object_user"; + public $boxlabel = "BoxMembersByType"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; + $staticmember = new Adherent($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByType", $max)); + + if ($user->rights->adherent->lire) { + $MembersToValidate = array(); + $MembersValidated = array(); + $MemberUpToDate = array(); + $MembersResiliated = array(); + + $SommeA = 0; + $SommeB = 0; + $SommeC = 0; + $SommeD = 0; + + $AdherentType = array(); + + // Type of membership + $sql = "SELECT t.rowid, t.libelle as label, t.subscription,"; + $sql .= " d.statut, count(d.rowid) as somme"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent as d"; + $sql .= " ON t.rowid = d.fk_adherent_type"; + $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " WHERE t.entity IN (" . getEntity('member_type') . ")"; + $sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; + + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $this->db->fetch_object($result); + + $adhtype = new AdherentType($this->db); + $adhtype->id = $objp->rowid; + $adhtype->subscription = $objp->subscription; + $adhtype->label = $objp->label; + $AdherentType[$objp->rowid] = $adhtype; + + if ($objp->statut == -1) { + $MembersToValidate[$objp->rowid] = $objp->somme; + } + if ($objp->statut == 1) { + $MembersValidated[$objp->rowid] = $objp->somme; + } + if ($objp->statut == 0) { + $MembersResiliated[$objp->rowid] = $objp->somme; + } + + $i++; + } + $this->db->free($result); + $now = dol_now(); + + // Members up to date list + // current rule: uptodate = the end date is in future whatever is type + // old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future) + $sql = "SELECT count(*) as somme , d.fk_adherent_type"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.statut = 1 AND (d.datefin >= '" . $this->db->idate($now) . "' OR t.subscription = 0)"; + $sql .= " AND t.rowid = d.fk_adherent_type"; + $sql .= " GROUP BY d.fk_adherent_type"; + + dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num2 = $this->db->num_rows($result); + $i = 0; + while ($i < $num2) { + $objp = $this->db->fetch_object($result); + $MemberUpToDate[$objp->fk_adherent_type] = $objp->somme; + $i++; + } + $this->db->free($result); + } + + $line = 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_titre"', + 'text' => $langs->trans("MembersTypes"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("MembersStatusToValid"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("OutOfDate"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("UpToDate"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("MembersStatusResiliated"), + ); + $line++; + foreach ($AdherentType as $key => $adhtype) { + $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; + $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; + $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; + $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $adhtype->getNomUrl(1, dol_size(32)), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0 ? $MemberToValidate[$key] : '') . ' ' . $staticmember->LibStatut(-1, $adhtype->subscription, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (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), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(1, $adhtype->subscription, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] : '') . ' ' . $staticmember->LibStatut(0, $adhtype->subscription, 0, 3), + 'asis' => 1, + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoRecordedMembersByType"), + ); + } else { + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeA.' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeB.' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeC.' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SommeD.' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error() . ' sql=' . $sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_members_last_modified.php b/htdocs/core/boxes/box_members_last_modified.php new file mode 100644 index 00000000000..9ec1bf70558 --- /dev/null +++ b/htdocs/core/boxes/box_members_last_modified.php @@ -0,0 +1,197 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_last_modified_members.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_last_modified_members extends ModeleBoxes +{ + public $boxcode = "box_last_modified_members"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastModifiedMembers"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + $memberstatic = new Adherent($this->db); + $statictype = new AdherentType($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastModifiedMembers", $max)); + + if ($user->rights->adherent->lire) { + $sql = "SELECT a.rowid, a.ref, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; + $sql .= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; + $sql .= ' a.photo, a.email, a.gender, a.morphy,'; + $sql .= " t.rowid as typeid, t.subscription, t.libelle as label"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; + $sql .= " WHERE a.entity IN (".getEntity('member').")"; + $sql .= " AND a.fk_adherent_type = t.rowid"; + $sql .= " ORDER BY a.tms DESC"; + $sql .= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + while ($line < $num) { + $objp = $this->db->fetch_object($result); + $datec = $this->db->jdate($objp->datec); + $datem = $this->db->jdate($objp->tms); + + $memberstatic->lastname = $objp->lastname; + $memberstatic->firstname = $objp->firstname; + $memberstatic->id = $objp->rowid; + $memberstatic->ref = $objp->ref; + $memberstatic->photo = $objp->photo; + $memberstatic->gender = $objp->gender; + $memberstatic->email = $objp->email; + $memberstatic->morphy = $objp->morphy; + $memberstatic->company = $objp->company; + $memberstatic->statut = $objp->status; + $memberstatic->need_subscription = $objp->subscription; + $memberstatic->datefin = $this->db->jdate($objp->date_end_subscription); + if (!empty($objp->fk_soc)) { + $memberstatic->socid = $objp->fk_soc; + $memberstatic->fetch_thirdparty(); + $memberstatic->name = $memberstatic->thirdparty->name; + } else { + $memberstatic->name = $objp->company; + } + $statictype->id = $objp->typeid; + $statictype->label = $objp->label; + $statictype->subscription = $objp->subscription; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $memberstatic->getNomUrl(-1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $statictype->getNomUrl(1, 32), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($datem, "day"), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $memberstatic->LibStatut($objp->status, $objp->subscription, $this->db->jdate($objp->date_end_subscription), 3), + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); + } + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_members_last_subscriptions.php b/htdocs/core/boxes/box_members_last_subscriptions.php new file mode 100644 index 00000000000..0b2cb02d920 --- /dev/null +++ b/htdocs/core/boxes/box_members_last_subscriptions.php @@ -0,0 +1,202 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_last_members_subscriptions.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_last_members_subscriptions extends ModeleBoxes +{ + public $boxcode = "box_last_members_subscriptions"; + public $boximg = "object_user"; + public $boxlabel = "BoxLastMembersSubscriptions"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; + require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; + $staticmember = new Adherent($this->db); + $statictype = new AdherentType($this->db); + $subscriptionstatic = new Subscription($this->db); + + $this->info_box_head = array('text' => $langs->trans("LastSubscriptionsModified", $max)); + + if ($user->rights->adherent->lire) { + $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 .= $this->db->order("c.tms", "DESC"); + $sql .= $this->db->plimit($max, 0); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + while ($line < $num) { + $obj = $this->db->fetch_object($result); + $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 = $this->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; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax100 maxwidth100onsmartphone"', + 'text' => $subscriptionstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $staticmember->getNomUrl(-1, 32, 'subscription'), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => get_date_range($this->db->jdate($obj->date_start), $this->db->jdate($obj->date_end)), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => price($obj->subscription), + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => dol_print_date($this->db->jdate($obj->datem ? $obj->datem : $obj->datec), 'dayhour'), + ); + + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedCustomers"), + ); + } + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php new file mode 100644 index 00000000000..55a11339c0f --- /dev/null +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -0,0 +1,242 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2021 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_members_subscriptions_by_year.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_members_subscriptions_by_year extends ModeleBoxes +{ + public $boxcode = "box_members_subscriptions_by_year"; + public $boximg = "object_user"; + public $boxlabel = "BoxMembersSubscriptionsByYear"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !($user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent_type.class.php'; + $memberstatic = new Adherent($this->db); + $statictype = new AdherentType($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersSubscriptionsByYear", $max)); + + if ($user->rights->adherent->lire) { + $num = 0; + $line = 0; + // List of subscription by year + $Total = array(); + $Number = array(); + $tot = 0; + $numb = 0; + + $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"; + + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $year = dol_print_date($this->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++; + } + + + $line = 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_titre"', + 'text' => $langs->trans("Year"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("Subscriptions"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("AmountTotal"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $langs->trans("AmountAverage"), + ); + + $line++; + + krsort($Total); + $i = 0; + foreach ($Total as $key => $value) { + if ($i >= 8) { + // print ''; + // print "..."; + // print ""; + // print ""; + // print ""; + // print "\n"; + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => '...', + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => '', + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => '', + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => '', + ); + $line++; + break; + } + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => ''.$key.'', + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => $Number[$key], + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => price($value), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => price(price2num($value / $Number[$key], 'MT')), + ); + $line++; + } + + if ($num == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text' => $langs->trans("NoRecordedMembers"), + ); + } else { + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total"), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $numb, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => price($tot), + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => price(price2num($numb > 0 ? ($tot / $numb) : 0, 'MT')), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error() . ' sql=' . $sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 09df7b7c758..e18689e3c2f 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -40,6 +40,8 @@ class InfoBox if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) { return array( 0 => 'Home', + 1 => 'userhome', + 2 => 'membersindex', 3 => 'thirdpartiesindex', 27 => 'AccountancyHome' ); @@ -152,7 +154,7 @@ class InfoBox $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile = $relsourcefile; - $box->class = $boxname; + $box->class = $boxname; if ($mode == 'activated' && !is_object($user)) { // List of activated box was not yet personalized into database if (is_numeric($box->box_order)) { diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index d72bb610012..3d3009fd667 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1183,7 +1183,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $lastid = $this->db->last_insert_id(MAIN_DB_PREFIX."boxes_def", "rowid"); foreach ($pos_name as $key2 => $val2) { - //print 'key2='.$key2.'-val2='.$val2."
\n"; + //print 'key2='.$key2.'-val2='.$val2."
\n"; if ($enabledbydefaulton && $val2 != $enabledbydefaulton) { continue; // Not enabled by default onto this page. } @@ -1202,8 +1202,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if (!$err) { $this->db->commit(); } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); + $this->error = $this->db->lasterror(); + $this->db->rollback(); } } // else box already registered into database diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 63ca0c6ad49..74c67d217d6 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -192,8 +192,12 @@ class modAdherent extends DolibarrModules // Boxes //------- $this->boxes = array( - 0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), - 2=>array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home') + 0 => array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'), + 2 => array('file'=>'box_birthdays_members.php', 'enabledbydefaulton'=>'Home'), + 3 => array('file'=>'box_members_last_modified', 'enabledbydefaulton'=>'membersindex'), + 4 => array('file'=>'box_members_last_subscriptions', 'enabledbydefaulton'=>'membersindex'), + 5 => array('file'=>'box_members_subscriptions_by_year', 'enabledbydefaulton'=>'membersindex'), + 6 => array('file'=>'box_members_by_type', 'enabledbydefaulton'=>'membersindex'), ); // Permissions @@ -399,19 +403,17 @@ class modAdherent extends DolibarrModules // Permissions $this->remove($options); - //ODT template + // ODT template /* $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; $dest=$dirodt.'/template_order.odt'; - if (file_exists($src) && ! file_exists($dest)) - { + if (file_exists($src) && ! file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_mkdir($dirodt); $result=dol_copy($src,$dest,0,0); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); return 0; diff --git a/htdocs/index.php b/htdocs/index.php index 3ed1cacdbd2..0754d297606 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -30,7 +30,7 @@ require 'main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // If not defined, we select menu "home" -$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ?GETPOST('mainmenu', 'aZ09') : 'home'; +$_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ? GETPOST('mainmenu', 'aZ09') : 'home'; $action = GETPOST('action', 'aZ09'); $hookmanager->initHooks(array('index')); diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index 7c656426e5f..6e70999fd77 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -18,9 +18,12 @@ BoxLastActions=Latest actions BoxLastContracts=Latest contracts BoxLastContacts=Latest contacts/addresses BoxLastMembers=Latest members +BoxLastModifiedMembers=Latest modified members BoxFicheInter=Latest interventions BoxCurrentAccounts=Open accounts balance BoxTitleMemberNextBirthdays=Birthdays of this month (members) +BoxTitleMembersByType=Members by type +BoxTitleMembersSubscriptionsByYear=Members Subscriptions by year BoxTitleLastRssInfos=Latest %s news from %s BoxTitleLastProducts=Products/Services: last %s modified BoxTitleProductsAlertStock=Products: stock alert @@ -87,8 +90,8 @@ BoxTitleLatestModifiedSupplierOrders=Vendor Orders: last %s modified BoxTitleLastModifiedCustomerBills=Customer Invoices: last %s modified BoxTitleLastModifiedCustomerOrders=Sales Orders: last %s modified BoxTitleLastModifiedPropals=Latest %s modified proposals -BoxTitleLatestModifiedJobPositions=Latest %s modified jobs -BoxTitleLatestModifiedCandidatures=Latest %s modified candidatures +BoxTitleLatestModifiedJobPositions=Latest %s modified jobs +BoxTitleLatestModifiedCandidatures=Latest %s modified candidatures ForCustomersInvoices=Customers invoices ForCustomersOrders=Customers orders ForProposals=Proposals diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 4863ed4b9d3..dfb201bc441 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -24,6 +24,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'userhome'; // To manage different context of search @@ -52,7 +53,24 @@ $fuserstatic = new User($db); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('userhome')); +if (!isset($form) || !is_object($form)) { + $form = new Form($db); +} +// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) +$resultboxes = FormOther::getBoxesArea($user, "1"); +if (GETPOST('addbox')) { + // Add box (when submit is done from a form when ajax disabled) + require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; + $zone = GETPOST('areacode', 'aZ09'); + $userid = GETPOST('userid', 'int'); + $boxorder = GETPOST('boxorder', 'aZ09'); + $boxorder .= GETPOST('boxcombo', 'aZ09'); + $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); + if ($result > 0) { + setEventMessages($langs->trans("BoxAdded"), null); + } +} /* * View @@ -61,40 +79,35 @@ $hookmanager->initHooks(array('userhome')); llxHeader(); -print load_fiche_titre($langs->trans("MenuUsersAndGroups"), '', 'user'); - - -print '
'; +print load_fiche_titre($langs->trans("MenuUsersAndGroups"), $resultboxes['selectboxlist'], 'user'); // Search User -print '
'; -print ''; +$searchbox = ''; +$searchbox .= ''; -print ''; -print ''; -print ''; +$searchbox .= '
'.$langs->trans("Search").'
'; -print $langs->trans("User").':
'; +$searchbox .= ''; +$searchbox .= ''; // Search Group if ($canreadperms) { - print ''; + $searchbox .= ''; } -print ''; -print "
'.$langs->trans("Search").'
'; +$searchbox .= $langs->trans("User").':
'; - print $langs->trans("Group").':
'; + $searchbox .= $langs->trans("Group").':

\n"; +$searchbox .= ''; +$searchbox .= "
\n"; -print '
'; - -print '
'; +$searchbox .= ''; /* * Latest created users */ $max = 10; - +$lastcreatedbox = ''; $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.login, u.fk_soc, u.datec, u.statut"; $sql .= ", u.entity"; $sql .= ", u.ldap_sid"; @@ -124,11 +137,11 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; - print ''."\n"; + $lastcreatedbox .='
'; + $lastcreatedbox .='
'.$langs->trans("LastUsersCreated", min($num, $max)).''.$langs->trans("FullList").'
'; + $lastcreatedbox .=''; + $lastcreatedbox .=''; + $lastcreatedbox .=''."\n"; $i = 0; while ($i < $num && $i < $max) { @@ -149,24 +162,24 @@ if ($resql) { $companystatic->code_client = $obj->code_client; $companystatic->canvas = $obj->canvas; - print ''; - print ''; + $lastcreatedbox .='"; - print ''; - print ""; + $lastcreatedbox .=''; + $lastcreatedbox .="'; - print ''; - print ''; + $lastcreatedbox .=''; + $lastcreatedbox .=''; + $lastcreatedbox .=''; - print ''; + $lastcreatedbox .=''; $i++; } - print "
'.$langs->trans("LastUsersCreated", min($num, $max)).''.$langs->trans("FullList").'
'; - print $fuserstatic->getNomUrl(-1); + $lastcreatedbox .='
'; + $lastcreatedbox .=$fuserstatic->getNomUrl(-1); if (!empty($conf->multicompany->enabled) && $obj->admin && !$obj->entity) { - print img_picto($langs->trans("SuperAdministrator"), 'redstar'); + $lastcreatedbox .=img_picto($langs->trans("SuperAdministrator"), 'redstar'); } elseif ($obj->admin) { - print img_picto($langs->trans("Administrator"), 'star'); + $lastcreatedbox .=img_picto($langs->trans("Administrator"), 'star'); } - print "'.$obj->login.'"; + $lastcreatedbox .="'.$obj->login.'"; if ($obj->fk_soc) { - print $companystatic->getNomUrl(1); + $lastcreatedbox .=$companystatic->getNomUrl(1); } else { - print $langs->trans("InternalUser"); + $lastcreatedbox .=$langs->trans("InternalUser"); } if ($obj->ldap_sid) { - print ' ('.$langs->trans("DomainUser").')'; + $lastcreatedbox .=' ('.$langs->trans("DomainUser").')'; } $entity = $obj->entity; @@ -180,19 +193,19 @@ if ($resql) { $entitystring = $mc->label; } } - print ($entitystring ? ' ('.$entitystring.')' : ''); + $lastcreatedbox .=($entitystring ? ' ('.$entitystring.')' : ''); - print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''; - print $fuserstatic->getLibStatut(3); - print ''.dol_print_date($db->jdate($obj->datec), 'dayhour').''; + $lastcreatedbox .=$fuserstatic->getLibStatut(3); + $lastcreatedbox .='
"; - print "

"; + $lastcreatedbox .=""; + $lastcreatedbox .="

"; $db->free($resql); } else { @@ -203,6 +216,7 @@ if ($resql) { /* * Last groups created */ +$lastgroupbox = ''; if ($canreadperms) { $max = 5; @@ -224,11 +238,11 @@ if ($canreadperms) { } $num = $db->num_rows($resql); - print '
'; - print ''; - print ''; - print ''; - print ''; + $lastgroupbox .='
'; + $lastgroupbox .='
'.$langs->trans("LastGroupsCreated", ($num ? $num : $max)).''.$langs->trans("FullList").'
'; + $lastgroupbox .=''; + $lastgroupbox .=''; + $lastgroupbox .=''; $i = 0; $grouptemp = new UserGroup($db); @@ -240,25 +254,25 @@ if ($canreadperms) { $grouptemp->name = $obj->name; $grouptemp->note = $obj->note; - print ''; - print ''; + $lastgroupbox .='"; + $lastgroupbox .=""; if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($obj->entity); - print ''; + $lastgroupbox .=''; } - print ''; - print ""; + $lastgroupbox .=''; + $lastgroupbox .=""; $i++; } - print "
'.$langs->trans("LastGroupsCreated", ($num ? $num : $max)).''.$langs->trans("FullList").'
'; - print $grouptemp->getNomUrl(1); + $lastgroupbox .='
'; + $lastgroupbox .=$grouptemp->getNomUrl(1); if (!$obj->entity) { - print img_picto($langs->trans("GlobalGroup"), 'redstar'); + $lastgroupbox .=img_picto($langs->trans("GlobalGroup"), 'redstar'); } - print "'; - print $mc->label; - print ''; + $lastgroupbox .=$mc->label; + $lastgroupbox .=''.dol_print_date($db->jdate($obj->datec), 'dayhour').'
'.dol_print_date($db->jdate($obj->datec), 'dayhour').'
"; - print "

"; + $lastgroupbox .= ""; + $lastgroupbox .= "

"; $db->free($resql); } else { @@ -266,7 +280,28 @@ if ($canreadperms) { } } -print '
'; +// boxes +print '
'; +print '
'; + +$boxlist = '
'; + +$boxlist .= '
'; +$boxlist .= $searchbox; +$boxlist .= $resultboxes['boxlista']; +$boxlist .= '
'."\n"; + +$boxlist .= '
'; +$boxlist .= $lastcreatedbox; +$boxlist .= $lastgroupbox; +$boxlist .= $resultboxes['boxlistb']; +$boxlist .= '
'."\n"; + +$boxlist .= '
'; + +print $boxlist; + +print '
'; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $parameters = array('user' => $user);