Example #1
0
 /**
  * reponder llamadas ajax de reportes estados de officetrack
  * POST reporte/estadoofficetrack
  *
  * @return Response
  */
 public function postEstadosot()
 {
     //recibir los parametros y enviarlos al modelo, ahi ejecutar el query
     $accion = Input::get('accion');
     if ($accion == 'tecnicosofficetrack') {
         $reporte = Tecnico::getTecnicosOfficetrackAll();
     } elseif ($accion == 'pendientes') {
         $fechaAgen = Input::get('fecha_agen');
         $empresaId = Input::get('empresaId');
         $celulaId = Input::get('celulaId');
         $estados = Input::get('estados');
         $carnets = Input::get('carnets');
         $pendientes = '';
         $tecnico = Tecnico::getTecnico($empresaId, $celulaId);
         if (count($tecnico) > 0) {
             $reporte = Tarea::getAgendasAll($fechaAgen, $estados, $carnets);
         }
     } elseif ($accion == 'tecnicosot') {
         $fechaIni = Input::get('fechaIni');
         $fechaFin = Input::get('fechaFin');
         $empresaId = Input::get('empresaId');
         $celulaId = Input::get('celulaId');
         //$carnets = Input::get('carnets');
         $reporte = Tarea::getTareas($fechaIni, $fechaFin . " 23:59:59 ", $empresaId, $celulaId);
     }
     if (Input::get("excel") == '1') {
         $filename = $accion;
         $filename = Helpers::convert_to_file_excel($filename);
         header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . $filename);
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header("Content-Transfer-Encoding: binary");
         header('Pragma: public');
         $n = 1;
         foreach ($reporte as $data) {
             //Encabezado
             if ($n == 1) {
                 foreach ($data as $key => $val) {
                     echo $key . "\t";
                 }
                 echo $val . "\r\n";
             }
             //Datos
             foreach ($data as $val) {
                 $val = str_replace(array("\r\n", "\n", "\n\n", "\t", "\r"), array("", "", "", "", ""), $val);
                 echo $val . "\t";
             }
             echo "\r\n";
             $n++;
         }
     } else {
         return Response::json(array('rst' => 1, 'datos' => $reporte));
     }
 }