Created
December 7, 2016 02:59
-
-
Save aranajhonny/fdd819e447cb9f2475365a4eabb3c2de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function all() | |
{ | |
$c = new compra(); | |
$compras = $c->get_compras() ; | |
$data = array(); | |
foreach ($compras as $com) { | |
$fecha = date_create($com['fecha']);//funcion para voltear la fecha | |
$row = array($com['codigo'], | |
$com['proveedor'], | |
date_format($fecha, 'd-m-Y'),//se voltea la fecha | |
$com['monto'], | |
'<a data-toggle="tooltip" title="Ver" href="javascript:void(0)" onclick=""><i class=" btn btn-xs btn-ver | |
glyphicon glyphicon-eye-open"></i></a> | |
<a data-toggle="tooltip" title="Eliminar" href="javascript:void(0)" onclick="" ><i class=" btn btn-xs btn-delete | |
glyphicon glyphicon-trash"></i></a>'); | |
$data[] = $row; | |
} | |
$output = array("data" => $data); | |
echo json_encode($output); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function get_compras() | |
{ | |
try | |
{ | |
$query = $this->dbh->prepare(' | |
SELECT | |
c.cod_compra AS codigo, | |
p.razon_social AS proveedor, | |
c.fecha_actual AS fecha, | |
c.tot AS monto | |
FROM | |
compras AS c | |
INNER JOIN | |
proveedores AS p | |
ON c.id_prov = p.id_prov | |
ORDER BY | |
c.cod_compra | |
DESC | |
'); | |
$query->execute(); | |
return $query->fetchAll(); | |
$this->dbh = null; | |
}catch (PDOException $e) | |
{ | |
$e->getMessage(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="content-header"> | |
<h1> | |
Listado de compras | |
<small></small> | |
</h1> | |
<ol class="breadcrumb"> | |
<a href="views/reportes/todas_las_compras.php" role="button" class="btn btn-delete"><span class="fa fa-file-pdf-o"></span> Imprimir</a> | |
</section> | |
<hr> | |
<section class="content"> | |
<div class="row"> | |
<div class="col-xs-12"> | |
<div class="box box-primary"> | |
<div class="box-header"> | |
<h3 class="box-title"><strong>Listado de compras</strong></h3> | |
</div><!-- /.box-header --> | |
<div class="box-body"> | |
<table id="table" class="table table-bordered table-striped"> | |
<thead> | |
<tr> | |
<th>Codigo</th> | |
<th>Proveedor</th> | |
<th>Fecha</th> | |
<th>Monto</th> | |
<th style="width: 80px;" >Acción</th> | |
</tr> | |
</thead> | |
</table> | |
</div><!-- /.box-body --> | |
</div><!-- /.box --> | |
</div><!-- /.col --> | |
</div><!-- /.row --> | |
</section><!-- /.content --> | |
</div> | |
<script type="text/javascript"> | |
var table; | |
$(document).ready(function() { | |
//datatables | |
table = $('#table').DataTable({ | |
"scrollX": true, | |
"processing": true, //Feature control the processing indicator. | |
"ajax": { | |
"url": "?controller=compras&action=all", | |
"type": "POST" | |
}, | |
}); | |
}); | |
function recargar(){ | |
table.ajax.reload(null,false); //reload datatable ajax | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment