Exemplo n.º 1
0
 /**
  * Permite ver un menu personalizado para cada planilla.
  */
 public function viewAction($planilla_id)
 {
     //Para el modal de eliminacion
     $this->assets->collection('footerInline')->addInlineJs('
         $(document).on("click", ".enviar-dato", function () {
             var id = $(this).data("id");
             $("#cuerpo #id").val( id );
         });
     ');
     $planilla = Planilla::findFirst(array('planilla_id=:planilla:', 'bind' => array('planilla' => $planilla_id)));
     if (!$planilla) {
         $this->flash->error("NO EXISTE LA PLANILLA QUE ESTÁ INTENTANDO ACCEDER");
         return $this->redireccionar('planilla/search');
     }
     if ($planilla->getCabecera() != null) {
         $columnas = Columna::find(array('columna_cabeceraId=:cabecera: AND columna_habilitado=1', 'bind' => array('cabecera' => $planilla->getCabecera()->getCabeceraId())));
         if ($columnas) {
             $this->view->columnas = $columnas;
         }
     }
     //$cliente = Cliente::findFirst(array('cliente_nombre LIKE :nombre:','bind'=>array('nombre'=>$pla)))
     $this->view->planilla = $planilla;
 }
Exemplo n.º 2
0
 /**
  * Guarda un remito escaneado en el servidor. La peticion se hace a traves de un modal.
  * [AJAX]
  */
 public function guardarRemitoEscaneadoAction()
 {
     $this->view->disable();
     $retorno = array();
     $retorno['success'] = true;
     $retorno['mensaje'] = '';
     if ($this->request->isPost()) {
         $planilla = Planilla::findFirst(array('planilla_id=:planilla_id: AND planilla_habilitado=1 AND planilla_armada=1 AND planilla_finalizada=0', 'bind' => array('planilla_id' => $this->request->getPost('planilla_id'))));
         if (!$planilla) {
             $retorno['success'] = false;
             $retorno['mensaje'] = "NO SE ENCONTRO NINGUNA PLANILLA HABILITADA. ID: " . $this->request->getPost('planilla_id');
         } else {
             $nombreCarpeta = 'temp/' . $planilla->getCliente()->getClienteNombre() . '/' . $planilla->getPlanillaFecha();
             if (!file_exists($nombreCarpeta)) {
                 mkdir($nombreCarpeta, 0777, true);
             }
             $path = $nombreCarpeta . '/' . $_FILES['file']['name'];
             #move the file and simultaneously check if everything was ok
             move_uploaded_file($_FILES['file']['tmp_name'], $path) ? $retorno['success'] = true : ($retorno['success'] = false);
             if (!$retorno['success']) {
                 $retorno['success'] = false;
                 $retorno['mensaje'] = "Ocurrio un problema al guardar el archivo en el servidor. ";
             } else {
                 $remito = Remito::findFirst(array('remito_id=:remito_id:', 'bind' => array('remito_id' => $this->request->getPost('remito_id'))));
                 if (!$remito) {
                     $retorno['success'] = false;
                     $retorno['mensaje'] = "El Remito no se encontró ID:" . $this->request->getPost('remito_id');
                     echo json_encode($retorno);
                     return;
                 }
                 $remito->setRemitoPdf($path);
                 if (!$remito->update()) {
                     $retorno['success'] = false;
                     foreach ($remito->getMessages() as $mensaje) {
                         $retorno['mensaje'] .= $mensaje . "<br>";
                     }
                 } else {
                     $retorno['mensaje'] = "Operación Exitosa, el archivo se ha guardado en {$path}";
                 }
             }
         }
     }
     echo json_encode($retorno);
     return;
 }
Exemplo n.º 3
0
 /**
  * Metodo llamado desde la administracion de la planilla. Genera una nueva cabecera con columnas basicas
  */
 public function nuevaCabeceraAction($planilla_id)
 {
     $planilla = Planilla::findFirst(array('planilla_id=:planilla_id: AND planilla_habilitado=1', 'bind' => array('planilla_id' => $planilla_id)));
     if (!$planilla) {
         $this->flash->error("Ocurrio un Problema: La Planilla no se encontró, o no se encuentra habilitada.");
         return $this->redireccionar('planilla/search');
     }
     if ($planilla->getPlanillaCabeceraId() != null) {
         $this->flash->warning("La Planilla ya tiene asignada una cabecera");
         return $this->redireccionar('planilla/view/' . $planilla->getPlanillaId());
     }
     $this->view->planilla = $planilla;
 }