Пример #1
0
 /**
  * Apply filter by card expiration date (extract valid cards only)
  *
  * @return CLS_Paypal_Model_Resource_Customerstored_Collection
  */
 public function filterByExpirationDate()
 {
     $now = new Zend_Date(null);
     $dateArray = $now->toArray();
     $this->getSelect()->where("\n            (cc_exp_year > '{$dateArray['year']}') OR\n            (cc_exp_year = '{$dateArray['year']}' AND cc_exp_month >= {$dateArray['month']})\n        ");
     return $this;
 }
Пример #2
0
 /**
  * Sets the internal value to ISO date format.
  * 
  * @param string|array $val String expects an ISO date format. Array notation with 'date' and 'time'
  *  keys can contain localized strings. If the 'dmyfields' option is used for {@link DateField},
  *  the 'date' value may contain array notation was well (see {@link DateField->setValue()}).
  */
 function setValue($val)
 {
     if (empty($val)) {
         $this->dateField->setValue(null);
         $this->timeField->setValue(null);
     } else {
         // String setting is only possible from the database, so we don't allow anything but ISO format
         if (is_string($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) {
             // split up in date and time string values.
             $valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'), $this->locale);
             // set date either as array, or as string
             if ($this->dateField->getConfig('dmyfields')) {
                 $this->dateField->setValue($valueObj->toArray());
             } else {
                 $this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat')));
             }
             // set time
             $this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat')));
         } elseif (is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) {
             $this->dateField->setValue($val['date']);
             $this->timeField->setValue($val['time']);
         } else {
             $this->dateField->setValue($val);
             $this->timeField->setValue($val);
         }
     }
 }
Пример #3
0
    /**
     * Converte um timestamp para array
     * 
     * @param int $timeStamp
     * @return ARRAY 
     */
    public function unixToArray($timeStamp)
    {
        if (!$timeStamp)
            return null;

        $date = new Zend_Date();
        $date->set($timeStamp, Zend_Date::TIMESTAMP);

        return $date->toArray();
    }
Пример #4
0
 public function indexAction()
 {
     // action body
     $service = new Application_Model_DbTable_Service();
     if ($this->getRequest()->isPost('select_date')) {
         $year = $this->getRequest()->getPost('select_year');
         $month = $this->getRequest()->getPost('select_month');
         $_SESSION['year'] = $year;
         $_SESSION['month'] = $month;
     } else {
         $currend_date = new Zend_Date();
         $ss = $currend_date->toArray();
         $year = $ss['year'];
         $month = (int) $ss['month'];
         if ($month < 10) {
             $month = "0{$month}";
         }
         $_SESSION['year'] = $year;
         $_SESSION['month'] = $month;
     }
     $date = "{$year}-{$month}";
     //обработка параметров поиска
     if ($this->getRequest()->isPost('search_catalog')) {
         $search = $this->getRequest()->getPost('search_catalog');
     } elseif ($this->getRequest()->getParam('search_catalog')) {
         $search = $this->getRequest()->getParam('search_catalog');
     }
     //c поиском
     if ($search != '') {
         $this->view->service = $service->searchService($search);
         $dd = $service->getcountsearchService($search);
         $this->view->countshow = $dd[0]['count'];
         //без поиска
     } else {
         $this->view->service = $service->showService($date);
         $dd = $service->getcountService($date);
         $this->view->countshow = $dd[0]['count'];
     }
     $dd = $service->getcountService($date);
     $this->view->count = $dd[0]['count'];
     $dd = $service->getcountService();
     $this->view->allcount = $dd[0]['count'];
     $this->view->search = $search;
 }
Пример #5
0
 /**
  * Sets the internal value to ISO date format, based on either a database value in ISO date format,
  * or a form submssion in the user date format. Uses the individual date and time fields
  * to take care of the actual formatting and value conversion.
  * 
  * Value setting happens *before* validation, so we have to set the value even if its not valid.
  * 
  * Caution: Only converts user timezones when value is passed as array data (= form submission).
  * Weak indication, but unfortunately the framework doesn't support a distinction between
  * setting a value from the database, application logic, and user input.
  * 
  * @param string|array $val String expects an ISO date format. Array notation with 'date' and 'time'
  *  keys can contain localized strings. If the 'dmyfields' option is used for {@link DateField},
  *  the 'date' value may contain array notation was well (see {@link DateField->setValue()}).
  */
 function setValue($val)
 {
     // If timezones are enabled, assume user data needs to be reverted to server timezone
     if ($this->getConfig('usertimezone')) {
         // Accept user input on timezone, but only when timezone support is enabled
         $userTz = is_array($val) && array_key_exists('timezone', $val) ? $val['timezone'] : null;
         if (!$userTz) {
             $userTz = $this->getConfig('usertimezone');
         }
         // fall back to defined timezone
     } else {
         $userTz = null;
     }
     if (empty($val)) {
         $this->value = null;
         $this->dateField->setValue(null);
         $this->timeField->setValue(null);
     } else {
         // Case 1: String setting from database, in ISO date format
         if (is_string($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) {
             $this->value = $val;
         } elseif (is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) {
             $dataTz = date_default_timezone_get();
             // If timezones are enabled, assume user data needs to be converted to server timezone
             if ($userTz) {
                 date_default_timezone_set($userTz);
             }
             // Uses sub-fields to temporarily write values and delegate dealing with their normalization,
             // actual sub-field value setting happens later
             $this->dateField->setValue($val['date']);
             $this->timeField->setValue($val['time']);
             if ($this->dateField->dataValue() && $this->timeField->dataValue()) {
                 $userValueObj = new Zend_Date(null, null, $this->locale);
                 $userValueObj->setDate($this->dateField->dataValue(), $this->dateField->getConfig('datavalueformat'));
                 $userValueObj->setTime($this->timeField->dataValue(), $this->timeField->getConfig('datavalueformat'));
                 if ($userTz) {
                     $userValueObj->setTimezone($dataTz);
                 }
                 $this->value = $userValueObj->get($this->getConfig('datavalueformat'), $this->locale);
                 unset($userValueObj);
             } else {
                 // Validation happens later, so set the raw string in case Zend_Date doesn't accept it
                 $this->value = sprintf($this->getConfig('datetimeorder'), $val['date'], $val['time']);
             }
             if ($userTz) {
                 date_default_timezone_set($dataTz);
             }
         } else {
             $this->dateField->setValue($val);
             if (is_string($val)) {
                 $this->timeField->setValue($val);
             }
             $this->value = $val;
         }
         // view settings (dates might differ from $this->value based on user timezone settings)
         if (Zend_Date::isDate($this->value, $this->getConfig('datavalueformat'), $this->locale)) {
             $valueObj = new Zend_Date($this->value, $this->getConfig('datavalueformat'), $this->locale);
             if ($userTz) {
                 $valueObj->setTimezone($userTz);
             }
             // Set view values in sub-fields
             if ($this->dateField->getConfig('dmyfields')) {
                 $this->dateField->setValue($valueObj->toArray());
             } else {
                 $this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat'), $this->locale));
             }
             $this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat'), $this->locale));
         }
     }
 }
Пример #6
0
 public function testToArray()
 {
     $date = new Zend_Date('2006-01-02 23:58:59', Zend_Date::ISO_8601, 'en_US');
     $return = $date->toArray();
     $orig = array('day' => 02, 'month' => 01, 'year' => 2006, 'hour' => 23, 'minute' => 58, 'second' => 59, 'timezone' => 'MVT', 'timestamp' => 1136228339, 'weekday' => 1, 'dayofyear' => 1, 'week' => '01', 'gmtsecs' => 18000);
     $this->assertEquals($orig, $return);
 }
Пример #7
0
 public function saveAction()
 {
     if ($data = $this->getRequest()->getPost()) {
         $_mcenterItem = Mage::getModel('clmcenter/mcenter')->getCollection()->addFieldToFilter('url_key', $data['url_key'])->setPageSize(1)->getFirstItem();
         /*
                     $arr = array();
                     $arr = $mcenterCollection->getData();
                     if (isset($arr[0]) && $this->getRequest()->getParam('id') == $arr[0]['mcenter_id'] && $data['url_key'] == $arr[0]['url_key']) {
                         $sameUrl = null;
                     } else {
                         $sameUrl = $mcenterCollection->getData();
                     }
                     if ($sameUrl != null) {*/
         if ($_mcenterItem->getId() && $this->getRequest()->getParam('id') == $_mcenterItem->getId() && $data['url_key'] == $_mcenterItem->getUrlKey() && count(array_diff($_mcenterItem->getStoreId(), $data['stores'])) == 0 && count(array_diff($data['stores'], $_mcenterItem->getStoreId())) == 0) {
             $sameUrl = false;
         } else {
             $sameUrl = false;
             $_mcenterItemCollection = Mage::getModel('clmcenter/mcenter')->getCollection()->addFieldToFilter('mcenter_id', array('neq' => $this->getRequest()->getParam('id')))->addFieldToFilter('url_key', $data['url_key']);
             foreach ($_mcenterItemCollection as $_mcenterItem) {
                 if (count(array_intersect($_mcenterItem->getStoreId(), $data['stores'])) != 0 || in_array(0, $data['stores']) || in_array(0, $_mcenterItem->getStoreId())) {
                     $sameUrl = true;
                 }
             }
         }
         if ($sameUrl) {
             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('clmcenter')->__('Статьи не найдено'));
             $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
         } else {
             if (isset($data['is_delete'])) {
                 $isDeleteFile = true;
             } else {
                 $isDeleteFile = false;
             }
             if (isset($_FILES['document_save']['name']) && $_FILES['document_save']['name'] != '' && $_FILES['document_save']['size'] != 0) {
                 try {
                     $uploader = new Varien_File_Uploader('document_save');
                     $uploader->setAllowRenameFiles(false);
                     // Set the file upload mode
                     // false -> get the file directly in the specified folder
                     // true -> get the file in folders like /media/a/b/
                     $uploader->setFilesDispersion(false);
                     $path = Mage::getBaseDir('media') . DS . 'clmcenter' . DS;
                     //saved the name in DB
                     $prefix = time() . rand();
                     $fileName = $prefix . '.' . pathinfo($_FILES['document_save']['name'], PATHINFO_EXTENSION);
                     $uploader->save($path, $fileName);
                     $filepath = 'clmcenter' . DS . $fileName;
                     $data['full_path_document'] = $path . $fileName;
                     $data['document'] = $fileName;
                     $data['document'] = str_replace('\\', '/', $data['document']);
                 } catch (Exception $e) {
                     Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                     $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                 }
             } elseif ($isDeleteFile === true) {
                 unlink($data['full_path_document']);
                 $data['document'] = '';
             } else {
                 /// to insert a code for deleting image
                 /// ....
                 if (isset($data['document'])) {
                     $data['document'] = $data['document'];
                 }
             }
             if (isset($_FILES['image_short_content']['name']) && $_FILES['image_short_content']['name'] != '' && $_FILES['image_short_content']['size'] != 0) {
                 try {
                     $uploader = new Varien_File_Uploader('image_short_content');
                     $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
                     $uploader->setAllowRenameFiles(false);
                     // Set the file upload mode
                     // false -> get the file directly in the specified folder
                     // true -> get the file in folders like /media/a/b/
                     $uploader->setFilesDispersion(false);
                     $path = Mage::getBaseDir('media') . DS . 'clmcenter' . DS;
                     //saved the name in DB
                     $prefix = time() . rand();
                     $fileName = $prefix . '.' . pathinfo($_FILES['image_short_content']['name'], PATHINFO_EXTENSION);
                     $uploader->save($path, $fileName);
                     $filepath = 'clmcenter' . DS . $fileName;
                     /*
                                             if (!getimagesize($filepath)) {
                                                 Mage::throwException($this->__('Disallowed file type.'));
                                             }*/
                     $data['image_short_content'] = $filepath;
                     $data['image_short_content'] = str_replace('\\', '/', $data['image_short_content']);
                 } catch (Exception $e) {
                     Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                     $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                     return;
                 }
             } elseif (isset($data['image_short_content']['delete'])) {
                 $path = Mage::getBaseDir('media') . DS;
                 $result = unlink($path . $data['image_short_content']['value']);
                 if ($data['short_height_resize'] && $data['short_width_resize']) {
                     $resizePath = Mage::getBaseDir('media') . DS . 'clmcenter' . DS . $data['short_width_resize'] . 'x' . $data['short_height_resize'] . DS;
                 }
                 $result = unlink($resizePath . str_replace('clmcenter/', '', $data['image_short_content']['value']));
                 $data['image_short_content'] = '';
             } else {
                 if (isset($data['image_short_content']['value'])) {
                     $data['image_short_content'] = $data['image_short_content']['value'];
                 }
             }
             if (isset($_FILES['image_full_content']['name']) && $_FILES['image_full_content']['name'] != '' && $_FILES['image_full_content']['size'] != 0) {
                 try {
                     $uploader = new Varien_File_Uploader('image_full_content');
                     $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
                     $uploader->setAllowRenameFiles(false);
                     // Set the file upload mode
                     // false -> get the file directly in the specified folder
                     // true -> get the file in folders like /media/a/b/
                     $uploader->setFilesDispersion(false);
                     $path = Mage::getBaseDir('media') . DS . 'clmcenter' . DS;
                     //saved the name in DB
                     $prefix = time() . rand();
                     $fileName = $prefix . '.' . pathinfo($_FILES['image_full_content']['name'], PATHINFO_EXTENSION);
                     $uploader->save($path, $fileName);
                     $filepath = 'clmcenter' . DS . $fileName;
                     $data['image_full_content'] = $filepath;
                     $data['image_full_content'] = str_replace('\\', '/', $data['image_full_content']);
                 } catch (Exception $e) {
                     Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                     $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                     return;
                 }
             } elseif (isset($data['image_full_content']['delete'])) {
                 $path = Mage::getBaseDir('media') . DS;
                 $result = unlink($path . $data['image_full_content']['value']);
                 if ($data['full_height_resize'] && $data['full_width_resize']) {
                     $resizePath = Mage::getBaseDir('media') . DS . 'clmcenter' . DS . $data['full_width_resize'] . 'x' . $data['full_height_resize'] . DS;
                 }
                 $result = unlink($resizePath . str_replace('clmcenter/', '', $data['image_full_content']['value']));
                 $data['image_full_content'] = '';
             } else {
                 if (isset($data['image_full_content']['value'])) {
                     $data['image_full_content'] = $data['image_full_content']['value'];
                 }
             }
             if (isset($data['use_full_img'])) {
                 if (isset($data['image_full_content'])) {
                     $data['image_short_content'] = $data['image_full_content'];
                 }
             }
             $model = Mage::getModel('clmcenter/mcenter');
             $hoursFrom = $this->getRequest()->getParam('publicate_from_hours');
             $minutesFrom = $this->getRequest()->getParam('publicate_from_minutes');
             $hoursTo = $this->getRequest()->getParam('publicate_to_hours');
             $minutesTo = $this->getRequest()->getParam('publicate_to_minutes');
             $data['publicate_from_hours'] = $hoursFrom;
             $data['publicate_from_minutes'] = $minutesFrom;
             $data['publicate_to_hours'] = $hoursTo;
             $data['publicate_to_minutes'] = $minutesTo;
             $data['link'] = $this->getRequest()->getParam('link');
             $data['tags'] = $this->getRequest()->getParam('tags');
             // prepare dates
             if ($this->getRequest()->getParam('mcenter_time') != '') {
                 $dateFormatIso = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
                 if (!Zend_Date::isDate($this->getRequest()->getParam('mcenter_time') . ' ' . date("H:i:s"), $dateFormatIso)) {
                     throw new Exception($this->__('Mcenter date field is required'));
                 }
                 $date = new Zend_Date($this->getRequest()->getParam('mcenter_time') . ' ' . date("H:i:s"), $dateFormatIso);
                 $dateInfo = $date->toArray();
                 $data['mcenter_time'] = preg_replace('/([0-9]{4})\\-(.*)/', $dateInfo['year'] . '-$2', $date->toString('YYYY-MM-dd HH:mm:ss'));
             } else {
                 $data['mcenter_time'] = new Zend_Db_Expr('null');
             }
             if ($this->getRequest()->getParam('publicate_from_time') != '') {
                 if (!Zend_Date::isDate($this->getRequest()->getParam('publicate_from_time') . ' ' . $hoursFrom . ':' . $minutesFrom . ':00', $dateFormatIso)) {
                     throw new Exception($this->__('Mcenter date field is required'));
                 }
                 $date = new Zend_Date($this->getRequest()->getParam('publicate_from_time') . ' ' . $hoursFrom . ':' . $minutesFrom . ':00', $dateFormatIso);
                 $dateInfo = $date->toArray();
                 $data['publicate_from_time'] = preg_replace('/([0-9]{4})\\-(.*)/', $dateInfo['year'] . '-$2', $date->toString('YYYY-MM-dd HH:mm:ss'));
             } else {
                 $data['publicate_from_time'] = new Zend_Db_Expr('null');
             }
             if ($this->getRequest()->getParam('publicate_to_time') != '') {
                 if (!Zend_Date::isDate($this->getRequest()->getParam('publicate_to_time') . ' ' . $hoursTo . ':' . $minutesTo . ':00', $dateFormatIso)) {
                     throw new Exception($this->__('Mcenter date field is required'));
                 }
                 $date = new Zend_Date($this->getRequest()->getParam('publicate_to_time') . ' ' . $hoursTo . ':' . $minutesTo . ':00', $dateFormatIso);
                 $dateInfo = $date->toArray();
                 $data['publicate_to_time'] = preg_replace('/([0-9]{4})\\-(.*)/', $dateInfo['year'] . '-$2', $date->toString('YYYY-MM-dd HH:mm:ss'));
             } else {
                 $data['publicate_to_time'] = new Zend_Db_Expr('null');
             }
             $model->setData($data)->setId($this->getRequest()->getParam('id'));
             try {
                 if ($this->getRequest()->getParam('mcenter_time') == NULL) {
                     $model->setMcenterTime(now());
                     $model->setCreatedTime(now());
                 } else {
                     if (isset($arr[0]) && !($mcenterItemId = $arr[0]['mcenter_id'])) {
                         $model->setCreatedTime(now());
                     }
                 }
                 $model->setUpdateTime(now());
                 if ($this->getRequest()->getParam('author') == NULL) {
                     $model->setUpdateAuthor(NULL);
                     /*$model->setAuthor(Mage::getSingleton('admin/session')->getUser()->getFirstname() .
                       " " . Mage::getSingleton('admin/session')->getUser()->getLastname())
                       ->setUpdateAuthor(Mage::getSingleton('admin/session')->getUser()->getFirstname() .
                       " " . Mage::getSingleton('admin/session')->getUser()->getLastname());*/
                 } else {
                     $model->setUpdateAuthor(Mage::getSingleton('admin/session')->getUser()->getFirstname() . " " . Mage::getSingleton('admin/session')->getUser()->getLastname());
                 }
                 $model->save();
                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('clmcenter')->__('Сохранено успешно!'));
                 Mage::getSingleton('adminhtml/session')->setFormData(false);
                 if ($this->getRequest()->getParam('back')) {
                     $this->_redirect('*/*/edit', array('id' => $model->getId()));
                     return;
                 }
                 $this->_redirect('*/*/');
                 return;
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
                 Mage::getSingleton('adminhtml/session')->setFormData($data);
                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
                 return;
             }
             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('clmcenter')->__('Нет данных для сохранения'));
             $this->_redirect('*/*/');
         }
     }
 }
Пример #8
0
 /**
  * ZF-6457
  */
 public function testArrayVerification()
 {
     $date = new Zend_Date();
     $array = $date->toArray();
     $this->assertTrue($this->_validator->isValid($array), "array expected to be valid");
 }
Пример #9
0
 /**
  * Set date values from Zend_Date instance.
  *
  * @param Zend_Date $date Zend_Date instance to use.
  * @return void
  */
 public function setZendDate(Zend_Date $date)
 {
     $datearray = $date->toArray();
     $this->setYear($datearray['year']);
     $this->setMonth($datearray['month']);
     $this->setDay($datearray['day']);
     $this->setHour($datearray['hour']);
     $this->setMinute($datearray['minute']);
     $this->setSecond($datearray['second']);
     $this->setTimezone($datearray['timezone']);
     $this->setUnixTimestamp($date->getTimestamp());
 }
Пример #10
0
 /**
  * Checks if date is allowed
  * @param Zend_Date $Date
  * @return bool
  */
 public function isAllowedDate(Zend_Date $Date, $Product = null)
 {
     if ($Product && !$Product->getAwSarpHasShipping()) {
         return true;
     }
     if (!$Product || $Product->getAwSarpHasShipping()) {
         $arr = $Date->toArray();
         $weekday = $arr['weekday'] == 7 ? 0 : $arr['weekday'];
         return array_search($weekday, $this->getExcludedWeekdays()) === false;
     } else {
         return true;
     }
 }
Пример #11
0
 public function toexcelmonthAction()
 {
     global $settings;
     // Подключаем класс для работы с excel
     require_once 'PHPExcel.php';
     // Подключаем класс для вывода данных в формате excel
     require_once 'PHPExcel/Writer/Excel5.php';
     // Создаем объект класса PHPExcel
     $xls = new PHPExcel();
     // Устанавливаем индекс активного листа
     $xls->setActiveSheetIndex(0);
     // Получаем активный лист
     $sheet = $xls->getActiveSheet();
     // Подписываем лист
     $sheet->setCellValue("A1", '№');
     $sheet->setCellValue("B1", 'Дата');
     $sheet->setCellValue("C1", 'Номер');
     $sheet->setCellValue("D1", 'Жалоба');
     $sheet->setCellValue("E1", 'Диагноз');
     $sheet->setCellValue("F1", 'Работа');
     $sheet->setCellValue("G1", 'Запчасти');
     $sheet->setCellValue("H1", 'Коментарии');
     //меняем цвет заголовка
     $sheet->getStyle('A1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('A1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('B1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('B1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('C1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('C1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('D1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('D1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('E1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('E1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('F1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('F1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('G1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('G1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('H1')->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
     $sheet->getStyle('H1')->getFill()->getStartColor()->setRGB('EEEEEE');
     $sheet->getStyle('A')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
     // автоматическая ширина ячейки
     $sheet->getColumnDimension('A')->setAutoSize(true);
     $sheet->getColumnDimension('B')->setAutoSize(true);
     $sheet->getColumnDimension('C')->setAutoSize(true);
     $sheet->getColumnDimension('D')->setAutoSize(true);
     $sheet->getColumnDimension('E')->setAutoSize(true);
     $sheet->getColumnDimension('F')->setAutoSize(true);
     $sheet->getColumnDimension('G')->setAutoSize(true);
     $sheet->getColumnDimension('H')->setAutoSize(true);
     // формат ячейки текстовый
     $sheet->getStyle('A')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('B')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('C')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('D')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('E')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('F')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('G')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     $sheet->getStyle('H')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);
     if (isset($_SESSION['year']) && isset($_SESSION['month'])) {
         $year = $_SESSION['year'];
         $month = $_SESSION['month'];
     } else {
         $currend_date = new Zend_Date();
         $ss = $currend_date->toArray();
         $year = $ss['year'];
         $month = (int) $ss['month'];
         if ($month < 10) {
             $month = "0{$month}";
         }
         $_SESSION['year'] = $year;
         $_SESSION['month'] = $month;
     }
     $date = "{$year}-{$month}";
     $repairs = new Application_Model_DbTable_Repairs();
     $data = $repairs->statisticRepairs($date);
     $i = 2;
     $sheet->setTitle("Repairs {$date}");
     foreach ($data as $rows) {
         $number = $i - 1;
         $sheet->setCellValue("A{$i}", "{$number}");
         $sheet->setCellValue("B{$i}", "{$rows['date']}");
         $sheet->setCellValue("C{$i}", "{$rows['number']}");
         $sheet->setCellValue("D{$i}", "{$rows['claim']}");
         $sheet->setCellValue("E{$i}", "{$rows['diagnos']}");
         $sheet->setCellValue("F{$i}", "{$rows['work']}");
         $sheet->setCellValue("G{$i}", "{$rows['spares']}");
         $sheet->setCellValue("H{$i}", "{$rows['comments']}");
         $i++;
     }
     // Выводим содержимое файла
     $objWriter = new PHPExcel_Writer_Excel5($xls);
     $objWriter->save('repairs_mounth.xls');
     // открываем файл в бинарном режиме
     header("Location: http://{$settings['excel']['site']}/repairs_mounth.xls");
 }