Example #1
0
 public function get()
 {
     $page = Request::getQuery('page', 1);
     $per = Configuration::getInstance()->per;
     $start = ($page - 1) * $per;
     $fotos = array();
     $count = 0;
     $pos = 0;
     if ($this->inmueble->found()) {
         $fotos = Inmuebles_Fotos::all(array('inmueble_id' => $this->inmueble->id), array('posicion'), array($start, $per));
         $count = Inmuebles_Fotos::count(array('inmueble_id' => $this->inmueble->id));
         $pos = Inmuebles_Fotos::pos($this->inmueble->id);
     }
     return array('codigo' => $this->codigo, 'inmueble' => $this->inmueble, 'fotos' => $fotos, 'count' => $count, 'start' => $start, 'page' => $page, 'per' => $per, 'pos' => $pos);
 }
Example #2
0
 public function init($inmueble)
 {
     if (!Session::getInstance()->usuario) {
         return '/admin/ingresar';
     }
     $this->inmuebleCodigo = $inmueble;
     $this->inmueble = new Inmuebles();
     $this->inmueble->codigo = $this->inmuebleCodigo;
     $this->inmueble->queryAll();
     if (!$this->inmueble->found()) {
         return true;
     }
     $new = '';
     if (Request::hasPost('codigo')) {
         $this->codigo = Request::getPost('codigo', '');
     } else {
         $this->codigo = str_pad(Inmuebles_Fotos::count(array('inmueble_id' => $this->inmueble->id)) + 1, 4, '0', STR_PAD_LEFT);
     }
     return true;
 }