Пример #1
1
 public function getkey($actionUrl = null, $mktime = null)
 {
     $actionUrl = $this->_getActionUrl($actionUrl);
     if ($mktime == null) {
         $lifetime = Centurion_Config_Manager::get('ticket.lifetime');
         list($lifetimeValue, $lifetimeUnit) = sscanf($lifetime, '%d%s');
         $mktime = new Zend_Date();
         switch ($lifetimeUnit) {
             case 'j':
             case 'd':
                 $mktime->setHour(0);
             case 'h':
                 $mktime->setMinute(0);
             case 'm':
             default:
                 $mktime->setSecond(0);
         }
     }
     if ($mktime instanceof Zend_Date) {
         $date = $mktime->toString('YYYYMMdd-HH:mm');
     } else {
         $date = date('Ymd-H:i', $mktime);
     }
     $salt = Centurion_Config_Manager::get('ticket.salt');
     $ticket = md5($salt . $actionUrl . $date);
     return $ticket;
 }
Пример #2
0
 public function date($value, $displayTime = false)
 {
     if ($displayTime) {
         $translate = Zend_Registry::get('Zend_Translate');
         $locale = key(Zend_Registry::get('Zend_Locale')->getDefault());
         $date = new Zend_Date($value, null, $locale);
         if ($date->isToday()) {
             $h = $date->toString('H');
             $m = $date->toString('m');
             $s = $date->toString('s');
             if (date('H') == $h) {
                 $min = (int) date('i') - (int) $m;
                 if ($min < 1) {
                     $sec = (int) date('s') - (int) $s;
                     if ($sec < 10) {
                         return $translate->_('now');
                     }
                     return $sec . ' ' . $translate->_('seconds ago');
                 }
                 return $min . ' ' . $translate->_('minutes ago');
             } elseif (date('H') > $h) {
                 return (int) date('H') - (int) $h . ' ' . $translate->_('hours ago');
             }
             return $date->toString('H:m');
         } else {
             return $date->toString('dd/MM/y H:m');
         }
     }
     return Zend_Filter::filterStatic($value, 'date', array(), 'Tri_Filter');
 }
Пример #3
0
 /**
  * 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;
 }
 public function indexAction()
 {
     $translate = Zend_Registry::get('Zend_Translate');
     $this->view->title = 'Duyệt chấm công - ' . $translate->_('TEXT_DEFAULT_TITLE');
     $this->view->headTitle($this->view->title);
     $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED;
     $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath);
     Zend_Layout::startMvc($option);
     $date = new Zend_Date();
     $date->subMonth(1);
     $thang = $this->_getParam('thang', $date->toString("M"));
     $nam = $this->_getParam('nam', $date->toString("Y"));
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     $em_id = $identity->em_id;
     $emModel = new Front_Model_Employees();
     $phongbanModel = new Front_Model_Phongban();
     $my_info = $emModel->fetchRow('em_id=' . $em_id . ' and em_status=1');
     $phong_ban_id = $list_phongban = $phong_ban = array();
     if ($my_info) {
         $phong_ban_id[] = $my_info->em_phong_ban;
         $list_phongban = $phongbanModel->fetchDataStatus($my_info->em_phong_ban, $phong_ban);
     }
     if (sizeof($list_phongban)) {
         foreach ($list_phongban as $phong_ban_info) {
             $phong_ban_id[] = $phong_ban_info->pb_parent;
         }
     }
     $phong_ban_id = implode(',', $phong_ban_id);
     $list_nhan_vien = $emModel->fetchAll("em_phong_ban in ({$phong_ban_id}) and em_status=1");
     $this->view->list_nhan_vien = $list_nhan_vien;
     $this->view->thang = $thang;
     $this->view->nam = $nam;
 }
Пример #5
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();
     $filter = new Zend_Filter_LocalizedToNormalized(array('precision' => 2));
     $number = self::returnApiData("https://api.clickbank.com/rest/1.3/orders/count?startDate=" . $dStartDate->toString("yyyy-MM-dd") . "&endDate=" . $dEndDate->toString("yyyy-MM-dd"));
     if ($number[0] != 0) {
         $transactionXMLList = self::returnApiData("https://api.clickbank.com/rest/1.3/orders/list?startDate=" . $dStartDate->toString("yyyy-MM-dd") . "&endDate=" . $dEndDate->toString("yyyy-MM-dd"));
         foreach ($transactionXMLList as $transactionXML) {
             $transactionXML = simplexml_load_string($transactionXML, null, LIBXML_NOERROR | LIBXML_NOWARNING);
             foreach ($transactionXML->orderData as $singleTransaction) {
                 $transaction = array();
                 $transaction['merchantId'] = 1;
                 $transactionDate = new Zend_Date(self::findAttribute($singleTransaction, 'date'), 'yyyy-MM-ddTHH:mm:ss');
                 $transaction['date'] = $transactionDate->toString("yyyy-MM-dd HH:mm:ss");
                 unset($transactionDate);
                 if (self::findAttribute($singleTransaction, 'affi') != null) {
                     $transaction['custom_id'] = self::findAttribute($singleTransaction, 'affi');
                 }
                 $transaction['unique_id'] = self::findAttribute($singleTransaction, 'receipt');
                 $transaction['amount'] = (double) $filter->filter(self::findAttribute($singleTransaction, 'amount'));
                 $transaction['commission'] = (double) $filter->filter(self::findAttribute($singleTransaction, 'amount'));
                 //if (self::findAttribute($singleTransaction, 'txnType') == 'RFND'){
                 //	$transaction['status'] = Oara_Utilities::STATUS_DECLINED;
                 //} else {
                 $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
                 //}
                 $totalTransactions[] = $transaction;
             }
         }
     }
     return $totalTransactions;
 }
Пример #6
0
 /**
  * (non-PHPdoc)
  * @see library/Oara/Network/Oara_Network_Publisher_Interface#getTransactionList($aMerchantIds, $dStartDate, $dEndDate, $sTransactionStatus)
  */
 public function getTransactionList($merchantList = null, Zend_Date $dStartDate = null, Zend_Date $dEndDate = null, $merchantMap = null)
 {
     $totalTransactions = array();
     $urls = array();
     $url = "http://www.foxtransfer.eu/index.php?q=prices.en.html&page=affiliate_orders&language=1&basedir=theme2&what=record_time&what=record_time&fy={$dStartDate->toString("yyyy")}&fm={$dStartDate->toString("M")}&fd={$dStartDate->toString("d")}&ty={$dEndDate->toString("yyyy")}&tm={$dEndDate->toString("M")}&td={$dEndDate->toString("d")}";
     $urls[] = new Oara_Curl_Request($url, array());
     $exportReport = array();
     $exportReport = $this->_client->get($urls);
     $exportReport = str_replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", "", $exportReport);
     $dom = new Zend_Dom_Query($exportReport[0]);
     $tableList = $dom->query('#tartalom-hatter table[cellspacing="0"][cellpadding="3"][border="0"]');
     $exportData = self::htmlToCsv(self::DOMinnerHTML($tableList->current()));
     $num = count($exportData);
     for ($i = 3; $i < $num; $i++) {
         $transactionExportArray = str_getcsv($exportData[$i], ";");
         $transaction = array();
         $transaction['merchantId'] = 1;
         $transaction['unique_id'] = $transactionExportArray[0];
         $transaction['date'] = "{$dStartDate->toString("yyyy")}-{$dStartDate->toString("MM")}-01 00:00:00";
         if ($transactionExportArray[7] == "Confirmed") {
             $transaction['status'] = Oara_Utilities::STATUS_CONFIRMED;
         } else {
             if ($transactionExportArray[7] == "Cancelled") {
                 $transaction['status'] = Oara_Utilities::STATUS_DECLINED;
             } else {
                 throw new Exception("New status found");
             }
         }
         $transaction['amount'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionExportArray[10]));
         $transaction['commission'] = Oara_Utilities::parseDouble(preg_replace("/[^0-9\\.,]/", "", $transactionExportArray[13]));
         $totalTransactions[] = $transaction;
     }
     return $totalTransactions;
 }
 public function indexAction()
 {
     $translate = Zend_Registry::get('Zend_Translate');
     $this->view->title = 'Thống kê tháng - ' . $translate->_('TEXT_DEFAULT_TITLE');
     $this->view->headTitle($this->view->title);
     $layoutPath = APPLICATION_PATH . '/templates/' . TEMPLATE_USED;
     $option = array('layout' => '1_column/layout', 'layoutPath' => $layoutPath);
     Zend_Layout::startMvc($option);
     $date = new Zend_Date();
     $date->subMonth(1);
     $thang = $this->_getParam('thang', $date->toString("M"));
     $nam = $this->_getParam('nam', $date->toString("Y"));
     $auth = Zend_Auth::getInstance();
     $identity = $auth->getIdentity();
     $em_id = $identity->em_id;
     $holidaysModel = new Front_Model_Holidays();
     $list_holidays = $holidaysModel->fetchData(array(), 'hld_order ASC');
     $xinnghiphepModel = new Front_Model_XinNghiPhep();
     $list_nghi_phep = $xinnghiphepModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $chamcongModel = new Front_Model_ChamCong();
     $cham_cong = $chamcongModel->fetchOneData(array('c_em_id' => $em_id, 'c_thang' => $thang, 'c_nam' => $nam));
     $khenthuongModel = new Front_Model_KhenThuong();
     $khen_thuong = $khenthuongModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $kyluatModel = new Front_Model_KyLuat();
     $ky_luat = $kyluatModel->fetchByDate($em_id, "{$nam}-{$thang}-01 00:00:00", "{$nam}-{$thang}-31 23:59:59");
     $this->view->cham_cong = $cham_cong;
     $this->view->thang = $thang;
     $this->view->nam = $nam;
     $this->view->list_holidays = $list_holidays;
     $this->view->list_nghi_phep = $list_nghi_phep;
     $this->view->khen_thuong = $khen_thuong;
     $this->view->ky_luat = $ky_luat;
 }
Пример #8
0
 /**
  * Set the backup file content
  *
  * @param string $content
  * @return AW_Lib_Model_Log_Logger
  */
 public function createBackupFile($content)
 {
     if (!extension_loaded("zlib") || !$content) {
         return $this;
     }
     $date = new Zend_Date();
     $fileName = $date->toString(Varien_Date::DATE_INTERNAL_FORMAT) . self::BACKUP_DEFAULT_FILE_NAME;
     $pathToBackupDir = Mage::getBaseDir() . self::PATH_TO_BACKUP_DIR;
     $pathToBackupFile = $pathToBackupDir . $fileName;
     $backupFile = fopen($pathToBackupFile, 'w');
     if (!$backupFile) {
         return $this;
     }
     $fwrite = fwrite($backupFile, $content);
     if (!$fwrite) {
         fclose($backupFile);
         unlink($pathToBackupFile);
         return $this;
     }
     $archiveName = $date->toString(Varien_Date::DATE_INTERNAL_FORMAT) . self::BACKUP_DEFAULT_ARCHIVE_NAME;
     $pathToBackupArchive = $pathToBackupDir . $archiveName;
     $zipArchive = new ZipArchive();
     $zipArchive->open($pathToBackupArchive, ZIPARCHIVE::CREATE);
     $zipArchive->addFile($pathToBackupFile, $fileName);
     $zipArchive->close();
     fclose($backupFile);
     unlink($pathToBackupFile);
     return $this;
 }
Пример #9
0
 public function findallAction()
 {
     if ($value_id = $this->getRequest()->getParam('value_id')) {
         try {
             $option = $this->getCurrentOptionValue();
             $start_at = new Zend_Date();
             $end_at = new Zend_Date();
             $format = 'y-MM-dd HH:mm:ss';
             $offset = $this->getRequest()->getParam('offset', 0);
             $events = $option->getObject()->getEvents($offset);
             $data = array('collection' => array());
             foreach ($events as $key => $event) {
                 $start_at->set($event->getStartAt(), $format);
                 $end_at->set($event->getEndAt(), $format);
                 $formatted_start_at = $start_at->toString($this->_("MM.dd.y"));
                 $subtitle2 = $this->_("Entrance: %s", $event->getStartTimeAt());
                 if ($event->getLocationLabel()) {
                     $subtitle2 .= " | " . $this->_("Location: %s", $event->getLocationLabel());
                 }
                 $data['collection'][] = array("id" => $key, "title" => $event->getName(), "title2" => "{$start_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_start_at}", "name" => $event->getName(), "subtitle" => $event->getSubtitle(), "subtitle2" => $subtitle2, "description" => $event->getDescription(), "month_name_short" => $start_at->toString(Zend_Date::MONTH_NAME_SHORT), "day" => $start_at->toString('dd'), "weekday_name" => $start_at->toString(Zend_Date::WEEKDAY_NAME), "start_time_at" => $event->getStartTimeAt(), "location" => $event->getLocation(), "url" => $this->getPath("event/mobile_view/index", array('value_id' => $option->getId(), "event_id" => $key)));
             }
             $data['page_title'] = $option->getTabbarName();
             $data['displayed_per_page'] = Event_Model_Event::DISPLAYED_PER_PAGE;
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
 public function selectedrequestcovenantAction()
 {
     $responce = new stdClass();
     $cdrequest = $_POST["idrequest"];
     $requestModel = new RequestModel();
     $clientCovenant = $requestModel->fetchRow($requestModel->getClientCovenantForward($cdrequest));
     if ($clientCovenant['dtbirth'] != '') {
         $dtbirth = new Zend_Date($clientCovenant['dtbirth'], 'dd-MM-YYYY');
         $year = $dtbirth->toString('YYYY');
         $month = $dtbirth->toString('MM');
         $day = $dtbirth->toString('dd');
         $today = new Zend_Date();
         $tdYear = $today->toString('YYYY');
         $tdMonth = $today->toString('MM');
         $tdDay = $today->toString('dd');
         $nrage = 0;
         $nrage = GslabUtils::calcAgeDifferenceShort($clientCovenant['dtbirth']);
         if ($tdMonth < $month || $tdMonth == $month && $tdDay < $day) {
             $nrage--;
         }
     } else {
         $nrage = " ";
     }
     $responce->forward = $clientCovenant['nmforward'];
     $responce->covenant = $clientCovenant['nmcovenant'];
     $responce->client = $clientCovenant['nmclient'];
     $responce->fgsex = $clientCovenant['fgsex'];
     $responce->age = $nrage;
     $responce = json_encode($responce);
     print_r($responce);
     return $responce;
 }
Пример #11
0
 public function getSavedTime()
 {
     $seconds = intval(Mage::helper('asyncindex')->getVariable('time'));
     $time = new Zend_Date();
     $time->setTime('00:00:00');
     $time->addSecond($seconds);
     return $time->toString('HH') . ' hr ' . $time->toString('mm') . ' min ' . $time->toString('ss') . ' sec';
 }
 public function viewCheckChuNhatThuBay($day = 0, $month = 0, $year = 0)
 {
     Zend_Date::setOptions(array('format_type' => 'php'));
     $date = new Zend_Date($day . '/' . $month . '/' . $year, 'd/m/Y');
     if ($date->toString('D') == 'CN' || $date->toString('D') == 'Th 7') {
         return 'class="error"';
     }
 }
Пример #13
0
 /**
  * Переводит строку datestamp, datetime из формата mysql в dd.MM.yyy
  *
  * @param $date строка даты
  * @param bool $showTime показывать время
  * @return string дата в необходимом формате 
  */
 public function toDate($date, $showTime = false)
 {
     $d = new Zend_Date($date);
     if ($showTime) {
         return $d->toString('dd.MM.yyyy, HH:mm');
     }
     return $d->toString('dd.MM.yyyy');
 }
Пример #14
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();
     $pathGsutil = realpath(dirname(__FILE__)) . '/../../../../../gsutil/gsutil';
     $dirDestination = realpath(dirname(__FILE__)) . '/../../data/pdf';
     $file = "{$this->_bucket}/sales/salesreport_" . $dStartDate->toString("yyyyMM") . ".zip";
     $url = "http://affjet.dc.fubra.net/tools/gsutil/gs.php?bucket=" . urlencode($file) . "&type=cp";
     $context = \stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode("{$this->_httpLogin}"))));
     \file_put_contents($dirDestination . "/report.zip", \file_get_contents($url, false, $context));
     $zip = new \ZipArchive();
     if ($zip->open($dirDestination . "/report.zip") === TRUE) {
         $zip->extractTo($dirDestination);
         $zip->close();
     } else {
         return $totalTransactions;
     }
     unlink($dirDestination . "/report.zip");
     $salesReport = file_get_contents($dirDestination . "/salesreport_" . $dStartDate->toString("yyyyMM") . ".csv");
     $salesReport = explode("\n", $salesReport);
     for ($i = 1; $i < count($salesReport) - 1; $i++) {
         $row = str_getcsv($salesReport[$i], ",");
         $sub = false;
         if ($row[12] < 0) {
             $sub = true;
         }
         $obj = array();
         $obj['unique_id'] = $row[0] . $row[3];
         $obj['merchantId'] = "1";
         $obj['date'] = $row[1] . " 00:00:00";
         $obj['custom_id'] = $row[5];
         $comission = 0.3;
         if ($row[6] == "com.petrolprices.app") {
             $value = 2.99;
             $obj['amount'] = Oara_Utilities::parseDouble($value);
             $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
         } else {
             if ($row[6] == "com.fubra.wac") {
                 if ($obj['date'] < "2013-04-23 00:00:00") {
                     $value = 0.6899999999999999;
                     $obj['amount'] = Oara_Utilities::parseDouble($value);
                     $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                 } else {
                     $value = 1.49;
                     $obj['amount'] = Oara_Utilities::parseDouble($value);
                     $obj['commission'] = Oara_Utilities::parseDouble($value - $value * $comission);
                 }
             }
         }
         if ($sub) {
             $obj['amount'] = -$obj['amount'];
             $obj['commission'] = -$obj['commission'];
         }
         $obj['status'] = Oara_Utilities::STATUS_CONFIRMED;
         $totalTransactions[] = $obj;
     }
     unlink($dirDestination . "/salesreport_" . $dStartDate->toString("yyyyMM") . ".csv");
     return $totalTransactions;
 }
