<?php

class Ticket extends AppObjeto {

    protected $codigoServicio;
    protected $fecha;
    protected $hora;
    protected $importe;
    protected $base;
    protected $formaPago;
    protected $concepto;
    protected $proveedor;
    protected $chofer;
    protected $vehiculo;
    protected $litros;
    protected $kms;

    public function __construct(
        $codigoServicio,
        $fecha,
        $hora,
        $importe,
        $base,
        $formaPago,
        $concepto,
        $proveedor,
        $chofer,
        $vehiculo,
        $litros,
        $kms
    ) {
        $this->codigoServicio = $codigoServicio;
        $this->fecha = $fecha;
        $this->hora = $hora;
        $this->importe = $importe;
        $this->base = $base;
        $this->formaPago = $formaPago;
        $this->concepto = $concepto;
        $this->proveedor = $proveedor;
        $this->chofer = $chofer;
        $this->vehiculo = $vehiculo;
        $this->litros = $litros;
        $this->kms = $kms;
    }

    

	public function save(){
		
        $sql = sprintf("execute spNuevoTicket @Servicio='%s',@Fecha='%s',@Hora='%s',@Importe='%s',@Base='%s',@FormaPago='%s',@Concepto='%s',@Proveedor='%s', @Chofer='%s', @Vehiculo='%s', @Litros='%s', @Kms='%s', @Usuario = null",
            $this->codigoServicio,
            $this->fecha,
            $this->hora,
            $this->importe,
            $this->base,
            $this->formaPago,
            $this->concepto,
            $this->proveedor,
            $this->chofer,
            $this->vehiculo,
            $this->litros,
            $this->kms
    );
	
		try{
			$db = self::getDb();
            $adapter = $db->getAdapter();
            $stmt = $adapter->prepare($sql);     
            $stmt->execute();
            $result = $stmt->fetch();
            return $result['@NUM'];
		} catch (Exception $e){
			echo $e->getMessage();
		}
	}

    public function setCodigoServicio($codigoServicio)
    {
        $this->codigoServicio = $codigoServicio;
    }
    public function setFecha($fecha)
    {
        $this->fecha = $fecha;
    }
    public function setHora($hora)
    {
        $this->hora = $hora;
    }
    public function setImporte($importe)
    {
        $this->importe = $importe;
    }
    public function setBase($base)
    {
        $this->base = $base;
    }
    public function setFormaPago($formaPago)
    {
        $this->formaPago = $formaPago;
    }
    public function setConcepto($concepto)
    {
        $this->concepto = $concepto;
    }
    public function setProveedor($proveedor)
    {
        $this->proveedor = $proveedor;
    }
    public function setChofer($chofer)
    {
        $this->chofer = $chofer;
    }
    public function setVehiculo($vehiculo)
    {
        $this->vehiculo = $vehiculo;
    }
    public function setLitros($litros)
    {
        $this->litros = $litros;
    }
    public function setKms($kms)
    {
        $this->kms = $kms;
    }

}