GlisWeb framework
progress.php
Vai alla documentazione di questo file.
1 <?php
2 
3  // inclusione del framework
4  require '../../../_src/_config.php';
5 
6  // decodifico l'input
7  $input = json_decode( file_get_contents('php://input'), true );
8 
9  // decodifico l'input
10  if( is_array( $input ) ) {
11  $_REQUEST = array_replace_recursive(
13  );
14  }
15 
16  // verifico che ci sia un job id
17  if( isset( $_REQUEST['job'] ) ) {
18 
19  // recupero i dati del job
20  $job = mysqlSelectRow(
21  $cf['mysql']['connection'],
22  'SELECT * FROM job WHERE id = ?',
23  array( array( 's' => $_REQUEST['job'] ) )
24  );
25 
26  // se il job va iniziato...
27  if( empty( $job ) ) {
28 
29  // costruzione dell'output
30  $dati = array(
31  'job' => $_REQUEST['job'],
32  'done' => false,
33  'totale' => 100,
34  'corrente' => 0,
35  'progresso' => 0,
36  'passo' => 1,
37  'message' => 'lavoro iniziato',
38  'error' => false
39  );
40 
41  // inserisco i dati del job
42  $job = mysqlQuery(
43  $cf['mysql']['connection'],
44  'INSERT INTO job ( id, totale, corrente, passo ) VALUES ( ?, ?, ?, ? )',
45  array(
46  array( 's' => $dati['job'] ),
47  array( 's' => $dati['totale'] ),
48  array( 's' => $dati['corrente'] ),
49  array( 's' => $dati['passo'] )
50  )
51  );
52 
53  } elseif( $job['totale'] == $job['corrente'] ) {
54 
55  // costruzione dell'output
56  $dati = array(
57  'job' => $job['id'],
58  'done' => true,
59  'totale' => $job['totale'],
60  'corrente' => $job['corrente'],
61  'progresso' => 100,
62  'passo' => $job['passo'],
63  'message' => 'lavoro completato',
64  'error' => false
65  );
66 
67  // reset del job
68  mysqlQuery(
69  $cf['mysql']['connection'],
70  'DELETE FROM job WHERE id = ?',
71  array( array( 's' => $_REQUEST['job'] ) )
72  );
73 
74  } else {
75 
76  // costruzione dell'output
77  $dati = array(
78  'job' => $job['id'],
79  'done' => false,
80  'totale' => $job['totale'],
81  'corrente' => $job['corrente'] + 1,
82  'progresso' => floor( ( $job['corrente'] * 100 ) / $job['totale'] ),
83  'passo' => $job['passo'],
84  'message' => 'lavoro al ' . floor( ( $job['corrente'] * 100 ) / $job['totale'] ) . '%',
85  'error' => false
86  );
87 
88  // aggiorno i dati del job
89  $job = mysqlQuery(
90  $cf['mysql']['connection'],
91  'REPLACE INTO job ( id, totale, corrente, passo ) VALUES ( ?, ?, ?, ? )',
92  array(
93  array( 's' => $dati['job'] ),
94  array( 's' => $dati['totale'] ),
95  array( 's' => $dati['corrente'] ),
96  array( 's' => $dati['passo'] )
97  )
98  );
99 
100  }
101 
102  } else {
103 
104  // costruzione dell'output
105  $dati = array(
106  'done' => true,
107  'message' => 'nessun job specificato',
108  'error' => true
109  );
110 
111  }
112 
113  // output
114  buildJson( $dati );
115 
116 ?>
$input
Definition: progress.php:7
mysqlSelectRow( $c, $q, $p=false, &$e=array())
mysqlQuery( $c, $q, $p=false, &$e=array())
$cf['ricerca']['template']
Definition: _030.common.php:7
buildJson( $content, $encoding=ENCODING_UTF8, $headers=array())
if(! isset( $_REQUEST['__view__'][ $ct['view']['id']]['__extra__']['assegnato'])|| $_REQUEST['__view__'][ $ct['view']['id']]['__extra__']['assegnato']=='__me__') elseif($_REQUEST[ '__view__'][$ct[ 'view'][ 'id']][ '__extra__'][ 'assegnato']=='__nessuno__')
$_REQUEST['__view__'][ $ct['view']['id']]['__restrict__']['id_progetto']['EQ']