Пример #15
0
 public function formatValue($str = null, $fancy = false)
 {
     if (!is_null($str)) {
         $date = new \Zend_Date($str);
         return $fancy ? $date->toString(\Zend_Date::DATE_LONG) : $date->toString('dd/MM/yyyy');
     } else {
         return $str;
     }
 }
Пример #16
0
 /**
  * @see Document\Tag\TagInterface::frontend
  */
 public function frontend()
 {
     if (!isset($this->options["output"]) || !$this->options["output"]) {
         $this->options["output"] = \Zend_Date::DATE_MEDIUM;
     }
     if ($this->date instanceof \Zend_Date) {
         return $this->date->toString($this->options["format"], "php");
     }
 }
Пример #17
0
 public function getOldPromotions($subDay = 30)
 {
     $date = new Zend_Date();
     $now = $date->toString('y-MM-dd');
     $date->subDay($subDay);
     $before = $date->toString('y-MM-dd');
     $where = join(' AND ', array($this->_db->quoteInto('end_at < ?', $now), $this->_db->quoteInto('end_at > ?', $before)));
     return $this->fetchAll($where);
 }
Пример #18
0
 public function sendReportEmail()
 {
     $websites = Mage::app()->getWebsites(true);
     $helper = Mage::helper('affiliateplus/config');
     foreach ($websites as $website) {
         if (!$website->getConfig('affiliateplus/email/is_sent_report')) {
             continue;
         }
         $periodData = array('week' => array('date' => 'w', 'label' => $helper->__('last week')), 'month' => array('date' => 'j', 'label' => $helper->__('last month')), 'year' => array('date' => 'z', 'label' => $helper->__('last year')));
         $period = $website->getConfig('affiliateplus/email/report_period');
         if (date($periodData[$period]['date']) != 1) {
             continue;
         }
         $store = $website->getDefaultStore();
         if (!$store) {
             continue;
         }
         $storeId = $store->getId();
         $accounts = Mage::getResourceModel('affiliateplus/account_collection')->addFieldToFilter('main_table.status', 1)->addFieldToFilter('main_table.notification', 1);
         $accounts->getSelect()->joinLeft(array('e' => $accounts->getTable('customer/entity')), 'main_table.customer_id	= e.entity_id', array('website_id'))->where('e.website_id = ?', $website->getId())->where('e.is_active = 1');
         //edit by Sally
         $date = new Zend_Date();
         $to = $date->toString();
         //$to = Mage::helper('core')->formatDate($date,'medium', true);
         $to = Mage::getModel('core/locale')->storeDate(Mage::app()->getStore(), $to, true)->toString('dd-MM-YYYY HH:mm:ss');
         $function = 'sub' . ucfirst($period);
         $fromDate = $date->{$function}(1)->toString('YYYY-MM-dd');
         $from = $date->toString();
         // $from = Mage::helper('core')->formatDate($date,'medium', true);
         $from = Mage::getModel('core/locale')->storeDate(Mage::app()->getStore(), $from, true)->toString('dd-MM-YYYY HH:mm:ss');
         //end by Sally
         $translate = Mage::getSingleton('core/translate');
         $translate->setTranslateInline(false);
         $template = $website->getConfig('affiliateplus/email/report_template');
         $sender = Mage::getStoreConfig('trans_email/ident_sales', $store);
         foreach ($accounts as $account) {
             $statistic = new Varien_Object();
             $transactions = Mage::getResourceModel('affiliateplus/transaction_collection')->addFieldToFilter('account_id', $account->getId());
             $transactions->getSelect()->reset(Zend_Db_Select::COLUMNS)->where('date(created_time) >= ?', $fromDate)->columns(array('status', 'sales' => 'SUM(`total_amount`)', 'transactions' => 'COUNT(`transaction_id`)', 'commissions' => 'SUM(`commission`+`commission`*`percent_plus`+`commission_plus`)'))->group('status');
             foreach ($transactions as $transaction) {
                 if ($transaction->getStatus() == 1) {
                     $statistic->setData('complete', $transaction->getData());
                 } elseif ($transaction->getStatus() == 2) {
                     $statistic->setData('pending', $transaction->getData());
                 } elseif ($transaction->getStatus() == 3) {
                     $statistic->setData('cancel', $transaction->getData());
                 }
             }
             $actions = Mage::getResourceModel('affiliateplus/action_collection');
             $actions->getSelect()->reset(Zend_Db_Select::COLUMNS)->where('account_id = ?', $account->getId())->where('type = ?', 2)->where('created_date >= ?', $fromDate)->columns(array('clicks' => 'SUM(totals)', 'unique' => 'SUM(is_unique)'))->group('account_id');
             $statistic->setData('click', $actions->getFirstItem()->getData());
             $mailTemplate = Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($template, $sender, $account->getEmail(), $account->getName(), array('store' => $store, 'account' => $account, 'statistic' => $statistic, 'period' => $helper->__($period), 'label' => $periodData[$period]['label'], 'from' => $from, 'to' => $to));
         }
         $translate->setTranslateInline(true);
     }
 }
