Example #1
0
 /**
  * Retrieve Bestseller product to show in frontend
  * @return mixed
  */
 public function myBest()
 {
     $storeId = Mage::app()->getStore()->getId();
     $HandleArray = Mage::app()->getLayout()->getUpdate()->getHandles();
     $CategoryHandle = 'catalog_category_view';
     $SourceConfig = Mage::getStoreConfig('sm_bestseller/sm_bestseller_source');
     if ($SourceConfig && !empty($SourceConfig)) {
         $SourceType = $SourceConfig['timeperiod'];
         $date = new Zend_Date();
         /**
          * Select time range to retrive bestseller
          */
         if ($SourceType && $SourceType == 'specify') {
             $fromDate = $date->setDate($SourceConfig['fromdate'])->get('Y-MM-dd');
             $toDate = $date->setDate($SourceConfig['todate'])->get('Y-MM-dd');
         } else {
             /**
              * use switch to return begin of week, month, year...
              */
             switch ($SourceType) {
                 case 'subWeek':
                     $toDate = $date->subDay($date->getDate()->get('e'))->getDate()->get('Y-MM-dd');
                     break;
                 case 'subMonth':
                     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
                     break;
                 case 'subYear':
                     $toDate = $date->subDay($date->getDate()->get('D'))->getDate()->get('Y-MM-dd');
                     break;
                 default:
                     $toDate = $date->getDate()->get('Y-MM-dd');
             }
             // end switch
             $subType = $SourceType;
             $unit = $SourceConfig['unit'] ? $SourceConfig['unit'] : 1;
             $fromDate = $date->{$subType}($unit)->getDate()->get('Y-MM-dd');
         }
         // end else
         /**
          * Limit maximum product retrieve
          */
         $limit = $SourceConfig['limitproduct'];
         if ($limit > 0 && ctype_digit($limit)) {
             $this->setProductsCount($limit);
         }
         $products = Mage::getResourceModel('reports/product_collection')->addOrderedQty($fromDate, $toDate)->addAttributeToSelect('*')->addAttributeToSelect(array('name', 'price', 'small_image'))->setStoreId($storeId)->addStoreFilter($storeId)->setOrder('ordered_qty', 'desc');
         // most best sellers on top
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
         $products->setPageSize($limit)->setCurPage(1);
         if (in_array($CategoryHandle, $HandleArray)) {
             $CategoryId = Mage::getModel('catalog/layer')->getCurrentCategory()->getId();
             $CategoryModel = Mage::getModel('catalog/category')->load($CategoryId);
             $products->addCategoryFilter($CategoryModel);
         }
         return $products;
     }
     // end if sourceconfig
 }
Example #2
0
 /**
  * The default action - show the home page
  */
 public function gettodaydateAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout()->disableLayout();
     $dateobj = new Zend_Date();
     echo $dateobj->getDate();
 }
Example #3
0
 public function isValid($data)
 {
     $isValid = parent::isValid($data);
     if ($isValid) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->set($data['date_for'], 'YYYY-MM-dd');
         $date2->set($data['date_to'], 'YYYY-MM-dd');
         if ($date->getDate()->isLater($date2->getDate())) {
             $isValid = false;
             $this->getElement('date_to')->addError('Data do musi być późniejsza niż Data od');
         } else {
             $date->addDay(31);
             if ($date->getDate()->isEarlier($date2->getDate())) {
                 $isValid = false;
                 $this->getElement('date_to')->addError('Wygenerowanie raportu możliwe jest za dowolny okres obejmujący max 31 dni');
             }
         }
     }
     return $isValid;
 }
