public function getIntervals()
 {
     if (!$this->_intervals) {
         $this->_intervals = array();
         if (!$this->_from && !$this->_to) {
             return $this->_intervals;
         }
         $dateStart = new Zend_Date($this->_from);
         $dateEnd = new Zend_Date($this->_to);
         $t = array();
         $firstInterval = true;
         /** START AITOC FIX **/
         if (in_array((string) $this->_period, array('day', 'month', 'year'))) {
             /** END AITOC FIX **/
             while ($dateStart->compare($dateEnd) <= 0) {
                 switch ($this->_period) {
                     case 'day':
                         $t['title'] = $dateStart->toString(Mage::app()->getLocale()->getDateFormat());
                         $t['start'] = $dateStart->toString('yyyy-MM-dd HH:mm:ss');
                         $t['end'] = $dateStart->toString('yyyy-MM-dd 23:59:59');
                         $dateStart->addDay(1);
                         break;
                     case 'month':
                         $t['title'] = $dateStart->toString('MM/yyyy');
                         $t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
                         $lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
                         $t['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
                         $dateStart->addMonth(1);
                         if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
                             $dateStart->setDay(1);
                         }
                         $firstInterval = false;
                         break;
                     case 'year':
                         $t['title'] = $dateStart->toString('yyyy');
                         $t['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-01-01 00:00:00');
                         $lastInterval = $dateStart->compareYear($dateEnd->getYear()) == 0;
                         $t['end'] = $lastInterval ? $dateStart->setMonth($dateEnd->getMonth())->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-12-31 23:59:59');
                         $dateStart->addYear(1);
                         if ($dateStart->compareYear($dateEnd->getYear()) == 0) {
                             $dateStart->setMonth(1)->setDay(1);
                         }
                         $firstInterval = false;
                         break;
                 }
                 $this->_intervals[$t['title']] = $t;
             }
             /** START AITOC FIX **/
         }
         /** END AITOC FIX **/
     }
     return $this->_intervals;
 }
