Welcome Guest, Not a member yet? Register   Sign In
Problems!!
#1

[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
?&gt;

This the code of my model.
Code:
&lt;?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;
        }
    }
}
?&gt;
#2

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

[removed][removed]
[removed][removed]
&lt;?=$xajax_js ?&gt;
&lt;/head&gt;
&lt;body&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>
            </ul>
            <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>
    </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">
    
        <tr>
          <td>Fecha:</td>
          <td>&lt;input name="fecha" type="text" id="fecha" size="8" /&gt;
            <img src="/images/scw.gif" id="fecha_id" style="cursor:pointer" />
            [removed]
                Calendar.setup({
                    inputField : "fecha",
                    ifFormat : "%Y-%m-%d",
                    button : "fecha_id",
                    align : "Br",
                    singleClick : true
                });
            [removed]            
          </td>
        </tr>
        <tr>
          <td></td>
          <td>&lt;input name="consultar" type="button" value="consultar"&gt;&lt;/td>
        </tr>
      </table>
      &lt;/form&gt;
    </div>
    &lt;!-- Fin Seccion Consulta --&gt;
  </div>
    <div id="bottom"><em>Software Porurco &reg; Septiembre de 2007</em></div>
</div>
&lt;/body&gt;
&lt;/html&gt;


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
#3

[eluser]kgill[/eluser]
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.
#4

[eluser]Spir[/eluser]
We all have problems. Don't put "problems" in the title of the topic. Explain quickly your problem.
#5

[eluser]darkhouse[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB