function tachionDetail($indicator = null) { // pr($indicator);exit(); // pr($this->Flotas->find('all')); $idx_empresa = $_SESSION['Auth']['User']['id_empresa']; $year = date('Y'); 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['Toneladas']);exit(); App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/calendar')); $myCalendar = new CalendarShell(new Object()); $myCalendar->initialize(); $months = $myCalendar->months(true, false, $year); App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/flotas')); $fleet = new FlotasShell(new Object()); $fleet->initialize(); $fleets = $fleet->fleets(true, false); pr($fleets); // exit(); App::import('Controller', 'Holiday'); $Holiday = new HolidayController(); $Holiday->constructClasses(); $startDate = date('Y-m-d', mktime('0', '0', '0', date('n'), '01', date('Y'))); // for CurrentMonth $endDate = date('Y-m-d', mktime('0', '0', '0', date('n'), date('t'), date('Y'))); // for CurrentMonth $GoToWork = $Holiday->RetrieveHolidays($startDate, $endDate, $debug = true, $year = date('Y')); // pr($GoToWork); $toneladas_labour_days = $Shell['Toneladas']['DailyReport']['report_day']; $kilometros_labour_days = $Shell['kms']['report_daily']; $ingresos_labour_days = $Shell['ingresos']['report_daily']; foreach ($toneladas_labour_days as $id_empresa => $areas) { foreach ($areas as $area_name => $meses) { foreach ($meses as $NombreMes => $fracciones) { foreach ($fracciones as $NombreFraccion => $dias) { if (!empty($dias)) { foreach ($dias as $id_dia => $tons_value) { if ($NombreMes == date('M')) { if (!empty($tons_value)) { $dias_toneladas[$id_empresa][$area_name][$NombreMes][$NombreFraccion][$id_dia] = $tons_value; } } } } } } } } foreach ($kilometros_labour_days as $id_empresa => $areas) { foreach ($areas as $area_name => $meses) { foreach ($meses as $NombreMes => $fracciones) { foreach ($fracciones as $NombreFraccion => $dias) { foreach ($dias as $id_dia => $kms_value) { if ($NombreMes == date('M')) { if (!empty($kms_value)) { $dias_kilometros[$id_empresa][$area_name][$NombreMes][$NombreFraccion][$id_dia] = $kms_value; } } } } } } } foreach ($ingresos_labour_days as $id_empresa => $areas) { foreach ($areas as $area_name => $meses) { foreach ($meses as $NombreMes => $fracciones) { foreach ($fracciones as $NombreFraccion => $dias) { foreach ($dias as $id_dia => $ingresos_value) { if ($NombreMes == date('M')) { if (!empty($ingresos_value)) { $dias_ingresos[$id_empresa][$area_name][$NombreMes][$NombreFraccion][$id_dia] = $ingresos_value; } } } } } } } $promedio['toneladas'] = $dias_toneladas; $promedio['kilometros'] = $dias_kilometros; $promedio['ingresos'] = $dias_ingresos; foreach ($promedio as $indicador => $dias_indicador) { foreach ($dias_indicador as $id_empresa => $area) { foreach ($area as $area_name => $meses) { foreach ($meses as $meses_name => $fractiones) { foreach ($fractiones as $fractiones_name => $days_pr) { $acum_men = array_sum($days_pr); // pr($acum_men); $dias_laborados = count($days_pr); $projection[$indicador][$id_empresa][$area_name][$meses_name][$fractiones_name] = $acum_men / $dias_laborados * $GoToWork; } } } } } pr($projection); exit; if (!isset($indicator)) { $this->set('projection', $projection); } else { $this->set('projection', $projection[$indicator]); } $this->set('months', $months); $today = null; // exit(); }
function RetrieveData($year = null, $fraction = null, $model = null, $criteria = null, $debug = null, $flotas = null) { if (empty($year) or !isset($year)) { $year = date('Y'); $mes = date('n'); } else { if ($year < date('Y')) { $mes = '12'; } elseif ($year > date('Y')) { exit; } else { $mes = date('n'); } } // var_dump($year); // var_dump($mes); // $year='2014'; // exit(); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/calendar')); $myCalendar = new CalendarShell(new Object()); $myCalendar->initialize(); $calendar = $myCalendar->main($year, false); $fraction_for_day = $this->Fraccion->find('list', array('fields' => array('id', 'fraccion'))); $reporte_diario = $criteria['kms']; foreach ($reporte_diario as $id_empresa => $area) { foreach ($area as $area_name => $month) { foreach ($calendar['days'] as $month_name => $dia) { foreach ($dia as $num_dia => $dia_detail) { foreach ($fraction_for_day as $id_fraction => $fraction_desc) { $dias[$id_empresa][$area_name][$month_name][$fraction_desc][$num_dia] = null; } } } } } // pr($dias);pr($reporte_diario);exit(); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // $_append = $this->Empresas(); $areas = $this->areas(); $months = $this->months($return = true, $set = false, $year); // var_dump($months);exit(); $filter['area'] = true; // pr($months); $toneladas = $criteria['toneladas']; $kms = $criteria['kms']; $ingresos = $criteria['ingresos']; foreach ($areas as $key => $value) { foreach ($value as $idx => $areadist) { foreach ($months as $ky => $dat) { foreach ($fraction as $llave => $dato) { if ($dat['num'] <= $mes) { $ConditionsToneladas[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['tonelaje'] . '.fecha_guia LIKE'] = "%" . $year . "-" . $dat['numeric'] . "%"; $ConditionsKms[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['kms'] . '.fecha_guia LIKE'] = "%" . $year . "-" . $dat['numeric'] . "%"; $ConditionsIngresos[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['ingresos'] . '.fecha_guia LIKE'] = "%" . $year . "-" . $dat['numeric'] . "%"; if ($filter['area'] == true) { // Only check the area , will assume that 0 are all areas -- remenber that zero value is taken as false $ConditionsToneladas[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['tonelaje'] . '.id_area'] = $idx; $ConditionsKms[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['kms'] . '.id_area'] = $idx; $ConditionsIngresos[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['ingresos'] . '.id_area'] = $idx; } if (isset($filter['flota'])) { // is $filter['flota'] over there ?? if ($filter['flota'] == true) { // is breathing ? foreach ($TpoOp as $k => $val) { $ConditionsToneladas[$key][trim($areadist)][$dat['short']][$dato]['OR'][$k][$model[$key]['tonelaje'] . '.id_tipo_operacion'] = $val; $ConditionsKms[$key][trim($areadist)][$dat['short']][$dato]['OR'][$k][$model[$key]['kms'] . '.id_tipo_operacion'] = $val; $ConditionsIngresos[$key][trim($areadist)][$dat['short']][$dato]['OR'][$k][$model[$key]['ingresos'] . '.id_tipo_operacion'] = $val; } } } // already have our answer $ConditionsToneladas[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['tonelaje'] . '.id_fraccion'] = $llave; $ConditionsKms[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['kms'] . '.id_fraccion'] = $llave; $ConditionsIngresos[$key][trim($areadist)][$dat['short']][$dato][$model[$key]['ingresos'] . '.id_fraccion'] = $llave; } // End if to current month dat[num] /** ALERT Scavenger ** @var => Sniff in the Databases @obj => Objetive Search for erroneous data in DB's only need one data to retrieve **/ // See what's happend if ($dat['num'] > $mes) { $ConditionsToneladasWarning[$key][trim($areadist)][date('M', mktime('0', '0', '0', $dat['numeric'], '01', $year))][$dato][$model[$key]['tonelaje'] . '.fecha_guia LIKE'] = "%" . $year . "-" . $dat['numeric'] . "%"; $ConditionsToneladasWarning[$key][trim($areadist)][date('M', mktime('0', '0', '0', $dat['numeric'], '01', $year))][$dato][$model[$key]['tonelaje'] . '.id_fraccion'] = $llave; if ($filter['area'] == true) { // Only check the area , will assume that 0 are all areas -- remenber that zero value is taken as false $ConditionsToneladasWarning[$key][trim($areadist)][date('M', mktime('0', '0', '0', $dat['numeric'], '01', $year))][$dato][$model[$key]['tonelaje'] . '.id_area'] = $idx; } } } // End foreach fraction } //end foreach of months } // End seek of area distinction } // End foreach areas with fleets // pr($ConditionsToneladasWarning['1']['Orizaba']);exit(); // pr($ConditionsToneladas);exit(); /** ALERT => Get the data from databases firts Toneladas then Kms and last Ingresos ** @var => no vars yet ** @params => unknow parameter yet ** @var => Set Toneladas arrays **/ // pr($toneladas); $tons_sum = $report_warning = $report_day = $tonelaje = $toneladas; // var_dump($ConditionsToneladas); foreach ($ConditionsToneladas as $id_empresa => $area) { foreach ($area as $id_area => $mes) { // Retrieve data for each area foreach ($mes as $month_name => $fraction) { // Retrieve data by month foreach ($fraction as $fraction_name => $query) { // And retrieve data for each fraction under month $tonelaje[$id_empresa][trim($id_area)][$month_name][$fraction_name] = $this->{$model}[$id_empresa]['tonelaje']->find('all', array('conditions' => $query)); } } } } // End of the world for conditions Die!! areas Die!! XD!!! // pr($tonelaje);exit(); $canceladas = $edicion = null; foreach ($tonelaje as $id_empresa => $area) { foreach ($area as $area_name => $mes) { if (isset($mes)) { // fix for tonelaje foreach ($mes as $month_name => $GetFractionData) { foreach ($GetFractionData as $FractionName => $GetData) { foreach ($GetData as $idx => $TonelajeCurrentData) { $toneladas[$id_empresa][$area_name][$month_name][$FractionName] += $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['peso']; /** @param => Set the tonelaje by day **/ $day = substr($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['fecha_guia'], 8, 2); if (!isset($report_day[$id_empresa][$area_name][$month_name][$FractionName][$day])) { $report_day[$id_empresa][$area_name][$month_name][$FractionName][$day] = null; } $report_day[$id_empresa][$area_name][$month_name][$FractionName][$day] += $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['peso']; if (!isset($report_day_check[$id_empresa][$area_name][$month_name][$FractionName][$day][trim($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia'])]['peso'])) { $report_day_check[$id_empresa][$area_name][$month_name][$FractionName][$day][trim($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia'])]['peso'] = null; } $report_day_check[$id_empresa][$area_name][$month_name][$FractionName][$day][trim($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia'])]['peso'] += $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['peso']; $report_day_check[$id_empresa][$area_name][$month_name][$FractionName][$day][trim($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia'])]['tipo_operacion'] = $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['id_tipo_operacion']; $report_day_check[$id_empresa][$area_name][$month_name][$FractionName][$day][trim($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia'])]['id_flota'] = $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['id_flota']; $report_day_check[$id_empresa][$area_name][$month_name][$FractionName][$day][trim($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia'])]['id_unidad'] = $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['id_unidad']; /** @param => Check if peso is zero **/ if ($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['peso'] == '0') { if (!isset($report_warning[$id_empresa][$area_name][$month_name][$FractionName][$day])) { $report_warning[$id_empresa][$area_name][$month_name][$FractionName][$day][] = $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['num_guia']; } } // Marauder /** @param => Check if tonelaje is overcharged **/ if ($TonelajeCurrentData[$model[$id_empresa]['tonelaje']]['peso'] > 60) { $ToneladasWarningData[$id_empresa][$area_name][$month_name][$FractionName][] = $TonelajeCurrentData[$model[$id_empresa]['tonelaje']]; } // ByFleet } } } } // end filtering of !isset months } //End foreach area => mes } if ($debug) { pr($ToneladasWarningData); pr($toneladas); pr($report_day); pr($report_warning); } else { $DataTons['DetailData']['toneladas'] = $toneladas; $DataTons['DailyReport']['report_day'] = $report_day; if (isset($ToneladasWarningData)) { $DataTons['Warnings']['ToneladasWarningData'] = $ToneladasWarningData; } $DataTons['Warnings']['report_warning'] = $report_warning; $DataTons['Warnings']['report_day_check_toneladas'] = $report_day_check; } // pr($DataTons);exit(); foreach ($toneladas as $id_empresa => $area) { // pr($area); foreach ($area as $area_name => $month) { foreach ($month as $month_name => $fracciones) { $TotalByMonth[$id_empresa][$area_name][$month_name] = array_sum($fracciones); foreach ($fracciones as $fraction_name => $data) { if (!isset($TotalByFraction[$id_empresa][$area_name][$fraction_name])) { $TotalByFraction[$id_empresa][$area_name][$fraction_name] = null; } $TotalByFraction[$id_empresa][$area_name][$fraction_name] += $data; } } } } if ($debug) { pr($TotalByMonth); pr($TotalByFraction); } else { $DataTons['totals']['TotalByMonth'] = $TotalByMonth; $DataTons['totals']['TotalByFraction'] = $TotalByFraction; } foreach ($TotalByMonth as $id_empresa => $area) { foreach ($area as $area_name => $fracciones) { $TotalByYear[$id_empresa][$area_name] = array_sum($fracciones); } } if ($debug) { pr($TotalByYear); } else { $DataTons['totals']['TotalByYear'] = $TotalByYear; } if (isset($DataTons)) { $Result['Toneladas'] = $DataTons; } // pr($report_day_check_toneladas); // exit(); // exit(); /** WARNING => @firts reset the vars that you going to need like totals ** @Section Kms => Result['kms'] @use => ConditionsKms **/ // pr($ConditionsKms);exit(); // KMS <--- //glosary // tonelaje = kilometros // toneladas = kms // tons_sum = kms_sum // TonelajeCurrentData = KilometrosCurrentData $full = $kms_full = $kms_all = $kms_sum = $report_warning = $kilometros = $count_month = $kms; $report_day_all = $report_day_full = $report_day = $report_day_plus = $dias; /*$count_day_merge =*/ $count_day_all = $count_day_full = $dias; $test = $query = $toneladas = null; foreach ($ConditionsKms as $id_empresa => $area) { foreach ($area as $id_area => $mes) { // Retrieve data for each area foreach ($mes as $month_name => $fraction) { // Retrieve data by month foreach ($fraction as $fraction_name => $query) { // And retrieve data for each fraction under month $kilometros[$id_empresa][trim($id_area)][$month_name][$fraction_name] = $this->{$model}[$id_empresa]['kms']->find('all', array('conditions' => $query)); } } } } // End of the world for conditions Die!! areas Die!! XD!!! // pr($kilometros['1']); // pr($ConditionsKms['1']); // var_dump($id_empresa); // exit(); $canceladas = $edicion = null; foreach ($kilometros as $id_empresa => $area) { foreach ($area as $area_name => $mes) { foreach ($mes as $month_name => $GetFractionData) { foreach ($GetFractionData as $FractionName => $GetData) { foreach ($GetData as $idx => $KilometrosCurrentData) { /** WARNING WARNING WARNING @fix @kms from @detail ****/ // issues for kms->sencillo are the same as for kms->full can have n->"cartas porte" for a onlyone dispatch so in consequence use the same logic for both and can use only one recurrence track for both otherside i use separates trackings just in case the need of know data of each of them /** WARNING WARNING WARNING @continue work form hir ****/ if ($KilometrosCurrentData[$model[$id_empresa]['kms']]['id_configuracionviaje'] == '3') { /** @param => Set kilometros by day full **/ /** NOTE if the fraction is others then use kms_real */ if (trim((string) $FractionName) === 'Granel' or trim((string) $FractionName) === 'Envasado' or trim((string) $FractionName) === 'Clinker') { $tripKms = 'kms_viaje'; } else { $tripKms = 'kms_real'; } $kms_day_full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)] = $KilometrosCurrentData[$model[$id_empresa]['kms']][$tripKms]; /** WARNING*/ if (!isset($full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)])) { $full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)] = null; } if (isset($KilometrosCurrentData[$model[$id_empresa]['kms']]['num_guia'])) { $full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)] = $KilometrosCurrentData[$model[$id_empresa]['kms']]['num_guia']; } foreach ($kms_day_full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']] as $valueKms) { if (count($kms_day_full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]) > 1) { // NOTE ok then assuming this is happeng always how to know in which day add the -- // NOTE counting travel and add the kilometers , in the total is ok but in the detail // NOTE we have the diferences in which day will put the data ??? $counting = count($kms_day_full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]); // NOTE if pass still be > 1 then array_pop($kms_day_full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]); pr($kms_day_full[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]); // $this->out('travel => '.$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje'].' month => '.$month_name.' Area => '.$area_name.' Sencillo and have => '.$counting.' records'); } } /** WARNING*/ } elseif ($KilometrosCurrentData[$model[$id_empresa]['kms']]['id_configuracionviaje'] == '2' or $KilometrosCurrentData[$model[$id_empresa]['kms']]['id_configuracionviaje'] == '1') { /** @param => Set kilometros by day kms_sencillo **/ /** NOTE if the fraction is others then use kms_real */ if (trim((string) $FractionName) === 'Granel' or trim((string) $FractionName) === 'Envasado' or trim((string) $FractionName) === 'Clinker') { $tripKms = 'kms_viaje'; } else { $tripKms = 'kms_real'; } $kms_day_all[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)] = $KilometrosCurrentData[$model[$id_empresa]['kms']][$tripKms]; /** WARNING*/ if (!isset($sencillo[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)])) { $sencillo[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)] = null; } if (isset($KilometrosCurrentData[$model[$id_empresa]['kms']]['num_guia'])) { $sencillo[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']][substr($KilometrosCurrentData[$model[$id_empresa]['kms']]['fecha_guia'], 8, 2)] = $KilometrosCurrentData[$model[$id_empresa]['kms']]['num_guia']; } foreach ($kms_day_all[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']] as $valuesKms) { if (count($kms_day_all[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]) > 1) { // NOTE ok then assuming this is happeng always how to know in which day add the -- // NOTE counting travel and add the kilometers , in the total is ok but in the detail // NOTE we have the diferences in which day will put the data ??? $counting = count($kms_day_all[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]); array_pop($kms_day_all[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]); pr($kms_day_all[$id_empresa][$area_name][$month_name][$FractionName][$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje']]); // $this->out('travel => '.$KilometrosCurrentData[$model[$id_empresa]['kms']]['no_viaje'].' month => '.$month_name.' Area => '.$area_name.' Sencillo and have => '.$counting.' records'); } } /** WARNING*/ } } } } } } // pr($kilometros); // exit(); // pr($kms_day_full['1']['Tijuana']['Mar']); // pr($kms_day_all['1']['Tijuana']['Mar']); // exit(); // pr($full); // pr($sencillo); // exit(); // pr(count($kms_day_all['1']['Orizaba']['Nov']['Granel'])); // exit(); foreach ($kms_day_full as $id_empresa => $area) { foreach ($area as $area_name => $month) { foreach ($month as $month_name => $fractions_data) { foreach ($fractions_data as $fraction_name => $viaje) { if ($viaje !== null) { // fix for empty fractions_data like Envasado ProductosVarios etc foreach ($viaje as $no_viaje => $kms_viaje_full) { foreach ($kms_viaje_full as $day_kms => $kms_value) { if (!isset($report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])) { $report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; } $report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] += $kms_value; if (!isset($count_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])) { $count_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; } $count_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] += 1; // if($no_viaje == '8211'){ // pr($no_viaje); // } // // // // // // // @make detail // if(!isset($count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])){ // $count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; // } // $count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms][] = $no_viaje; // // // // // // // @make detail /** WARNING*/ if (!isset($count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])) { $count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; } $count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms][$no_viaje] = $full[$id_empresa][$area_name][$month_name][$fraction_name][$no_viaje][$day_kms]; /** WARNING*/ } } } } } } } // end $kms_sum foreach ($kms_day_all as $id_empresa => $area) { foreach ($area as $area_name => $month) { foreach ($month as $month_name => $fractions_data) { foreach ($fractions_data as $fraction_name => $viaje) { if ($viaje !== null) { // fix for empty fractions_data like Envasado ProductosVarios etc foreach ($viaje as $no_viaje => $kms_viaje_all) { foreach ($kms_viaje_all as $day_kms => $kms_value) { if (!isset($report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])) { // if var not exists then build it $report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; } $report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] += $kms_value; if (!isset($count_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])) { // if var not exists then build it $count_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; } $count_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] += 1; // // // // // // // // // detail of counting // if(!isset($count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])){ // $count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; // } // $count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms][] = $no_viaje; // // // // // // // // // /** WARNING*/ if (!isset($count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms])) { $count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms] = null; } $count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$day_kms][$no_viaje] = $sencillo[$id_empresa][$area_name][$month_name][$fraction_name][$no_viaje][$day_kms]; /** WARNING*/ } } } } } } } // end $kms_sum // pr($kms_day_all); // pr($kms_day_full); // // pr($count_day_full); // // pr($count_day_all); // pr($count_day_full_detail); // pr($count_day_all_detail); // // // exit(); // pr($counting_day_full_detail); // pr($counting_day_all_detail); // unset($count_day_full_detail); // unset($count_day_all_detail); // $count_day_all_detail = $count_day_full_detail = null; // $count_day_full_detail = $counting_day_full_detail; // $count_day_all_detail = $counting_day_all_detail; // pr($kms_day_full['1']['Tijuana']['Mar']); // pr($kms_day_all['1']['Tijuana']['Mar']); // pr($count_day_full_detail['1']['Tijuana']['Mar']); // pr($count_day_all_detail['1']['Tijuana']['Mar']); // pr($count_day_full['1']['Tijuana']['Mar']['Granel']); // pr($count_day_all['1']['Tijuana']['Mar']['Granel']); // exit(); // // exit(); foreach ($report_day as $id_empresa => $area) { foreach ($area as $area_name => $month) { foreach ($month as $month_name => $fractions_data) { // if(!isset($kms_day[$id_empresa][$area_name][$month_name])){ // $kms_day[$id_empresa][$area_name][$month_name] = null; // } foreach ($fractions_data as $fraction_name => $month_days) { foreach ($month_days as $dia_kms => $value_kms) { if (!empty($report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]) or !empty($report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { $report_day[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = $report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] + $report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]; // NOTE if one day you need made changes for otros // NOTE and now that day comes to live jajajaja NOTE if (trim((string) $fraction_name) === 'Granel' or trim((string) $fraction_name) === 'Envasado' or trim((string) $fraction_name) === 'Clinker') { $report_day_plus[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = ($report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] + $report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]) * 2; } else { $report_day_plus[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = $report_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] + $report_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]; } } if (!empty($count_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]) or !empty($count_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { //counting trips if (!isset($count_day[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { $count_day[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = null; } $count_day[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = $count_day_full[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] + $count_day_all[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]; /** * @first ask if is an array or exists but this is implicit right!!! on not ? */ if (isset($count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]) and is_array($count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]) and (isset($count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]) and is_array($count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]))) { if (!isset($count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { $count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = null; } $count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = array_merge_recursive($count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms], $count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]); } else { //hir goes the else if (isset($count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { if (!isset($count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { $count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = null; } $count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = $count_day_full_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]; } if (isset($count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { if (!isset($count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms])) { $count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = null; } $count_day_merge[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms] = $count_day_all_detail[$id_empresa][$area_name][$month_name][$fraction_name][$dia_kms]; } } } //End if not empty } } } } } // pr($count_day_full_detail);exit(); // pr($count_day_all_detail);exit(); // pr($count_day_merge); // exit(); // $log = $this->Model->getDataSource()->getLog(false, false); // debug($log); // pr($report_day);exit();//for operations this is the correct param // pr($report_day_all);pr($report_day_full); // this is for DailyReport() foreach ($report_day_full as $id_empresa => $area) { foreach ($area as $area_name => $month) { foreach ($month as $month_name => $fractions_data) { if (!isset($kms_sum[$id_empresa][$area_name][$month_name])) { $kms_sum[$id_empresa][$area_name][$month_name] = null; } foreach ($fractions_data as $fraction_name => $viaje) { if (!isset($kms_sum[$id_empresa][$area_name][$month_name][$fraction_name])) { $kms_sum[$id_empresa][$area_name][$month_name][$fraction_name] = null; } // NOTE if one day you need made changes for otros // NOTE and now that day comes to live jajajaja NOTE if (trim((string) $fraction_name) === 'Granel' or trim((string) $fraction_name) === 'Envasado' or trim((string) $fraction_name) === 'Clinker') { $kms_sum[$id_empresa][$area_name][$month_name][$fraction_name] += (array_sum($report_day_full[$id_empresa][$area_name][$month_name][$fraction_name]) + array_sum($report_day_all[$id_empresa][$area_name][$month_name][$fraction_name])) * 2; } else { $kms_sum[$id_empresa][$area_name][$month_name][$fraction_name] += array_sum($report_day_full[$id_empresa][$area_name][$month_name][$fraction_name]) + array_sum($report_day_all[$id_empresa][$area_name][$month_name][$fraction_name]); } // NOTE if one day you need made changes for otros // NOTE and now that day comes to live jajajaja NOTE if (isset($count_day[$id_empresa][$area_name][$month_name][$fraction_name])) { // $count_month[$id_empresa][$area_name][$month_name][$fraction_name] = null; $count_month[$id_empresa][$area_name][$month_name][$fraction_name] = array_sum($count_day[$id_empresa][$area_name][$month_name][$fraction_name]); if (!isset($count_year[$id_empresa][$area_name][$fraction_name])) { $count_year[$id_empresa][$area_name][$fraction_name] = null; } $count_year[$id_empresa][$area_name][$fraction_name] += array_sum($count_day[$id_empresa][$area_name][$month_name][$fraction_name]); } } } } } // pr($count_day);exit(); // pr($count_month); // exit(); // pr($kms_sum);exit(); // this is for fraction report by month foreach ($kms_sum as $id_empresa => $area) { foreach ($area as $area_name => $month) { foreach ($month as $month_name => $fractions_data) { foreach ($fractions_data as $fraction => $value) { if (!isset($kms_monthly[$id_empresa][$area_name][$month_name])) { $kms_monthly[$id_empresa][$area_name][$month_name] = null; } $kms_monthly[$id_empresa][$area_name][$month_name] += $value; } if (isset($count_month[$id_empresa][$area_name][$month_name])) { $count_month_no_fraction[$id_empresa][$area_name][$month_name] = array_sum($count_month[$id_empresa][$area_name][$month_name]); } } } } // pr($kms_monthly); // totals by month // exit(); // yearly report // pr($count_year);exit(); foreach ($kms_monthly as $id_empresa => $area) { foreach ($area as $area_name => $month) { $kms_yearly[$id_empresa][$area_name] = array_sum($month); if (!isset($count_year_no_fraction[$id_empresa][$area_name])) { $count_year_no_fraction[$id_empresa][$area_name] = null; } if (isset($count_year[$id_empresa][$area_name])) { $count_year_no_fraction[$id_empresa][$area_name] = array_sum($count_year[$id_empresa][$area_name]); } } } // pr($count_year_no_fraction);exit(); // pr($kms_yearly); // Totals by Year foreach ($kms_yearly as $id_empresa => $area_name) { $kms_full_year[$id_empresa] = array_sum($area_name); } $kms_detail = array(); $kms_detail['report_day_all'] = $report_day_all; $kms_detail['report_day_full'] = $report_day_full; $kms_detail['report_daily'] = $report_day; $kms_detail['report_daily_plus'] = $report_day_plus; $kms_detail['kms_month_by_fraction'] = $kms_sum; $kms_detail['total_kms_monthly'] = $kms_monthly; $kms_detail['total_kms_yearly'] = $kms_yearly; $kms_detail['full_total_kms_yearly'] = $kms_full_year; //Counting trips... $kms_detail['count']['count_day_all'] = $count_day_all; //count all "sencillos" by empresa,area,month,fraction and day $kms_detail['count']['count_day_full'] = $count_day_full; // same as before but is for "full" $kms_detail['count']['count_day'] = $count_day; // sum of both count's before and classified by day $kms_detail['count']['count_month'] = $count_month; // the sum counting by id_empresa, area, month and fraction $kms_detail['count']['count_month_no_fraction'] = $count_month_no_fraction; //same as before with out fraction $kms_detail['count']['count_year'] = $count_year; //sum of all the months by area yearly by fraction $kms_detail['count']['count_year_no_fraction'] = $count_year_no_fraction; //sum of all the months by area yearly without fraction $kms_detail['count']['count_day_merge'] = $count_day_merge; // pr($kms_detail['count']); // exit(); $Result['kms'] = $kms_detail; if ($debug) { pr($Result['kms']); } /** WARNING => @firts reset the vars that you going to need like totals ** @Section Ingresos => Result['ingresos'] @use => ConditionsIngresos **/ //INGRESOS <--- $report_warning = $ingresos; $report_day_all = $report_day_full = $report_day = $dias; $test = $query = null; foreach ($ConditionsIngresos as $id_empresa => $area) { foreach ($area as $id_area => $mes) { // Retrieve data for each area foreach ($mes as $month_name => $fraction) { // Retrieve data by month foreach ($fraction as $fraction_name => $query) { // And retrieve data for each fraction under month $ingresos[$id_empresa][trim($id_area)][$month_name][$fraction_name] = $this->{$model}[$id_empresa]['ingresos']->find('all', array('conditions' => $query)); } } } } // End of the world for conditions Die!! areas Die!! XD!!! // pr($ingresos);exit(); // pr($model); // exit(); $canceladas = $edicion = null; foreach ($ingresos as $id_empresa => $area) { foreach ($area as $area_name => $mes) { foreach ($mes as $month_name => $GetFractionData) { foreach ($GetFractionData as $FractionName => $GetData) { foreach ($GetData as $idx => $IngresosCurrentData) { // pr($IngresosCurrentData); /** @param => Set ingresos by day full **/ if (!isset($ingresos_day[$id_empresa][$area_name][$month_name][$FractionName][substr($IngresosCurrentData[$model[$id_empresa]['ingresos']]['fecha_guia'], 8, 2)])) { $ingresos_day[$id_empresa][$area_name][$month_name][$FractionName][substr($IngresosCurrentData[$model[$id_empresa]['ingresos']]['fecha_guia'], 8, 2)] = null; } $ingresos_day[$id_empresa][$area_name][$month_name][$FractionName][substr($IngresosCurrentData[$model[$id_empresa]['ingresos']]['fecha_guia'], 8, 2)] += $IngresosCurrentData[$model[$id_empresa]['ingresos']]['subtotal']; // pr($ingresos_day[$id_empresa][$area_name][$month_name][$FractionName][substr($IngresosCurrentData[$model[$id_empresa]['ingresos']]['fecha_guia'],8,2)]); // pr($IngresosCurrentData[$model[$id_empresa]['ingresos']]['subtotal']); } } } } } // pr($ingresos_day);exit(); foreach ($ingresos_day as $id_empresa => $Areas) { foreach ($Areas as $AreasName => $months_) { foreach ($months_ as $months_Name => $fractions_) { foreach ($fractions_ as $fractions_Name => $fractionValue) { $ingresos_by_month[$id_empresa][$AreasName][$months_Name][$fractions_Name] = array_sum($fractionValue); } } } } $ingresos_detail = array(); $ingresos_detail['report_daily'] = $ingresos_day; $ingresos_detail['ingresos_month_by_fraction'] = $ingresos_sum = null; // pending $ingresos_detail['total_ingresos_monthly'] = $ingresos_by_month; // Done // $ingresos_detail['totalIngresosByMonth'] =$ingresos_by_month ;// Done $ingresos_detail['total_ingresos_yearly'] = $ingresos_yearly = null; // pending $Result['ingresos'] = $ingresos_detail; // pr($this->fleets(true,false)); // exit(); return $Result; }
function week() { pr($this->Areas->find('all')); pr($this->Flotas->find('all')); // pr($this->data); 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); $fraction = $this->Fraccion->find('list', array('fields' => array('id', 'fraccion'))); // pr($fraction); foreach ($calendar['days'] as $month => $dia) { foreach ($dia as $num_dia => $dia_detail) { foreach ($fraction as $id_fraction => $fraction_desc) { $dias[$month][$fraction_desc][$num_dia] = null; } } // pr($dia); } pr($dias); exit; }
function operations($year = null) { if (empty($year)) { $year = date('Y'); } $tipoOperacion = null; $operations = $this->dbOp(); App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/calendar')); $myCalendar = new CalendarShell(new Object()); $myCalendar->initialize(); $calendar = $myCalendar->main($year, false); $months = $calendar['months']; $fraction = $this->Fraccion->find('list', array('fields' => array('id', 'fraccion'))); // pr($fraction); 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, $year); $coverOps['Toneladas']['days'] = $Shell['Toneladas']['DailyReport']['report_day']; $coverOps['Toneladas']['months'] = $Shell['Toneladas']['DetailData']['toneladas']; $coverOps['kms']['days'] = $Shell['kms']['report_daily_plus']; $coverOps['kms']['months'] = $Shell['kms']['kms_month_by_fraction']; $coverOps['ingresos']['days'] = $Shell['ingresos']['report_daily']; $coverOps['ingresos']['months'] = $Shell['ingresos']['total_ingresos_monthly']; /** * TODO this don't have a db is a add like a pluging **/ $coverOps['Viajes']['days'] = $Shell['kms']['count']['count_day']; $coverOps['Viajes']['months'] = $Shell['kms']['count']['count_month']; // $kms_detail['count']['count_day'] = $count_day; // sum of both count's before and classified by day // $kms_detail['count']['count_month'] = $count_month; // the sum counting by id_empresa, area, month and fraction // $kms_detail['count']['count_month_no_fraction'] = $count_month_no_fraction; //same as before with out fraction // $kms_detail['count']['count_year'] = $count_year ; //sum of all the months by area yearly by fraction // $kms_detail['count']['count_year_no_fraction'] = $count_year_no_fraction;//sum of all the months by area yearly foreach ($operations as $idOp => $opName) { $tipoOperacion = $idOp; if (in_array($operations[$tipoOperacion], $operations) == true) { $Operacion = $coverOps[$operations[$tipoOperacion]]['days']; $monthOperacion = $coverOps[$operations[$tipoOperacion]]['months']; } // Building databases foreach ($Operacion as $id_empresa => $areas) { foreach ($areas as $areaName => $Months) { foreach ($Months as $monthName => $Fractions) { foreach ($Fractions as $fractionName => $DaysOperacion) { if (isset($DaysOperacion)) { foreach ($DaysOperacion as $day => $operacion) { if (!empty($operacion)) { foreach ($months as $numMonth => $monthData) { foreach ($monthData as $description => $monthContent) { if ($monthData['short'] == $monthName) { $numMes = $monthData['num']; } } } foreach ($fraction as $id_fraction => $fractionDescription) { if ($fractionDescription == $fractionName) { $numFraction = $id_fraction; } } $day = str_pad((int) $day, '2', "0", STR_PAD_LEFT); $operacionesDiarias['Operacion'][] = array('id_empresa' => $id_empresa, 'area' => $areaName, 'year' => $year, 'day' => $day, 'operacion' => $operacion, 'tipoOperacion' => $tipoOperacion, 'month' => $monthName, 'numMes' => $numMes, 'id_fraction' => $numFraction, 'fraccion' => $fractionName); } } } // if isset($DaysToneladas) } } } } //next go for mensual toneladas // Reset the vars to reuse; $areas = $areaName = $monthName = $dataOperacion = $numMes = null; foreach ($monthOperacion as $id_empresa => $areas) { // in this case the Area is under Empresa foreach ($areas as $areaName => $month) { foreach ($month as $monthName => $dataOperacion) { foreach ($dataOperacion as $fractionName => $dataOperacionValue) { if (isset($dataOperacionValue) and !empty($dataOperacionValue)) { foreach ($months as $numMonth => $monthData) { foreach ($monthData as $description => $monthContent) { if ($monthData['short'] == $monthName) { $numMes = $monthData['num']; } } } foreach ($fraction as $id_fraction => $fractionDescription) { if ($fractionDescription == $fractionName) { $numFraction = $id_fraction; } } $operacionesMensuales['OperacionMensual'][] = array('id_empresa' => $id_empresa, 'area' => $areaName, 'year' => $year, 'operacion' => $dataOperacionValue, 'tipoOperacion' => $tipoOperacion, 'month' => $monthName, 'numMes' => $numMes, 'id_fraction' => $numFraction, 'fraccion' => $fractionName); } } } } } } //End of each operations $conditionsDaily['Operacion.year'] = $year; $this->idCheck($conditionsDaily, $operations[$tipoOperacion], $frecuency = 'Diaria', $data = $operacionesDiarias['Operacion'], $model = 'Operacion', $useTable = 'operacion', $system = false); $conditions['OperacionMensual.year'] = $year; $this->idCheck($conditions, $operations[$tipoOperacion], $frecuency = 'Mensual', $data = $operacionesMensuales['OperacionMensual'], $model = 'OperacionMensual', $useTable = 'operacionMensual', $system = false); }
function grapBuild($id_empresa = null, $concepto = null, $area_name = null, $fracciones_name = null, $month_name = null, $grapColor = null, $operacion = null, $dateParam = null, $year = null) { // build the data for ImagesShell // $operacion = array('1'=>'0'); // $month_name = ''; $EmpConditions['Empresas.active'] = '1'; // Check if the area is alive $empresas = $this->Empresas->find('list', array('fields' => array('id_empresa', 'empresa'), array('conditions' => $EmpConditions))); App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/calendar')); $myCalendar = new CalendarShell(new Object()); $myCalendar->initialize(); // $calendar = $myCalendar->main($year=date('Y'),false); $month = $myCalendar->months(true, false, $year); // $url= '/tmp/images/'; $url = "../../app/webroot/img/thumbs/daily/"; $this->autoRender = false; // i don't remember why is this but do it App::import('Vendor', 'pData', array('file' => 'pcharts' . DS . 'class' . DS . 'pData.class.php')); App::import('Vendor', 'pDraw', array('file' => 'pcharts' . DS . 'class' . DS . 'pDraw.class.php')); App::import('Vendor', 'pImage', array('file' => 'pcharts' . DS . 'class' . DS . 'pImage.class.php')); $fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pcharts' . DS . 'fonts' . DS; $maxValue = max($operacion); /* Create and populate the pData object */ $MyData = new pData(); // $MyData->addPoints($report_day,"Temperature"); $MyData->addPoints($operacion, $concepto); // $MyData->setSerieDrawable($concepto,TRUE); $MyData->setAxisName(0, $concepto); // $MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),"Labels"); $MyData->addPoints($dateParam, "dateParam"); $MyData->setSerieDescription("dateParam", "Dias"); $MyData->setAbscissa("dateParam"); // $MyData->drawAll(); /* Create the per bar palette */ $Palette = array("0" => array("R" => 188, "G" => 224, "B" => 46, "Alpha" => 80), "1" => array("R" => 143, "G" => 189, "B" => 216, "Alpha" => 80), "2" => array("R" => 239, "G" => 210, "B" => 121, "Alpha" => 80), "3" => array("R" => 122, "G" => 224, "B" => 146, "Alpha" => 80), "4" => array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 80), "5" => array("R" => 46, "G" => 151, "B" => 224, "Alpha" => 80), "6" => array("R" => 137, "G" => 154, "B" => 173, "Alpha" => 80), "7" => array("R" => 76, "G" => 136, "B" => 190, "Alpha" => 80), "8" => array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80)); // $MyData->normalize(100,"%"); $xLenght = "220"; /* Create the pChart object */ $myPicture = new pImage(700, $xLenght, $MyData, TRUE); /* Draw serie 1 in red with a 80% opacity */ $MyData->setPalette(array($concepto), $Palette[$grapColor]); $Settings = array("R" => 200, "G" => 200, "B" => 200, "StartR" => 250, "StartG" => 250, "StartB" => 250, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 0); $Settings = array("R" => 255, "G" => 255, "B" => 255, "StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 0); //$myPicture->drawRectangle(0,0,699,229,array("R"=>200,"G"=>200,"B"=>200)); $myPicture->drawFilledRectangle(0, 0, 700, $xLenght + 10, $Settings); /* Overlay with a gradient */ $myPicture->drawGradientArea(0, 0, 700, $xLenght + 10, DIRECTION_VERTICAL, $Settings); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => $fontFolder . "Forgotte.ttf", "FontSize" => 10)); /* Draw some thresholds */ // $myPicture->setShadow(FALSE); // $myPicture->drawThreshold(-40,array("WriteCaption"=>TRUE,"R"=>0,"G"=>0,"B"=>0,"Ticks"=>4)); // $myPicture->drawThreshold($maxValue,array("WriteCaption"=>TRUE,"R"=>0,"G"=>0,"B"=>0,"Ticks"=>4)); //TODO->Define if mensual or annual if (isset($month_name) and isset($area_name)) { if (trim($area_name) === 'Tijuana') { $area = 'Mexicali'; } else { $area = $area_name; } $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $area . "-" . $month[$month_name]['spanish'] . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); //Diario } if (!isset($month_name) and !isset($area_name)) { $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $empresas[$id_empresa] . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); //Annual } if (!isset($month_name) and isset($area_name)) { if (trim($area_name) === 'Tijuana') { $area = 'Mexicali'; } else { $area = $area_name; } $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $area . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); //areaAnnual } if (isset($month_name) and !isset($area_name)) { $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $empresas[$id_empresa] . "-" . $month[$month_name]['spanish'] . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); //areaAnnual } /* Define the 2nd chart area */ $myPicture->setGraphArea(60, 35, 660, 200); $myPicture->setFontProperties(array("FontName" => $fontFolder . "pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale */ $scaleSettings = array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "RemoveXAxis" => FALSE, "Mode" => SCALE_MODE_ADDALL_START0, "DrawArrows" => TRUE, "ArrowSize" => 6); $myPicture->drawScale($scaleSettings); $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => FALSE, "Rounded" => FALSE, "Surrounding" => 15, "InnerSurrounding" => 15)); //TODO->Define if mensual or annual if (isset($month_name) and isset($area_name)) { $myPicture->autoOutput($url . "{$concepto}" . "_" . "{$area_name}" . "_" . "{$month_name}" . "_" . $year . ".png"); //Diario } if (!isset($month_name) and !isset($area_name)) { $myPicture->autoOutput($url . $concepto . "_" . strtolower($empresas[$id_empresa]) . "_" . $year . ".png"); //Annual } if (!isset($month_name) and isset($area_name)) { $myPicture->autoOutput($url . "{$concepto}" . "_" . $area_name . "_" . $year . ".png"); //areaAnnual } if (isset($month_name) and !isset($area_name)) { $myPicture->autoOutput($url . $concepto . "_" . strtolower($empresas[$id_empresa]) . "_" . $month_name . "_" . $year . ".png"); //areaAnnual } }
/** @function index() * @arg <null> ** @param var_returned => <print the firts page > * @package scriptaculous * @function => no,bridge for pass vars ** @use => App::Import = false ** @set => retrieve old data and get new data for export and update the db * @div => null **/ function index($get = null) { // print data and retrieve data for update the db // pr($_SESSION); // exit(); // if(isset($_SESSION['data'])){ // pr($_SESSION['data']); // // exit(); // } // set permissions // >> Add month Specifications // >> Add month Specifications $this->set('st_egresos', true); if ($_SESSION['Auth']['User']['level'] == '0') { $this->set('status', false); } else { $this->set('status', true); } $this->ViewConfig(); // unset($_SESSION['anexo']); if (!isset($_SESSION['lastDate'])) { $Date['year'] = date('Y'); $Date['month'] = date('m'); $Date['day'] = date('d'); $Date['week'] = date('W'); // $this->set('Date',$Date); } else { // $this->set('Date',.'-'..'-'.); $Date['year'] = $_SESSION['lastDate']['year']; $Date['month'] = $_SESSION['lastDate']['month']; $Date['day'] = $_SESSION['lastDate']['day']; $Date['week'] = $_SESSION['lastDate']['week']; // $this->set('Date',$Date); } App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/calendar')); $myCalendar = new CalendarShell(new Object()); $myCalendar->initialize(); $calendar = $myCalendar->main($year = date('Y'), false); // $this->set('month',$calendar['months'][$Date['month']]['spanish']); // set the monthName to the view $Date['mes'] = $calendar['months'][(int) $Date['month']]['spanish']; // if (isset($get)) { return $Date; } else { $this->set('Date', $Date); // $this->set('AnX',$this->getAnexos()); $this->set('saldo', $this->GetSaldo()); if (!isset($_SESSION['Getdata']['flujo'])) { $this->set('estimate', $this->GetCurrentWeek()); } else { $this->set('estimate', $_SESSION['Getdata']); } } }
function monthWeeks($year = null) { // $_SESSION['viewConfig'] = null; $_SESSION['viewConfig']['width'] = '320'; $_SESSION['viewConfig']['height'] = '80'; $_SESSION['viewConfig']['fontSize'] = '180'; $_SESSION['viewConfig']['fontSizeTitle'] = '110'; App::Import('Shell', 'Shell'); App::Import('Vendor', array('shells/calendar')); $myCalendar = new CalendarShell(new Object()); $myCalendar->initialize(); $calendar = $myCalendar->main($year, false); $_SESSION['calendar']['months'] = $calendar['months']; foreach ($calendar['days'] as $month => $dia) { foreach ($dia as $num_dia => $dia_detail) { $stats[$month][$dia_detail['week']] = $dia_detail['month']; $daysWeek[$month][$dia_detail['week']] = $num_dia; } } // pr($stats); foreach ($stats as $month => $weekMonth) { foreach ($weekMonth as $week => $monthNum) { $weeksMonth[$week][$monthNum] = $month; } } $_SESSION['weeksMonth'] = $weeksMonth; $_SESSION['calAcumulado'] = $stats; $_SESSION['daysWeek'] = $daysWeek; return $weeksMonth; }