Advertisement
Guest User

hdp

a guest
Jan 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.57 KB | None | 0 0
  1. private function _view($id=1, $isAjax = false, $forExport = false)
  2. {
  3. ini_set('memory_limit', '512M');
  4.  
  5. if (Input::get('report_exceeded')) {
  6. $filter_arr = Input::all();
  7. $filter_obj = array();
  8. unset($filter_arr['report_exceeded']);
  9. unset($filter_arr['dynamicDates']);
  10. unset($filter_arr['format']);
  11. foreach ($filter_arr as $key => $value) {
  12. if (!strpos($key, '_comparator') && !strpos($key, '_logicOperator')) {
  13. if (isset($filter_arr[$key . '_logicOperator'])) {
  14. $filter_obj[] = (object) array($key => $value, $key . '_comparator' => $filter_arr[$key . '_comparator'], $key . '_logicOperator' => $filter_arr[$key . '_logicOperator']);
  15. } else {
  16. $filter_obj[] = (object) array($key => $value, $key . '_comparator' => $filter_arr[$key . '_comparator']);
  17. }
  18. }
  19. }
  20.  
  21. $this->_createReportSchedule($id, json_encode($filter_obj));
  22. }
  23.  
  24. $filter = (Input::get('filter')) ? true : false;
  25. $output = Input::get('output', 'view');
  26. $NR = (null !== (Input::get('NR'))) ? true : false;
  27. $XD = (Input::get('XD')) ? Input::get('XD') : false;
  28. if (!$XD) {
  29. $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT);
  30. }
  31. $page = (Input::get('page') && is_numeric(Input::get('page'))) ? filter_var(Input::get('page'), FILTER_SANITIZE_NUMBER_INT) : 1;
  32. $perPage = Setting::get('resultsPerPage');
  33. $theme = Input::get('theme', 'light');
  34. if (!in_array($theme, ['light', 'dark'])) {
  35. $theme = 'light';
  36. }
  37.  
  38. Log::error(__METHOD__ .' REPORT ID: '. $id);
  39. if ($XD) {
  40. Log::error(__METHOD__ .' XD: '. json_encode($XD));
  41. }
  42.  
  43. $arrayReport = array();
  44. $arrayReport['NR'] = $NR;
  45. $arrayReport['chart'] = 0;
  46. $arrayReport['error'] = '';
  47. $arrayReport['errorExport'] = '';
  48. $arrayReport['multi'] = false;
  49. $filters = [];
  50. $savedFilters = [];
  51. $sponsorsFilter = [];
  52. $agregadorFilter = [];
  53. $tgestadoFilter = [];
  54. $tgsponsorsFilter = [];
  55. $activoFilter = [];
  56. $campaniaFilter = [];
  57. $mediosFilter = [];
  58. $rowsFilter = [];
  59. $estadoEsFilter = [];
  60. $resultadoFilter = [];
  61. $mdsFilter = [];
  62. $paquetesFilter = [];
  63. $aplicacionesFilter = [];
  64. $paymentFilter = [];
  65. $redesFilter = [];
  66. $actionFilter = [];
  67. $operadorKey = null;
  68. $operadorValue = null;
  69. $mdsUserFiltered = false;
  70. $mdsValue = null;
  71. $mdsRedFiltered = false;
  72. $userRedAuthorized = true;
  73. $redValue = null;
  74. $repo = null;
  75. $reportExec = null;
  76. $catched = false;
  77. $aDynamicDates = null;
  78.  
  79. $data = array();
  80.  
  81. if ($id) {
  82. // $results = [];
  83. $this->_resultHeader = [];
  84. $this->_resultBody = [0 => []];
  85. $this->_resultRaw = [0 => []];
  86. try {
  87.  
  88. if (!$XD) {
  89. $this->_report[0] = OrtReports::findOrFail($id);
  90. if (!Auth::user()->hasRole('admin')) {
  91. $roleUser = RoleUser::where('user_id', Auth::user()->user_id)->get(['role_id']);
  92. $myRoles = [];
  93. foreach ($roleUser as $role) {
  94. $myRoles[] = $role->role_id;
  95. }
  96. $this->_report[0] = OrtReports::where('report.report_id', $id)->select("report.*");
  97. $this->_report[0] = $this->_report[0]->leftJoin('role_report', 'role_report.report_id', '=', 'report.report_id');
  98. $whereClause = "(report.user_id = ". Auth::user()->user_id . " OR (report_tool = 'ort'";
  99. if (count($myRoles)) {
  100. $whereClause .= " AND role_report.role_id IN(".implode(',', $myRoles).")";
  101. }
  102. $whereClause .= "))";
  103. $this->_report[0] = $this->_report[0]->whereRaw($whereClause)->first();
  104. // if no report_id user has NO privileges over the report but the report exists. Otherwise it would throw an exception at the findOrFail sentence
  105. if (!isset($this->_report[0]->report_id)) {
  106. return Response::view('forbidden', array(), 403);
  107. }
  108. }
  109.  
  110. if (!$this->_report[0]->report_enabled) {
  111. throw new Exception(sprintf(trans('messages.reporte_deshabilitado'), $id), 1);
  112. }
  113.  
  114. $filters = $this->_getFilters($this->_report[0]->report_query);
  115. if (in_array(trans("ort.Operador"), $filters)) {
  116. if (Auth::user()->hasRole('admin')) {
  117. $sponsorsFilter = Sponsor::noLock()->orderBy('Sponsor')->lists('Sponsor', 'SponsorId');
  118. } else {
  119. $roleSponsorsModel = RoleSponsor::whereIn('role_id', $myRoles)->get(['sponsor_id']);
  120. $roleSponsors = [];
  121. foreach ($roleSponsorsModel as $modelObj) {
  122. $roleSponsors[] = $modelObj->sponsor_id;
  123. }
  124. if (count($roleSponsors)) {
  125. $sponsorsFilter = Sponsor::noLock()->orderBy('Sponsor')->whereIn('SponsorId', $roleSponsors)->lists('Sponsor', 'SponsorId');
  126. }
  127. }
  128. $operadorKey = array_search(trans("ort.Operador"), $filters);
  129. $operadorValue = Input::get($operadorKey) ? Input::get($operadorKey) : Input::old($operadorKey);
  130. // if operador not submitted, then select first
  131. if (is_array($sponsorsFilter) && count($sponsorsFilter) && !$operadorValue) {
  132. $operadorValue = array_keys($sponsorsFilter)[0];
  133. }
  134.  
  135. // validar que el usuario tiene permisos sobre el sponsor seleccionado
  136. if (!in_array($operadorValue, array_keys($sponsorsFilter))) {
  137. throw new \Exception(trans('messages.sin_permisos_sobre_operador'));
  138. }
  139. }
  140. if (in_array(trans("ort.Operador2"), $filters)) {
  141. $tgsponsorsFilter = ['' => trans('messages.select_seleccionar')] + Sponsor::noLock()->orderBy('Sponsor')->lists('Sponsor', 'SponsorId');
  142. }
  143. if (in_array(trans("ort.Agregador"), $filters)) {
  144. $agregadorFilter = ['' => trans('messages.select_seleccionar')] +
  145. Aggregator::orderBy('name')->lists('name', 'id');
  146. }
  147. if (in_array('Estado usuario', $filters)) {
  148. $tgestadoFilter = ['' => trans('messages.select_seleccionar')] +
  149. TGStatus::orderBy('status')->lists('status', 'status_id');
  150. }
  151. if (in_array(trans("ort.activo"), $filters)) {
  152. $activoFilter = ['' => trans('messages.select_seleccionar')] +
  153. ['1' => trans('messages.Sí'), '0' => 'No'];
  154. }
  155. if (in_array(trans("ort.campania"), $filters)) {
  156. $campaniaFilter = ['' => trans('messages.select_seleccionar')] +
  157. Campaign::orderBy('name')->lists('name', 'id');
  158. }
  159. if (in_array(trans("ort.Medio"), $filters)) {
  160. if ($operadorKey) {//dd($operadorValue);
  161. if ($operadorValue) {
  162. $mediosFilter = ['' => trans('messages.select_seleccionar')] + Medio::noLock()->where('SponsorId', $operadorValue)->orderBy('Medio')->lists('Medio', 'MedioId');
  163. } else {
  164. $mediosFilter = ['' => trans('messages.select_seleccionar_operador')];
  165. }
  166. } else {
  167. $mediosFilter = ['' => trans('messages.select_seleccionar')] + Medio::noLock()->leftJoin('OpratelInfo.dbo.SuscripcionDiario', 'OpratelInfo.dbo.SuscripcionDiario.MedioId', '=', 'Medio.MedioId')
  168. ->join('Sponsor', 'Sponsor.SponsorId', '=', 'Medio.SponsorId')
  169. ->whereNotNull('OpratelInfo.dbo.SuscripcionDiario.SuscripcionId')
  170. ->orderBy('Sponsor')->select(
  171. [DB::raw("DISTINCT(Medio.MedioId)"), DB::raw("Medio + ' (' + Sponsor.Sponsor + ')' as Medio"), "Sponsor"]
  172. )->lists("Medio", "MedioId");
  173. }
  174. }
  175. if (in_array(trans("ort.Records"), $filters)) {
  176. $rowsFilter = ['' => trans('ort.label_todas'), '10' => '10', '25' => '25', '50' => '50', '100' => '100', '1000' => '1000'];
  177. }
  178. if (in_array(trans("ort.Estado"), $filters)) {
  179. $estados = EstadoES::noLock()->get();
  180. foreach ($estados as $estado) {
  181. $estadoEsFilter[$estado->EstadoESId] = trans('estadoes.' . $estado->Estado);
  182. }
  183. }
  184. if (in_array(trans("ort.ResultadoId"), $filters)) {
  185. $resultados = Resultado::noLock()->get();
  186. foreach ($resultados as $resultado) {
  187. $resultadoFilter[$resultado->ResultadoId] = trans('resultado.' . $resultado->Resultado);
  188. }
  189. }
  190. if (in_array(trans("ort.Action"), $filters)) {
  191.  
  192. $actionFilter[""] = trans('ort.Accion_Todos');
  193. $actionFilter["1"] = trans('ort.Accion_Altas');
  194. $actionFilter["0"] = trans('ort.Accion_Bajas');
  195. }
  196. if (in_array(trans("ort.Red"), $filters)) {
  197. $redKey = array_search(trans("ort.Red"), $filters);
  198. $redValue = Input::get($redKey) ? Input::get($redKey) : Input::old($redKey);
  199. $redesObjList = Red::noLock()->orderBy('OpratelInfo.dbo.Red.Red');
  200. if (!Auth::user()->hasRole('admin')) {
  201. $redesOriginalList = [];
  202. $userRedesObj = UserRedes::where(['user_id' => Auth::id()])->get(['redid']);
  203. if (count($userRedesObj)) {
  204. $mdsRedFiltered = true;
  205. foreach ($userRedesObj as $value) {
  206. $redesOriginalList[] = $value->redid;
  207. }
  208. $redesObjList = $redesObjList->whereIn('redid', $redesOriginalList);
  209. }
  210. }
  211. $redesObjList = $redesObjList->lists("Red", "Red");
  212. $redesFilter = ['' => trans('messages.select_seleccionar')] + $redesObjList;
  213. }
  214. if (in_array(trans("ort.MDS"), $filters)) {
  215. $mdsKey = array_search(trans("ort.MDS"), $filters);
  216. $mdsValue = Input::get($mdsKey) ? Input::get($mdsKey) : Input::old($mdsKey);
  217.  
  218. if ($operadorKey) {
  219. if ($operadorValue) {
  220. if (in_array(trans("ort.Red"), $filters)) {
  221. if (!$redValue) {
  222. $mdsFilter = ['' => trans('messages.select_seleccionar_red')];
  223. } else {
  224.  
  225. $mdsObjList = MedioSuscripcionMySql::getBySponsorIdAndRed($operadorValue, $redValue);
  226. $mdsUserFiltered = $mdsObjList->mdsUserFiltered;
  227. $userRedAuthorized = $mdsObjList->userRedAuthorized;
  228. if (count($mdsObjList->medios)) {
  229. $mdsFilter = ['' => trans('messages.select_seleccionar')];
  230. foreach ($mdsObjList->medios as $value) {
  231. $mdsFilter[$value['mediosuscripcion']] = $value['mediosuscripcion'];
  232. }
  233. }
  234. }
  235. } else {
  236. $mdsObjList = MedioSuscripcionMySql::getBySponsorId($operadorValue);
  237. $mdsUserFiltered = $mdsObjList->mdsUserFiltered;
  238. if (count($mdsObjList->medios)) {
  239. $mdsFilter = ['' => trans('messages.select_seleccionar')];
  240. foreach ($mdsObjList->medios as $value) {
  241. $mdsFilter[$value['mediosuscripcion']] = $value['mediosuscripcion'];
  242. }
  243. }
  244. }
  245. } else {
  246. $mdsFilter = ['' => trans('messages.select_seleccionar_operador')];
  247. }
  248. } else {
  249. $mdsObjList = MedioSuscripcionMySql::orderBy('mediosuscripcion');
  250. if (!Auth::user()->hasRole('admin')) {
  251. $mdsOriginalList = [];
  252. $userMedioSuscripcionObj = UserMedioSuscripcion::where(['user_id' => Auth::id()])->get(['mediosuscripcionid']);
  253. if (count($userMedioSuscripcionObj)) {
  254. $mdsUserFiltered = true;
  255. foreach ($userMedioSuscripcionObj as $value) {
  256. $mdsOriginalList[] = $value->mediosuscripcionid;
  257. }
  258. $mdsObjList = $mdsObjList->whereIn('mediosuscripcionid', $mdsOriginalList);
  259. }
  260. }
  261. $mdsObjList = $mdsObjList->lists("MedioSuscripcion", "MedioSuscripcion");
  262. if (!$mdsUserFiltered) {
  263. $mdsObjList = ['SMS' => 'SMS'] + $mdsObjList;
  264. }
  265. $mdsFilter = ['' => trans('messages.select_seleccionar')] + $mdsObjList;
  266. }
  267. }
  268.  
  269. if (in_array(trans("ort.Paquete"), $filters)) {
  270. $paquetesFilter = ['' => trans('messages.select_seleccionar')] +
  271. Paquete::noLock()->leftJoin('OpratelInfo.dbo.SuscripcionDiario', 'OpratelInfo.dbo.SuscripcionDiario.PaqueteId', '=', 'Paquete.PaqueteId')
  272. ->whereNotNull('OpratelInfo.dbo.SuscripcionDiario.SuscripcionId')->orderBy('Paquete')->select(
  273. [DB::raw("DISTINCT(Paquete.PaqueteId)"), "Paquete"]
  274. )->lists("Paquete", "PaqueteId");
  275. }
  276. if (in_array(trans("ort.Aplicacion"), $filters)) {
  277. $aplicacionesFilter = ['' => trans('messages.select_seleccionar')] +
  278. Paquete::noLock()->leftJoin('OpratelCenter.dbo.Aplicacion', 'Paquete.AplicacionId', '=', 'OpratelCenter.dbo.Aplicacion.AplicacionId')
  279. ->leftJoin('OpratelInfo.dbo.SuscripcionDiario', 'OpratelInfo.dbo.SuscripcionDiario.PaqueteId', '=', 'Paquete.PaqueteId')
  280. ->whereNotNull('OpratelInfo.dbo.SuscripcionDiario.SuscripcionId')->orderBy('OpratelCenter.dbo.Aplicacion.Aplicacion')->select(
  281. [DB::raw("DISTINCT(OpratelCenter.dbo.Aplicacion.AplicacionId)"), "OpratelCenter.dbo.Aplicacion.Aplicacion"]
  282. )->lists("Aplicacion", "AplicacionId");
  283. }
  284. if (in_array(trans("ort.Payment"), $filters)) {
  285. $paymentFilter = ['' => trans('messages.select_seleccionar')] +
  286. Payment::noLock()->lists("Descripcion", "PaymentId");
  287. }
  288. // @TODO agregar redes a este exception
  289. if ($filters
  290. && (!$filter
  291. || (in_array(trans("ort.Operador"), $filters) && !$operadorValue)
  292. || ($mdsUserFiltered && (!$mdsValue || (!in_array($mdsValue, $mdsFilter))))
  293. || ($mdsRedFiltered && (!$redValue || !$userRedAuthorized || ($mdsFilter && !in_array($mdsValue, $mdsFilter)))))
  294. ) {
  295. throw new Exception("Faltan filtros", 1);
  296. }
  297.  
  298. $dataSource = DataSource::findOrFail($this->_report[0]->data_source_id);
  299. if ($filter) {
  300. $this->_report[0]->report_query = $this->_replaceFilters($this->_report[0]->report_query, Input::all(), $dataSource->data_source_type);
  301. }
  302. Log::error(__METHOD__ .' QUERY ' . $this->_report[0]->report_query);
  303.  
  304. $connection = [
  305. 'conn' => 'otf',
  306. 'host' => $dataSource->data_source_host,
  307. 'driver' => str_replace('sqlserver', 'sqlsrv', $dataSource->data_source_type),
  308. 'database' => $dataSource->data_source_dbname,
  309. 'username' => $dataSource->data_source_dbuser,
  310. 'password' => $dataSource->data_source_dbpass
  311. ];
  312. if ($dataSource->data_source_port) {
  313. $connection['port'] = $dataSource->data_source_port;
  314. }
  315. $db = new OTF($connection);
  316. try {
  317. $db->getConnection()->disableQueryLog();
  318. $repo = $db->getConnection()->select($this->_report[0]->report_query);
  319.  
  320. if ($this->_report[0]->report_exec) {
  321. $reportExec = json_decode($this->_report[0]->report_exec);
  322. }
  323. if ($repo) {
  324. if ($forExport) {
  325. $this->_resultRaw[0] = $repo;
  326. }
  327. $i = 0;
  328. foreach ($repo as $value) {
  329. // Log::error(var_export($value, true));
  330. if ($i == 0) {
  331. $this->_resultHeader[0] = array_keys(get_object_vars($value));
  332. foreach ($this->_resultHeader[0] as $rkey => $rval) {
  333. $this->_resultHeader[0][$rkey] = $this->friendlyName($rval);
  334. }
  335. }
  336. $tmp_values = get_object_vars($value);
  337. foreach ($tmp_values as $key => $value) {
  338. if (strpos($value, ",") !== false) {
  339. $tmp_values[$key] = '"'.rtrim($value).'"';
  340. }else{
  341. $tmp_values[$key] = rtrim($value);
  342. }
  343. }
  344. $this->_resultBody[0][] = array_values($tmp_values);
  345. $i++;
  346. }
  347.  
  348. if ($this->_report[0]->report_chart_enabled) {
  349. $this->_drawLavaChart($NR, $theme, $forExport);
  350. }
  351. }
  352.  
  353. } catch (\Illuminate\Database\QueryException $e) {
  354. var_dump($e->getMessage()); // wtf
  355. }
  356. } else {
  357. if (!is_array($XD)) {
  358. $arrayReport['multi'] = true;
  359. $XD = (array) $XD;
  360.  
  361. }
  362. $chartType = Input::get('chartType', 'Pie');
  363. if (!is_array($chartType)) {
  364. $chartType = (array) $chartType;
  365. // foreach ($chartType as $index => $chart) {
  366. // $chartType[$index] = ucfirst(filter_var($chart, FILTER_SANITIZE_STRING));
  367. // }
  368. }
  369. $filters = [];
  370. $this->_report = [];
  371. foreach ($XD as $index => $XD_item) {
  372. // echo $index . ' --- ' . $XD_item. "<br>";
  373. $repo = $this->_getExternalData($XD_item);
  374. // Log::error('XD DECOD ' . var_export($repo, true));
  375. $this->_report[$index] = new stdClass;
  376. $this->_report[$index]->report_chart_enabled = 0;
  377. $this->_report[$index]->report_id = 0;
  378. $this->_report[$index]->report_name = ''; // 'External Report';
  379. if (count($repo)) {
  380. $this->_report[$index]->report_chart_type = (isset($chartType[$index])) ? ucfirst(filter_var($chartType[$index], FILTER_SANITIZE_STRING)) : 'Pie';
  381. $this->_report[$index]->report_chart_enabled = 1;
  382. $this->_report[$index]->report_description = '';
  383.  
  384. if ($forExport) {
  385. $this->_resultRaw[$index] = $repo;
  386. }
  387. $i = 0;
  388. foreach ($repo as $value) {
  389. // Log::error(var_export($value, true));
  390. if ($i == 0) {
  391. $this->_resultHeader[$index] = array_keys(get_object_vars($value));
  392. }
  393. $this->_resultBody[$index][] = array_values(get_object_vars($value));
  394. $i++;
  395. }
  396.  
  397. if ($this->_report[$index]->report_chart_enabled) {
  398. $this->_drawLavaChart($NR, $theme, $forExport, $index);
  399. }
  400. }
  401. }
  402. }
  403. } catch (Exception $e) {
  404. Log::error(__METHOD__ .' Exception on ORT report '. $id. ': ' . $e->getMessage());
  405. if (!isset($this->_report[0]) || !$this->_report[0]) {
  406. $this->_report[0] = new stdClass;
  407. $this->_report[0]->report_id = 0;
  408. }
  409. $this->_report[0]->report_chart_type = '';
  410. $this->_report[0]->report_chart_enabled = 0;
  411. if (!isset($this->_report[0]->report_name)) {
  412. $this->_report[0]->report_name = '';
  413. }
  414. if (!isset($this->_report[0]->report_description)) {
  415. $this->_report[0]->report_description = '';
  416. }
  417. $arrayReport['error'] = ($e->getMessage() == 'Faltan filtros') ? '' : $e->getMessage();
  418. $arrayReport['errorExport'] = $e->getMessage();
  419.  
  420. $catched = true;
  421. }
  422.  
  423. if ($forExport) {
  424. $perPage = (count($this->_resultBody[0])) ? count($this->_resultBody[0]) : $perPage;
  425. $_body = Paginator::make($this->_resultBody[0], count($this->_resultBody[0]), $perPage);
  426. } else {
  427. $offset = ($page * $perPage) - $perPage;
  428. $_paginateBody = array_slice($this->_resultBody[0], $offset, $perPage);
  429. $_body = Paginator::make($_paginateBody, count($this->_resultBody[0]), $perPage);
  430. $savedFilters = ReportFilter::where(['report_id' => $id, 'user_id' => Auth::id()])->orderBy('id')->get();
  431. }
  432.  
  433. $inputFilters = Input::all();
  434. unset($inputFilters['page']);
  435.  
  436. $dateFilters = $this->_getDateFilters($filters);
  437. $dynamicDates = Input::get('dynamicDates', null);
  438. if ($dynamicDates) {
  439. $aDynamicDates = explode(',', $dynamicDates);
  440. }
  441.  
  442. $arrayReport['report'] = $this->_report;
  443. $arrayReport['rheader'] = $this->_resultHeader;
  444. $arrayReport['rbody'] = $_body;
  445. $arrayReport['results'] = count($this->_resultBody[0]);
  446. $arrayReport['isPaginated'] = ($arrayReport['results'] > $perPage);
  447. $arrayReport['isAjax'] = $isAjax;
  448. $arrayReport['isExport'] = $forExport;
  449. $arrayReport['chartType'] = $this->_chartType;
  450. $arrayReport['filters'] = $filters;
  451. $arrayReport['dateFilters'] = $dateFilters;
  452. $arrayReport['dynamicDates'] = $aDynamicDates;
  453. $arrayReport['flagFields'] = \Setting::get('ortFlagFields');
  454. $arrayReport['inputFilters'] = $inputFilters;
  455. $arrayReport['sponsorsFilter'] = ($sponsorsFilter) ? $sponsorsFilter : ['' => trans('messages.no_hay_sponsors_disponibles')];
  456. $arrayReport['tgsponsorsFilter'] = ($tgsponsorsFilter) ? $tgsponsorsFilter : ['' => trans('messages.no_hay_sponsors_disponibles')];
  457. $arrayReport['agregadorFilter'] = ($agregadorFilter) ? $agregadorFilter : ['' => trans('messages.no_hay_agregadores_disponibles')];
  458. $arrayReport['tgestadoFilter'] = ($tgestadoFilter) ? $tgestadoFilter : ['' => trans('messages.no_hay_agregadores_disponibles')];
  459. $arrayReport['activoFilter'] = ($activoFilter) ? $activoFilter : ['' => 'Error'];
  460. $arrayReport['campaniaFilter'] = ($campaniaFilter) ? $campaniaFilter : ['' => trans('messages.no_hay_campania_disponibles')];
  461. $arrayReport['mediosFilter'] = ($mediosFilter) ? $mediosFilter : ['' => trans('messages.no_hay_medios_disponibles')];
  462. $arrayReport['rowsFilter'] = $rowsFilter;
  463. $arrayReport['estadoEsFilter'] = ['' => trans('messages.select_seleccionar')] + $estadoEsFilter;
  464. $arrayReport['resultadoFilter'] = ['' => trans('messages.select_seleccionar')] + $resultadoFilter;
  465. $arrayReport["ActionFilter"] = $actionFilter;
  466. $arrayReport['paquetesFilter'] = ($paquetesFilter) ? $paquetesFilter : ['' => trans('messages.no_hay_paquetes_disponibles')];
  467. $arrayReport['aplicacionesFilter'] = ($aplicacionesFilter) ? $aplicacionesFilter : ['' => trans('messages.no_hay_aplicaciones_disponibles')];
  468. $arrayReport['paymentFilter'] = ($paymentFilter) ? (['' => trans('messages.select_seleccionar')] + $paymentFilter) : ['' => trans('messages.no_hay_payments_disponibles')];
  469. $arrayReport['redesFilter'] = ($redesFilter) ? $redesFilter : ['' => trans('messages.no_hay_redes_disponibles')];
  470. $arrayReport['mdsFilter'] = ($mdsFilter) ? $mdsFilter : ['' => trans('messages.no_hay_medios_disponibles')];
  471. $arrayReport['msg_bgreport']= (Input::get('report_exceeded')) ? trans('messages.reporte_sin_memoria') : '';
  472. $arrayReport['reportExec']= $reportExec;
  473. $arrayReport['savedFilters']= $savedFilters;
  474. $arrayReport['cookieViewStates'] = $this->_getCookieViewStates();
  475. $arrayReport['callbackUrl'] = Session::get('ORTcallback', asset('reportes/ort/'));
  476. if (!$catched && !count($_body) && !$arrayReport['error'] && !$arrayReport['msg_bgreport']) {
  477. $arrayReport['error'] = trans('ort.no_results');
  478. }
  479.  
  480. if (is_array($arrayReport) && count($arrayReport) > 0) {
  481. $arrayReport['show'] = true;
  482. }
  483. }
  484. if ($forExport) {
  485. $tipo = filter_var(Input::get('tipo', 'pdf'), FILTER_SANITIZE_STRING);
  486. $exportView = ($tipo == 'pdf') ? View::make("reportes.view_report_container", $arrayReport)->render() : ''; // Render view only if export is PDF
  487.  
  488. return new ReportExport(
  489. $this->_report[0]->report_name,
  490. ['header' => $this->_resultHeader[0], 'body' => $this->_resultBody[0], 'arrayReport' => $arrayReport],
  491. $exportView
  492. );
  493.  
  494. }
  495. if ($isAjax) {
  496. return Response::view("reportes.view_report", $arrayReport);
  497. }
  498.  
  499. $container = "reportes.view_report_container";
  500. if ($NR) {
  501. $container .= "_nr";
  502. $arrayReport['bodycolor'] = ($theme == 'light') ? 'black' : 'white';
  503. $arrayReport['backgroundcolor'] = ($theme == 'light') ? 'white' : 'black';
  504. }
  505.  
  506. return Response::view($container, $arrayReport);
  507. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement