GlisWeb framework
_fatturati.gestione.php
Vai alla documentazione di questo file.
1 <?php
2 
12  // tabella della vista
13  $ct['etc']['table'] = 'fatturati';
14 /*
15  // tendina anagrafica
16  // $ct['etc']['id_responsabile'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view' );
17  if( isset( $_REQUEST[ $ct['etc']['table'] ]['id_responsabile'] ) ) {
18  $ct['etc']['id_responsabile'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE se_collaboratore = 1 OR id = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_responsabile'] ) ) );
19  } else {
20  $ct['etc']['id_responsabile'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE se_collaboratore = 1' );
21  }
22 */
23 
24 
25 
26 // SDF 18-7-19 commento la parte di codice che popola la tendina dei clienti
27 
28 
29 # if( isset( $_REQUEST[ $ct['etc']['table'] ]['id_cliente'] ) && !empty($_REQUEST[ $ct['etc']['table'] ]['id_cliente'] )) {
30 # $idAgente = mysqlSelectValue( $cf['mysql']['connection'], 'SELECT id_agente FROM anagrafica WHERE id = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_cliente'] ) ) );
31  //print_r('id cliente: ' . $_REQUEST[ $ct['etc']['table'] ]['id_cliente']);
32  //print_r('id agente: ' . $idAgente);
33 # $ct['etc']['id_cliente'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_clienti_view WHERE id = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_cliente'] ) ) );
34 # }
35 # else {
36  $ct['etc']['id_cliente'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_clienti_estesa_view' );
37 
38  $ct['etc']['id_emittente'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE se_azienda_gestita = 1' );
39 
40 # }
41 
42  // timer
43  timerCheck( $cf['speed'], ' -> fine generazione tendina clienti' );
44 
45 
46  // timer
47  timerCheck( $cf['speed'], ' -> inizio generazione tendina agenti' );
48 
49  if( isset( $_REQUEST[ $ct['etc']['table'] ]['id_agente'] ) ) {
50 // print_r('ho un request id agente: '. $_REQUEST[ $ct['etc']['table'] ]['id_agente'] );echo "\n";
51  //$idAgente = $_REQUEST[ $ct['etc']['table'] ]['id_agente'];
52 # $ct['etc']['id_agente'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE '.( ( isset( $idAgente ) ) ? ' id = '.$idAgente : NULL ).' OR id = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_agente'] ) ) );
53  $ct['etc']['id_agente'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE id = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_agente'] ) ) );
54 // print_r( $ct['etc']['id_agente'] );
55 # } else {
56 // print_r('non mi risulta un request id agente');echo "\n";
57 # $ct['etc']['id_agente'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view '/*.( ( isset( $idAgente ) ) ? ' AND id = '.$idAgente : NULL )*/ );
58  }
59 
60 
61 // print_r ($ct['etc']['id_agente']);echo "\n";
62 // print_r('variabile idAgente: ' . $idAgente);echo "\n";
63 
64  // timer
65  timerCheck( $cf['speed'], ' -> fine generazione tendina agenti' );
66 
67 /*
68 */
69 
70 # if( isset( $_REQUEST[ $ct['etc']['table'] ]['id_mandante'] ) && !empty( $_REQUEST[ $ct['etc']['table'] ]['id_mandante']) ) {
71 # $ct['etc']['id_mandante'] = mysqlCachedQuery( $cf['memcache']['connection'], $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE se_mandante = 1 OR id = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_mandante'] ) ) );
72 # } else {
73  $ct['etc']['id_mandante'] = mysqlCachedQuery( $cf['memcache']['connection'], $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view WHERE se_mandante = 1' );
74 # }
75 
76 /*
77 */
78 
79 /*
80  // modifico il controllo righe duplicate in modo che legga mese, anno, cliente, mandante, tipologia
81  if( isset( $_REQUEST[ $ct['etc']['table'] ]['id_tipologia'] ) && !empty( $_REQUEST[ $ct['etc']['table'] ]['id_tipologia']) ) {
82  $ct['etc']['esistente'] = mysqlQuery( $cf['mysql']['connection'],
83  'SELECT id FROM fatturati WHERE anno = ? AND mese = ? AND id_cliente = ? AND id_mandante = ? '.
84  'AND id_tipologia = ? AND id <> ?',
85  array(
86  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['anno'] ),
87  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['mese'] ),
88  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_cliente'] ),
89  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_mandante'] ),
90  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_tipologia'] ),
91  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id'] )
92  ) );
93  }
94 */
95 
96  // SDF commentato codice seguente sostituito con precedente
97  //controllo righe duplicate
98  if( isset( $_REQUEST[ $ct['etc']['table'] ]['id_tipologia'] ) && !empty( $_REQUEST[ $ct['etc']['table'] ]['id_tipologia'])
99  && isset( $_REQUEST[ $ct['etc']['table'] ]['id'] ) && !empty( $_REQUEST[ $ct['etc']['table'] ]['id'] ) ) {
100  $ct['etc']['esistente'] = mysqlQuery( $cf['mysql']['connection'],
101  'SELECT id FROM fatturati WHERE anno = ? AND mese = ? AND id_cliente = ? AND id_mandante = ? '.
102  'AND id_agente = ? And id_tipologia = ? AND id <> ?',
103  array(
104  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['anno'] ),
105  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['mese'] ),
106  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_cliente'] ),
107  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_mandante'] ),
108  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_agente'] ),
109  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id_tipologia'] ),
110  array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id'] )
111  ) );
112  }
113 /*
114  echo "stampo la request che arriva in input\n";
115  print_r($_REQUEST[ $ct['etc']['table'] ]);
116  echo "stampo la ct[esistente] in output\n";
117  print_r($ct['etc']['esistente']);
118 
119 
120 
121 // print_r("id riga: " . $_REQUEST[ $ct['etc']['table'] ]['id']);
122 
123  // timer
124  timerCheck( $cf['speed'], ' -> fine generazione tendina mandanti' );
125 
126 /*
127  // tendina anagrafica
128  $ct['etc']['id_anagrafica'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM anagrafica_view' );
129 */
130  // tendina tipologia
131  $ct['etc']['id_tipologia'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM tipologie_progetti_view' );
132 
133  // tendina tipologia attivita rimossa perché sostituita da id_emittente
134 // $ct['etc']['id_tipologia_attivita'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM tipologie_attivita_view' );
135 
136  // timer
137  timerCheck( $cf['speed'], ' -> fine generazione tendina tipologia attività' );
138 
139  foreach( range( 1, 12 ) as $mese ) {
140  $ct['etc']['mese'][] = array( 'id' => $mese, '__label__' => int2month( $mese ) );
141  }
142 
143 //$ct['etc']['mese'] = 'gennaio' ;
144 
145 /*
146  // tendina priorita
147  $ct['etc']['id_priorita'] = mysqlQuery( $cf['mysql']['connection'], 'SELECT id, __label__ FROM priorita_view' );
148 
149  // tendina anni
150  foreach( range( date( 'Y' ) + 1, 2017 ) as $y ) {
151  $ct['etc']['anni'][] = array( 'id' => $y, '__label__' => $y );
152  }
153 
154  // tendina settimane
155  foreach( range( 1, 52 ) as $w ) {
156  $ct['etc']['settimane'][] = array( 'id' => $w, '__label__' => $w . ' / ' . substr( int2month( ceil( $w / 4.348125 ) ), 0, 3 ) );
157  }
158 
159  // totale ore svolte
160  if( isset( $_REQUEST[ $ct['etc']['table'] ]['id'] ) ) {
161  $ct['etc']['tot_ore_fatte'] = str_replace( '.', ',', mysqlSelectValue( $cf['mysql']['connection'], 'SELECT sum( ore ) FROM attivita LEFT JOIN task ON task.id = attivita.id_task WHERE attivita.id_progetto = ? OR task.id_progetto = ?', array( array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id'] ), array( 's' => $_REQUEST[ $ct['etc']['table'] ]['id'] ) ) ) );
162  }
163 */
164  // gestione default
165  require DIRECTORY_BASE . '_src/_inc/_macro/_default.gestione.php';
166 
167 ?>
int2month( $m, $l='it-IT')
mysqlQuery( $c, $q, $p=false, &$e=array())
$cf['ricerca']['template']
Definition: _030.common.php:7
$ct['etc']['table']
mysqlCachedQuery( $m, $c, $q, $p=false, $t=MEMCACHE_DEFAULT_TTL, &$e=array())
const DIRECTORY_BASE
Definition: _osm.php:3
timerCheck(&$a, $c)
$_REQUEST['__view__'][ $ct['view']['id']]['__restrict__']['id_progetto']['EQ']