Example #4
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $form = new Logic_Raports_Form_Search();
     $search = new Logic_Raports_Search($this->_model);
     if ($request->isPost()) {
         $values = $request->getPost();
         if ($form->isValid($values)) {
             if (isset($values['create_raport'])) {
                 if ($this->_model->getRaportByDate($values['date_for'], $values['date_to']) === null) {
                     $config = Zend_Registry::get('config');
                     $base = $config['general']['default']['base_path'];
                     $date = new Zend_Date();
                     $values['hash'] = SHA1($date->getTimestamp());
                     $this->_model->addRaport($values);
                     $form->date_for->setValue('');
                     $form->date_to->setValue('');
                     $view = new Zend_View();
                     $date = new Zend_Date();
                     throw new Exception("Do zmiany.");
                     $packageModel = new WsPackageMail();
                     $packageQueue = new WsPackageQueue();
                     $packageData = new WsPackageDataMail();
                     $package = $packageModel->addPackage(array('name' => 'wysyka raportu', 'time_send_start' => '08:00', 'time_send_end' => "20:00", 'send_start' => $date->getDate()->toString('YYYY-MM-dd'), 'file_type' => Logic_Ws_ServiceSet_ServiceSet::TYPE_ANY));
                     /* TODO zmiana adresu email doręczena raportów */
                     $view->setScriptPath(APPLICATION_PATH . '/views/scripts/_mail/');
                     $view->output = array('baseurl' => $base, 'hash' => $values['hash']);
                     $packageData->addPackageData(array('message' => $view->render('sendreport.phtml'), 'ws_package_id' => $package, 'email_address' => '*****@*****.**'));
                     $packageQueue->addQueue(array('ws_package_id' => $package));
                 }
             }
         }
     }
     $this->view->form = $form;
     $this->view->headers = $search->getHeaders();
     $this->view->paginator = $search->paginator();
 }
Example #5
0
 /**
  * Test for getDate
  */
 public function testGetDate()
 {
     $locale = new Zend_Locale('de_AT');
     $date = new Zend_Date(1010101010, null, $locale);
     $d2 = new Zend_Date(1010101010, null, $locale);
     $result = $date->getDate();
     $this->assertSame('2002-01-04T00:00:00+05:00', $result->get(Zend_Date::W3C));
 }
Example #6
0
 public static function getCurrentDate()
 {
     $date = new Zend_Date();
     return $date->getDate();
 }
Example #7
0
 /**
  * Returns a clone of $this, with the time part set to 00:00:00.
  *
  * @param  string|Zend_Locale  $locale  OPTIONAL Locale for parsing input
  * @return Axis_Date
  */
 public function getDate($locale = null)
 {
     // supress notice about PCRE without UTF8 support
     return @parent::getDate($locale);
 }