Пример #19
0
 /**
  * @see Document_Tag_Interface::frontend
  */
 public function frontend()
 {
     Pimcore_Date::setOptions(array('format_type' => 'php'));
     if (!$this->options["output"]) {
         $this->options["output"] = Zend_Date::DATE_MEDIUM;
     }
     if ($this->date instanceof Zend_Date) {
         return $this->date->toString($this->options["format"]);
     }
 }
Пример #20
0
 /**
  * @see Document\Tag\TagInterface::frontend
  */
 public function frontend()
 {
     if (!isset($this->options["format"]) || !$this->options["format"]) {
         $this->options["format"] = \DateTime::ISO8601;
     }
     if ($this->date instanceof \Zend_Date) {
         return $this->date->toString($this->options["format"], "php");
     } elseif ($this->date instanceof \DateTimeInterface) {
         return $this->date->formatLocalized($this->options["format"]);
     }
 }
Пример #21
0
Файл: Date.php Проект: abdala/la
 /**
  * Filter date
  *
  * @param string $value
  * @return null|string
  */
 public function filter($value)
 {
     if ($value) {
         $date = new Zend_Date($value, null, $this->_options['locale']);
         if (Zend_Date::isDate($value, $this->_options['date_format'], $this->_options['locale'])) {
             return $date->toString('yyyy-MM-dd');
         } else {
             return $date->toString($this->_options['date_format']);
         }
     }
     return null;
 }
