facturas.php
Código PHP:
<?php
include_once("ABM.php");
include_once("conexion.php");
class Factura extends ABM
{
var $id_factura;
var $id_local;
var $fecha;
var $fechaLocal;
var $id_cliente;
var $condicion_venta;
var $condicion_iva;
var $cuit;
var $monto;
function Factura()
{
$this->ABM();
$this->nombre_tabla = 'facturas';
$this->nombre_campo_id = 'id_factura';
$this->id_factura = &$this->id;
}
function definirConexion($conexion)
{
$this->conexion = $conexion;
}
function setFechaLocal($f)
{
$this->fechaLocal = $f;
//Formatear fecha
$dia = substr($f,0,2);
$mes = substr($f,3,2);
$anio = substr($f,6,4);
$this->fecha = $anio."/".$mes."/".$dia;
}
function buscarPorMatricula($matricula)
{
$this->res = mysql_query("SELECT * FROM facturas WHERE matricula = $matricula->matricula;", $this->conexion->conexion);
return $this->siguiente();
}
function asignarCampos($reg)
{
$this->id_factura = $reg['id_factura'];
$this->id_local = $reg['id_local'];
$this->fecha = $reg['fecha'];
$this->id_cliente = $reg['id_cliente'];
$this->condicion_venta = $reg['condicion_venta'];
$this->condicion_iva = $reg['condicion_iva'];
$this->cuit = $reg['cuit'];
$this->monto = $reg['monto'];
}
function agregar()
{
mysql_query("INSERT INTO facturas VALUES (
0, $this->id_local,
'$this->fecha',
$this->id_cliente, '$this->condicion_venta',
'$this->condicion_iva',
'$this->cuit',
$this->monto
)", $this->conexion->conexion) or die ("Invalid query");
return $this->ultimoId();
}
function modificar()
{
mysql_query("UPDATE facturas SET
id_factura = $this->id_factura,
id_local = $this->id_local,
fecha = '$this->fecha',
id_cliente = $this->id_cliente,
condicion_venta = $this->condicion_venta,
condicion_iva = $this->condicion_iva,
cuit = $this->cuit,
monto = $this->monto
WHERE id_factura = $this->id_factura;", $this->conexion->conexion);
return $this->id;
}
}
?>