CodeIgniter Forums

Full Version: Problems!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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
class Creportesestadisticos extends Controller {#principal

    function __construct() {#1
        $this->load->model('contabilidad/mreportesestadisticos', 'model');
    function index() {#2
            $data['xajax_js']      = $this->_loadXajax();
            $data['nombreUsuario'] = $this->db_session->userdata('nombreUsuario');
    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
    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;
    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;
    function showTable($form) {#7
        $objResponse = new xajaxResponse();
        return $objResponse;            
    function _loadXajax() {
        $this->xajax = new xajax();
        return $this->xajax->getJavascript('/javascripts/');

This the code of my model.
class Mreportesestadisticos extends Model {
    function __construct() {
    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 = 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;

El Forum

And this is the code of the view.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
&lt;html &gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;.:: Sistema Software Porurco ::.&lt;/title&gt;
&lt;style type="text/css"&gt;
@import url('/stylesheets/calendar-blue.css');
@import url('/stylesheets/main.css');
    #hd {
        min-height: 20px;
        padding: 5px 0 0 10px;
        font-weight: bold;
    #list h3 {
        font-family:"Trebuchet MS",arial,verdana;
        font-size: 12px;
        padding-left: 5px;
        min-height: 20px;
    .divisor {
        border: solid .1em #ccc;
    .element {
        padding: 10px;

&lt;?=$xajax_js ?&gt;
<div style="position:absolute; top:15em; left:75em; display:none;" id="loading"><img src="/images/loading.gif" alt="Cargando. Espere.." /></div>
<div id="wrap">
    <div id="header">
        <div id="logo">&nbsp;</div>
        <div id="topmain"><p class="nameuser">&lt;?=$this->db_session->userdata('nombreUsuario')?&gt;</p></div>
        <div id="navcontainer">
            <ul id="navlist">
                <li><a href="&lt;?=site_url()?&gt;main">Principal</a></li>
                <li><a href="&lt;?=site_url()?&gt;contabilidad">Contabilidad</a></li>
                <li><a href="&lt;?=site_url()?&gt;contabilidad/ccmain">Cuentas por Cobrar</a></li>
                <li><a href="#" class="lastnav">Reportes Estad√≠sticos</a></li>
            <div style="float:right; padding-top:2px; padding-right:180px;"><a href="&lt;?=site_url()?&gt;logout"><img src="/images/gnome-session-logout.png" alt="Cerrar Sesion" /></a></div>
    <div id="contents">
        <h3>Reportes Estad√≠sticos</h3>        
        &lt;!-- Inicio Seccion Consulta Reportes --&gt;
    <div style="margin:0px auto; width:60%;">
      &lt;form id="reporte"&gt;
      <table id="tablacaptura">
          <td>&lt;input name="fecha" type="text" id="fecha" size="8" /&gt;
            <img src="/images/scw.gif" id="fecha_id" style="cursor:pointer" />
                    inputField : "fecha",
                    ifFormat : "%Y-%m-%d",
                    button : "fecha_id",
                    align : "Br",
                    singleClick : true
          <td>&lt;input name="consultar" type="button" value="consultar"&gt;&lt;/td>
    &lt;!-- Fin Seccion Consulta --&gt;
    <div id="bottom"><em>Software Porurco &reg; Septiembre de 2007</em></div>

Well, I'm expecting to print the results of the query into de view, but I don't know why it doesn't print anything. After you click in the button "consultar", it doesn't do anything.

Thanks...Again, and I'm Sorry

El Forum

Just a quick note, you'll get a lot more help if you actually tell us what the problem is - you said you don't get the results you were expecting, what were you expecting and what did you get? It's a little hard for us to help you fix something if we don't know what's wrong with it.

El Forum

We all have problems. Don't put "problems" in the title of the topic. Explain quickly your problem.

El Forum

I don't see anything that tells your button to do anything. If there's some javascript that tells it what to do, that code is missing (probably in the [removed] sections). Can't help because I can't see it.

If it's supposed to submit your form, then just change it to &lt;input type="submit" value="consultar" /&gt; and add a method and action to your &lt;form&gt; like &lt;form action="some_controller_method" method="post" id="reporte"&gt;

Basically I think you just need to learn how to debug things a little better. Follow your code, make sure each step is happening when it's supposed to happen, and if it isn't, you should be able to figure out why it isn't. Use echo statements in php, and use alert messages in javascript. Make sure the data you expect is actually being received properly.

That's about all the help I can give.