Пример #22
0
 public function formatDate($date, $format = 'dmy', $formatStr = 'dd.mm.yy')
 {
     $locale = new Zend_Locale('ru_RU.UTF-8');
     if (!$date instanceof Zend_Date) {
         $date = new Zend_Date($date, 'YYYY-MM-dd HH:mm:ss', $locale);
     }
     if ($format != null && array_key_exists($format, $this->_formats)) {
         return $date->toString($this->_formats[$format], null, $locale);
     } elseif ($formatStr != null) {
         return $date->toString($formatStr, null, $locale);
     } else {
         return $date;
     }
 }
Пример #23
0
 public function formatDate($date, $formatName, $formatStr = '')
 {
     if (!Zend_Date::isDate($date)) {
         return $date;
     } else {
         $date = new Zend_Date($date);
         if ($formatName != null && in_array($this->date_formats, $formatName)) {
             return $date->toString($this->date_formats[$formatName]);
         } else {
             if ($formatStr != null) {
                 return $date->toString($formatStr);
             }
         }
     }
 }
Пример #24
0
 public function getMagentoCronStatusToHtml($fieldName = 'scheduled_at')
 {
     $scheduleCollection = Mage::getModel('cron/schedule')->getCollection();
     $scheduleCollection->setOrder($fieldName);
     $scheduleModel = $scheduleCollection->getFirstItem();
     $result = sprintf(self::ERROR_RESULT, $this->__('Never'));
     if ($scheduleModel->getId() && $scheduleModel->getData($fieldName) != '0000-00-00 00:00:00') {
         $findDate = new Zend_Date($scheduleModel->getData($fieldName), Varien_Date::DATETIME_INTERNAL_FORMAT);
         $today = new Zend_Date(null, Zend_Date::DATE_SHORT);
         $result = sprintf(self::SUCCESS_RESULT, $findDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
         if ($findDate->compare($today, Zend_Date::DATE_SHORT) < 0) {
             $result = sprintf(self::ERROR_RESULT, $findDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
         }
     }
     return $result;
 }
Пример #25
0
 public function insert(array $data)
 {
     $date = new Zend_Date();
     $data['datebug'] = $date->toString('Y-MM-d');
     $data['statut'] = "Non lu";
     return parent::insert($data);
 }
Пример #26
0
 public function collectValidatedAttributes($productCollection)
 {
     $attribute = $this->getAttribute();
     $arr = explode('_', $attribute);
     $type = $arr[0];
     $period = $arr[1];
     $date = new Zend_Date();
     $date->sub($period * 24 * 60 * 60);
     $resource = Mage::getSingleton('core/resource');
     $connection = $resource->getConnection('core_read');
     switch ($type) {
         case 'clicks':
             $expr = new Zend_Db_Expr('SUM(clicks)');
             break;
         case 'orders':
             $expr = new Zend_Db_Expr('SUM(orders)');
             break;
         case 'revenue':
             $expr = new Zend_Db_Expr('SUM(revenue)');
             break;
         case 'cr':
             $expr = new Zend_Db_Expr('SUM(orders) / SUM(clicks) * 100');
             break;
     }
     $select = $connection->select();
     $select->from(array('ta' => $resource->getTableName('feedexport/performance_aggregated')), array($expr))->where('ta.product_id = e.entity_id')->where('ta.period >= ?', $date->toString('YYYY-MM-dd'));
     $select = $productCollection->getSelect()->columns(array($attribute => $select));
     return $this;
 }
Пример #27
0
 /**
  * Get trip paginator adapter
  * @param string $filtingField
  * @param string $filtingCriteria
  * @param string $sortingField
  * @return Zend_Paginator_Adapter_DbSelect|Zend_Paginator_Adapter_DbTableSelect
  */
 public function getTripPaginatorAdapter($filtingField, $filtingCriteria, $sortingField)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
     if (!empty($filtingField)) {
         // switch filting field
         switch ($filtingField) {
             case 'departure_time':
             case 'arrival_time':
                 if (!empty($filtingCriteria)) {
                     $dateFormat = new Zend_Date($filtingCriteria, 'dd-MM-y HH:mm:ss');
                     $filtingCriteria = $dateFormat->toString('y-MM-dd HH:mm:ss');
                 }
                 break;
             case 'from_city':
             case 'to_city':
                 $db = Zend_Db_Table::getDefaultAdapter();
                 $select = $db->select()->from(array('t' => 'trip'), array('t.trip_id', 't.departure_time', 't.arrival_time', 'fare'))->joinInner(array('r' => 'route'), 't.route_id = r.route_id', array('r.from_city', 'r.to_city'));
                 break;
             default:
                 break;
         }
         // add filting criteria
         $select->where($filtingField . ' = ?', $filtingCriteria);
     }
     // add sorting criteria
     if (!empty($sortingField)) {
         $select->order($sortingField);
     }
     $adapter = new Zend_Paginator_Adapter_DbSelect($select);
     return $adapter;
 }
Пример #28
0
 /**
  * @param date $d data a ser comparada
  */
 public function getDays($d)
 {
     $now = time();
     $date = new Zend_Date($d, Zend_Date::ISO_8601);
     $time = $now - $date->getTimestamp();
     if ($time < 86400) {
         //60*60*24
         $time = 'hoje';
     } elseif ($time < 172800) {
         //60*60*24*2
         $time = 'ontem';
         //mostrar quantidade de dias até 14 dias
     } elseif ($time < 604800) {
         //60*60*24*30
         $time = 'há ' . round(floatval($time) / 86400) . ' dias';
         //mostrar quantidades de semanas apartir da 2 semana até 1 mes
     } elseif ($time > 1209600 && $time <= 2592000) {
         //60*60*24*(7*4)
         $time = 'há ' . round(floatval($time) / 604800) . ' semanas';
     } elseif ($time > 2592000 && $time <= 5184000) {
         //60*60*24*30 && 60*60*24*30*2
         $time = 'há ' . round(floatval($time) / 2592000) . ' mês';
     } elseif ($time > 5184000 && $time < 31104000) {
         //60*60*24*30*2  && 60*60*24*30*12
         $time = 'há ' . round(floatval($time) / 2592000) . ' meses';
     } else {
         //if ($time < 31104000) { //60*60*24*30*12
         $time = 'há mais de um ano (' . $date->toString() . ')';
     }
     return $time;
 }
Пример #29
0
 public function isValid($value)
 {
     $front = Zend_Controller_Front::getInstance()->getRequest();
     $action = $front->action;
     if ($action == "edit-evento") {
         return true;
     }
     if (!isset($value) or empty($value)) {
         return false;
     }
     //date_default_timezone_set( 'America/Sao_Paulo' );
     //  Zend_Registry::get('logger')->log("valor=", Zend_Log::INFO);
     // Zend_Registry::get('logger')->log($value, Zend_Log::INFO);
     $date = new Zend_Date();
     $data = new Zend_Date($date->toString('dd/MM/YYYY'));
     $data2 = new Zend_Date($value);
     $comparacao = $data->isLater($data2);
     $comparacao2 = $data->isEarlier($data2);
     $comparacao3 = $data->equals($data2);
     // Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO);
     //  Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO);
     // Zend_Registry::get('logger')->log($comparacao3, Zend_Log::INFO);
     if ($comparacao3 || $comparacao2) {
         Zend_Registry::get('logger')->log("data igual ou maior", Zend_Log::INFO);
     } else {
         $this->_setValue($value);
         //	Zend_Registry::get('logger')->log("data menor", Zend_Log::INFO);
         $this->_error(self::INVALID);
         return false;
     }
     // $comparacao= $data->compare($date2);
     // Zend_Registry::get('logger')->log($comparacao, Zend_Log::INFO);
     //  Zend_Registry::get('logger')->log($comparacao2, Zend_Log::INFO);
     return true;
 }
Пример #30
0
 public function testFormatTime()
 {
     $this->assertEquals($this->_dateTime->format(self::TIME_FORMAT_SHORT), $this->_helper->formatTime());
     $this->assertEquals($this->_dateTime->format(self::DATETIME_FORMAT_SHORT), $this->_helper->formatTime(null, 'short', true));
     $zendDate = new Zend_Date($this->_dateTime->format('U'));
     $this->assertEquals($zendDate->toString(self::TIME_FORMAT_SHORT_ISO), $this->_helper->formatTime($zendDate, 'short'));
 }