function ModelTest()
 {
     pr($_SESSION['Auth']['User']);
     // 		  $_SESSION['Auth']['User']['id_empresa'] = '1';
     // 		  $_SESSION['Auth']['User']['empresa'] = 'Bonampak';
     // 		  $_SESSION['Auth']['User']['id_empresa'] = '2';
     // 		  $_SESSION['Auth']['User']['empresa'] = 'ATM';
     // 		  pr($_SESSION['Auth']['User']);
     exit;
     // 		  pr('current month is :'. $_SESSION['week']['month']);
     // 		  pr($this->Flujo->getFlujo($week='31',$year='2014',$status='Active',$month='08'));
     // 		  pr($this->FlujoSaldo->getSaldo($week='31',$year='2014',$status='Active',$month='7'));
     pr($this->GetSaldo());
     exit;
     App::Import('Shell', 'Shell');
     App::Import('Vendor', array('shells/calendar'));
     $myCalendar = new CalendarShell(new Object());
     $myCalendar->initialize();
     $calendar = $myCalendar->main($year = date('Y'), false);
     $ical = $myCalendar->DaysInMonth($year);
     //Get the days in CurrentMonth from specific method in CalendarShell
     // 			pr($calendar);pr($ical);
     exit;
 }
 function DailyReport($concepto = null, $area = null, $mes = null, $flota = null, $fraccion = null, $year = null)
 {
     // 	for switch between method in the shell only change the object->method call example $myShell->months();
     // 	grab the vars
     $filter['get_area'] = $area;
     $filter['get_mes'] = $mes;
     $filter['concepto'] = $concepto;
     if (!isset($_SESSION['projections']['months'])) {
         $_SESSION['projections']['months'] = $this->months($return = true, $set = false, $year = date('Y'));
     }
     $months = $_SESSION['projections']['months'];
     // 		  $fraction = $myShell->Fraccion->find('list',array('fields'=>array('id','fraccion')));
     if (!isset($_SESSION['projections']['fraction'])) {
         $_SESSION['projections']['fraction'] = $this->Fraccion->find('list', array('fields' => array('id', 'fraccion')));
     }
     $fraction = $_SESSION['projections']['fraction'];
     // 		  pr($fraction);
     $id_empresa = $_SESSION['Auth']['User']['id_empresa'];
     // 			$months = $this->months(true,false,$year);
     // 	import the shell that calculates->toneladas and main method
     // 		App::Import('Shell', 'Shell');
     // 		App::Import('Vendor',array('shells/sniffer_data'));
     // 		$myShell = new SnifferDataShell(new Object());
     // 		$myShell->initialize();
     // 	// 	Select the method to call
     // 		$Shell = $myShell->main($view=true,$debug=false);
     // 	// 	pr($Shell);exit();
     // 		$getShell = $Shell['Toneladas']; // Fix for compability
     // 	// 	pr($getShell);exit();
     // 		$kms = $Shell['kms'];
     // 	// 	pr($kms);exit();
     // 		$ingresos = $Shell['ingresos'];
     // 	// 	pr($ingresos);exit();
     $ingresos = null;
     // 		pr($concepto);
     App::Import('Shell', 'Shell');
     App::Import('Vendor', array('shells/calendar'));
     $myCalendar = new CalendarShell(new Object());
     $myCalendar->initialize();
     $calendar = $myCalendar->main($year = date('Y'), false);
     $ical = $myCalendar->DaysInMonth($year);
     //Get the days in CurrentMonth from specific method in CalendarShell
     if (!isset($_SESSION['projections']['operacion'])) {
         $this->operations();
     }
     if (isset($area)) {
         // comes from detail.ctp view for toneladas
         if ($area == '0') {
             // for all areas
             $Calendar = $calendar['days'][$mes];
             $cal_viajes = $cal_ingresos = $cal_kms = $cal_tons = $Calendar;
             // 		$DailyReport = $getShell['DailyReport']['report_day'][$id_empresa];// Set All areas for Toneladas
             $DailyReport = $_SESSION['projections']['operacion']['toneladasDaily'][$id_empresa];
             foreach ($DailyReport as $area_name => $month) {
                 foreach ($month as $month_name => $fraccion_) {
                     if (!empty($fraccion_)) {
                         foreach ($fraccion_ as $fraccion_name => $day) {
                             if (!empty($day)) {
                                 foreach ($day as $day_num => $DailyTons) {
                                     if (!isset($days_all_tons[$month_name][$fraccion_name][$day_num])) {
                                         $days_all_tons[$month_name][$fraccion_name][$day_num] = null;
                                     }
                                     $days_all_tons[$month_name][$fraccion_name][$day_num] += $DailyTons;
                                 }
                             }
                         }
                     }
                 }
             }
             // Then build the calendar
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($days_all_tons[$mes][$fraction_desc])) {
                         foreach ($days_all_tons[$mes][$fraction_desc] as $day => $tonsValue) {
                             if (isset($days_all_tons[$mes][$fraction_desc][$day])) {
                                 $cal_tons[$day][$fraction_desc] = $tonsValue;
                                 $_fraccion['toneladas'][$id_fraction] = $fraction_desc;
                             }
                         }
                     }
                 }
             }
             $cal = $cal_tons;
             // Set All areas for Kilometros
             // 		$DailyReportKms = $kms['report_daily'][$id_empresa];
             $DailyReportKms = $_SESSION['projections']['operacion']['kilometrosDaily'][$id_empresa];
             foreach ($DailyReportKms as $area_name => $month) {
                 foreach ($month as $month_name => $fraccion_) {
                     if (!empty($fraccion_)) {
                         foreach ($fraccion_ as $fraccion_name => $day) {
                             if (!empty($day)) {
                                 foreach ($day as $day_num => $DailyKms) {
                                     // 			if($days_all_kms[$month_name][$fraccion_name][$day_num] == 0){
                                     // 			  unset($days_all_kms[$month_name][$fraccion_name][$day_num]);
                                     // 			}
                                     if (!isset($days_all_kms[$month_name][$fraccion_name][$day_num])) {
                                         $days_all_kms[$month_name][$fraccion_name][$day_num] = null;
                                     }
                                     $days_all_kms[$month_name][$fraccion_name][$day_num] += $DailyKms;
                                 }
                             }
                         }
                     }
                 }
             }
             // Then build the calendar
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($days_all_kms[$mes][$fraction_desc])) {
                         foreach ($days_all_kms[$mes][$fraction_desc] as $day => $kmsValue) {
                             if (isset($days_all_kms[$mes][$fraction_desc][$day])) {
                                 $cal_kms[$day][$fraction_desc] = $kmsValue;
                                 $_fraccion['kilometros'][$id_fraction] = $fraction_desc;
                             }
                         }
                     }
                 }
             }
             $kms_days = $cal_kms;
             // 		$DailyReportIngresos = $ingresos['report_daily'][$id_empresa];
             $DailyReportIngresos = $_SESSION['projections']['operacion']['ingresosDaily'][$id_empresa];
             foreach ($DailyReportIngresos as $area_name => $month) {
                 foreach ($month as $month_name => $fraccion_) {
                     if (!empty($fraccion_)) {
                         foreach ($fraccion_ as $fraccion_name => $day) {
                             if (!empty($day)) {
                                 foreach ($day as $day_num => $DailyIngresos) {
                                     if (!isset($days_all_ingresos[$month_name][$fraccion_name][$day_num])) {
                                         $days_all_ingresos[$month_name][$fraccion_name][$day_num] = null;
                                     }
                                     $days_all_ingresos[$month_name][$fraccion_name][$day_num] += $DailyIngresos;
                                 }
                             }
                         }
                     }
                 }
             }
             // Then build the calendar
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($days_all_ingresos[$mes][$fraction_desc])) {
                         foreach ($days_all_ingresos[$mes][$fraction_desc] as $day => $ingresosValue) {
                             if (isset($days_all_ingresos[$mes][$fraction_desc][$day])) {
                                 $cal_ingresos[$day][$fraction_desc] = $ingresosValue;
                                 $_fraccion['ingresos'][$id_fraction] = $fraction_desc;
                             }
                         }
                     }
                 }
             }
             $ingresos_days = $cal_ingresos;
             // // // // // // // // // // // // // // // // // // // // // // // // // // // // //
             // Set All areas for Kilometros
             // 		$DailyReportKms = $kms['report_daily'][$id_empresa];
             $DailyReportViajes = $_SESSION['projections']['operacion']['viajesDaily'][$id_empresa];
             foreach ($DailyReportViajes as $area_name => $month) {
                 foreach ($month as $month_name => $fraccion_) {
                     if (!empty($fraccion_)) {
                         foreach ($fraccion_ as $fraccion_name => $day) {
                             if (!empty($day)) {
                                 foreach ($day as $day_num => $DailyViajes) {
                                     // 			if($days_all_kms[$month_name][$fraccion_name][$day_num] == 0){
                                     // 			  unset($days_all_kms[$month_name][$fraccion_name][$day_num]);
                                     // 			}
                                     if (!isset($days_all_viajes[$month_name][$fraccion_name][$day_num])) {
                                         $days_all_viajes[$month_name][$fraccion_name][$day_num] = null;
                                     }
                                     $days_all_viajes[$month_name][$fraccion_name][$day_num] += $DailyViajes;
                                 }
                             }
                         }
                     }
                 }
             }
             // Then build the calendar
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($days_all_viajes[$mes][$fraction_desc])) {
                         foreach ($days_all_viajes[$mes][$fraction_desc] as $day => $viajesValue) {
                             if (isset($days_all_viajes[$mes][$fraction_desc][$day])) {
                                 $cal_viajes[$day][$fraction_desc] = $viajesValue;
                                 $_fraccion['viajes'][$id_fraction] = $fraction_desc;
                             }
                         }
                     }
                 }
             }
             $viajes_days = $cal_viajes;
             // // // // // // // // // // // // // // // // // // // // // // // // // // // //
         } else {
             // 		Toneladas <---- bug
             $DailyReport = $_SESSION['projections']['operacion']['toneladasDaily'][$id_empresa][$this->areas()[$area]][$mes];
             $Calendar = $calendar['days'][$mes];
             // Get only the selected month come from detail.ctp
             $viajes_days = $ingresos_days = $kms_days = $cal = $Calendar;
             //create the array that's containt the toneladas data
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($DailyReport[$fraction_desc])) {
                         if (isset($DailyReport[$fraction_desc][$day])) {
                             $cal[$day][$fraction_desc] = $DailyReport[$fraction_desc][$day];
                             $_fraccion['toneladas'][$id_fraction] = $fraction_desc;
                         }
                     }
                 }
             }
             // 		Kilometros  <----
             $DailyReportKms = $_SESSION['projections']['operacion']['kilometrosDaily'][$id_empresa][$this->areas()[$area]][$mes];
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($DailyReportKms[$fraction_desc])) {
                         if (isset($DailyReportKms[$fraction_desc][$day])) {
                             $kms_days[$day][$fraction_desc] = $DailyReportKms[$fraction_desc][$day];
                             $_fraccion['kilometros'][$id_fraction] = $fraction_desc;
                         }
                     }
                 }
             }
             // 		Ingresos  <----
             $DailyReportIngresos = $_SESSION['projections']['operacion']['ingresosDaily'][$id_empresa][$this->areas()[$area]][$mes];
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($DailyReportIngresos[$fraction_desc])) {
                         if (isset($DailyReportIngresos[$fraction_desc][$day])) {
                             $ingresos_days[$day][$fraction_desc] = $DailyReportIngresos[$fraction_desc][$day];
                             $_fraccion['ingresos'][$id_fraction] = $fraction_desc;
                         }
                     }
                 }
             }
             // 		Viajes  <----
             $DailyReportViajes = $_SESSION['projections']['operacion']['viajesDaily'][$id_empresa][$this->areas()[$area]][$mes];
             foreach ($Calendar as $day => $details) {
                 foreach ($fraction as $id_fraction => $fraction_desc) {
                     if (isset($DailyReportViajes[$fraction_desc])) {
                         if (isset($DailyReportViajes[$fraction_desc][$day])) {
                             $viajes_days[$day][$fraction_desc] = $DailyReportViajes[$fraction_desc][$day];
                             $_fraccion['viajes'][$id_fraction] = $fraction_desc;
                         }
                     }
                 }
             }
         }
     }
     // 	pr($ingresos_days);exit();
     foreach ($months as $num => $data) {
         if (in_array($mes, $data)) {
             $mes = $data['spanish'];
             $id_mes = $data['num'];
             // 		  pr($data);
         }
     }
     if (isset($cal)) {
         $filter['toneladas'] = $cal;
         // set the Toneladas bug => compability
     }
     if (isset($kms_days)) {
         $filter['kilometros'] = $kms_days;
         // Set kilometros daily;
     }
     if (isset($ingresos_days)) {
         $filter['ingresos'] = $ingresos_days;
     }
     if (isset($viajes_days)) {
         $filter['viajes'] = $viajes_days;
     }
     /** WARNING work from hir
     	$filter['kilometros'] = $kms; // set the kms ==> fixed
     	$filter['ingresos'] = $ingresos; // set the ingresos ==> fixed
     	**/
     $filter['_fraccion'] = $_fraccion;
     $filter['fraction'] = $fraction;
     // 	pr($_fraccion);exit();
     $filter['graphs']['ingresos'] = $ingresos;
     $filter['area'] = $this->areas()[$area];
     $filter['mes'] = $mes;
     $filter['id_mes'] = $id_mes;
     $filter['year'] = $year;
     // 	$filter['ical'] = $ical[substr($mes,0,3)];
     $filter['daysArray'] = $calendar['daysArray'];
     // Send var to view
     $this->set('filter', $filter);
     $this->set('months', $months);
     // 	exit();
 }