/**
  * Devuelve el listado principal de registros del mantenimiento
  * @return Response
  */
 public function consultarCuotasJSONAction($entId, $cuoTipo)
 {
     $rows = null;
     $request = $this->getRequest();
     $cuotaDao = new CuotaDao($this->getDoctrine());
     $year = new \DateTime();
     $cuotas = $cuotaDao->getCuotas($entId, $cuoTipo, $year->format('Y'));
     $numfilas = count($cuotas);
     if ($numfilas != 0) {
         //array_multisort($cuotas, SORT_ASC);
     } else {
         //$rows[0]['id'] = 0;
         //$rows[0]['cell'] = array(' ', ' ',' ', ' ', ' ', ' ', ' ', ' ');
     }
     $datos = json_encode($cuotas);
     $pages = floor($numfilas / 10) + 1;
     $jsonresponse = '{
            "page":"1",
            "total":"' . $pages . '",
            "records":"' . $numfilas . '", 
            "rows":' . $datos . '}';
     $response = new Response($jsonresponse);
     return $response;
 }
 /**
  * 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;
 }