<!DOCTYPE html>
<?php 
include 'model.dal/PropiedadDal.php';
include 'model.dal/ComunaDal.php';
header('Content-Type: text/html; charset=UTF-8');
//Llamados de clases
$comunaDal = new ComunaDal();
$propiedadDal = new PropiedadDal();
?>
<html>
    <head>
        <title>Listado de propiedades</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!--Bootstrap-->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
	<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
        <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
        <!--Font Awesome-->
	<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
        <!--Google fonts-->
        <link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
	<link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="icon" type="image/png" href="images/pi.png">
    </head>
    <body>
        <style>
            html {
                position: relative;
<?php

try {
    session_start();
    if (isset($_POST['txt_despacho'])) {
        include_once '../model.business/Despacho.php';
        include_once '../model.business/Comunas.php';
        include_once '../model.dal/DespachoDal.php';
        include_once '../model.dal/ComunaDal.php';
        include_once '../conexion.php';
        //Class
        $despacho = new Despacho();
        $despachoDal = new DespachoDal();
        $comunaDal = new ComunaDal();
        //Set
        $despacho->setIdDespacho($despachoDal->countDespacho());
        $despacho->setDireccion($_POST['txt_despacho'] . " " . $_POST['txt_numeroCasa']);
        $despacho->setNombrePersonaAEntregar($_POST['txt_persona_a_entregar']);
        $despacho->setIdComuna($_POST['dll_comunas']);
        $despacho->setNombreComuna($comunaDal->nombreComunas($_POST['dll_comunas']));
        //Create Session
        $arrayDespacho = array('idDespacho' => $despacho->getIdDespacho(), 'direccion' => $despacho->getDireccion(), 'nombrePersona' => $despacho->getNombrePersonaAEntregar(), 'idComuna' => $despacho->getIdComuna(), 'nombreComuna' => $despacho->getNombreComuna());
        $_SESSION['despacho'] = $arrayDespacho;
        //Pagina Siguiente
        header("Location: ../intranet/metodo_pago.php");
    } else {
        header("Location: ../index.php");
    }
} catch (Exception $e) {
    //Error genérico
    header("Location: ../redirect_index_error.php");
            
            <div  class="row">
                <!--side menu-->
                <div class="list-group col-sm-2">
                    <a href="buscar_propiedad.php" class="list-group-item"><i class="fa fa-search"></i>&nbsp;Buscar propiedades</a>
                    <a href="listar_propiedades.php" class="list-group-item"><i class="fa fa-list-ol"></i>&nbsp;Listar propiedades</a>
                    <a href="agregar_propiedad.php" class="list-group-item active"><i class="fa fa-plus-circle"></i>&nbsp;Agregar propiedades</a>
                    <a href="preguntas.php" class="list-group-item"><i class="fa fa-inbox"></i>&nbsp;Responder preguntas</a>
                </div>
                <div class="col-sm-10">

                    <form action="../controller/ingreso_propiedad.php" method="POST" enctype="multipart/form-data">
                        <table class="table table-hover">
                            <?php 
    $propiedadDal = new PropiedadDal();
    $comunaDal = new ComunaDal();
    $codigo = $propiedadDal->maxProp() + 1;
    ?>
                            <tr>
                                <td class="col-sm-2">
                                    <i class="fa fa-list-ol"></i>
                                    &nbsp;Codigo Propiedad 		
                                </td>				
                                <td class="col-sm-5">
                                    <input type="text" 
                                           name="txt_codigo" 
                                           value="<?php 
    echo $codigo;
    ?>
" 
                                           size="5" 
                                    required="true" />
                         </div>
                         <div class="w3-col m1"></div>
                     </div>
                     <div class="w3-row w3-padding">
                         <div class="w3-col m1">
                             &nbsp;
                         </div>
                         <div class="w3-col m5">
                             Comuna
                         </div>
                         <div class="w3-col m5">
                             
                             <select name="dll_comunas" class="form-control"> 
                             <?php 
 $comunaDal = new ComunaDal();
 $comunaDal->showComunas();
 ?>
                       
                             </select>
                         </div>    
                         <div class="w3-col m1"></div>
                     </div>
                     
                     <div class="w3-row w3-padding">
                         <div class="w3-col m1">
                             &nbsp;
                         </div>
                         <div class="w3-col m5">
                             Persona a Entregar
                         </div>