GlisWeb framework
_progetti.analisi.php
Vai alla documentazione di questo file.
1 <?php
2 
13  // tabella del modulo
14  $ct['etc']['table'] = 'task';
15 
16  // gruppi di controlli
17  $ct['page']['contents']['metros'] = array(
18  'general' => array(
19  'label' => NULL
20  ),
21  'produzione' => array(
22  'label' => 'sprint planning'
23  ),
24  'focus' => array(
25  'label' => 'dettaglio task'
26  ),
27  'diario' => array(
28  'label' => NULL
29  )
30  );
31 
32 
33  // task aperti non pianificati per la settimana corrente
34  $ct['etc']['task_backlog'] = mysqlQuery(
35  $cf['mysql']['connection'],
36  'SELECT id, concat(cliente,\' | \', progetto,\' | \',nome ,\' | \',responsabile,\' | \',ore_previste,\' h\' ) AS __label__ FROM task_view '.
37  'WHERE ((anno_previsto <> ? AND settimana_prevista <> ?) OR (anno_previsto = ? AND settimana_prevista > ?) OR ( anno_previsto IS NULL OR settimana_prevista IS NULL ) ) AND timestamp_completamento IS NULL '.
38  'ORDER BY __label__, id_priorita DESC ',
39  array(
40  array( 's' => date( 'Y', strtotime( 'monday this week' ) ) ),
41  array( 's' => date( 'W', strtotime( 'monday this week' ) ) ),
42  array( 's' => date( 'Y', strtotime( 'monday this week' ) ) ),
43  array( 's' => date( 'W', strtotime( 'monday this week' ) ) )
44  )
45  );
46 
47  // aggiungo in sprint il task se selezionato
48  if( isset($_REQUEST['__add__']) && ! empty($_REQUEST['__add__']) ){
49  $update = mysqlQuery(
50  $cf['mysql']['connection'],
51  'UPDATE task SET anno_previsto = ?, settimana_prevista = ? '.
52  'WHERE id = ? ',
53  array(
54  array( 's' => date( 'Y', strtotime( 'monday this week' ) ) ),
55  array( 's' => date( 'W', strtotime( 'monday this week' ) ) ),
56  array( 's' => $_REQUEST['__add__'] )
57  )
58  );
59  }
60 
61  // richiamo il file nella cartella bin con il blocco modal
62 // $ct['page']['contents']['metro']['diario'][] = array(
63 // 'modal' => array( 'id' => 'aggiungi', 'include' => 'inc/progetti.analisi.html' )
64 // );
65 
66  // riepilogo settimana
67  if( in_array( '1100.attivita', $cf['mods']['active']['array'] ) && getAccessPermission( 'task' ) ) {
68 
69  /* // riepilogo attività svolte durante la settimana
70  $diario = mysqlQuery(
71  $cf['mysql']['connection'],
72  'SELECT attivita_view.* FROM attivita_view WHERE ore > 0 AND data BETWEEN ? AND ? '.
73  'ORDER BY data ASC, id ASC ',
74  array(
75  array( 's' => date( 'Y-m-d', strtotime( 'monday this week' ) ) ),
76  array( 's' => date( 'Y-m-d', strtotime( 'friday this week' ) ) )
77  )
78  );
79 
80  // preparo i dati
81  foreach( $diario as $d ) {
82  $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['righe'][] = $d;
83  if( ! isset( $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['totale'] ) ) {
84  $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['totale'] = $d['ore'];
85  } else {
86  $ct['etc']['diario'][ strftime( '%A', strtotime( $d['data'] ) ) ]['totale'] += $d['ore'];
87  }
88  }*/
89 
90  $ct['page']['contents']['metro']['produzione'][] = array(
91  'include' => 'inc/progetti.pianificazione.ore.html');
92 
93 /*
94  // includo il widget
95  if( ! isset( $_REQUEST['nw'] ) ) {
96  $ct['page']['contents']['metro']['diario'][] = array(
97  'include' => 'inc/attivita.riepilogo.html'
98  );
99  }
100 */
101  }
102 
103  // promemoria cose da fare
104 /* if( in_array( '1150.task', $cf['mods']['active']['array'] ) && getAccessPermission( 'task' ) ) {
105  $n = mysqlSelectValue( $cf['mysql']['connection'],
106  'SELECT count( id ) FROM task WHERE timestamp_completamento IS NULL'
107  );
108  $ct['page']['contents']['metro']['general'][] = array(
109  'url' => $cf['contents']['pages']['task_gestione']['url'][ $cf['localization']['language']['ietf'] ],
110  'icon' => NULL,
111  'fa' => 'fa-wrench',
112  'title' => 'inserisci nuove cose da fare',
113  'text' => 'crea rapidamente un nuovo task'
114  );
115  if( $n > 0 ) {
116  $ct['page']['contents']['metro']['general'][] = array(
117  'url' => $cf['contents']['pages']['task']['url'][ $cf['localization']['language']['ietf'] ],
118  'icon' => NULL,
119  'fa' => 'fa-cogs',
120  'title' => 'hai ' . $n . ' cose da fare',
121  'text' => 'gestisci i task assegnati a te'
122  );
123  }
124  }*/
125 
126  // focus di produzione
127  if( in_array( '1150.task', $cf['mods']['active']['array'] ) && getAccessPermission( 'task' ) ) {
128 
129  // anteprima prossima settimana
130  if( isset( $_REQUEST['lw'] ) ) {
131  $wPrefix = 'last';
132  } else {
133  $wPrefix = 'this';
134  }
135 
136  // task su cui mantenere il focus
137  $ct['etc']['focus'] = mysqlQuery(
138  $cf['mysql']['connection'],
139  'SELECT task_view.* FROM task_view WHERE ( (anno_previsto = ? AND settimana_prevista <= ?) OR anno_previsto < ?) '.
140  'AND (timestamp_completamento IS NULL OR (timestamp_completamento >= ? AND timestamp_completamento <= ? ) )'.
141  'ORDER BY timestamp_completamento ASC, timestamp_revisione ASC, id_priorita DESC ',
142  array(
143  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
144  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) ),
145  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
146  array( 's' => strtotime( 'monday '.$wPrefix.' week' ) ),
147  array( 's' => strtotime( 'sunday '.$wPrefix.' week' ) )
148  )
149  );
150 
151  //$ct['etc']['ore_'] =
152  $ct['etc']['task']['pianificati'] = sizeof($ct['etc']['focus']);
153  $ct['etc']['task']['chiusi'] = mysqlSelectValue(
154  $cf['mysql']['connection'],
155  'SELECT COUNT(*) AS totale FROM task_view WHERE ( (anno_previsto = ? AND settimana_prevista <= ?) OR anno_previsto < ?) '.
156  'AND (timestamp_completamento IS NOT NULL AND (timestamp_completamento >= ? AND timestamp_completamento <= ? ) )'.
157  'ORDER BY timestamp_completamento ASC, timestamp_revisione ASC, id_priorita DESC ',
158  array(
159  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
160  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) ),
161  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
162  array( 's' => strtotime( 'monday '.$wPrefix.' week' ) ),
163  array( 's' => strtotime( 'sunday '.$wPrefix.' week' ) )
164  )
165  );
166 
167  $ct['etc']['domenica'] = strtotime( 'sunday '.$wPrefix.' week' );
168 //print_r($ct['etc']['task']['chiusi']);
169  $ct['etc']['task']['revisione'] = mysqlSelectValue(
170  $cf['mysql']['connection'],
171  'SELECT COUNT(*) AS totale FROM task_view WHERE ((anno_previsto = ? AND settimana_prevista <= ?) OR anno_previsto <? ) '.
172  'AND timestamp_completamento IS NULL AND timestamp_revisione IS NOT NULL '.
173  'AND (timestamp_revisione >= ? AND timestamp_revisione <= ? ) '.
174  'ORDER BY anno_previsto ASC, settimana_prevista ASC ',
175  array(
176  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
177  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) ),
178  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) ),
179  array( 's' => strtotime( 'monday '.$wPrefix.' week' ) ),
180  array( 's' => strtotime( 'sunday '.$wPrefix.' week' ) )
181  )
182  );
183 
184  $ct['etc']['task']['mancanti'] = $ct['etc']['task']['pianificati'] - $ct['etc']['task']['revisione'] - $ct['etc']['task']['chiusi'];
185 
186 
187  // ore fatte la scorsa settimana per i task
188  $ct['etc']['ore']['fatte'] = mysqlSelectValue(
189  $cf['mysql']['connection'],
190  'SELECT coalesce( sum( attivita_view.ore ) ) AS t FROM attivita_view INNER JOIN task_view ON task_view.id = attivita_view.id_task '.
191  'WHERE attivita_view.data >= ? AND attivita_view.data <= ? AND ((task_view.anno_previsto = ? AND task_view.settimana_prevista <= ?) OR task_view.anno_previsto < ? )',
192  array(
193  array( 's' => date( 'Y-m-d', strtotime( 'monday '.$wPrefix.' week' ) ) ),
194  array( 's' => date( 'Y-m-d', strtotime( 'sunday '.$wPrefix.' week' ) ) ),
195 // array( 's' => $_SESSION['account']['id_anagrafica'] ),
196  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
197  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) ),
198  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) )
199  )
200  );
201 
202 
203 
204  $ct['etc']['ore']['passate'] = mysqlSelectValue(
205  $cf['mysql']['connection'],
206  'SELECT coalesce( sum( attivita_view.ore ) ) AS t FROM attivita_view INNER JOIN task_view ON task_view.id = attivita_view.id_task '.
207  'WHERE attivita_view.data < ? AND ((task_view.anno_previsto = ? AND task_view.settimana_prevista <= ?) OR task_view.anno_previsto < ? ) '.
208  'AND (timestamp_completamento IS NULL OR ( timestamp_completamento >= ? AND timestamp_completamento <= ? ) )' ,
209  array(
210  array( 's' => date( 'Y-m-d', strtotime( 'monday '.$wPrefix.' week' ) ) ),
211 // array( 's' => $_SESSION['account']['id_anagrafica'] ),
212  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
213  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) ),
214  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
215  array( 's' => strtotime( 'monday '.$wPrefix.' week' ) ),
216  array( 's' => strtotime( 'sunday '.$wPrefix.' week' ) )
217  )
218  );
219 
220 
221  $ct['etc']['ore']['pianificate'] = 0;
222  foreach($ct['etc']['focus'] as $task ){
223  $ct['etc']['ore']['pianificate'] += $task['ore_previste'];
224  }
225 
226  // ore fatte per altri task o attività varie
227  $ct['etc']['ore']['extra'] = mysqlSelectValue(
228  $cf['mysql']['connection'],
229  'SELECT coalesce( sum( attivita_view.ore ) ) AS t FROM attivita_view '.
230  'LEFT JOIN task_view ON task_view.id = attivita_view.id_task '.
231  'WHERE attivita_view.data >= ? AND ( '.
232  '( attivita_view.id_task IS NULL ) OR ( '.
233  '( task_view.anno_previsto > ? OR ( task_view.anno_previsto = ? AND task_view.settimana_prevista <> ? ) )'.
234  ') )',
235  array(
236  array( 's' => date( 'Y-m-d', strtotime( 'monday '.$wPrefix.' week' ) ) ),
237 // array( 's' => $_SESSION['account']['id_anagrafica'] ),
238 // array( 's' => $_SESSION['account']['id_anagrafica'] ),
239  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
240  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
241  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) )
242  )
243  );
244 
245  if( $ct['etc']['ore']['pianificate']>0 ){
246  $ct['etc']['ore']['variazione_h'] = $ct['etc']['ore']['pianificate'] - $ct['etc']['ore']['fatte'] - $ct['etc']['ore']['passate'];
247  $ct['etc']['ore']['variazione_perc'] = 100 - (($ct['etc']['ore']['fatte'] + $ct['etc']['ore']['passate'] )* 100 / $ct['etc']['ore']['pianificate']);}
248 
249 /*
250  // ore da fare per i task di questa settimana
251  $ct['etc']['ore']['residue'] = mysqlSelectValue(
252  $cf['mysql']['connection'],
253  'SELECT sum( coalesce( task_view.ore_residue, 0 ) ) AS t FROM task_view WHERE task_view.id_responsabile = ? '.
254  'AND task_view.timestamp_completamento IS NULL '.
255  'AND ( task_view.anno_previsto < ? OR ( task_view.anno_previsto = ? AND task_view.settimana_prevista <= ? ) )',
256  array(
257  array( 's' => $_SESSION['account']['id_anagrafica'] ),
258  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
259  array( 's' => date( 'Y', strtotime( 'monday '.$wPrefix.' week' ) ) ),
260  array( 's' => date( 'W', strtotime( 'monday '.$wPrefix.' week' ) ) )
261  )
262  );
263 */
264 
265  // grafico delle ore pianificate per settimana
266  $ct['contents']['chartjs']['doughnut']['avanzamento'] = array(
267  'data' => array(
268  'task chiusi' => array(
269  '#' => array(
270  'value' => $ct['etc']['task']['chiusi'],
271  'bgColor' => 'rgba( 16, 16, 16, 0.5 )',
272  'bdColor' => 'rgba( 96, 96, 96, 0.5 )'
273  )
274  ),
275  'task in revisione' => array(
276  '#' => array(
277  'value' => $ct['etc']['task']['revisione'],
278  'bgColor' => 'rgba( 126, 126, 126, 0.5 )',
279  'bdColor' => 'rgba( 96, 96, 96, 0.5 )'
280  )
281  ),
282  'task aperti' => array(
283  '#' => array(
284  'value' => $ct['etc']['task']['mancanti'],
285  'bgColor' => 'rgba( 200, 200, 200, 0.5 )',
286  'bdColor' => 'rgba( 96, 96, 96, 0.5 )'
287  )
288  )
289  ),
290  'options' => array(
291  'scales' => array(
292  'gridLines' => array( 'display' => false )
293  ),
294  'legend' => array(
295  'position' => 'left'
296  )
297  )
298  );
299 
300  // TODO qui inizia il codice da trasformare in funzione
301 
302  foreach( $ct['contents']['chartjs']['doughnut']['avanzamento']['data'] as $label => $dataset ) {
303  foreach( $dataset as $dsName => $dsData ) {
304  $ct['contents']['chartjs']['doughnut']['avanzamento']['dataset'][ $dsName ]['data'][ $label ] = $dsData;
305  }
306  }
307 
308  $ct['contents']['chartjs']['doughnut']['avanzamento']['options'] = json_encode( $ct['contents']['chartjs']['doughnut']['avanzamento']['options'], true );
309 
310  // --> fine codice da trasformare in funzione
311 /* $ct['page']['contents']['metro']['focus'][] = array(
312  'modal' => array( 'id' => 'aggiungi', 'include' => 'inc/progetti.analisi.aggiunta.task.html' ),
313  'icon' => NULL,
314  'fa' => 'fa-plus',
315  'title' => 'aggiungi task',
316  'text' => 'sposta task dal backlog allo sprint'
317  );
318 */
319  $ct['page']['contents']['metro']['focus'][] = array(
320  'include' => 'inc/progetti.analisi.html'
321  );
322 
323 
324  $ct['page']['contents']['metro']['focus'][] = array(
325 # 'include' => 'inc/progetti.analisi.aggiunta.task.html'
326  'modal' => array( 'id' => 'aggiungi', 'include' => 'inc/progetti.analisi.aggiunta.task.html' )
327  );
328 
329 
330  }
331 
332  // gestione default
333  require DIRECTORY_BASE . '_src/_inc/_macro/_default.gestione.php';
334 
335  // debug
336  // print_r( $_SESSION );
337  // print_r( $ct['etc'] );
338 
339 ?>
mysqlQuery( $c, $q, $p=false, &$e=array())
$cf['ricerca']['template']
Definition: _030.common.php:7
mysqlSelectValue( $c, $q, $p=false, &$e=array())
const DIRECTORY_BASE
Definition: _osm.php:3
getAccessPermission( $p)
Definition: _acl.utils.php:22
$ct['etc']['table']
$_REQUEST['__view__'][ $ct['view']['id']]['__restrict__']['id_progetto']['EQ']