Example #8
0
 public function baseInit()
 {
     $dict = new Base_Dictionary();
     $date = new Zend_Date();
     $user = Zend_Auth::getInstance()->getIdentity();
     $client = Logic_Client::getInstance();
     $wsServiceSet = $client->getGroupListAsDict(Wsclient::GROUP_SERVICE_SET);
     $config = Zend_Registry::get('config');
     $this->addElement('text', 'name', array('required' => true, 'label' => 'Nazwa wysyłki'));
     $this->datee(false, "send_start", "Początek wysyłki");
     $this->send_start->setValue($date->getDate()->toString('YYYY-MM-dd'))->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd')->getTimestamp();
     }));
     $this->timee(false, "time_send_start", "Okno czasowe od");
     $this->time_send_start->setValue('8:00');
     $this->timee(false, "time_send_end", "Okno czasowe do");
     $this->time_send_end->setValue('20:00');
     $this->time_send_end->addValidator('Callback', false, array('callback' => function ($value) {
         return strtotime($value) > strtotime($this->time_send_start->getValue());
     }));
     $this->datetimee(false, 'expiry_date', "Ważność wiadomości", false, array('value' => ''));
     $this->expiry_date->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date2->setDate($value, 'YYYY-MM-dd HH:mm');
         $date->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm');
         return $date->getTimestamp() <= $date2->getTimestamp() && $date->addHour(72)->getTimestamp() >= $date2->getTimestamp();
     }));
     $this->expiry_date->getValidator('Callback')->setMessages(array(Zend_Validate_Callback::INVALID_VALUE => "Data ważności wiadmości może wynosić maksymalnie 72 godziny"));
     $this->addElement('checkbox', 'repeat_message', array('label' => 'Powtarzaj tą wiadomość', 'attribs' => array('onchange' => 'checkPackageOptions();')));
     $this->repeat_message->addValidator('Callback', false, array('callback' => function ($value) {
         if ($value) {
             $this->repeat_interval->setRequired(true);
             $this->repeat_count->setRequired(true);
             $this->repeat_end->setRequired(true);
         }
         return true;
     }));
     $this->addElement('radio', 'repeat_interval', array('MultiOptions' => $dict->setSource('package_repeat')->getDictionary(), 'attribs' => array('disable' => 'disable'), 'attribs' => array('onchange' => 'checkPackageOptions();')));
     $this->repeat_interval->addValidator('Callback', false, array('callback' => function ($value) {
         if ($value == 5) {
             $this->repeat_days->setRequired(true);
         } elseif ($value == 4) {
             $this->repeat_day_interval->setRequired(true);
         }
         return true;
     }));
     $this->addElement('multiselect', 'repeat_days', array('MultiOptions' => $dict->setSource('day_of_week')->getDictionary(), 'attribs' => array('disable' => 'disable')));
     $this->addElement('text', 'repeat_day_interval', array('label' => 'Powtarzań wiadomość co (liczba dni)', 'attribs' => array('disable' => 'disable')));
     $this->addElement('text', 'repeat_count', array('label' => 'Ilość powtórzeń wiadomości', 'attribs' => array('disable' => 'disable')));
     $this->datetimee(false, "repeat_end", "Powtarzań do", false, array('value' => '', 'attribs' => array('disabled' => 'disabled')));
     $this->repeat_end->addValidator('Callback', false, array('callback' => function ($value) {
         $date = new Zend_Date();
         $date2 = clone $date;
         $date->setDate($value, 'YYYY-MM-dd HH:mm');
         $date2->setDate($this->send_start->getValue(), 'YYYY-MM-dd HH:mm');
         return $date->getTimestamp() <= $date2->setDate($value, 'YYYY-MM-dd HH:mm')->getTimestamp();
     }));
     $this->addElement('select', 'ws_service_set_id', array('label' => 'Wysyłka', 'required' => true, 'MultiOptions' => $this->addClearStart($wsServiceSet), 'attribs' => array('onchange' => 'getServiceSetOptions();')));
     $this->addElement('select', 'file_type', array('required' => true, 'label' => 'Typ wysyłki:', 'multioptions' => $this->addClearStart($dict->setSource('service_import_file_type')->getDictionary())));
     $this->addElement('file', 'addressbook_import_csv', array('label' => 'CSV z listą kontaktów do zaimportowania', 'decorators' => $this->_fileDecorator, 'validators' => array(array('Extension', false, 'csv'), array('Size', false, $config['uploads']['maxfilesize']))));
     $this->addElement('select', 'delimeter', array('label' => "Separator pola", 'MultiOptions' => $this->addClearStart($dict->setSource('csv_delimeter')->getDictionary())));
     $this->addElement('select', 'phone_heders', array('label' => "Kolumna z kontaktami"));
     $this->addElement('select', 'ws_addressbook_id', array('label' => 'Adresy', 'MultiOptions' => $this->addClearStart($dict->setSource(new Addressbook(), array('created_by =' . (int) $user->id, 'ghost=false'), 'id', 'id', array('addressbook_name'))->getDictionary())));
     $this->addDisplayGroup(array($this->addressbook_import_csv, $this->delimeter, $this->phone_heders), 'tags_import');
     $this->addElement('select', 'message_heders', array('label' => "Kolumna z wiadomością"));
     $this->submit(false, 'save_send', 'Wyślij');
     $this->submit();
     $this->cancel();
 }