PHP - Como Ejecutar Grafica chart Morris con selector de fechas

 
Vista:

Como Ejecutar Grafica chart Morris con selector de fechas

Publicado por marcos (6 intervenciones) el 17/03/2017 10:24:24
Buenas. Me estoy volviendo un poco loco y mirando por internet no encuentro ningun ejemplo claro. Lo que quiero hacer es que con un datepicker seleccionar un rango de fechas y pasarlas a una query de oracle y con un boton me aplique esa consulta en la grafica. Tengo este codigo. Como deberia de hacerlo??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
session_start();
if ($_SESSION['login'] == true)
{
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<?php include './header.php' ?>
</head>
<body class="hold-transition skin-blue sidebar-mini">
	<div class="wrapper">
         <?php include './header2.php' ?>
         <?php include './menu.php' ?>
 
<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Estadisticas
        <small>Version 1.0</small>
      </h1>
 
		<section class="content">
 
		<?php include './conexion.php';
			$base = new Database();
			$con = $base->connect();
      $peticioneshoy = "AQUI VA EL SELECT";
      $rpetihoy = oci_parse($con, $peticioneshoy);
      oci_execute($rpetihoy);
 
		?>
 
 
			<div class="box box-info">
				<div class="box-header with-border">
					<h3 class="box-title"> Peticiones </h3>
					<div class="col-md-3">
					<input type="text" name="from_date" id="from_date" class="form-control" placeholder="From Date" />
            </div>
            <div class="col-md-3">
					 <input type="text" name="to_date" id="to_date" class="form-control" placeholder="To Date" />
          </div>
          <div class="col-md-3">
					<input type="button" name="filter" id="filter" value="Filter" class="btn btn-info" />
					</div>
					<div class="box-body">
 
					<div id="total" style="height: 200px;"></div>
 
					</div>
 
				</div>
 
			</div>
 
		</section>
    </div>
	<?php include './footer.php' ?>
	 <script>
   $(function(){
    Morris.Bar({
    element: 'total',
    data: [
    <?php while($row = oci_fetch_array($rpetihoy)){ ?>
    {
        total: '<?php echo $row['TOTAL']; ?>',
        urgente:'<?php echo $row['ISURGENT'] ?>'
 
 
    },
    <?php } ?>],
    xkey: 'urgente',
    ykeys: ['total'],
    labels: ['peticiones'],
    xLabels:['TOTAL'],
    hideHover: 'auto',
    pointSize: 2,
    resize: true,
});
});
</script>
<script>
     $(document).ready(function(){
           $.datepicker.setDefaults({
                dateFormat: 'dd-mm-yy'
           });
           $(function(){
                $("#from_date").datepicker();
                $("#to_date").datepicker();
           });
           $('#filter').click(function(){
                var from_date = $('#from_date').val();
                var to_date = $('#to_date').val();
 
      });
 </script>
  <script>
 $.datepicker.regional['es'] = {
 closeText: 'Cerrar',
 prevText: '< Ant',
 nextText: 'Sig >',
 currentText: 'Hoy',
 monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
 monthNamesShort: ['Ene','Feb','Mar','Abr', 'May','Jun','Jul','Ago','Sep', 'Oct','Nov','Dic'],
 dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
 dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
 dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
 weekHeader: 'Sm',
 dateFormat: 'dd/mm/yy',
 firstDay: 1,
 isRTL: false,
 showMonthAfterYear: false,
 yearSuffix: ''
 };
 $.datepicker.setDefaults($.datepicker.regional['es']);
</script>
</body>
</html>
<?php
  } else {
    echo '<script> window.location="index.php"; </script>';
  }
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder