/**
  * Se encarga de validar que el valor de los grados se encuentre dentro del rango
  */
 public function isValid($doctrine, $entidad)
 {
     $msg = array();
     if ($this->getImpDetLitros()) {
         if ($this->getImpDetLitros() + 0 <= 0) {
             $msg[] = '- La cantidad en litros ingresados "' . $this->getImpDetLitros() . '" debe ser mayor a 0';
         } else {
             $solImportacionDao = new SolImportacionDao($doctrine);
             $solImportacionDetDao = new SolImportacionDetDao($doctrine);
             $litrosInventario = $solImportacionDetDao->getLitrosInventarioXCuota($entidad->getEntId(), $this->getCuota()->getCuoId());
             $litrosSolicitudesPendientes = $solImportacionDao->getLitrosSolicitudXCuota($entidad->getEntId(), $this->getCuota()->getCuoId());
             $disponible = $this->getCuota()->getCuoLitros() - $litrosInventario - $litrosSolicitudesPendientes;
             if ($this->getImpDetLitros() > $disponible) {
                 $msg[] = '- La cantidad en litros ingresados "' . $this->getImpDetLitros() . '" es mayor al saldo disponible de la cuota "' . $disponible . '"';
             }
         }
     } else {
         $msg[] = '- El campo "Cantidad" se encuentra vacio';
     }
     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();
     $impDetId = $request->get('impDetId');
     $cuotaDao = new CuotaDao($this->getDoctrine());
     $solImportacionDetDao = new SolImportacionDetDao($this->getDoctrine());
     $solImportacionDao = new SolImportacionDao($this->getDoctrine());
     $solImportacionDet = $solImportacionDao->getSolImportacionDet($impDetId);
     $verSolicitud = $impDetId != '0';
     if ($verSolicitud) {
         $entId = $solImportacionDet->getSolImportacion()->getEntidad()->getEntId();
     } else {
         $entId = $user->getEntidad()->getEntId();
     }
     $registros = $cuotaDao->getCuotas($entId, Cuota::$cuoTipoImportacion, $year->format('Y'));
     $numfilas = count($registros);
     $debug = array();
     $htmlResponse = '';
     if ($numfilas != 0) {
         $i = 0;
         $selected = '';
         foreach ($registros as $reg) {
             $litrosInventario = $solImportacionDetDao->getLitrosInventarioXCuota($entId, $reg['cuoId']);
             $litrosSolicitudesPendientes = $solImportacionDao->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;
 }