este es el codigo del archivo que llama la ckase
Código PHP:
<?php
require_once '../path_temprana.php';
$p="../";
require_once($pathtemprana."cetelem/inicializacion_temprana_cetelem.php");
require_once './classes/cetelem.class.php';
$detalle = new detallecetelem($tpl);
$misc = new misc($tpl);
//$detalle->ver_detalle1();
$detalle->Gestiones_deldia_xhora();
if (isset($_GET['check']) && $_GET['check'] <>'' ){
header("location: export_resumen.php?consultar=".$_GET['query']);
exit;
}
$tpl->set_filenames(array('body' => 'tpl/includes/resumen2.tpl'));
require_once($pathraiz."includes/finalizacion.php");
?>
esta es la clase
Código PHP:
class detallecetelem{
var $tpl;
function Gestiones_deldia_xhora(){
require_once './../../../includes/conexion.php';
require_once './../../../includes/conexionHistorico.php';
$con=conectar($host,$usuario,$clave,'ECRM_0007');
$historico=conectar($hostHistorico,$usuarioHistorico,$claveHistorico,'ECRM_0007');
$sql="SELECT USUARIO, COUNT(*) AS TOTAL , datepart(hour,ts_traida) as HORA FROM CONTACTOS_DETALLE (nolock)
WHERE FECHA = CONVERT(DATE, GETDATE() , 104) GROUP BY USUARIO, datepart(hour,ts_traida) ORDER BY USUARIO, datepart(hour,ts_traida)";
$this->tpl->assign_block_vars('QUERY', array('QUERY' => $sql));
$tabla=mssql_query($sql,$con);
$usuarioactual = '';
$total = 0;
$nueveam =0;
$diezam =0;
$onceam =0;
$doceam =0;
$unapm =0;
$dospm =0;
$trespm =0;
$cuatropm =0;
$cincopm =0;
$seispm =0;
$sietepm =0;
$ochopm =0;
$nuevepm =0;
while($mag = mssql_fetch_assoc($tabla)) {
if($usuarioactual==''){
$usuarioactual= $mag['USUARIO'];
}
if ($usuarioactual != $mag['USUARIO']){
$this->tpl->assign_block_vars('LINK', array(
'GESTOR' => $usuarioactual,
'NUEVEAM' => $nueveam,
'DIEZAM' => $diezam,
'ONCEAM' => $onceam,
'DOCEAM' => $doceam,
'UNAPM' => $unapm,
'DOSPM' => $dospm,
'TRESPM' => $trespm,
'CUATROPM' => $cuatropm,
'CINCOPM' => $cincopm,
'SEISPM' => $seispm,
'SIETEPM' => $sietepm,
'OCHOPM' => $ochopm,
'NUEVEPM' => $nuevepm,
'TOTAL' => $total));
$usuarioactual = $mag['USUARIO'];
$total = 0;
$nueveam =0;
$diezam =0;
$onceam =0;
$doceam =0;
$unapm =0;
$dospm =0;
$trespm =0;
$cuatropm =0;
$cincopm =0;
$seispm =0;
$sietepm =0;
$ochopm =0;
$nuevepm =0;
}
if ((int)$mag['HORA'] == 9){$nueveam = $mag['TOTAL'];}
if ($mag['HORA'] == 10){$diezam = $mag['TOTAL'];}
if ((int)$mag['HORA'] == 11){$onceam = $mag['TOTAL'];}
if ((int)$mag['HORA'] == 12){$doceam = $mag['TOTAL'];}
if ((int)$mag['HORA'] == 13){$unapm = $mag['TOTAL'];}
if ((int)$mag['HORA'] == 14){$dospm = $mag['TOTAL'];}
if ($mag['HORA'] == 15){$trespm = $mag['TOTAL'];}
if ($mag['HORA'] == 16){$cuatropm = $mag['TOTAL'];}
if ($mag['HORA'] == 17){$cincopm = $mag['TOTAL'];}
if ($mag['HORA'] == 18){$seispm = $mag['TOTAL'];}
if ($mag['HORA'] == 19){$sietepm = $mag['TOTAL'];}
if ($mag['HORA'] == 20){$ochopm = $mag['TOTAL'];}
if ($mag['HORA'] == 21){$nuevepm = $mag['TOTAL'];}
$total = $nueveam + $diezam + $onceam + $doceam + $unapm + $dospm + $trespm + $cuatropm + $cincopm + $seispm + $sietepm + $ochopm + $nuevepm ;
}
$this->tpl->assign_block_vars('LINK', array('GESTOR' => $usuarioactual,
'NUEVEAM' => $nueveam,
'DIEZAM' => $diezam,
'ONCEAM' => $onceam,
'DOCEAM' => $doceam,
'UNAPM' => $unapm,
'DOSPM' => $dospm,
'TRESPM' => $trespm,
'CUATROPM' => $cuatropm,
'CINCOPM' => $cincopm,
'SEISPM' => $seispm,
'SIETEPM' => $sietepm,
'OCHOPM' => $ochopm,
'NUEVEPM' => $nuevepm,
'TOTAL' => $total));
}
Código PHP:
class Template {
var $classname = "Template";
// variable that holds all the data we'll be substituting into
// the compiled templates.
// ...
// This will end up being a multi-dimensional array like this:
// $this->_tpldata[block.][iteration#][child.][iteration#][child2.][iteration#][variablename] == value
// if it's a root-level variable, it'll be like this:
// $this->_tpldata[.][0][varname] == value
var $_tpldata = array();
// Hash of filenames for each template handle.
var $files = array();
// Root template directory.
var $root = "";
// this will hash handle names to the compiled code for that handle.
var $compiled_code = array();
// This will hold the uncompiled code for that handle.
var $uncompiled_code = array();
/**
* Constructor. Simply sets the root dir.
*
*/
function Template($root = ".")
{
$this->set_rootdir($root);
}
/**
* Destroys this template object. Should be called when you're done with it, in order
* to clear out the template data so you can load/parse a new template set.
*/
function destroy()
{
$this->_tpldata = array();
}
/**
* Sets the template root directory for this Template object.
*/
function set_rootdir($dir)
{
if (!is_dir($dir))
{
return false;
}
$this->root = $dir;
return true;
}
/**
* Sets the template filenames for handles. $filename_array
* should be a hash of handle => filename pairs.
*/
function set_filenames($filename_array)
{
if (!is_array($filename_array))
{
return false;
}
reset($filename_array);
while(list($handle, $filename) = each($filename_array))
{
// $this->files[$handle] = $this->make_filename($filename);
$this->files[$handle] = $filename;
}
return true;
}
/**
* Load the file for the handle, compile the file,
* and run the compiled code. This will print out
* the results of executing the template.
*/
function pparse($handle)
{
if (!$this->loadfile($handle))
{
die("Template->pparse(): Couldn't load template file for handle $handle");
}
// actually compile the template now.
if (!isset($this->compiled_code[$handle]) || empty($this->compiled_code[$handle]))
{
// Actually compile the code now.
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
}
// Run the compiled code.
eval($this->compiled_code[$handle]);
return true;
}
/**
* Inserts the uncompiled code for $handle as the
* value of $varname in the root-level. This can be used
* to effectively include a template in the middle of another
* template.
* Note that all desired assignments to the variables in $handle should be done
* BEFORE calling this function.
*/
function assign_var_from_handle($varname, $handle)
{
if (!$this->loadfile($handle))
{
die("Template->assign_var_from_handle(): Couldn't load template file for handle $handle");
}
// Compile it, with the "no echo statements" option on.
$_str = "";
$code = $this->compile($this->uncompiled_code[$handle], true, '_str');
// evaluate the variable assignment.
eval($code);
// assign the value of the generated variable to the given varname.
$this->assign_var($varname, $_str);
return true;
}
/**
* Block-level variable assignment. Adds a new block iteration with the given
* variable assignments. Note that this should only be called once per block
* iteration.
*/
function assign_block_vars($blockname, $vararray)
{
if (strstr($blockname, '.'))
{
// Nested block.
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$str = '$this->_tpldata';
for ($i = 0; $i < $blockcount; $i++)
{
$str .= '[\'' . $blocks[$i] . '.\']';
eval('$lastiteration = sizeof(' . $str . ') - 1;');
$str .= '[' . $lastiteration . ']';
}
// Now we add the block that we're actually assigning to.
// We're adding a new iteration to this block with the given
// variable assignments.
$str .= '[\'' . $blocks[$blockcount] . '.\'][] = $vararray;';
// Now we evaluate this assignment we've built up.
eval($str);
}
else
{
// Top-level block.
// Add a new iteration to this block with the variable assignments
// we were given.
$this->_tpldata[$blockname . '.'][] = $vararray;
}
return true;
}