/** * Se encarga de validar que el valor de los grados se encuentre dentro del rango */ public function isValid($doctrine, $entidad, $invId, $productor) { $msg = array(); if ($this->getLocalDetLitros() && $invId) { if ($this->getLocalDetLitros() + 0 <= 0) { $msg[] = '- La cantidad en litros ingresados "' . $this->getLocalDetLitros() . '" debe ser mayor a 0'; } else { $solLocalDao = new SolLocalDao($doctrine); $solLocalDetDao = new SolLocalDetDao($doctrine); $inventarioDao = new InventarioDao($doctrine); $litrosInventario = $solLocalDetDao->getLitrosInventarioXCuota($entidad->getEntId(), $this->getCuota()->getCuoId()); $litrosSolicitudesPendientes = $solLocalDao->getLitrosSolicitudXCuota($entidad->getEntId(), $this->getCuota()->getCuoId()); $disponible = $this->getCuota()->getCuoLitros() - $litrosInventario - $litrosSolicitudesPendientes; if ($this->getLocalDetLitros() > $disponible) { $msg[] = '- La cantidad en litros ingresados "' . $this->getLocalDetLitros() . '" es mayor al saldo disponible de la cuota "' . $disponible . '"'; } if ($productor == false) { $inventario = $inventarioDao->getInventario($invId); $litrosDisponiblesProveedor = $inventario->getInvLitros() - $inventario->getInvReservado(); if ($this->getLocalDetLitros() > $litrosDisponiblesProveedor) { $msg[] = '- No se puede ingresar la solicitud debido a que las existencias del proveedor no pueden cubrir la cantidad a solicitar'; } } } } else { if (!$this->getLocalDetLitros()) { $msg[] = '- El campo "Cantidad" se encuentra vacio'; } if (!$invId && $productor == false) { $msg[] = '- Debe seleccionar un proveedor'; } } return $msg; }
/** * Devuelve el listado de cuotas asignadas a la entidad * @return Response */ public function getCuotasAction(Request $request) { $user = $this->get('security.context')->getToken()->getUser(); $entId = 0; $year = new \DateTime(); $localDetId = $request->get('localDetId'); $cuotaDao = new CuotaDao($this->getDoctrine()); //$inventarioDetDao = new InventarioDetDao($this->getDoctrine()); $solLocalDao = new SolLocalDao($this->getDoctrine()); $solLocalDetDao = new SolLocalDetDao($this->getDoctrine()); $solLocalDet = $solLocalDao->getSolLocalDet($localDetId); $verSolicitud = $localDetId != '0'; if ($verSolicitud) { $entId = $solLocalDet->getSolLocal()->getEntidad()->getEntId(); } else { $entId = $user->getEntidad()->getEntId(); } $registros = $cuotaDao->getCuotas($entId, Cuota::$cuoTipoLocal, $year->format('Y')); $numfilas = count($registros); $debug = array(); $htmlResponse = ''; if ($numfilas != 0) { $i = 0; $selected = ''; foreach ($registros as $reg) { $litrosInventario = $solLocalDetDao->getLitrosInventarioXCuota($entId, $reg['cuoId']); $litrosSolicitudesPendientes = $solLocalDao->getLitrosSolicitudXCuota($entId, $reg['cuoId']); $disponible = $reg['cuoLitros'] - $litrosInventario - $litrosSolicitudesPendientes; $debug[$i]['$litrosInventario'] = $litrosInventario; $debug[$i]['$litrosSolicitudesPendientes'] = $litrosSolicitudesPendientes; $debug[$i]['cuoLitros'] = $reg['cuoLitros']; if ($disponible > 0 || $verSolicitud) { if ($i == 0) { $selected = 'selected'; } else { $selected = ''; } $htmlResponse = $htmlResponse . "<option value=" . $reg['cuoId'] . " grado=" . $reg['cuoGrado'] . " disponible=" . $disponible . ">" . $reg['cuoNombreEsp'] . "</option>"; $i++; } } //var_dump($debug);die; if ($i == 0) { $htmlResponse = $htmlResponse . '<option value="">No Existen cuotas asociadas</option>'; } } else { $htmlResponse = $htmlResponse . '<option value="">No Existen cuotas asociadas</option>'; } //$htmlResponse = $htmlResponse.'</select>'; $response = new Response($htmlResponse); return $response; }