Exemple #2
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $report = $this->_adsense->reports->generate($dStartDate->toString("YYYY-MM-dd"), $dEndDate->toString("YYYY-MM-dd"), array("dimension" => "DATE", "metric" => array("PAGE_VIEWS", "CLICKS", "EARNINGS"), "sort" => "DATE"));
     $firstDayMonth = new Zend_Date();
     $firstDayMonth->setDay(1);
     $firstDayMonth->setHour("00");
     $firstDayMonth->setMinute("00");
     $firstDayMonth->setSecond("00");
     if (isset($report["rows"])) {
         foreach ($report["rows"] as $row) {
             $obj = array();
             $obj['merchantId'] = 1;
             $tDate = new Zend_Date($row[0], "yyyy-MM-dd");
             $tDate->setHour("00");
             $tDate->setMinute("00");
             $tDate->setSecond("00");
             $obj['date'] = $tDate->toString("yyyy-MM-dd HH:mm:ss");
             $obj['impression_number'] = (int) Oara_Utilities::parseDouble($row[1]);
             $obj['click_number'] = Oara_Utilities::parseDouble($row[2]);
             if ($firstDayMonth->compare($tDate) <= 0) {
                 $obj['amount'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['commission'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['status'] = Oara_Utilities::STATUS_PENDING;
             } else {
                 $obj['amount'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['commission'] = Oara_Utilities::parseDouble($row[3]);
                 $obj['status'] = Oara_Utilities::STATUS_CONFIRMED;
             }
             $totalTransactions[] = $obj;
         }
     }
     return $totalTransactions;
 }
 /**
  * Enter description here...
  *
  */
 public function indexAction()
 {
     $currentDate = new Zend_Date();
     $currentMonth = $currentDate->toString(Zend_Date::MONTH_SHORT);
     $currentDay = $currentDate->toString(Zend_Date::DAY_SHORT);
     $month = $this->_getParam('month', $currentMonth);
     if (false === is_numeric($month)) {
         $month = $this->_monthMap[urldecode($month)];
     }
     $currentDate->setMonth($month);
     $currentDate->setDay(1);
     $days = $currentDate->toString(Zend_Date::MONTH_DAYS);
     $this->view->selectedMonth = $month;
     $this->view->currentMonth = $currentMonth;
     $this->view->currentDay = $currentDay;
     $result = Bc_UserDTO::fetchAsArray(array('month' => $month));
     $month = array();
     for ($i = 1; $i <= $days; $i++) {
         $data = array();
         $data['date'] = $currentDate->toString(Zend_Date::DAY . '.' . Zend_Date::MONTH . '.' . Zend_Date::YEAR);
         $user = array();
         foreach ($result as $birthday) {
             if ($i == $birthday['birthday']) {
                 $user[] = $birthday;
             }
         }
         $data['user'] = empty($user) ? null : $user;
         $month[$i] = $data;
         $currentDate->add('24:00:00', Zend_Date::TIMES);
     }
     $this->view->month = $month;
 }
Exemple #4
0
 /**
  * Test the network provided
  * @param $affiliateNetwork
  * @return none
  */
 public static function testNetwork($network)
 {
     //Start date, the first two months ago
     $startDate = new Zend_Date();
     $startDate->setDay(1);
     $startDate->subMonth(2);
     $startDate->setHour(00);
     $startDate->setMinute(00);
     $startDate->setSecond(00);
     //Yesterday, some networks don't give us the data for the same day, then is the safer way to have our data
     $endDate = new Zend_Date();
     $endDate->subDay(1);
     $endDate->setHour(23);
     $endDate->setMinute(59);
     $endDate->setSecond(59);
     //are we connected?
     if ($network->checkConnection()) {
         //Get all the payments for this network.
         $paymentsList = $network->getPaymentHistory();
         echo "Total Number of payments: " . count($paymentsList) . "\n\n";
         //Get all the Merhcants
         $merchantList = $network->getMerchantList(array());
         echo "Number of merchants: " . count($merchantList) . "\n\n";
         // Building the array of merchant Id we want to retrieve data from.
         $merchantIdList = array();
         foreach ($merchantList as $merchant) {
             $merchantIdList[] = $merchant['cid'];
         }
         //If we have joined any merchant
         if (!empty($merchantIdList)) {
             //Split the dates monthly, Most of the network don't allow us to retrieve more than a month data
             $dateArray = Oara_Utilities::monthsOfDifference($startDate, $endDate);
             for ($i = 0; $i < count($dateArray); $i++) {
                 // Calculating the start and end date for the current month
                 $monthStartDate = clone $dateArray[$i];
                 $monthEndDate = null;
                 if ($i != count($dateArray) - 1) {
                     $monthEndDate = clone $dateArray[$i];
                     $monthEndDate->setDay(1);
                     $monthEndDate->addMonth(1);
                     $monthEndDate->subDay(1);
                 } else {
                     $monthEndDate = $endDate;
                 }
                 $monthEndDate->setHour(23);
                 $monthEndDate->setMinute(59);
                 $monthEndDate->setSecond(59);
                 echo "\n importing from " . $monthStartDate->toString("dd-MM-yyyy HH:mm:ss") . " to " . $monthEndDate->toString("dd-MM-yyyy HH:mm:ss") . "\n";
                 $transactionList = $network->getTransactionList($merchantIdList, $monthStartDate, $monthEndDate);
                 echo "Number of transactions: " . count($transactionList) . "\n\n";
                 $overviewList = $network->getOverviewList($transactionList, $merchantIdList, $monthStartDate, $monthEndDate);
                 echo "Number register on the overview: " . count($overviewList) . "\n\n";
             }
         }
         echo "Import finished \n\n";
     } else {
         echo "Error connecting to the network, check credentials\n\n";
     }
 }
 /**
  * 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
 }
 /**
  * 
  */
 public function indexAction()
 {
     $formSearch = new Fefop_Form_BankStatementSearch();
     $formSearch->setAction($this->_helper->url('list-statement'));
     $this->view->formSearch = $formSearch;
     $today = new Zend_Date();
     $today->setDay(1)->subDay(1);
     $this->view->lastMonth = $today;
 }
Exemple #7
0
 /**
  * @return Zend_Date
  * เปลี่ยนวันที่ในรูปแบบ dd/mm/yyyy   เป็น object DateTime
  */
 static function toZendDateTime($stringDateTime, $dateType = 'AD', $delimiter = '/')
 {
     //echo "toDateTime". $stringDateTime;
     $dates = explode($delimiter, $stringDateTime);
     $year = $dates[2];
     $month = $dates[1];
     $day = $dates[0];
     $date = new Zend_Date();
     $date->setDay($day)->setMonth($month)->setYear($year);
     return $date;
 }
 /**
  * 
  */
 public function indexAction()
 {
     $form = $this->_getForm($this->_helper->url('save'));
     // Get items to consolidate
     $itemsToConsolidate = $this->_mapper->listExpensesToConsolidate();
     $this->view->items = $itemsToConsolidate;
     $this->view->form = $form;
     $today = new Zend_Date();
     $today->setDay(1)->subDay(1);
     $this->view->lastMonth = $today;
 }
 public function getBestsellerProducts()
 {
     $storeId = (int) Mage::app()->getStore()->getId();
     // Date
     $date = new Zend_Date();
     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
     $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
     $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addStoreFilter()->setPageSize(6);
     $collection->getSelect()->joinLeft(array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
     return $collection;
 }
Exemple #10
0
 public function getLoadedProductCollection()
 {
     if ($this->getRequest()->getParam('id') != null) {
         $id = $this->getRequest()->getParam('id');
         // benchmarking
         $memory = memory_get_usage();
         $time = microtime();
         $catId = $id;
         /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
         $collection = Mage::getResourceModel('catalog/product_collection');
         // join sales order items column and count sold products
         $expression = new Zend_Db_Expr("SUM(oi.qty_ordered)");
         $condition = new Zend_Db_Expr("e.entity_id = oi.product_id AND oi.parent_item_id IS NULL");
         $collection->addAttributeToSelect('*')->getSelect()->join(array('oi' => $collection->getTable('sales/order_item')), $condition, array('sales_count' => $expression))->group('e.entity_id')->order('sales_count' . ' ' . 'desc');
         // join category
         $condition = new Zend_Db_Expr("e.entity_id = ccp.product_id");
         $condition2 = new Zend_Db_Expr("c.entity_id = ccp.category_id");
         $collection->getSelect()->join(array('ccp' => $collection->getTable('catalog/category_product')), $condition, array())->join(array('c' => $collection->getTable('catalog/category')), $condition2, array('cat_id' => 'c.entity_id'));
         $condition = new Zend_Db_Expr("c.entity_id = cv.entity_id AND ea.attribute_id = cv.attribute_id");
         // cutting corners here by hardcoding 3 as Category Entiry_type_id
         $condition2 = new Zend_Db_Expr("ea.entity_type_id = 3 AND ea.attribute_code = 'name'");
         $collection->getSelect()->join(array('ea' => $collection->getTable('eav/attribute')), $condition2, array())->join(array('cv' => $collection->getTable('catalog/category') . '_varchar'), $condition, array('cat_name' => 'cv.value'));
         // if Category filter is on
         if ($catId) {
             $collection->getSelect()->where('c.entity_id = ?', $catId)->limit(20);
         }
         // unfortunately I cound not come up with the sql query that could grab only 1 bestseller for each category
         // so all sorting work lays on php
         $result = array();
         foreach ($collection as $product) {
             /** @var $product Mage_Catalog_Model_Product */
             if (isset($result[$product->getCatId()])) {
                 continue;
             }
             $result[$product->getCatId()] = 'Category:' . $product->getCatName() . '; Product:' . $product->getName() . '; Sold Times:' . $product->getSalesCount();
         }
     } else {
         $id = 2;
         $storeId = (int) Mage::app()->getStore()->getId();
         // Date
         $date = new Zend_Date();
         $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
         $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
         $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addStoreFilter()->addPriceData()->addTaxPercents()->addUrlRewrite()->setPageSize(6);
         $collection->getSelect()->joinLeft(array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'))->limit(5);
         Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
         Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
     }
     return $collection;
 }
 public function monthAction()
 {
     // param handling
     $year = $this->_getParam('year');
     $month = $this->_getParam('month');
     if (!$year or !$month) {
         throw new Exception('');
     }
     // start & stop date
     $startDate = new Zend_Date($year . '-' . $month . '-01', 'yyyy-M-dd');
     $stopDate = new Zend_Date($startDate);
     $stopDate->addMonth(1)->addDay(-1);
     // spacings (start & end)
     $startSpace = $startDate->get(Zend_Date::WEEKDAY_8601) - 1;
     $stopSpace = 7 - $stopDate->get(Zend_Date::WEEKDAY_8601);
     // arrays
     $calendar = array();
     $week = array();
     for ($startSpace; $startSpace >= 1; $startSpace--) {
         $spaceDate = new Zend_Date($startDate);
         $spaceDate->addDay(-$startSpace);
         $day = array('date' => $spaceDate);
         $week[] = $day;
     }
     for ($currentDay = 1; $currentDay <= $stopDate->get('d'); $currentDay++) {
         $currentDate = new Zend_Date($startDate);
         $currentDate->setDay($currentDay);
         $day = array('date' => $currentDate);
         $week[] = $day;
         if (count($week) / 7 == 1) {
             $calendar[] = array('info' => $currentDate, 'columns' => $week);
             $week = array();
         }
     }
     for ($stopSpace; $stopSpace >= 1; $stopSpace--) {
         $spaceDate = new Zend_Date($stopDate);
         $spaceDate->addDay(-$stopSpace);
         $day = array('date' => $spaceDate);
         $week[] = $day;
         if (count($week) / 7 == 1) {
             $calendar[] = array('info' => $currentDate, 'columns' => $week);
             $week = array();
         }
     }
     // view
     $this->view->rows = $calendar;
 }
Exemple #12
0
 /**
  * @param string $year
  * @param string $month
  * @param integer $page
  * @param integer $perPage
  * @return Zend_Paginator
  */
 public function getListByDate($year, $month = null, $page = 1, $perPage = 10)
 {
     $month = (int) $month;
     if ($month < 1 || $month > 12) {
         $month = 0;
         $date = new Zend_Date("{$year}-01-01", Zend_Date::ISO_8601);
     } else {
         if (1 == strlen($month)) {
             $month = "0{$month}";
         }
         $date = new Zend_Date("{$year}-{$month}-01", Zend_Date::ISO_8601);
     }
     $from = (int) $date->getTimestamp();
     if ($month) {
         $to = (int) $date->setDay($date->get(Zend_Date::MONTH_DAYS))->getTimestamp();
     } else {
         $to = (int) $date->setMonth(12)->setDay(31)->getTimestamp();
     }
     $list = $this->_getList();
     $list->setCondition('date BETWEEN ? AND ?', array($from, $to));
     return $this->_paginate($list, $page, $perPage);
 }
Exemple #13
0
 /**
  * test looseBehaviour
  */
 public function testLoose()
 {
     $date = new Zend_Date(0, 'de_DE');
     try {
         $date->set(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->set(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->add(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->add(10, 'de_DE');
     $this->assertEquals(20, $date->getTimestamp());
     try {
         $date->sub(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->sub(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->compare(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->equals(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isEarlier(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isLater(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
 }
Exemple #14
0
 public function getCalendar($month = null, $year = null, $location = null)
 {
     $zd = new Zend_Date();
     if (is_null($month)) {
         $month = date('n');
     }
     if (is_null($year)) {
         $year = date('Y');
     }
     $zd->setMonth($month);
     $zd->setYear($year);
     $zd->setDay(1);
     $calData = array();
     $calData['startDay'] = $zd->get(Zend_Date::WEEKDAY_DIGIT);
     $calData['month'] = $zd->get(Zend_Date::MONTH_SHORT);
     $calData['monthName'] = $zd->get(Zend_Date::MONTH_NAME);
     $calData['monthDays'] = $zd->get(Zend_Date::MONTH_DAYS);
     $calData['year'] = $zd->get(Zend_Date::YEAR);
     if ($calData['month'] == 12) {
         $calData['nextMonth'] = 1;
     } else {
         $calData['nextMonth'] = $calData['month'] + 1;
     }
     $calData['nextYear'] = $calData['year'];
     if ($calData['nextMonth'] == 1) {
         $calData['nextYear'] = $calData['year'] + 1;
     }
     if ($calData['month'] == 1) {
         $calData['prevMonth'] = 12;
     } else {
         $calData['prevMonth'] = $calData['month'] - 1;
     }
     $calData['prevYear'] = $calData['year'];
     if ($calData['prevMonth'] == 12) {
         $calData['prevYear'] = $calData['year'] - 1;
     }
     $tmpDate = new Zend_Date();
     $calData['week'] = $tmpDate->get(Zend_Date::WEEK);
     $calData['rows'] = array();
     $dayCounter = 1;
     // make sure we don't have an empty row
     if ($calData['startDay'] > 4) {
         $numRows = intval($calData['monthDays'] / 5);
     } else {
         $numRows = intval($calData['monthDays'] / 6);
     }
     for ($x = 0; $x < $numRows; $x++) {
         $sd = 0;
         if ($x == 0) {
             // this sets the first row to start on the correct day of the week
             for ($y = 0; $y < $calData['startDay']; $y++) {
                 $tmp = array();
                 $tmp['num'] = "";
                 $calData['rows'][$x]['days'][$y] = $tmp;
             }
             $sd = $calData['startDay'];
         }
         $event = new Event();
         // put the numbers in the rows
         for ($z = $sd; $z < 7; $z++) {
             $tmp = array();
             if ($dayCounter <= $calData['monthDays']) {
                 $zd->setDay($dayCounter);
                 // set the week number
                 $calData['rows'][$x]['weekNum'] = $zd->get(Zend_Date::WEEK);
                 $calData['rows'][$x]['weekYear'] = $zd->get(Zend_Date::YEAR);
                 if (isset($calData['rows'][$x - 1]['weekNum'])) {
                     if ($calData['rows'][$x - 1]['weekNum'] == 52) {
                         $calData['rows'][$x]['weekNum'] = "01";
                         $calData['rows'][$x]['weekYear'] = $year + 1;
                     }
                 }
                 $tmp['num'] = $dayCounter;
                 $calData['rows'][$x]['days'][$z] = $tmp;
                 $where = $event->getAdapter()->quoteInto('date = ?', $year . "-" . $month . "-" . $dayCounter);
                 $where .= " AND ";
                 $where .= $event->getAdapter()->quoteInto('status = ?', 'open');
                 if (!is_null($locationId)) {
                     $where .= " AND ";
                     $where .= $event->getAdapter()->quoteInto('locationId = ?', $locationId);
                 }
                 $events = $event->fetchAll($where, 'startTime')->toArray();
                 $calData['rows'][$x]['days'][$z]['numEvents'] = count($events);
             } else {
                 $tmp['num'] = "";
                 $calData['rows'][$x]['days'][$z] = $tmp;
             }
             $dayCounter++;
         }
     }
     return $calData;
 }
Exemple #15
0
 /**
  * test setting dates to specify weekdays
  */
 public function testDay()
 {
     // all tests and calculations below are in GMT (that is intention for this test)
     $date = new Zend_Date(0, 'de_AT');
     $date->setTimeZone('UTC');
     $dw = $date->getDay();
     $this->assertSame($dw->toString(), '01.01.1970 00:00:00');
     for ($day = 1; $day < 31; $day++) {
         $date->setDay($day);
         $dw = $date->getDay();
         $weekday = str_pad($day, 2, '0', STR_PAD_LEFT);
         $this->assertSame($dw->toString(), "{$weekday}.01.1970 00:00:00");
     }
 }
Exemple #16
0
 public function getListBestSellerProducts($fieldorder = 'ordered_qty', $order = 'desc')
 {
     $limit = $this->getConfig('limit_item', 'catalog_source_setting');
     $limit = empty($limit) ? 6 : (int) $limit;
     $storeId = Mage::app()->getStore()->getId();
     $cateids = $this->getConfig('catsid', 'catalog_source_setting');
     $arr_catsid = array();
     if (stristr($cateids, ',') === FALSE) {
         $arr_catsid = array($cateids);
     } else {
         $arr_catsid = explode(",", $cateids);
     }
     $date = new Zend_Date();
     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
     $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
     if ($this->getConfig('bestseller_from_date') != '') {
         $fromDate = $this->getConfig('bestseller_from_date');
     }
     if ($this->getConfig('bestseller_to_date') != '') {
         $toDate = $this->getConfig('bestseller_to_date');
     }
     $resource = Mage::getSingleton('core/resource');
     $products = $this->getCollectionPro()->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addStoreFilter()->addPriceData()->addTaxPercents()->addUrlRewrite()->joinTable($resource->getTableName('catalog_category_product'), 'product_id=entity_id', array('category_id' => 'category_id'), null, 'left')->addAttributeToFilter(array(array('attribute' => 'category_id', 'in' => array('finset' => $arr_catsid))));
     $products->getSelect()->joinLeft(array('aggregation' => $products->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     $products->setPageSize($limit)->setCurPage($this->_current_page);
     $this->setProductCollection($products);
     $this->_addProductAttributesAndPrices($products);
     $list = array();
     if (($_products = $this->getProductCollection()) && $_products->getSize()) {
         $list = $products;
     }
     return $list;
 }
 /**
  * 取得某个预定义时间段
  * 
  * @static
  * @param integer $interval
  * @param string $forceUnit
  * @param integer $timestamp
  * @return array
  */
 public static function getPredefinedRange($interval, $forceUnit = null, $timestamp = null)
 {
     if (empty($timestamp)) {
         $timestamp = time();
     }
     $start = new Zend_Date($timestamp);
     $end = new Zend_Date($timestamp);
     switch ($interval) {
         case self::TODAY:
             $start->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::HOUR;
             break;
         case self::YESTODAY:
             $start->subDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::TOMORROW:
             $start->addDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addDay(1);
             $unit = Zend_Date::HOUR;
             break;
         case self::THIS_MONTH:
             $start->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_YEAR:
             $start->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end->addMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
             break;
         case self::THIS_SEASON:
             $start->setMonth(3 * floor(($start->toValue('M') - 1) / 3) + 1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $unit = Zend_Date::DAY;
         case self::RECENT_24HOUR:
             $start->subHour(24);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_48HOUR:
             $start->subHour(48);
             $unit = Zend_Date::HOUR;
             break;
         case self::RECENT_1WEEK:
             $start->subWeek(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_1MONTH:
             $start->subMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::RECENT_24MONTH:
             $start->subMonth(24);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1MONTH:
             $start->subMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addMonth(1);
             $unit = Zend_Date::DAY;
             break;
         case self::LAST_1YEAR:
             $start->subYear(1)->setMonth(1)->setDay(1)->setHour(0)->setMinute(0)->setSecond(0);
             $end = clone $start;
             $end->addYear(1);
             $unit = Zend_Date::DAY;
             break;
         case self::ENTIRE_DAY:
             $start->setDate(self::ERA_DATE, self::ZF_DATE_FORMAT)->setTime(self::ERA_TIME, self::ZF_TIME_FORMAT);
             $end->addDay(1);
             $unit = Zend_Date::DAY;
             break;
         default:
             $unit = Zend_Date::SECOND;
     }
     if (!empty($forceUnit)) {
         $unit = $forceUnit;
     }
     $start = max(self::truncateDatetime($start, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     $end = max(self::truncateDatetime($end, $unit), self::truncateDatetime(self::ERA_DATETIME, $unit));
     return compact('start', 'end', 'unit');
 }
 /**
  * @param $filter
  *
  * @return mixed
  */
 protected function _processFilter($filter)
 {
     $period = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS;
     if (array_key_exists('period', $filter)) {
         $period = intval($filter['period']);
     }
     $filter['period'] = $period;
     $fromDate = new Zend_Date();
     $toDate = new Zend_Date();
     $fromDate->setHour(23)->setMinute(59)->setSecond(59);
     $toDate->setHour(23)->setMinute(59)->setSecond(59);
     switch ($period) {
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_TODAY:
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_YESTERDAY:
             $fromDate->subDay(1);
             $toDate->subDay(1);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_WEEK:
             $firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
             if ($firstDayOfWeek === 0) {
                 $firstDayOfWeek = 7;
             }
             $fromDate->setWeekday($firstDayOfWeek);
             if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
                 $fromDate->subWeek(1);
             }
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_WEEK:
             $fromDate->subWeek(1);
             $toDate->subWeek(1);
             $firstDayOfWeek = (int) Mage::getStoreConfig('general/locale/firstday');
             if ($firstDayOfWeek === 0) {
                 $firstDayOfWeek = 7;
             }
             $fromDate->setWeekday($firstDayOfWeek);
             if ($firstDayOfWeek > (int) $fromDate->toString('e')) {
                 $fromDate->subWeek(1);
             }
             $lastDayOfWeek = $firstDayOfWeek - 1;
             if ($lastDayOfWeek < 1) {
                 $lastDayOfWeek = 7;
             }
             $toDate->setWeekday($lastDayOfWeek);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_THIS_MONTH:
             $fromDate->setDay(1);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_MONTH:
             $fromDate->subMonth(1)->setDay(1);
             $toDate->setDay(1)->subDay(1);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SIX_MONTHS:
             $fromDate->subMonth(6);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_CUSTOM:
             $_reversed = false;
             $_now = new Zend_Date(null, 'dd/MM/y');
             try {
                 $_fromDate = new Zend_Date($filter['from_date'], 'dd/MM/y');
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "From" date value'));
                 $_fromDate = clone $_now;
             }
             try {
                 $_toDate = new Zend_Date($filter['to_date'], 'dd/MM/y');
                 if ($_fromDate->compare($_toDate) > 0) {
                     $_reversed = true;
                 }
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('aw_hdu3')->__('Please select correct "To" date value'));
                 $_toDate = clone $_now;
             }
             if ($_reversed) {
                 $fromDate = $_toDate;
                 $toDate = $_fromDate;
             } else {
                 $fromDate = $_fromDate;
                 $toDate = $_toDate;
             }
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_SEVEN_DAYS:
             $fromDate->subDay(6);
             break;
         case AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::PERIOD_LAST_THIRTY_DAYS:
             $fromDate->subDay(29);
             break;
     }
     $filter['from_date'] = $fromDate;
     $filter['to_date'] = $toDate;
     if (!array_key_exists('group', $filter)) {
         $filter['group'] = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::GROUP_BY_WEEK;
     }
     if (!array_key_exists('agents[]', $filter)) {
         $filter['agents[]'] = $this->_getAgentIds();
     }
     if (!array_key_exists('report', $filter)) {
         $filter['report'] = AW_Helpdesk3_Block_Adminhtml_Statistic_Agent_View_Chart::REPORT_FIRST_REPLY_AVG_TIME;
     }
     return $filter;
 }
Exemple #19
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Interface#getOverviewList($aMerchantIds, $dStartDate, $dEndDate)
  */
 public function getOverviewList($transactionList = null, $merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null)
 {
     $overviewArray = array();
     $firstDayMonth = new Zend_Date();
     $firstDayMonth->setDay(1);
     $firstDayMonth->setHour("00");
     $firstDayMonth->setMinute("00");
     $firstDayMonth->setSecond("00");
     $modeArray = array("AdSense for Content", "AdSense for Search", "AdSense for Feeds", "AdSense for Domains");
     $valuesExport = array();
     $valuesExport[] = new Oara_Curl_Parameter('d', $dStartDate->toString("yyyy/M/d") . "-" . $dEndDate->toString("yyyy/M/d"));
     $valuesExportReport[] = new Oara_Curl_Parameter('ag', 'date');
     $valuesExport[] = new Oara_Curl_Parameter('oc', 'earnings');
     $valuesExport[] = new Oara_Curl_Parameter('oo', 'descending');
     $valuesExport[] = new Oara_Curl_Parameter('hl', 'en_GB');
     $urls = array();
     $valuesExportReport = Oara_Utilities::cloneArray($valuesExport);
     $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFCYAdSense for Content');
     $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport);
     $valuesExportReport = Oara_Utilities::cloneArray($valuesExport);
     $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFSYAdSense for Search');
     $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport);
     $valuesExportReport = Oara_Utilities::cloneArray($valuesExport);
     $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFFYAdSense for Feeds');
     $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport);
     $valuesExportReport = Oara_Utilities::cloneArray($valuesExport);
     $valuesExportReport[] = new Oara_Curl_Parameter('dd', '1YproductY1YAFDYAdSense for Domains');
     $urls[] = new Oara_Curl_Request('https://www.google.com/adsense/v3/gwt/exportCsv?', $valuesExportReport);
     $content = $this->_client->post($urls);
     for ($i = 0; $i < count($content); $i++) {
         $exportData = str_getcsv(@iconv('UTF-16', 'UTF-8', $content[$i]), "\n");
         for ($j = 1; $j < count($exportData); $j++) {
             $overviewExportArray = str_getcsv($exportData[$j], "\t");
             $obj = array();
             $obj['merchantId'] = 1;
             $overviewDate = new Zend_Date($overviewExportArray[0], "yyyy-MM-dd");
             $overviewDate->setHour("00");
             $overviewDate->setMinute("00");
             $overviewDate->setSecond("00");
             $obj['date'] = $overviewDate->toString("yyyy-MM-dd HH:mm:ss");
             $obj['link'] = $modeArray[$i];
             $obj['transaction_number'] = 0;
             $obj['transaction_confirmed_commission'] = 0;
             $obj['transaction_confirmed_value'] = 0;
             $obj['transaction_pending_commission'] = 0;
             $obj['transaction_pending_value'] = 0;
             $obj['transaction_declined_commission'] = 0;
             $obj['transaction_declined_value'] = 0;
             $obj['impression_number'] = (int) Oara_Utilities::parseDouble($overviewExportArray[1]);
             $obj['click_number'] = Oara_Utilities::parseDouble($overviewExportArray[2]);
             if ($firstDayMonth->compare($overviewDate) <= 0) {
                 $obj['transaction_pending_commission'] = Oara_Utilities::parseDouble($overviewExportArray[6]);
                 $obj['transaction_pending_value'] = Oara_Utilities::parseDouble($overviewExportArray[6]);
             } else {
                 $obj['transaction_confirmed_commission'] = Oara_Utilities::parseDouble($overviewExportArray[6]);
                 $obj['transaction_confirmed_value'] = Oara_Utilities::parseDouble($overviewExportArray[6]);
             }
             if (Oara_Utilities::checkRegister($obj)) {
                 $overviewArray[] = $obj;
             }
         }
     }
     unset($urls);
     return $overviewArray;
 }
Exemple #20
0
 /**
  * Get interval for a month
  *
  * @param Zend_Date $dateStart
  * @param Zend_Date $dateEnd
  * @param bool $firstInterval
  * @return array
  */
 protected function _getMonthInterval(Zend_Date $dateStart, Zend_Date $dateEnd, $firstInterval)
 {
     $interval = array();
     $interval['period'] = $dateStart->toString('MM/yyyy');
     $interval['start'] = $firstInterval ? $dateStart->toString('yyyy-MM-dd 00:00:00') : $dateStart->toString('yyyy-MM-01 00:00:00');
     $lastInterval = $dateStart->compareMonth($dateEnd->getMonth()) == 0;
     $interval['end'] = $lastInterval ? $dateStart->setDay($dateEnd->getDay())->toString('yyyy-MM-dd 23:59:59') : $dateStart->toString('yyyy-MM-' . date('t', $dateStart->getTimestamp()) . ' 23:59:59');
     $dateStart->addMonth(1);
     if ($dateStart->compareMonth($dateEnd->getMonth()) == 0) {
         $dateStart->setDay(1);
     }
     return $interval;
 }
Exemple #21
0
 public function getListBestSellerProducts($config = array())
 {
     $this->_config = $config;
     $fieldorder = 'ordered_qty';
     $order = 'desc';
     $storeId = Mage::app()->getStore()->getId();
     $cateids = $this->getConfig('catsid');
     $list = array();
     $limit_item = $this->getConfig('limit_item', 12);
     $itemspage = $this->getConfig('itemspage', 6);
     $curPage = $this->getConfig('page', 1);
     $date = new Zend_Date();
     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
     $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
     $resource = Mage::getSingleton('core/resource');
     if ($curPage * $itemspage > $limit_item + $itemspage) {
         return '';
     }
     if ($cateids && $cateids != "1") {
         $arr_catsid = array();
         if (is_array($cateids)) {
             $arr_catsid = $cateids;
         } else {
             if (stristr($cateids, ',') === FALSE) {
                 $arr_catsid = array($cateids);
             } else {
                 $arr_catsid = explode(",", $cateids);
             }
         }
         $products = $this->getCollectionPro()->addStoreFilter()->addPriceData()->addTaxPercents()->addUrlRewrite()->joinTable($resource->getTableName('catalog_category_product'), 'product_id=entity_id', array('category_id' => 'category_id'), null, 'left')->addAttributeToFilter(array(array('attribute' => 'category_id', 'in' => array('finset' => $arr_catsid))));
         $products->getSelect()->joinLeft(array('aggregation' => $products->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
     } else {
         $products = $this->getCollectionPro()->addStoreFilter()->addPriceData()->addTaxPercents()->addUrlRewrite();
         $products->getSelect()->joinLeft(array('aggregation' => $products->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
     }
     $list = array();
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     $this->_addProductAttributesAndPrices($products);
     $products->setPageSize($itemspage)->setCurPage($curPage);
     $this->setProductCollection($products);
     if (($_products = $this->getProductCollection()) && $_products->getSize()) {
         $list['products'] = $products;
     }
     $size = $products->getSize();
     $list['hasNextData'] = true;
     if ($limit_item < $size) {
         $size = $limit_item;
     }
     if ($size <= $curPage * $itemspage) {
         $list['hasNextData'] = false;
     }
     return $list;
 }
Exemple #22
0
 public function getListBestSellerProducts1($config = array())
 {
     $this->_config = $config;
     $fieldorder = 'ordered_qty';
     $order = 'desc';
     $storeId = Mage::app()->getStore()->getId();
     $cateids = $this->getConfig('catsid');
     if ($this->getConfig('bestseller_from_date') != '' && $this->getConfig('bestseller_to_date') != '') {
         $days = (strtotime($this->getConfig('bestseller_to_date')) - strtotime($this->getConfig('bestseller_from_date'))) / (60 * 60 * 24);
     }
     $list = array();
     $limit_item = $this->getConfig('limit_item', 12);
     $itemspage = $this->getConfig('itemspage', 6);
     $curPage = $this->getConfig('page', 1);
     if ($curPage * $itemspage > $limit_item + $itemspage) {
         return '';
     }
     $date = new Zend_Date();
     $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
     $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
     if ($this->getConfig('bestseller_from_date') != '') {
         $fromDate = $this->getConfig('bestseller_from_date');
     }
     if ($this->getConfig('bestseller_from_date') != '') {
         $toDate = $this->getConfig('bestseller_from_date');
     }
     if ($cateids && $cateids != "1") {
         $productIds = $this->getProductByCategory();
         $visibility = Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds();
         $attributesToSelect = array('name', 'small_image', 'short_description', 'price');
         $productFlatTable = Mage::getResourceModel('catalog/product_flat')->getFlatTableName($storeId);
         try {
             $products = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect($attributesToSelect)->addStoreFilter()->setStoreId($storeId)->addStoreFilter($storeId)->addPriceData()->addTaxPercents()->addUrlRewrite()->addIdFilter($productIds);
             $products->getSelect()->joinLeft(array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
         } catch (Exception $e) {
             Mage::logException($e);
         }
     } else {
         $visibility = Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds();
         $attributesToSelect = array('name', 'small_image', 'short_description', 'price');
         $productFlatTable = Mage::getResourceModel('catalog/product_flat')->getFlatTableName($storeId);
         try {
             $products = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect($attributesToSelect)->addStoreFilter()->setStoreId($storeId)->addStoreFilter($storeId)->addPriceData()->addTaxPercents()->addUrlRewrite();
             $products->getSelect()->joinLeft(array('aggregation' => $products->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
         } catch (Exception $e) {
             Mage::logException($e);
         }
     }
     $list = array();
     $products->setPageSize($itemspage)->setCurPage($curPage);
     $list['products'] = $products;
     $size = $products->getSize();
     $list['hasNextData'] = true;
     if ($limit_item < $size) {
         $size = $limit_item;
     }
     if ($size <= $curPage * $itemspage) {
         $list['hasNextData'] = false;
     }
     return $list;
 }
 public function output()
 {
     $endDate = $this->getEndDate();
     $beginDate = $this->getBeginDate();
     $totalDays = $endDate->get('dd');
     $beginSpace = $beginDate->get(Zend_Date::WEEKDAY_8601) - 1;
     $endSpace = 7 - $endDate->get(Zend_Date::WEEKDAY_8601);
     for ($beginSpace; $beginSpace >= 1; $beginSpace--) {
         $spaceDate = new Zend_Date($beginDate);
         $spaceDate->addDay(-$beginSpace);
         $this->_addDay($spaceDate);
     }
     for ($day = 1; $day <= $totalDays; $day++) {
         $currentDate = new Zend_Date($beginDate);
         $currentDate->setDay($day);
         $this->_addDay($currentDate);
     }
     for ($i = 0; $i <= $endSpace; $i++) {
         $spaceDate = new Zend_Date($beginDate);
         $spaceDate->addDay($i);
         $this->_addDay($spaceDate);
     }
     return $this->getWeeks();
 }
Exemple #24
0
 /**
  * 
  * @return array
  */
 public function calcTotals()
 {
     $dbFEFOPBankStatements = App_Model_DbTable_Factory::get('FEFOPBankStatements');
     $select = $dbFEFOPBankStatements->select()->from(array('bs' => $dbFEFOPBankStatements), array('total' => new Zend_Db_Expr('SUM( bs.amount * IF( bs.operation = "D", -1, 1) )')));
     $selectConsolidated = clone $select;
     $selectLastMonth = clone $select;
     $today = new Zend_Date();
     $today->setDay(1)->subDay(1);
     $selectConsolidated->where('bs.status = ?', self::CONSOLIDATED);
     $selectLastMonth->where('bs.date_statement < ?', $today->toString('yyyy-MM-dd'));
     $currentTotal = $dbFEFOPBankStatements->fetchRow($select)->total;
     $consolidatedTotal = $dbFEFOPBankStatements->fetchRow($selectConsolidated)->total;
     $lastMonthTotal = $dbFEFOPBankStatements->fetchRow($selectLastMonth)->total;
     $totals = array('current' => (double) $currentTotal, 'consolidated' => (double) $consolidatedTotal, 'last_month' => (double) $lastMonthTotal);
     return $totals;
 }
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../vendor/ZendFramework/library'), get_include_path())));
require_once 'Zend/Application.php';
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();
// the needed resources
$frontController = $application->getBootstrap()->getResource('FrontController');
$view = $application->getBootstrap()->getResource('View');
// init request
$request = new Zend_Controller_Request_Http();
$request->setControllerName('partner-usage');
$request->setActionName('export-csv');
$fromDate = new Zend_Date();
$fromDate->setHour(0);
$fromDate->setMinute(0);
$fromDate->setSecond(0);
$fromDate->setDay(1);
$fromDate->addMonth(-1);
$request->setParam('from_date', $fromDate->getTimestamp());
// beginning of last month
$toDate = new Zend_Date($fromDate);
$toDate->addMonth(1);
$toDate->addSecond(-1);
$request->setParam('to_date', $toDate->getTimestamp());
// end of last month
// init response
$response = new Zend_Controller_Response_Cli();
// dispatch
$frontController->getDispatcher()->dispatch($request, $response);
// send mail
$config = Zend_Registry::get('config');
$sentToArray = explode(',', $config->settings->monthlyUsageSendTo);
Exemple #26
0
 /**
  * 
  * @param array $filters
  * @return array
  */
 public function chartSentDay(array $filters = array())
 {
     $date = new Zend_Date();
     // Set the date to search the current month
     $filters['date_ini'] = $date->setDay(1)->toString('yyyy-MM-dd');
     $filters['date_fin'] = $date->addMonth(1)->subDay(1)->toString('yyyy-MM-dd');
     // Search just the sending successfully
     $filters['status'] = 'S';
     $sent = $this->sentByDays($filters);
     // Search the erros with errors
     $filters['status'] = 'E';
     $errors = $this->sentByDays($filters);
     $months = array();
     foreach ($sent as $row) {
         $months[] = $row->day;
     }
     foreach ($errors as $row) {
         $months[] = $row->day;
     }
     $months = array_fill_keys(array_unique($months), array('errors' => 0, 'sent' => 0));
     foreach ($sent as $row) {
         $months[$row->day]['sent'] = $row->sent;
     }
     foreach ($errors as $row) {
         $months[$row->day]['errors'] = $row->sent;
     }
     $data = array('months' => array_keys($months), 'errors' => array(), 'sent' => array());
     foreach ($months as $row) {
         $data['errors'][] = (int) $row['errors'];
         $data['sent'][] = (int) $row['sent'];
     }
     return $data;
 }
 /**
  * Bestellungen auflisten
  */
 public function listAction()
 {
     // create new order list
     $list = $this->orderManager->createOrderList();
     // set list type
     $list->setListType($this->getParam('type', $list::LIST_TYPE_ORDER));
     // set order state
     $list->setOrderState(OnlineShop_Framework_AbstractOrder::ORDER_STATE_COMMITTED);
     // add select fields
     $list->addSelectField('order.OrderDate');
     $list->addSelectField(['OrderNumber' => 'order.orderNumber']);
     if ($list->getListType() == $list::LIST_TYPE_ORDER) {
         $list->addSelectField(['TotalPrice' => 'order.totalPrice']);
     } else {
         if ($list->getListType() == $list::LIST_TYPE_ORDER_ITEM) {
             $list->addSelectField(['TotalPrice' => 'orderItem.totalPrice']);
         }
     }
     $list->addSelectField(['Items' => 'count(orderItem.o_id)']);
     // Search
     if ($this->getParam('q')) {
         $q = htmlentities($this->getParam('q'));
         $search = $this->getParam('search');
         switch ($search) {
             case 'productType':
                 $filterProductType = new Filter\ProductType();
                 $filterProductType->setTypes([$q]);
                 $list->addFilter($filterProductType);
                 break;
             case 'order':
             default:
                 $filterOrder = new Filter\OrderSearch();
                 $filterOrder->setKeyword($q);
                 $list->addFilter($filterOrder);
                 break;
         }
     }
     // add Date Filter
     $filterDate = new Filter\OrderDateTime();
     if ($this->getParam('from') || $this->getParam('till')) {
         $from = $this->getParam('from') ? new Zend_Date($this->getParam('from')) : null;
         $till = $this->getParam('till') ? new Zend_Date($this->getParam('till')) : null;
         if ($till) {
             $till->add(1, Zend_Date::DAY);
         }
         if ($from) {
             $filterDate->setFrom($from);
         }
         if ($till) {
             $filterDate->setTill($till);
         }
     } else {
         // als default, nehmen wir den ersten des aktuellen monats
         $from = new Zend_Date();
         $from->setDay(1);
     }
     $list->addFilter($filterDate);
     // set default order
     $list->setOrder('order.orderDate desc');
     // create paging
     $paginator = Zend_Paginator::factory($list);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($this->getParam('page', 1));
     // view
     $this->view->paginator = $paginator;
 }
Exemple #28
0
 /**
  * @param array $statistics (array('2014-01-01' => 2,'2014-01-02' => 0))
  * @param int $periodType
  *
  * @return array (array('2014-01' => 2))
  */
 public function getGroupedByPeriod($statistics, $periodType)
 {
     if ($periodType == self::PERIOD_DAY_TYPE) {
         return $statistics;
     }
     ksort($statistics);
     //get first key
     $intervalDate = new Zend_Date(key($statistics), Varien_Date::DATE_INTERNAL_FORMAT);
     //reset day to 1
     $intervalDate->setDay(1);
     if ($periodType == self::PERIOD_WEEK_TYPE) {
         //for week period need set start interval like 2014-01-07
         $firstWeekDay = (int) Mage::getStoreConfig('general/locale/firstday') == 0 ? 7 : (int) Mage::getStoreConfig('general/locale/firstday');
         $intervalDate->setWeekday($firstWeekDay);
         if ($intervalDate->toString(Varien_Date::DATE_INTERNAL_FORMAT) == key($statistics)) {
             $intervalDate->addWeek(1);
         }
         $intervalDate->subDay(1);
     }
     $result = array();
     foreach ($statistics as $key => $value) {
         if (!$this->_isInPeriodInterval($intervalDate, $key, $periodType)) {
             $this->_setPeriodIntervalIndex($intervalDate, $key, $periodType);
         }
         $intervalIndex = $intervalDate->toString($this->_getPeriodIntervalDateFormat($periodType));
         if ($periodType == self::PERIOD_WEEK_TYPE) {
             $_prevWeek = clone $intervalDate;
             $_prevWeek->subWeek(1);
             $_prevWeek->addDay(1);
             $_prevWeekIndex = $_prevWeek->toString($this->_getPeriodIntervalDateFormat($periodType));
             $result[$_prevWeekIndex . '/' . $intervalIndex] = (array_key_exists($_prevWeekIndex . '/' . $intervalIndex, $result) ? $result[$_prevWeekIndex . '/' . $intervalIndex] : 0) + $this->_getValue($value);
         } else {
             $result[$intervalIndex] = (array_key_exists($intervalIndex, $result) ? $result[$intervalIndex] : 0) + $this->_getValue($value);
         }
     }
     return $result;
 }
Exemple #29
0
 /**
  *
  */
 public function renderWidgetProduct_carouselContent($args, $setting, $widget_name = "")
 {
     $t = array('show_name' => '1', 'list_type' => '', 'limit' => 5, 'category_id' => 0, 'max_items' => 1, 'limit_cols' => 1, 'auto_play' => 0, 'speed' => 6000, 'image_width' => '200', 'image_height' => '200');
     $products = array();
     $resource = Mage::getSingleton('core/resource');
     $setting = array_merge($t, $setting);
     $storeId = Mage::app()->getStore()->getId();
     $category_id = $setting['category_id'] ? (int) $setting['category_id'] : 0;
     if ($setting['list_type'] == 'bestseller') {
         $category_id = $setting['category_id'] ? (int) $setting['category_id'] : 0;
         if (!$category_id || $category_id == -1) {
             $catsid = $this->getStoreCategories();
         } else {
             $catsid = array($category_id);
         }
         $date = new Zend_Date();
         $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
         $fromDate = $date->subMonth(1)->getDate()->get('Y-MM-dd');
         $products = $this->getCollectionPro()->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addAttributeToSelect(array('name', 'price', 'small_image'))->addStoreFilter()->addPriceData()->addTaxPercents()->addUrlRewrite()->joinTable($resource->getTableName('catalog_category_product'), 'product_id=entity_id', array('category_id' => 'category_id'), null, 'left')->addAttributeToFilter(array(array('attribute' => 'category_id', 'in' => array('finset' => $catsid))));
         $products->getSelect()->joinLeft(array('aggregation' => $products->getResource()->getTable('sales/bestsellers_aggregated_monthly')), "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'", array('SUM(aggregation.qty_ordered) AS sold_quantity'))->group('e.entity_id')->order(array('sold_quantity DESC', 'e.created_at'));
     } else {
         if ($setting['list_type'] == 'special') {
             if (!$category_id || $category_id == -1) {
                 $catsid = $this->getStoreCategories();
             } else {
                 $catsid = array($category_id);
             }
             $products = $this->getCollectionPro()->addFieldToFilter('visibility', array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG))->addMinimalPrice()->addUrlRewrite()->addTaxPercents()->addStoreFilter($storeId)->addFinalPrice()->joinTable($resource->getTableName('catalog_category_product'), 'product_id=entity_id', array('category_id' => 'category_id'), null, 'left')->addAttributeToFilter(array(array('attribute' => 'category_id', 'in' => array('finset' => $catsid))))->groupByAttribute('entity_id');
             $products->getSelect()->where('price_index.final_price < price_index.price');
         } else {
             if ($setting['list_type'] == 'featured') {
                 if (!$category_id || $category_id == -1) {
                     $catsid = $this->getStoreCategories();
                 } else {
                     $catsid = array($category_id);
                 }
                 if ($catsid) {
                     $productIds = $this->getProductByCategory($catsid);
                     $products = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('*')->addMinimalPrice()->addUrlRewrite()->addTaxPercents()->addStoreFilter($storeId)->addIdFilter($productIds)->addAttributeToFilter("featured", 1)->setOrder('created_at', Varien_Db_Select::SQL_DESC);
                 } else {
                     $products = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('*')->addMinimalPrice()->addUrlRewrite()->addTaxPercents()->addStoreFilter($storeId)->addAttributeToFilter("featured", 1)->setOrder('created_at', Varien_Db_Select::SQL_DESC);
                 }
             } else {
                 if (!$category_id || $category_id == -1) {
                     $catsid = $this->getStoreCategories();
                 } else {
                     $catsid = array($category_id);
                 }
                 $todayStartOfDayDate = Mage::app()->getLocale()->date()->setTime('00:00:00')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
                 $todayEndOfDayDate = Mage::app()->getLocale()->date()->setTime('23:59:59')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
                 $products = $this->getCollectionPro()->addAttributeToFilter(array(array('attribute' => 'news_from_date', array('or' => array(0 => array('date' => true, 'to' => $todayEndOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')))->addAttributeToFilter(array(array('attribute' => 'news_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayStartOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')))->joinTable($resource->getTableName('catalog_category_product'), 'product_id=entity_id', array('category_id' => 'category_id'), null, 'left')->addAttributeToFilter(array(array('attribute' => 'category_id', 'in' => array('finset' => $catsid))))->addAttributeToSort('news_from_date', 'desc')->addAttributeToSort("created_at", "DESC")->addAttributeToSort("updated_at", "DESC")->addMinimalPrice()->addFinalPrice()->addStoreFilter($storeId)->addUrlRewrite()->addTaxPercents()->groupByAttribute('entity_id');
             }
         }
     }
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     $products->setPage(1, (int) $setting['limit']);
     $products = $this->_addProductAttributesAndPrices($products);
     $data = array("widget_name" => $widget_name, "show_name" => $setting['show_name'], "max_items" => $setting['max_items'], "limit_cols" => $setting['limit_cols'], "auto_play" => $setting['auto_play'], "speed" => $setting['speed'], "image_width" => $setting['image_width'], "image_height" => $setting['image_height'], "products" => $products);
     $output = $this->renderLayoutHtml("product_carousel", $data);
     return $output;
 }
 /**
  * The main scheduler page.  This allows a user to view and edit the schedule.  Users
  * will almost certainly need access to this entire controller to make the
  * scheduler work properly and look right.
  *
  */
 public function indexAction()
 {
     $this->view->acl = array('addEvent' => $this->_helper->hasAccess('add-event'));
     $get = Zend_Registry::get('getFilter');
     if (isset($get->workshopId)) {
         $workshopId = $get->workshopId;
         $this->view->workshopId = $workshopId;
         $this->view->startInAddMode = 1;
     }
     if (isset($get->startYear)) {
         $this->view->startYear = $get->startYear;
     } else {
         $this->view->startYear = date('Y');
     }
     if (isset($get->startMonth)) {
         $this->view->startMonth = $get->startMonth;
     } else {
         $this->view->startMonth = date('m');
     }
     $eventId = null;
     if (isset($get->eventId)) {
         $eventId = $get->eventId;
         $this->view->eventId = $eventId;
         $this->view->startInEditMode = 1;
         $e = new Event();
         $thisEvent = $e->find($eventId)->toArray();
         $this->view->locationId = $thisEvent['locationId'];
     }
     $zd = new Zend_Date();
     $this->view->workshopLength = mktime(1, 0, 0, 1, 1, 1970);
     $this->view->startTime = mktime(0, 0, 0, 1, 1, 1970);
     $this->view->endTime = mktime(23, 30, 0, 1, 1, 1970);
     $this->view->baseTime = mktime(0, 0, 0, 1, 1, 1970);
     $this->view->today = $zd->get(Zend_Date::MONTH) . "/" . $zd->get(Zend_Date::DAY) . "/" . $zd->get(Zend_Date::YEAR);
     $this->view->thisYear = $zd->get(Zend_Date::YEAR);
     $this->view->thisWeek = $zd->get(Zend_Date::WEEK);
     if (!is_null($eventId)) {
         $tmpDate = explode('-', $thisEvent['date']);
         $zd->setYear($tmpDate[0]);
         $zd->setMonth($tmpDate[1]);
         $zd->setDay($tmpDate[2]);
     }
     $this->view->year = $zd->get(Zend_Date::YEAR);
     $this->view->week = $zd->get(Zend_Date::WEEK);
     $this->_helper->pageTitle('workshop-schedule-index:title');
     $workshop = new Workshop();
     $where = $workshop->getAdapter()->quoteInto('status = ?', 'enabled');
     $workshops = $workshop->fetchAll($where, 'title');
     $workshopList = array();
     $workshopList[0] = "";
     foreach ($workshops as $w) {
         $workshopList[$w->workshopId] = $w->title;
     }
     $this->view->workshops = $workshopList;
     $location = new Location();
     $where = $location->getAdapter()->quoteInto('status = ?', 'enabled');
     $locations = $location->fetchAll($where, 'name');
     if (count($locations) == 0) {
         $this->_helper->redirector->gotoUrl('/workshop/schedule/noLocationsFound');
     }
     foreach ($locations as $l) {
         $locationList[$l->locationId] = $l->name;
     }
     $this->view->locationList = $locationList;
     //get all the users available for the instructor list
     $profile = new Ot_Account();
     $profiles = $profile->fetchAll(null, array('lastName', 'firstName'))->toArray();
     $instructors = array();
     foreach ($profiles as $p) {
         $instructors[$p['username']] = $p['lastName'] . ", " . $p['firstName'];
     }
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->instructors = $instructors;
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/public/scripts/jMonthCalendar-1.1.0.js');
     //$this->view->headScript()->appendFile($this->view->baseUrl() . '/scripts/jMonthCalendar-1.2.2.js');
     $this->view->headScript()->appendFile($this->view->baseUrl() . '/public/scripts/jquery.bt.min.js');
 }