Example #1
0
 /**
  * Actualiza el numero de cajas del pedido
  * 
  * @param int $pedido_cab_id
  * @param int $pedido_det_sec
  * @param int $nro_cajas_new
  * @param int $usuario_id
  * @throws Exception
  * @return array
  */
 public function actualizarNroCajas($pedido_cab_id, $pedido_det_sec, $nro_cajas_new, $usuario_id)
 {
     $DispoBO = new DispoBO();
     $PedidoCabDAO = new PedidoCabDAO();
     $PedidoDetDAO = new PedidoDetDAO();
     $PedidoCabData = new PedidoCabData();
     $PedidoDetData = new PedidoDetData();
     $this->getEntityManager()->getConnection()->beginTransaction();
     try {
         $DispoBO->setEntityManager($this->getEntityManager());
         $PedidoCabDAO->setEntityManager($this->getEntityManager());
         $PedidoDetDAO->setEntityManager($this->getEntityManager());
         /*
          * 1. Actualiza el detalle del Pedido
          */
         $PedidoDetData = $PedidoDetDAO->consultar($pedido_cab_id, $pedido_det_sec);
         if (empty($PedidoDetData)) {
             $result['respuesta_code'] = 'NO-EXISTE-DET';
             $result['respuesta_msg'] = 'No existe detalle del Pedido';
             $this->getEntityManager()->getConnection()->rollback();
             return $result;
         }
         //end if
         $cantidad_bunch_x_caja = $PedidoDetData->getCantidadBunch() / $PedidoDetData->getNroCajas();
         $cantidad_bunch = $nro_cajas_new * $cantidad_bunch_x_caja;
         $tallos_total = $cantidad_bunch * $PedidoDetData->getTallosxBunch();
         $total = $tallos_total * $PedidoDetData->getPrecio();
         $PedidoDetData->setPedidoCabId($pedido_cab_id);
         $PedidoDetData->setPedidoDetSec($pedido_det_sec);
         $PedidoDetData->setNroCajas($nro_cajas_new);
         $PedidoDetData->setCantidadBunch($cantidad_bunch);
         $PedidoDetData->setTallosTotal($tallos_total);
         $PedidoDetData->setTotal($total);
         $PedidoDetData->setUsuarioModId($usuario_id);
         $key_det = $PedidoDetDAO->actualizarNroCajas($PedidoDetData);
         /*
          * 2. Se actualiza la cabecera del Pedido
          */
         $PedidoCabDAO->actualizarTotal($pedido_cab_id);
         /*
          * 3. Devuelve el resultado del registro del PEDIDO
          */
         $result['respuesta_code'] = 'OK';
         $result['respuesta_msg'] = '';
         $this->getEntityManager()->getConnection()->commit();
         return $result;
     } catch (Exception $e) {
         $this->getEntityManager()->getConnection()->rollback();
         $this->getEntityManager()->close();
         throw $e;
     }
 }
 public function listadoAgrupadoFechaBunchDataAction()
 {
     try {
         $EntityManagerPlugin = $this->EntityManagerPlugin();
         $DispoBO = new DispoBO();
         $DispoBO->setEntityManager($EntityManagerPlugin->getEntityManager());
         $SesionUsuarioPlugin = $this->SesionUsuarioPlugin();
         $SesionUsuarioPlugin->isLoginAdmin();
         $request = $this->getRequest();
         $inventario_id = $request->getQuery('inventario_id', "");
         $proveedor_id = $request->getQuery('proveedor_id', "");
         $clasifica = $request->getQuery('clasifica', "");
         $color_ventas_id = $request->getQuery('color_ventas_id', "");
         $calidad_variedad_id = $request->getQuery('calidad_variedad_id', "");
         $nro_tallos = $request->getQuery('nro_tallos', "");
         $page = $request->getQuery('page');
         $limit = $request->getQuery('rows');
         $sidx = $request->getQuery('sidx', 1);
         $sord = $request->getQuery('sord', "");
         $DispoBO->setPage($page);
         $DispoBO->setLimit($limit);
         $DispoBO->setSidx($sidx);
         $DispoBO->setSord($sord);
         $condiciones = array("inventario_id" => $inventario_id, "proveedor_id" => $proveedor_id, "clasifica" => $clasifica, "color_ventas_id" => $color_ventas_id, "calidad_variedad_id" => $calidad_variedad_id, "nro_tallos" => $nro_tallos);
         //$omitir_registro_vacio = false;
         $result = $DispoBO->listadoAgrupadoFechaBunch($condiciones);
         $response = new \stdClass();
         $i = 0;
         if ($result) {
             foreach ($result as $row) {
                 $row['fecha_bunch'] = $row['fecha_bunch'];
                 $response->rows[$i] = $row;
                 $i++;
             }
             //end foreach
         }
         //end if
         $tot_reg = $i;
         $response->total = ceil($tot_reg / $limit);
         $response->page = $page;
         $response->records = $tot_reg;
         $json = new JsonModel(get_object_vars($response));
         return $json;
     } catch (\Exception $e) {
         $excepcion_msg = utf8_encode($this->ExcepcionPlugin()->getMessageFormat($e));
         $response = $this->getResponse();
         $response->setStatusCode(500);
         $response->setContent($excepcion_msg);
         return $response;
     }
 }