protected function summaryUsers() { $this->mTemplate->sSectionTitle = $this->getLang('summary_meals'); $sCurrentDate = date('Y-m-d'); if (isset($_POST['submit'])) { $sFrom = $this->post('from'); $sTo = $this->post('to'); $oValidator = new Module_Validator(); $oValidator->field('summary_from', $sFrom, $this->getLang('summary_from'))->rules('required|date'); $oValidator->field('summary_to', $sTo, $this->getLang('summary_to'))->rules('required|date'); if ($oValidator->validate()) { $oOrder = new Model_Order(); // pobieramy wartosc jaka zwraca firma $iEmployeePercent = $this->oCurrentUser->get('account_id')->employee_percent; $aSummary = $oOrder->getSummaryForUsers((int) $this->oCurrentUser->account_id, $sFrom, $sTo); $aData['aSummary'] = $this->generateSummaryDataForUsers($aSummary, $iEmployeePercent); } else { $aErrors = $oValidator->getError(); foreach ($aErrors as $sField => $aError) { $sMsg .= '<br />' . $this->getLang($aError['msg'], $aError['field_name']); } $aData['error'] = $this->getLang('input_validation_failed') . $sMsg; } // sprawdzamy czy podpiac widok dla excela czy normalny if ($_POST['submit'] == $this->getLang('summary_generate_excel')) { $this->mTemplate = View::factory('account/summary_users_excel', $aData); return; } } else { $sFrom = date('Y-m-') . '01'; $sTo = date('Y-m-') . date('d', mktime(0, 0, 0, date('n') + 1, 0, date('Y'))); } $aData['aForm'] = array('sPeriod' => $this->getLang('summary_period'), 'sFrom' => $this->getLang('summary_from'), 'sTo' => $this->getLang('summary_to'), 'sDateFrom' => $sFrom, 'sDateTo' => $sTo, 'sSubmit' => $this->getLang('summary_generate'), 'sSubmitExcel' => $this->getLang('summary_generate_excel')); $this->mTemplate->content = View::factory('account/summary_users', $aData)->render(); }