dolibarr  7.0.0-beta
byproperties.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
24 require '../../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
26 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
27 
28 $graphwidth = 700;
29 $mapratio = 0.5;
30 $graphheight = round($graphwidth * $mapratio);
31 
32 $mode=GETPOST('mode')?GETPOST('mode'):'';
33 
34 
35 // Security check
36 if ($user->societe_id > 0)
37 {
38  $action = '';
39  $socid = $user->societe_id;
40 }
41 $result=restrictedArea($user,'adherent','','','cotisation');
42 
43 $year = strftime("%Y", time());
44 $startyear=$year-2;
45 $endyear=$year;
46 
47 $langs->load("members");
48 $langs->load("companies");
49 
50 
51 /*
52  * View
53  */
54 
55 $memberstatic=new Adherent($db);
56 
57 llxHeader('',$langs->trans("MembersStatisticsByProperties"),'','',0,0,array('https://www.google.com/jsapi'));
58 
59 $title=$langs->trans("MembersStatisticsByProperties");
60 
61 print load_fiche_titre($title, $mesg);
62 
63 dol_mkdir($dir);
64 
65 $tab='byproperties';
66 
67 $data = array();
68 $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code";
69 $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
70 $sql.=" WHERE d.entity IN (".getEntity('adherent').")";
71 $sql.=" AND d.statut = 1";
72 $sql.=" GROUP BY d.morphy";
73 
74 $foundphy=$foundmor=0;
75 
76 // Define $data array
77 dol_syslog("Count member", LOG_DEBUG);
78 $resql=$db->query($sql);
79 if ($resql)
80 {
81  $num=$db->num_rows($resql);
82  $i=0;
83  while ($i < $num)
84  {
85  $obj=$db->fetch_object($resql);
86 
87  if ($obj->code == 'phy') $foundphy++;
88  if ($obj->code == 'mor') $foundmor++;
89 
90  $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate));
91 
92  $i++;
93  }
94  $db->free($resql);
95 }
96 else
97 {
98  dol_print_error($db);
99 }
100 
101 
102 $head = member_stats_prepare_head($adh);
103 
104 dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user');
105 
106 
107 // Print title
108 if (! count($data))
109 {
110  print $langs->trans("NoValidatedMemberYet").'<br>';
111  print '<br>';
112 }
113 else
114 {
115  print load_fiche_titre($langs->trans("MembersByNature"),'','');
116 }
117 
118 // Print array
119 print '<table class="liste" width="100%">';
120 print '<tr class="liste_titre">';
121 print '<td>'.$langs->trans("Nature").'</td>';
122 print '<td align="right">'.$langs->trans("NbOfMembers").'</td>';
123 print '<td align="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
124 print '</tr>';
125 
126 if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');
127 if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'');
128 
129 $oldyear=0;
130 foreach ($data as $val)
131 {
132  $year = $val['year'];
133  print '<tr class="oddeven">';
134  print '<td>'.$memberstatic->getmorphylib($val['label']).'</td>';
135  print '<td align="right">'.$val['nb'].'</td>';
136  print '<td align="center">'.dol_print_date($val['lastdate'],'dayhour').'</td>';
137  print '</tr>';
138  $oldyear=$year;
139 }
140 
141 print '</table>';
142 
143 
144 dol_fiche_end();
145 
146 
147 llxFooter();
148 
149 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Class to manage members of a foundation.
llxHeader()
Empty header.
Definition: wrapper.php:46
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats informations.
Definition: member.lib.php:206
print
Draft customers invoices.
Definition: index.php:91
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.