récupérer des variables sur le Controller depuis le Model
Bonjour,
j essaye de récupérer plusieurs graphs sur une page pour créer un dashboard, j ai pu faire cela en codant directement sur le Controller, mais ce n est pas du tout propre en ayant zend framework et puis MVC, alors j ai pensé a stocker chaque code de graphe par fonctions sur une class Model (chaque Function associé a un graphe) je voudrais récupérer les datas ($data, $data1) de chaque graphe sur le Controller pour ensuite les passer sur la vue
Model:
Code:
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| <?php
class App_Model_Table_Dash extends Oft_Crud_Db_Table
{
protected function _setupDatabaseAdapter()
{
if (!$this->_db) {
$this->_db = Oft_App::getInstance()->getResource('multidb')->getDb('oracledb');
}
}
public function MoFsm(){
$view = $this->view;
$dateInBetween = array();
$SmsSum = array();
$smsSumGraph = array();
$y_axis_values = array();
$x_axis_values = array();
$conn = oci_connect('sm_statistics', 'sm_statistics',
'//10.241.45.5/ODS')or die ('Error binding string');
$queryparse = oci_parse($conn, $query);
oci_execute($queryparse);
while ($row_date = oci_fetch_array($queryparse,
OCI_ASSOC+OCI_RETURN_NULLS))
{
$y_axis_values[] = intval($row_date['SMSSUM']);
$x_axis_values[] = $row_date['DATETO'];
}
$chart = new open_flash_chart();
$y_axis = new y_axis();
$x_axis = new x_axis();
$default_dot = new line_dot();
$tooltip = new tooltip();
$x_labels = new x_axis_labels();
$x_labels->set_labels($x_axis_values);
$taille=sizeof($x_labels);
$step=2;
if ($taille>100) $step=4;
if ($taille>200) $step=8;
if ($taille>300) $step=12;
if ($taille>400) $step=24;
$x_labels->set_steps( $step );
$x_labels->rotate('45');
$x_axis->set_labels($x_labels);
$x_axis->set_offset(false);
$y_axis->set_range( 0, max($y_axis_values)+10, round( max($y_axis_values) / 4 ) );
$chart->set_x_axis( $x_axis );
$chart->add_y_axis( $y_axis );
//LINE
$line = new line();
$line->set_values( $y_axis_values );
$line->set_halo_size( 0 );
$line->set_width( 2 );
$chart->add_element($line);
$data = $chart->toPrettyString();
}
public function graph2 (){
$y_axis_values1 = array();
$x_axis_values1 = array();
$y_axis_values2 = array();
$x_axis_values2 = array();
$conn = oci_connect('sm_statistics', 'sm_statistics',
'//10.241.45.5/ODS')or die ('Error binding string');
$SuccRecMsgParse = oci_parse($conn, $query1);
oci_execute($SuccRecMsgParse);
while ($row_date1 = oci_fetch_array($SuccRecMsgParse,
OCI_ASSOC+OCI_RETURN_NULLS))
{
$y_axis_values1[] = intval($row_date1['SMSSUM']);
$x_axis_values1[] = $row_date1['DATETO'];
}
$MOtotalIncParse = oci_parse($conn, $query2);
oci_execute($MOtotalIncParse);
while ($row_date2 = oci_fetch_array($MOtotalIncParse,
OCI_ASSOC+OCI_RETURN_NULLS))
{
$y_axis_values2[] = intval($row_date2['SMSSUM']);
$x_axis_values2[] = $row_date2['DATETO'];
}
$y_axis1 = new y_axis();
$x_axis1 = new x_axis();
$default_dot = new line_dot();
$tooltip = new tooltip();
$x_labels1 = new x_axis_labels();
$x_labels1->set_labels($x_axis_values1);
$taille=sizeof($x_labels1);
$step=2;
if ($taille>100) $step=4;
if ($taille>200) $step=8;
if ($taille>300) $step=12;
if ($taille>400) $step=24;
$x_labels1->set_steps( $step );
$x_labels1->rotate('45');
$x_axis1->set_labels($x_labels1);
$x_axis1->set_offset(false);
$y_axis1->set_range( 0, max($y_axis_values1)+10, round( max($y_axis_values1) / 4 ) );
$default_dot = new line_dot();
$default_dot->set_colour('#DFC329');
$line_dot = new line();
$line_dot->set_default_dot_style($default_dot);
$line_dot->set_width( 4 );
$line_dot->set_colour( '#DFC329' );
$line_dot->set_values( $y_axis_values1 );
$line_dot->set_key( "SuccRecMsg", 10 );
$default_hollow_dot = new line_hollow();
$default_hollow_dot->set_colour('#6363AC');
$line_hollow = new line();
$line_hollow->set_default_dot_style($default_hollow_dot);
$line_hollow->set_width( 4 );
$line_hollow->set_colour( '#6363AC' );
$line_hollow->set_values( $y_axis_values2 );
$line_hollow->set_key( "MOtotalInc", 10 );
$chart1 =new open_flash_chart();
$chart1->set_x_axis( $x_axis1 );
$chart1->add_y_axis( $y_axis1 );
$chart1->add_element($line_dot);
$chart1->add_element($line_hollow);
$data1 = $chart1->toPrettyString();
}
} |