index.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
  4. * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  6. * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
  7. * Copyright (C) 2021-2023 Frédéric France <frederic.france@netlgic.fr>
  8. * Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/adherents/index.php
  25. * \ingroup member
  26. * \brief Home page of membership module
  27. */
  28. // Load Dolibarr environment
  29. require '../main.inc.php';
  30. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array("companies", "members"));
  36. $hookmanager = new HookManager($db);
  37. // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
  38. $hookmanager->initHooks(array('membersindex'));
  39. // Security check
  40. $result = restrictedArea($user, 'adherent');
  41. /*
  42. * Actions
  43. */
  44. $userid = GETPOST('userid', 'int');
  45. if (GETPOST('addbox')) {
  46. // Add box (when submit is done from a form when ajax disabled)
  47. require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
  48. $zone = GETPOST('areacode', 'int');
  49. $boxorder = GETPOST('boxorder', 'aZ09');
  50. $boxorder .= GETPOST('boxcombo', 'aZ09');
  51. $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
  52. if ($result > 0) {
  53. setEventMessages($langs->trans("BoxAdded"), null);
  54. }
  55. }
  56. /*
  57. * View
  58. */
  59. $form = new Form($db);
  60. // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
  61. $resultboxes = FormOther::getBoxesArea($user, "2");
  62. llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder');
  63. $staticmember = new Adherent($db);
  64. $statictype = new AdherentType($db);
  65. $subscriptionstatic = new Subscription($db);
  66. print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members');
  67. /*
  68. * Statistics
  69. */
  70. $boxgraph = '';
  71. if ($conf->use_javascript_ajax) {
  72. $year = date('Y');
  73. $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH");
  74. $boxgraph .='<div class="div-table-responsive-no-min">';
  75. $boxgraph .='<table class="noborder nohover centpercent">';
  76. $boxgraph .='<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").($numberyears ? ' ('.($year-$numberyears).' - '.$year.')' : '').'</th></tr>';
  77. $boxgraph .='<tr><td class="center" colspan="2">';
  78. require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
  79. $stats = new AdherentStats($db, 0, $userid);
  80. // Show array
  81. $sumMembers = $stats->countMembersByTypeAndStatus($numberyears);
  82. if (is_array($sumMembers) && !empty($sumMembers)) {
  83. $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated'];
  84. } else {
  85. $total = 0;
  86. }
  87. foreach (array('members_draft', 'members_pending', 'members_uptodate', 'members_expired', 'members_excluded', 'members_resiliated') as $val) {
  88. if (empty($sumMembers['total'][$val])) {
  89. $sumMembers['total'][$val] = 0;
  90. }
  91. }
  92. $dataseries = array();
  93. $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']); // Draft, not yet validated
  94. $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']);
  95. $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), $sumMembers['total']['members_uptodate']);
  96. $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), $sumMembers['total']['members_expired']);
  97. $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), $sumMembers['total']['members_excluded']);
  98. $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']);
  99. include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
  100. include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
  101. $dolgraph = new DolGraph();
  102. $dolgraph->SetData($dataseries);
  103. $dolgraph->SetDataColor(array('-'.$badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus8, '-'.$badgeStatus8, $badgeStatus6));
  104. $dolgraph->setShowLegend(2);
  105. $dolgraph->setShowPercent(1);
  106. $dolgraph->SetType(array('pie'));
  107. $dolgraph->setHeight('200');
  108. $dolgraph->draw('idgraphstatus');
  109. $boxgraph .=$dolgraph->show($total ? 0 : 1);
  110. $boxgraph .= '</td></tr>';
  111. $boxgraph .= '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
  112. $boxgraph .= $total;
  113. $boxgraph .= '</td></tr>';
  114. $boxgraph .= '</table>';
  115. $boxgraph .= '</div>';
  116. $boxgraph .= '<br>';
  117. }
  118. // boxes
  119. print '<div class="clearboth"></div>';
  120. print '<div class="fichecenter fichecenterbis">';
  121. print '<div class="twocolumns">';
  122. print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  123. print $boxgraph;
  124. print $resultboxes['boxlista'];
  125. print '</div>'."\n";
  126. print '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  127. print $resultboxes['boxlistb'];
  128. print '</div>'."\n";
  129. print '</div>';
  130. print '</div>';
  131. $parameters = array('user' => $user);
  132. $reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook
  133. // End of page
  134. llxFooter();
  135. $db->close();