[eluser]Mareli[/eluser]
Hi everyone!! How are you? Well, I need your help, you'll see, I have the idea of been doing the things right, but, for some reason, I don't get the result that I expected. I hope you can help me.
This is the code of my controller
Code:
<?php
class Creportesestadisticos extends Controller {#principal
function __construct() {#1
parent::Controller();
$this->uicomponents->checkSession();
$this->load->model('contabilidad/mreportesestadisticos', 'model');
setPathXajax();
}#1
function index() {#2
$data['xajax_js'] = $this->_loadXajax();
$data['nombreUsuario'] = $this->db_session->userdata('nombreUsuario');
$this->load->view('contabilidad/cuentascobrar/reportesestadisticos',$data);
}#2
function makeTable($mixed) {#3
$total = 0;
$table = $this->_tableHeader();
$queryReporte = $this->model->getReporteEstadistico($mixed['fecha']);
foreach ($queryReporte as $reporte){#4
$table .= $this->_add_row(array($reporte->cliente." ".$reporte->monto." ".$reporte->fecha." ".$reporte->estatus,' ',' ',' ',' ',' ',' '),"reporte");
return $table; }#4
}#3
function _tableHeader() {#5
$table = '<table width="750" id="tablareporte" cellspacing="0"><tr>';
$table .= '<td width="250" height="24" id="header">Cliente</td>';
$table .= '<td width="64" id="header">Monto</td>';
$table .= '<td width="283" id="header">Fecha</td>';
$table .= '<td width="64" id="header">Estatus</td></tr>';
return $table;
}#5
function _add_row($array,$style) {#6
$row = '<tr id="'. $style .'"><td height="24">'. $array[0] .'</td>';
$row .= '<td align="center" valign="top">'. $array[1] .'</td>';
$row .= '<td valign="top">'. $array[2] .'</td>';
$row .= '<td align="center" valign="top">'. $array[3] .'</td>';
$row .= '<td valign="top">'. $array[4] .'</td>';
$row .= '<td valign="top">'. $array[5] .'</td>';
$row .= '<td valign="top">'. $array[6] .'</td></tr>';
return $row;
}#6
function showTable($form) {#7
$objResponse = new xajaxResponse();
$objResponse->assign('tabla','innerHTML',$this->makeTable($form));
return $objResponse;
}#7
function _loadXajax() {
$this->xajax = new xajax();
//$this->xajax->configure('debug',true);
$this->xajax->registerFunction(array("showTable",&$this,"showTable"));
$this->xajax->processRequest();
return $this->xajax->getJavascript('/javascripts/');
}
}#principal
?>
This the code of my model.
Code:
<?php
class Mreportesestadisticos extends Model {
function __construct() {
parent::Model();
}
function getReporteEstadistico($fecha) {
$sql = "SELECT CONCAT( clientes.apellidos, ' ', clientes.nombre ) AS cliente, movauxiliarpagos.pago AS monto, movauxiliarpagos.fechapago AS fecha, movauxiliarpagos.estatus AS estatus FROM movauxiliarpagos INNER JOIN pagoventas ON movauxiliarpagos.idpagoventa = pagoventas.id INNER JOIN registros ON pagoventas.idregistro = registros.idregistro INNER JOIN clientes ON registros.idcliente = clientes.idcliente WHERE movauxiliarpagos.fechapago <= ".$fecha."";
$resultSet = $this->db->query($sql);
if($resultSet->num_rows() > 0) {
return $resultSet->result();
} else {
return null;
}
}
}
?>