GlisWeb framework
_default.dashboard.php
Vai alla documentazione di questo file.
1 <?php
2 
12  // gruppi di controlli
13  $ct['page']['contents']['metros'] = array(
14  'general' => array(
15  'label' => NULL
16  ),
17  'produzione' => array(
18  'label' => 'produzione'
19  ),
20  'focus' => array(
21  'label' => 'i tuoi focus per ' . ( ( isset( $_REQUEST['nw'] ) ) ? 'la settimana prossima' : 'questa settimana' )
22  ),
23  'diario' => array(
24  'label' => 'la tua settimana'
25  )
26  );
27 
28  // promemoria ore da inserire
29  if( in_array( '1100.attivita', $cf['mods']['active']['array'] ) && getAccessPermission( 'attivita' ) ) {
30  $ct['page']['contents']['metro']['general'][] = array(
31  'url' => $cf['contents']['pages']['attivita_gestione']['url'][ $cf['localization']['language']['ietf'] ],
32  'icon' => NULL,
33  'fa' => 'fa-clock-o',
34  'title' => 'inserimento ore lavoro',
35  'text' => 'registra le ore per le tue attività in corso'
36  );
37  }
38 
39  // riepilogo settimana
40  if( in_array( '1100.attivita', $cf['mods']['active']['array'] ) && isset( $_SESSION['account']['id_anagrafica'] ) && getAccessPermission( 'task' ) ) {
41 
42  // riepilogo attività svolte durante la settimana
43  $diario = mysqlQuery(
44  $cf['mysql']['connection'],
45  'SELECT attivita_view.* FROM attivita_view WHERE ore > 0 AND id_anagrafica = ? AND data BETWEEN ? AND ? '.
46  'ORDER BY data ASC, id ASC ',
47  array(
48  array( 's' => $_SESSION['account']['id_anagrafica'] ),
49  array( 's' => date( 'Y-m-d', strtotime( 'monday this week' ) ) ),
50  array( 's' => date( 'Y-m-d', strtotime( 'friday this week' ) ) )
51  )
52  );
53 
54  // preparo i dati
55  foreach( $diario as $d ) {
56  $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['righe'][] = $d;
57  if( ! isset( $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['totale'] ) ) {
58  $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['totale'] = $d['ore'];
59  } else {
60  $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['totale'] += $d['ore'];
61  }
62  }
63 
64  // includo il widget
65  if( ! isset( $_REQUEST['nw'] ) ) {
66  $ct['page']['contents']['metro']['diario'][] = array(
67  'include' => 'inc/attivita.riepilogo.html'
68  );
69  }
70 
71  }
72 
73  // promemoria cose da fare
74  if( in_array( '1150.task', $cf['mods']['active']['array'] ) && isset( $_SESSION['account']['id_anagrafica'] ) && getAccessPermission( 'task' ) ) {
75  if( isset( $_SESSION['account']['se_cliente'] ) && ! empty( $_SESSION['account']['se_cliente'] ) ) {
76  $ct['page']['contents']['metro']['general'][] = array(
77  'url' => $cf['contents']['pages']['task_gestione']['url'][ $cf['localization']['language']['ietf'] ],
78  'icon' => NULL,
79  'fa' => 'fa-wrench',
80  'title' => 'inserisci una richiesta',
81  'text' => 'verrà gestita e analizzata entro 24/48 ore lavorative'
82  );
83  } else {
84  $n = mysqlSelectValue( $cf['mysql']['connection'],
85  'SELECT count( id ) FROM task WHERE id_responsabile = ? AND timestamp_completamento IS NULL',
86  array( array( 's' => $_SESSION['account']['id_anagrafica'] ) )
87  );
88  $ct['page']['contents']['metro']['general'][] = array(
89  'url' => $cf['contents']['pages']['task_gestione']['url'][ $cf['localization']['language']['ietf'] ],
90  'icon' => NULL,
91  'fa' => 'fa-wrench',
92  'title' => 'inserisci nuove cose da fare',
93  'text' => 'crea rapidamente un nuovo task'
94  );
95  if( $n > 0 ) {
96  $ct['page']['contents']['metro']['general'][] = array(
97  'url' => $cf['contents']['pages']['task']['url'][ $cf['localization']['language']['ietf'] ],
98  'icon' => NULL,
99  'fa' => 'fa-cogs',
100  'title' => 'hai ' . $n . ' cose da fare',
101  'text' => 'gestisci i task assegnati a te'
102  );
103  }
104  }
105  }
106 
107  // focus di produzione
108  if( in_array( '1150.task', $cf['mods']['active']['array'] ) && isset( $_SESSION['account']['id_anagrafica'] ) && getAccessPermission( 'task' ) ) {
109 
110  // anteprima prossima settimana
111  if( isset( $_REQUEST['nw'] ) ) {
112  $wPrefix = 'next';
113  } else {
114  $wPrefix = 'this';
115  }
116 
117  // task su cui mantenere il focus
118  $ct['etc']['focus'] = mysqlQuery(
119  $cf['mysql']['connection'],
120  'SELECT task_view.* FROM task_view WHERE id_responsabile = ? AND ( anno_previsto < ? OR ( anno_previsto = ? AND settimana_prevista <= ? ) ) AND timestamp_completamento IS NULL '.
121  'ORDER BY anno_previsto ASC, settimana_prevista ASC ',
122  array(
123  array( 's' => $_SESSION['account']['id_anagrafica'] ),
124  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
125  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
126  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) )
127  )
128  );
129 
130  // ore fatte per i task di questa settimana
131  $ct['etc']['ore']['fatte'] = mysqlSelectValue(
132  $cf['mysql']['connection'],
133  'SELECT coalesce( sum( attivita_view.ore ) ) AS t FROM attivita_view INNER JOIN task_view ON task_view.id = attivita_view.id_task WHERE attivita_view.data >= ? AND task_view.id_responsabile = ? AND task_view.anno_previsto <= ? AND task_view.settimana_prevista <= ?',
134  array(
135  array( 's' => date( 'Y-m-d', strtotime( 'monday '.$wPrefix.' week' ) ) ),
136  array( 's' => $_SESSION['account']['id_anagrafica'] ),
137  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
138  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) )
139  )
140  );
141 
142  // ore fatte per altri task o attività varie
143  $ct['etc']['ore']['extra'] = mysqlSelectValue(
144  $cf['mysql']['connection'],
145  'SELECT coalesce( sum( attivita_view.ore ) ) AS t FROM attivita_view '.
146  'LEFT JOIN task_view ON task_view.id = attivita_view.id_task '.
147  'WHERE attivita_view.data >= ? AND attivita_view.id_anagrafica = ? AND ( '.
148  '( attivita_view.id_task IS NULL ) OR ( '.
149  'task_view.id_responsabile = ? AND ( task_view.anno_previsto > ? OR ( task_view.anno_previsto = ? AND task_view.settimana_prevista > ? ) )'.
150  ') )',
151  array(
152  array( 's' => date( 'Y-m-d', strtotime( 'monday '.$wPrefix.' week' ) ) ),
153  array( 's' => $_SESSION['account']['id_anagrafica'] ),
154  array( 's' => $_SESSION['account']['id_anagrafica'] ),
155  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
156  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
157  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) )
158  )
159  );
160 
161  // ore da fare per i task di questa settimana
162  $ct['etc']['ore']['residue'] = mysqlSelectValue(
163  $cf['mysql']['connection'],
164  'SELECT sum( coalesce( task_view.ore_residue, 0 ) ) AS t FROM task_view WHERE task_view.id_responsabile = ? '.
165  'AND task_view.timestamp_completamento IS NULL '.
166  'AND ( task_view.anno_previsto < ? OR ( task_view.anno_previsto = ? AND task_view.settimana_prevista <= ? ) )',
167  array(
168  array( 's' => $_SESSION['account']['id_anagrafica'] ),
169  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
170  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
171  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) )
172  )
173  );
174 
175  // grafico delle ore pianificate per settimana
176  $ct['contents']['chartjs']['doughnut']['avanzamento'] = array(
177  'data' => array(
178  'ore da fare' => array(
179  '# ore' => array(
180  'value' => $ct['etc']['ore']['residue'],
181  'bgColor' => 'rgba( 96, 96, 96, 0.5 )',
182  'bdColor' => 'rgba( 96, 96, 96, 0.5 )'
183  )
184  ),
185  'ore fatte' => array(
186  '# ore' => array(
187  'value' => $ct['etc']['ore']['fatte'],
188  'bgColor' => 'rgba( 160, 160, 160, 0.5 )',
189  'bdColor' => 'rgba( 96, 96, 96, 0.5 )'
190  )
191  ),
192  'altre attività' => array(
193  '# ore' => array(
194  'value' => $ct['etc']['ore']['extra'],
195  'bgColor' => 'rgba( 16, 16, 16, 0.5 )',
196  'bdColor' => 'rgba( 96, 96, 96, 0.5 )'
197  )
198  )
199  ),
200  'options' => array(
201  'scales' => array(
202  'gridLines' => array( 'display' => false )
203  ),
204  'legend' => array(
205  'position' => 'left'
206  )
207  )
208  );
209 
210  // TODO qui inizia il codice da trasformare in funzione
211 
212  foreach( $ct['contents']['chartjs']['doughnut']['avanzamento']['data'] as $label => $dataset ) {
213  foreach( $dataset as $dsName => $dsData ) {
214  $ct['contents']['chartjs']['doughnut']['avanzamento']['dataset'][ $dsName ]['data'][ $label ] = $dsData;
215  }
216  }
217 
218  $ct['contents']['chartjs']['doughnut']['avanzamento']['options'] = json_encode( $ct['contents']['chartjs']['doughnut']['avanzamento']['options'], true );
219 
220  // --> fine codice da trasformare in funzione
221 
222  $ct['page']['contents']['metro']['focus'][] = array(
223  'include' => 'inc/progetti.focus.html'
224  );
225 
226  }
227 
228  // debug
229  // print_r( $_SESSION );
230  // print_r( $ct['etc'] );
231 
232 ?>
mysqlQuery( $c, $q, $p=false, &$e=array())
if(!empty($_REQUEST['id'])) $d
$cf['ricerca']['template']
Definition: _030.common.php:7
mysqlSelectValue( $c, $q, $p=false, &$e=array())
if(isset( $_REQUEST['amazonCheckoutSessionId'])) $_SESSION['carrello']
$ct['page']['contents']['metros']
getAccessPermission( $p)
Definition: _acl.utils.php:22
$_REQUEST['__view__'][ $ct['view']['id']]['__restrict__']['id_progetto']['EQ']