<?php

namespace App\Modelos;

use Core\Database;

class Pedidos extends Database
{
    protected $table = 'app_pedidos';
    protected $id = 'pe_id';

    public function obtenerFactura(int $id_factura)
    {
        return $this->consultar("SELECT * FROM app_pedidos WHERE pe_id=$id_factura")->row();
    }

    public function obtenerSucursal($sucursal)
    {
        return $this->consultar("SELECT * FROM app_sucursales su 
        WHERE su.su_id=$sucursal")->row();
    }

    public function obtenerDivisaMaster()
    {
        return $this->consultar("SELECT * FROM app_divisas WHERE div_predeterminado = 1")->row();
    }
    
    public function obtenerFacturaCompleta($id_factura)
    {
        return $this->consultar("SELECT * 
        FROM app_pedidos pe 
        JOIN app_series s ON s.ser_id = pe.pe_serid
        JOIN app_divisas d ON d.div_id = pe.pe_divid
        WHERE pe.pe_id=$id_factura")->row();
    }
}
