/** * Find Day Begining Of Month * * @deprecated since 5.0.0 */ function mstart($month, $day, $year) { list($jyear, $jmonth, $jday) = gregorian_to_jalali($year, $month, $day); list($year, $month, $day) = jalali_to_gregorian($jyear, $jmonth, "1"); $timestamp = mktime(0, 0, 0, $month, $day, $year); return date("w", $timestamp); }
function _process() { global $messageStack, $osC_Database, $osC_Language, $osC_Customer; $data = array(); $j_to_g = array(); if (ACCOUNT_GENDER == '1') { if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) { $data['gender'] = $_POST['gender']; } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error')); } } else { $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : ''; } if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) { $data['firstname'] = $_POST['firstname']; } else { $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME)); } if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) { $data['lastname'] = $_POST['lastname']; } else { $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME)); } if (ACCOUNT_DATE_OF_BIRTH == '1') { if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && jcheckdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) { $j_to_g = jalali_to_gregorian($_POST['dob_years'], $_POST['dob_months'], $_POST['dob_days']); // tabdil shamsi be miladi $data['dob'] = mktime(0, 0, 0, $j_to_g['1'], $j_to_g['2'], $j_to_g['0']); } else { $messageStack->add('account_edit', $osC_Language->get('field_customer_date_of_birth_error')); } } if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) { if (osc_validate_email_address($_POST['email_address'])) { if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) { $data['email_address'] = $_POST['email_address']; } else { $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_exists_error')); } } else { $messageStack->add('account_edit', $osC_Language->get('field_customer_email_address_check_error')); } } else { $messageStack->add('account_edit', sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS)); } if ($messageStack->size('account_edit') === 0) { if (osC_Account::saveEntry($data)) { // reset the session variables if (ACCOUNT_GENDER > -1) { $osC_Customer->setGender($data['gender']); } $osC_Customer->setFirstName(trim($data['firstname'])); $osC_Customer->setLastName(trim($data['lastname'])); $osC_Customer->setEmailAddress($data['email_address']); $messageStack->add_session('account', $osC_Language->get('success_account_updated'), 'success'); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, null, 'SSL')); } }
/** * Formating date value before save * * Should set (bool, string) correct type for empty value from html form, * neccessary for farther proccess, else date string * * @param Varien_Object $object * @throws Mage_Eav_Exception * @return Mage_Eav_Model_Entity_Attribute_Backend_Datetime */ public function beforeSave($object) { $attributeName = $this->getAttribute()->getName(); $_formated = $object->getData($attributeName . '_is_formated'); if (!$_formated && $object->hasData($attributeName)) { try { if (Mage::app()->getLocale()->getLocale() == 'fa_IR') { require_once Mage::getBaseDir('lib') . '/pdate/pdate.php'; if ($object->getData($attributeName) != NULL) { list($j_y, $j_m, $j_d) = explode('/', $object->getData($attributeName)); $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d); $date = implode('-', $gregorianlArray); $object->setData($attributeName, $date); } } $value = $this->formatDate($object->getData($attributeName)); } catch (Exception $e) { throw Mage::exception('Mage_Eav', Mage::helper('eav')->__('Invalid date')); } if (is_null($value)) { $value = $object->getData($attributeName); } //Mage::log( "$attributeName, $value ") ; $object->setData($attributeName, $value); $object->setData($attributeName . '_is_formated', true); } return $this; }
private function makeFromJalali($time) { if (preg_match("#(\\d{2,4})([-/])(\\d{1,2})\\2(\\d{1,2})( +(\\d{1,2}):(\\d{1,2})(:(\\d{1,2}))?)?#", $time, $a)) { if (strlen($a[1]) == 2) { $a[1] = "13{$a[1]}"; } list($yy, $mm, $dd) = jalali_to_gregorian($a[1], $a[3], $a[4]); if (!isset($a[5])) { $a[5] = ' 00:00:00'; } $date = "{$yy}-{$mm}-{$dd} {$a[5]}"; return strtotime($date); } return 0; }
protected function _convertDate($date, $locale) { if ($this->getColumn()->getFilterTime()) { try { if (Mage::app()->getLocale()->getLocale() == 'fa_IR') { require_once Mage::getBaseDir('lib') . '/pdate/pdate.php'; list($j_y, $j_m, $j_d) = explode('/', $date); $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d); $date = implode('/', $gregorianlArray); } $dateObj = $this->getLocale()->date(null, null, $locale, false); //set default timezone for store (admin) $dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE)); //set date with applying timezone of store $dateObj->set($date, $this->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT), $locale); //convert store date to default date in UTC timezone without DST $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); return $dateObj; } catch (Exception $e) { return null; } } return parent::_convertDate($date, $locale); }
function days_of_year($jmonth, $jday, $jyear) { $year = ""; $month = ""; $year = ""; $result = ""; if ($jmonth == "01") { return $jday; } for ($i = 1; $i < $jmonth || $i == 12; $i++) { list($year, $month, $day) = jalali_to_gregorian($jyear, $i, "1"); $result += lastday($month, $day, $year); } return $result + $jday; }
function formatted_jalali_to_georgian($dt) { list($d, $t) = explode(" ", $dt); list($y, $m, $d) = explode("/", $d); list($y, $m, $d) = jalali_to_gregorian($y, $m, $d); return sprintf("%04d/%02d/%02d", $y, $m, $d) . " " . $t; }
protected function _prepareCollection() { if (Mage::app()->getLocale()->getLocale() == 'fa_IR') { require_once Mage::getBaseDir('lib') . '/pdate/pdate.php'; $from = $this->getFilterData()->getData('from'); list($j_y, $j_m, $j_d) = explode('-', $from); $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d); $gFrom = implode('/', $gregorianlArray); $this->getFilterData()->setFrom($gFrom); $to = $this->getFilterData()->getData('to'); list($j_y, $j_m, $j_d) = explode('-', $to); $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d); $gTo = implode('/', $gregorianlArray); $this->getFilterData()->setTo($gTo); } $filterData = $this->getFilterData(); if ($filterData->getData('from') == null || $filterData->getData('to') == null) { $this->setCountTotals(false); $this->setCountSubTotals(false); return parent::_prepareCollection(); } $storeIds = $this->_getStoreIds(); $orderStatuses = $filterData->getData('order_statuses'); if (is_array($orderStatuses)) { if (count($orderStatuses) == 1 && strpos($orderStatuses[0], ',') !== false) { $filterData->setData('order_statuses', explode(',', $orderStatuses[0])); } } $resourceCollection = Mage::getResourceModel($this->getResourceCollectionName())->setPeriod($filterData->getData('period_type'))->setDateRange($filterData->getData('from', null), $filterData->getData('to', null))->addStoreFilter($storeIds)->addOrderStatusFilter($filterData->getData('order_statuses'))->setAggregatedColumns($this->_getAggregatedColumns()); if ($this->_isExport) { $this->setCollection($resourceCollection); return $this; } if ($filterData->getData('show_empty_rows', false)) { Mage::helper('reports')->prepareIntervalsCollection($this->getCollection(), $filterData->getData('from', null), $filterData->getData('to', null), $filterData->getData('period_type')); } if ($this->getCountSubTotals()) { $this->getSubTotals(); } if ($this->getCountTotals()) { $totalsCollection = Mage::getResourceModel($this->getResourceCollectionName())->setPeriod($filterData->getData('period_type'))->setDateRange($filterData->getData('from', null), $filterData->getData('to', null))->addStoreFilter($storeIds)->addOrderStatusFilter($filterData->getData('order_statuses'))->setAggregatedColumns($this->_getAggregatedColumns())->isTotals(true); foreach ($totalsCollection as $item) { $this->setTotals($item); break; } } $this->getCollection()->setColumnGroupBy($this->_columnGroupBy); $this->getCollection()->setResourceCollection($resourceCollection); return parent::_prepareCollection(); }
protected function _prepareCollection() { $filter = $this->getParam($this->getVarNameFilter(), null); if (is_null($filter)) { $filter = $this->_defaultFilter; } if (is_string($filter)) { $data = array(); $filter = base64_decode($filter); parse_str(urldecode($filter), $data); if (!isset($data['report_from'])) { // getting all reports from 2001 year $date = new Zend_Date(mktime(0, 0, 0, 1, 1, 2001)); $data['report_from'] = $date->toString($this->getLocale()->getDateFormat('short')); } if (!isset($data['report_to'])) { // getting all reports from 2001 year $date = new Zend_Date(); $data['report_to'] = $date->toString($this->getLocale()->getDateFormat('short')); } $this->_setFilterValues($data); } else { if ($filter && is_array($filter)) { $this->_setFilterValues($filter); } else { if (0 !== sizeof($this->_defaultFilter)) { $this->_setFilterValues($this->_defaultFilter); } } } /** @var $collection Mage_Reports_Model_Resource_Report_Collection */ $collection = Mage::getResourceModel('reports/report_collection'); $collection->setPeriod($this->getFilter('report_period')); if ($this->getFilter('report_from') && $this->getFilter('report_to')) { /** * Validate from and to date */ try { if (Mage::app()->getLocale()->getLocale() == 'fa_IR') { require_once Mage::getBaseDir('lib') . '/pdate/pdate.php'; $from = $this->getFilter('report_from'); list($j_y, $j_m, $j_d) = explode('/', $from); $From = jalali_to_gregorian($j_y, $j_m, $j_d); $report_from = implode('/', $From); $to = $this->getFilter('report_to'); list($j_y, $j_m, $j_d) = explode('/', $to); $gTo = jalali_to_gregorian($j_y, $j_m, $j_d); $report_to = implode('/', $gTo); $part = Zend_Date::DATE_MEDIUM; } else { $report_from = $this->getFilter('report_from'); $report_to = $this->getFilter('report_to'); $part = Zend_Date::DATE_SHORT; } $from = $this->getLocale()->date($report_from, $part, null, false); $to = $this->getLocale()->date($report_to, $part, null, false); $collection->setInterval($from, $to); } catch (Exception $e) { $this->_errors[] = Mage::helper('reports')->__('Invalid date specified.'); } } /** * Getting and saving store ids for website & group */ $storeIds = array(); if ($this->getRequest()->getParam('store')) { $storeIds = array($this->getParam('store')); } elseif ($this->getRequest()->getParam('website')) { $storeIds = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getStoreIds(); } elseif ($this->getRequest()->getParam('group')) { $storeIds = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getStoreIds(); } // By default storeIds array contains only allowed stores $allowedStoreIds = array_keys(Mage::app()->getStores()); // And then array_intersect with post data for prevent unauthorized stores reports $storeIds = array_intersect($allowedStoreIds, $storeIds); // If selected all websites or unauthorized stores use only allowed if (empty($storeIds)) { $storeIds = $allowedStoreIds; } // reset array keys $storeIds = array_values($storeIds); $collection->setStoreIds($storeIds); if ($this->getSubReportSize() !== null) { $collection->setPageSize($this->getSubReportSize()); } $this->setCollection($collection); Mage::dispatchEvent('adminhtml_widget_grid_filter_collection', array('collection' => $this->getCollection(), 'filter_values' => $this->_filterValues)); }
$adult = array(); $roomscount = $_POST['room-num']; for ($k = 1; $k <= $roomscount; $k++) { $adult[$k] = $_POST['room-' . $k . '-ad-num']; } foreach ($_POST as $key => $value) { $_SESSION[$key] = $_POST[$key]; } $arr = split('_', $_SESSION['city_id']); $country = $arr[0]; $city = $arr[1]; $_SESSION['city'] = $city; $arr_in = split('/', $_SESSION['date-in']); $_SESSION['check-in'] = jalali_to_gregorian($arr_in[0], $arr_in[1], $arr_in[2], '/'); $arr_in = split('/', $_SESSION['date-out']); $_SESSION['check-out'] = jalali_to_gregorian($arr_in[0], $arr_in[1], $arr_in[2], '/'); $arr = explode('_', $_POST['city_id']); $r = new Request(); $ctrl = new HotelController(); $ctrl->safar_Aviable(); break; case 'gallery': $ctrl = new HotelController(); $ctrl->Gallery($hid); break; case 'reserve': foreach ($_POST as $key => $item) { $_SESSION['Reserve'][$key] = $item; } //print_r($_SESSION['Reserve']);exit; $ctrl = new HotelController();
function print_annual_balance_breakdown_detail() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $title = _("Annual Balance Breakdown - Detailed"); $output_filename = "AnnualBalanceBreakDownDetail"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 12; // 12 amount columns for ($i = 2; $i < 15; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } /* $header_row[] = "Fiscal Year Begin"; $header_row[] = "Fiscal YTD"; for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i+2] - $cols[$i+1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } */ if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 1); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->NewLine(); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $oldFontSize = $rep->fontSize; $rep->fontSize = 12; $rep->Font('b'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->fontSize = $oldFontSize; $rep->SetCellPadding($oldcMargin); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 5; $rep->Line($rep->row - 3); $rep->NewLine(); $rep->Font('b'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $fill = 0; $rep->TextCol(0, 1, _('Total') . " " . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $ctotal[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Net Assets (Liabilities)'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $sales[$i] * -1, $dec, 0, 4, 0, $fill, NULL, 1, true); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $convert = get_class_type_convert($class["ctype"]); //Print Class Name $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->Font('b'); $rep->TextCol(0, 1, _("Total ") . $class["class_name"], 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); $typeresult = get_account_types(false, $class['cid']); while ($accounttype = db_fetch($typeresult)) { $result = get_gl_accounts(null, null, $accounttype['id']); while ($account = db_fetch($result)) { $bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2); $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); for ($i = 1; $i <= 12; $i++) { $total[$i] += $balance[$i]; } } } for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, $total[$i] * $convert, $dec, 0, 4, 0, $fill, NULL, 1, true); $calc[$i] += $total[$i]; $total[$i] = 0; } $rep->NewLine(2); } $oldcMargin = $rep->GetCellPadding(); $rep->SetCellPadding(0); $rep->TextCol(0, 1, _('Total Profit/Loss'), 0, 4, 0, $fill, NULL, 1); $rep->SetCellPadding($oldcMargin); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol2($i, $i + 1, -$calc[$i], $dec, 0, 4, 0, $fill, NULL, 1, true); // no convert } $rep->Font(); $rep->End(); }
function jmktime($h = '', $m = '', $s = '', $jm = '', $jd = '', $jy = '', $is_dst = -1) { $h = tr_num($h); $m = tr_num($m); $s = tr_num($s); $jm = tr_num($jm); $jd = tr_num($jd); $jy = tr_num($jy); if ($h == '' and $m == '' and $s == '' and $jm == '' and $jd == '' and $jy == '') { return mktime(); } else { list($year, $month, $day) = jalali_to_gregorian($jy, $jm, $jd); return mktime($h, $m, $s, $month, $day, $year, $is_dst); } }
/** * return Unix timestamp for a date (jalali equivalent of php mktime() function) * @param int $hour [optional] max : 23 * @param int $minute [optional] max : 59 * @param int $second [optional] max: 59 * @param int $month [optional] max: 12 * @param int $day [optional] max: 31 * @param int $year [optional] * @param int $is_dst [optional] * @return timestamp * @since 5.0.0 */ function jmktime($hour = 0, $minute = 0, $second = 0, $month = 0, $day = 0, $year = 0, $is_dst = -1) { if ($hour == 0 && $minute == 0 && $second == 0 && $month == 0 && $day == 0 && $year == 0) { return time(); } list($year, $month, $day) = jalali_to_gregorian($year, $month, $day); return mktime($hour, $minute, $second, $month, $day, $year, $is_dst); }
/** * Convert given date to default (UTC) timezone * * @param string $date * @param string $locale * @return Zend_Date */ protected function _convertDate($date, $locale) { try { if (Mage::app()->getLocale()->getLocale() == 'fa_IR') { require_once Mage::getBaseDir('lib') . '/pdate/pdate.php'; list($j_y, $j_m, $j_d) = explode('/', $date); $gregorianlArray = jalali_to_gregorian($j_y, $j_m, $j_d); $date = implode('/', $gregorianlArray); } $dateObj = $this->getLocale()->date(null, null, $locale, false); //set default timezone for store (admin) $dateObj->setTimezone(Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE)); //set begining of day $dateObj->setHour(00); $dateObj->setMinute(00); $dateObj->setSecond(00); //set date with applying timezone of store $dateObj->set($date, Zend_Date::DATE_SHORT, $locale); //convert store date to default date in UTC timezone without DST $dateObj->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE); return $dateObj; } catch (Exception $e) { return null; } }
/** * own widget function */ function ztjalali_calendar_widget($shortname = TRUE, $echo = TRUE, $thisyear = 0, $thismonth = 0) { global $wpdb, $posts, $wp; global $jdate_month_name, $ztjalali_option; if (isset($wp->query_vars['m'])) { $m_year = (int) substr($wp->query_vars['m'], 0, 4); $m_month = (int) substr($wp->query_vars['m'], 4, 2); if ($m_year < 1700) { list($m_year, $m_month, $tmp_day) = jalali_to_gregorian($m_year, $m_month, 15); } } elseif (isset($wp->query_vars['m'])) { $thisyear = (int) substr($wp->query_vars['m'], 0, 4); } if (empty($thisyear)) { if (isset($wp->query_vars['year'])) { $thisyear = (int) $wp->query_vars['year']; } elseif (isset($m_year)) { $thisyear = $m_year; } else { $thisyear = date('Y', time()); } } if (empty($thismonth)) { if (isset($wp->query_vars['monthnum'])) { $thismonth = (int) $wp->query_vars['monthnum']; } elseif (isset($m_month)) { $thismonth = $m_month; } else { $thismonth = date('m', time()); } } //doing: support $_GET['w'] // if (isset($_GET['w'])) // $w = '' . (int)($_GET['w']); // if (!empty($w)) { //// We need to get the month from MySQL // $thisyear = '' . (int)(substr($m, 0, 4)); // $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's // $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')"); // } /* doing : cache */ $cache = array(); $key = md5($thismonth . $thisyear); if ($cache = wp_cache_get('ztjalali_calendar', 'calendar')) { if (is_array($cache) && isset($cache[$key])) { if ($echo) { /** This filter is documented in wp-includes/general-template.php */ echo apply_filters('ztjalali_calendar', $cache[$key]); return; } else { /** This filter is documented in wp-includes/general-template.php */ return apply_filters('ztjalali_calendar', $cache[$key]); } } } if (!is_array($cache)) { $cache = array(); } // Quick check. If we have no posts at all, abort! if (!$posts) { $gotsome = $wpdb->get_var("SELECT 1 as test FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1"); if (!$gotsome) { $cache[$key] = ''; wp_cache_set('ztjalali_calendar', $cache, 'calendar'); return; } } if ($thisyear > 1700) { list($thisyear, $thismonth, $thisday) = gregorian_to_jalali($thisyear, $thismonth, 1); } $unixmonth = jmktime(0, 0, 0, $thismonth, 1, $thisyear); $jthisyear = $thisyear; $jthismonth = $thismonth; list($thisyear, $thismonth, $jthisday) = jalali_to_gregorian($jthisyear, $jthismonth, 1); $last_day = jdate('t', $unixmonth, FALSE, FALSE); // Get the next and previous month and year with at least one post $startdate = date("Y:m:d", jmktime(0, 0, 0, $jthismonth, 1, $jthisyear)); $enddate = date("Y:m:d", jmktime(23, 59, 59, $jthismonth, $last_day, $jthisyear)); $previous = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_date < '{$startdate}'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date DESC\n\t\t\tLIMIT 1"); $next = $wpdb->get_row("SELECT DAYOFMONTH(post_date) AS `dayofmonth`,MONTH(post_date) AS month, YEAR(post_date) AS year\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_date > '{$enddate} 23:59:59'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\t\tORDER BY post_date ASC\n\t\t\tLIMIT 1"); /* translators: Calendar caption: 1: month name, 2: 4-digit year */ $calendar_caption = _x('%1$s %2$s', 'calendar caption'); $calendar_output = '<table id="wp-calendar" class="widget_calendar"> <caption>' . sprintf($calendar_caption, $jdate_month_name[(int) $jthismonth], jdate('Y', $unixmonth)) . '</caption> <thead> <tr>'; $myweek = $myshortweek = array(); $week_begins = (int) get_option('start_of_week'); for ($wdcount = 0; $wdcount <= 6; $wdcount++) { $myweek[] = ztjalali_get_week_name(($wdcount + $week_begins) % 7); $myshortweek[] = ztjalali_get_short_week_name(($wdcount + $week_begins) % 7); } foreach ($myweek as $k => $wd) { $day_name = true == $shortname ? $myshortweek[$k] : $wd; $wd = esc_attr($wd); $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>"; } $calendar_output .= ' </tr> </thead> <tfoot> <tr>'; if ($previous) { $jprevious = gregorian_to_jalali($previous->year, $previous->month, $previous->dayofmonth); if ($ztjalali_option['change_url_date_to_jalali']) { $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($jprevious[0], $jprevious[1]) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jprevious[1]], jdate('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">« ' . $jdate_month_name[$jprevious[1]] . '</a></td>'; } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jprevious[1]], jdate('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">« ' . $jdate_month_name[$jprevious[1]] . '</a></td>'; } } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad"> </td>'; } $calendar_output .= "\n\t\t" . '<td class="pad"> </td>'; if ($next) { $jnext = gregorian_to_jalali($next->year, $next->month, $next->dayofmonth); if ($ztjalali_option['change_url_date_to_jalali']) { $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($jnext[0], $jnext[1]) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jnext[1]], jdate('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $jdate_month_name[$jnext[1]] . ' »</a></td>'; } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'ztjalali'), $jdate_month_name[$jnext[1]], jdate('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">' . $jdate_month_name[$jnext[1]] . ' »</a></td>'; } } else { $calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad"> </td>'; } $calendar_output .= ' </tr> </tfoot> <tbody> <tr>'; // Get days with posts $dayswithposts = $wpdb->get_results("SELECT DISTINCT post_date\n\t\tFROM {$wpdb->posts} WHERE post_date >= '{$startdate} 00:00:00'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\tAND post_date <= '{$enddate} 23:59:59'", ARRAY_N); if ($dayswithposts) { foreach ((array) $dayswithposts as $daywith) { $jdaywithpost[] = jdate('j', strtotime($daywith[0]), FALSE, FALSE); } } else { $jdaywithpost = array(); } if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) { $ak_title_separator = "\n"; } else { $ak_title_separator = ', '; } $ak_titles_for_day = array(); $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, post_date as dom " . "FROM {$wpdb->posts} " . "WHERE post_date >= '{$startdate} 00:00:00' " . "AND post_date <= '{$enddate} 23:59:59' " . "AND post_type = 'post' AND post_status = 'publish'"); if ($ak_post_titles) { foreach ((array) $ak_post_titles as $ak_post_title) { /** This filter is documented in wp-includes/post-template.php */ $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID)); $jdom = $jdaywithpost[] = jdate('j', strtotime($ak_post_title->dom), FALSE, FALSE); if (empty($ak_titles_for_day['day_' . $jdom])) { $ak_titles_for_day['day_' . $jdom] = ''; } if (empty($ak_titles_for_day["{$jdom}"])) { // first one $ak_titles_for_day["{$jdom}"] = $post_title; } else { $ak_titles_for_day["{$jdom}"] .= $ak_title_separator . $post_title; } } } // See how much we should pad in the beginning $pad = calendar_week_mod(jdate('w', $unixmonth, false, false) - $week_begins); $pad--; if ($pad < 0) { $pad = 6; } if (0 != $pad) { $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad"> </td>'; } $jdaysinmonth = (int) jdate('t', $unixmonth, FALSE, FALSE); for ($jday = 1; $jday <= $jdaysinmonth; ++$jday) { if (isset($newrow) && $newrow) { $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t"; } $newrow = false; if ($jday == jdate('j', time(), FALSE, FALSE) && $jthismonth == jdate('m', time(), FALSE, FALSE) && $jthisyear == jdate('Y', time(), FALSE, FALSE)) { $calendar_output .= '<td id="today">'; } else { $calendar_output .= '<td>'; } if (in_array($jday, $jdaywithpost)) { // any posts today? $day = jalali_to_gregorian($jthisyear, $jthismonth, $jday); if ($ztjalali_option['change_url_date_to_jalali']) { $calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $jday) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">{$jday}</a>"; } else { $calendar_output .= '<a href="' . get_day_link($day[0], $day[1], $day[2]) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">{$jday}</a>"; } } else { $calendar_output .= $jday; } $calendar_output .= '</td>'; jdate('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear), FALSE, FALSE); if (6 == calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins)) { $newrow = true; } } $pad = 7 - calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins); if ($pad != 0 && $pad != 7) { $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '"> </td>'; } $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>"; $cache[$key] = $calendar_output; wp_cache_set('ztjalali_calendar', $cache, 'calendar'); if ($ztjalali_option['change_jdate_number_to_persian']) { $calendar_output = ztjalali_persian_num($calendar_output); } if ($echo) { /** * Filter the HTML calendar output. * * @since 3.0.0 * * @param string $calendar_output HTML output of the calendar. */ echo apply_filters('ztjalali_calendar', $calendar_output); } else { /** This filter is documented in wp-includes/general-template.php */ return apply_filters('ztjalali_calendar', $calendar_output); } }
//انتخاب مطالب از پایگاه داده $result = mysql_query("SELECT * FROM `article` ORDER BY `date` DESC,`time` DESC LIMIT 0,30"); $url = "http://asremajazi.com/"; //استفاده از ردیف های پایگاه داده while ($row = mysql_fetch_array($result)) { $id = $row['id']; $title = $row['title']; $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $summary = $row['sum']; $summary = htmlspecialchars($summary, ENT_QUOTES, 'UTF-8'); //تبدیل تاریخ دیتابیس به تاریخ استاندار $date = $row['date']; // 22-12-1999 $date = $date['0'] . $date['1'] . $date['2'] . $date['3'] . "-" . $date['4'] . $date['5'] . "-" . $date['6'] . $date['7']; list($jyear, $jmonth, $jday) = preg_split('/-/', $date); list($gyear, $gmonth, $gday) = jalali_to_gregorian($jyear, $jmonth, $jday); $date = $gyear . "-" . $gmonth . "-" . $gday; $stringArray = explode("-", $date); $date = mktime(0, 0, 0, $stringArray[1], $stringArray[2], $stringArray[0]); $convert = date("D, j M Y", $date); $date = $convert . ' ' . $row['time'] . ' ' . 'GMT'; //تعریف لینک خروجی $link = $url . "articles.php?id=" . $id; //ایجاد آیتم برای فید $rssfeed .= "<item>"; $rssfeed .= "<title>" . $title . "</title>"; $rssfeed .= "<description>" . $summary . "</description>"; $rssfeed .= "<link>" . $link . "</link>"; $rssfeed .= "<guid>" . $link . "</guid>"; $rssfeed .= "<pubDate>" . $date . "</pubDate>"; //$rssfeed .= "<author>" . mail . "(url)"."</author>"; //اختیاری
> <img id="datepicker-in-btn" src="images/calendar.png"> </div> <?php } ?> </div> <div class="hottel-search-box-row"> <div class="ht-st-title-field"><?php echo LANG::T('Check-Out-Date'); ?> </div> <div class="ht-st-field"> <?php if (isset($_POST['check-out'])) { $pst_date = explode('/', $_POST['check-out']); $new_date = jalali_to_gregorian($pst_date[0], $pst_date[1], $pst_date[2], '/'); //var_dump($new_date);exit; ?> <input type="text" name="date-out" id="datepicker-out" aria-describedby="inputGroupSuccess2Status" <?php echo "value='" . $new_date . "'"; ?> > <img id="datepicker-out-btn" src="images/calendar.png"> </div> <?php } else { ?> <input type="text" name="date-out" id="datepicker-out" aria-describedby="inputGroupSuccess2Status" <?php if (isset($_SESSION['date-in'])) { echo "value='" . $_SESSION['date-in'] . "'"; } ?>
function _process() { global $osC_Language, $messageStack, $osC_Search, $Qlisting; if (isset($_GET['datefrom_days']) && is_numeric($_GET['datefrom_days']) && isset($_GET['datefrom_months']) && is_numeric($_GET['datefrom_months']) && isset($_GET['datefrom_years']) && is_numeric($_GET['datefrom_years'])) { if (@jcheckdate($_GET['datefrom_months'], $_GET['datefrom_days'], $_GET['datefrom_years'])) { $sfrom_j_to_g = jalali_to_gregorian($_GET['datefrom_years'], $_GET['datefrom_months'], $_GET['datefrom_days']); // tabdil shamsi be miladi $osC_Search->setDateFrom(mktime(0, 0, 0, $sfrom_j_to_g['1'], $sfrom_j_to_g['2'], $sfrom_j_to_g['0'])); } else { $messageStack->add('search', $osC_Language->get('error_search_invalid_from_date')); } } if (isset($_GET['dateto_days']) && is_numeric($_GET['dateto_days']) && isset($_GET['dateto_months']) && is_numeric($_GET['dateto_months']) && isset($_GET['dateto_years']) && is_numeric($_GET['dateto_years'])) { if (@jcheckdate($_GET['dateto_months'], $_GET['dateto_days'], $_GET['dateto_years'])) { $sto_j_to_g = jalali_to_gregorian($_GET['dateto_years'], $_GET['dateto_months'], $_GET['dateto_days']); // tabdil shamsi be miladi $osC_Search->setDateTo(mktime(23, 59, 59, $sto_j_to_g['1'], $sto_j_to_g['2'], $sto_j_to_g['0'])); } else { $messageStack->add('search', $osC_Language->get('error_search_invalid_to_date')); } } if ($osC_Search->hasDateSet()) { if ($osC_Search->getDateFrom() > $osC_Search->getDateTo()) { $messageStack->add('search', $osC_Language->get('error_search_to_date_less_than_from_date')); } } if (isset($_GET['pfrom']) && !empty($_GET['pfrom'])) { if (settype($_GET['pfrom'], 'double')) { $osC_Search->setPriceFrom($_GET['pfrom']); } else { $messageStack->add('search', $osC_Language->get('error_search_price_from_not_numeric')); } } if (isset($_GET['pto']) && !empty($_GET['pto'])) { if (settype($_GET['pto'], 'double')) { $osC_Search->setPriceTo($_GET['pto']); } else { $messageStack->add('search', $osC_Language->get('error_search_price_to_not_numeric')); } } if ($osC_Search->hasPriceSet('from') && $osC_Search->hasPriceSet('to') && $osC_Search->getPriceFrom() >= $osC_Search->getPriceTo()) { $messageStack->add('search', $osC_Language->get('error_search_price_to_less_than_price_from')); } if (isset($_GET['keywords']) && is_string($_GET['keywords']) && !empty($_GET['keywords'])) { $osC_Search->setKeywords(urldecode($_GET['keywords'])); if ($osC_Search->hasKeywords() === false) { $messageStack->add('search', $osC_Language->get('error_search_invalid_keywords')); } } if (!$osC_Search->hasKeywords() && !$osC_Search->hasPriceSet('from') && !$osC_Search->hasPriceSet('to') && !$osC_Search->hasDateSet('from') && !$osC_Search->hasDateSet('to')) { $messageStack->add('search', $osC_Language->get('error_search_at_least_one_input')); } if (isset($_GET['cPath']) && is_numeric($_GET['cPath']) && $_GET['cPath'] > 0) { $osC_Search->setCategory($_GET['cPath'], isset($_GET['recursive']) && $_GET['recursive'] == '1' ? true : false); //filter the products with category, manufactuer and shop by price if (isset($_GET['filter']) && is_numeric($_GET['filter']) && $_GET['filter'] > 0) { $osC_Search->setManufacturer($_GET['filter']); } } if (isset($_GET['manufacturers']) && is_numeric($_GET['manufacturers']) && $_GET['manufacturers'] > 0) { $osC_Search->setManufacturer($_GET['manufacturers']); //filter the products with category, manufactuer and shop by price if (isset($_GET['filter']) && is_numeric($_GET['filter']) && $_GET['filter'] > 0) { $osC_Search->setCategory($_GET['filter']); } } if (isset($_GET['sort']) && !empty($_GET['sort'])) { if (strpos($_GET['sort'], '|d') !== false) { $osC_Search->setSortBy(substr($_GET['sort'], 0, -2), '-'); } else { $osC_Search->setSortBy($_GET['sort']); } } if ($messageStack->size('search') > 0) { $this->_page_contents = 'search.php'; $this->addJavascriptPhpFilename('templates/' . $this->getCode() . '/javascript/search/search.php'); } else { $Qlisting = $osC_Search->execute(); } }
function print_annual_expense_breakdown() { global $path_to_root, $date_system; include_once $path_to_root . "reporting/includes/pdf_report.inc"; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $year = $_REQUEST['PARAM_0']; $dimension = $_REQUEST['PARAM_1']; $dimension2 = $_REQUEST['PARAM_2']; $comments = $_REQUEST['PARAM_3']; } else { if ($dim == 1) { $year = $_REQUEST['PARAM_0']; $dimension = $_REQUEST['PARAM_1']; $comments = $_REQUEST['PARAM_2']; } else { $year = $_REQUEST['PARAM_0']; $comments = $_REQUEST['PARAM_1']; } } $dec = 1; //$pdec = user_percent_dec(); $cols = array(0, 40, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510); //------------0--1---2----3----4----5----6----7----8----10---11---12---13---14---15- //$yr = date('Y'); //$mo = date('m'): // from now $yr = $year; $mo = 12; $da = 1; if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $per12 = strftime('%b', mktime(0, 0, 0, $mo, $da, $yr)); $per11 = strftime('%b', mktime(0, 0, 0, $mo - 1, $da, $yr)); $per10 = strftime('%b', mktime(0, 0, 0, $mo - 2, $da, $yr)); $per09 = strftime('%b', mktime(0, 0, 0, $mo - 3, $da, $yr)); $per08 = strftime('%b', mktime(0, 0, 0, $mo - 4, $da, $yr)); $per07 = strftime('%b', mktime(0, 0, 0, $mo - 5, $da, $yr)); $per06 = strftime('%b', mktime(0, 0, 0, $mo - 6, $da, $yr)); $per05 = strftime('%b', mktime(0, 0, 0, $mo - 7, $da, $yr)); $per04 = strftime('%b', mktime(0, 0, 0, $mo - 8, $da, $yr)); $per03 = strftime('%b', mktime(0, 0, 0, $mo - 9, $da, $yr)); $per02 = strftime('%b', mktime(0, 0, 0, $mo - 10, $da, $yr)); $per01 = strftime('%b', mktime(0, 0, 0, $mo - 11, $da, $yr)); $headers = array(tr('Account'), tr('Account Name'), $per01, $per02, $per03, $per04, $per05, $per06, $per07, $per08, $per09, $per10, $per11, $per12); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr("Dimension") . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr("Dimension") . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => '')); } } $rep = new FrontReport(tr('Annual Expense Breakdown'), "AnnualBreakDown.pdf", user_pagesize()); $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->Header(); $classname = ''; $group = ''; $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $total2 = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $accounts = get_gl_accounts_all(0); while ($account = db_fetch($accounts)) { $bal = getPeriods($year, $account["account_code"], $dimension, $dimension2); if (!$bal['per01'] && !$bal['per02'] && !$bal['per03'] && !$bal['per04'] && !$bal['per05'] && !$bal['per06'] && !$bal['per07'] && !$bal['per08'] && !$bal['per09'] && !$bal['per10'] && !$bal['per11'] && !$bal['per12']) { continue; } $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']); if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total[$i], $dec)); } $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total2[$i], $dec)); $sales[$i] += $total2[$i]; } $rep->Font(); $total2 = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $rep->NewLine(3); $closeclass = false; } } if ($account['AccountClassName'] != $classname) { $rep->Font('bold'); $rep->TextCol(0, 5, $account['AccountClassName']); $rep->Font(); $rep->row -= $rep->lineHeight + 4; } $group = $account['AccountTypeName']; $rep->TextCol(0, 5, $account['AccountTypeName']); $rep->Line($rep->row - 4); $rep->row -= $rep->lineHeight + 4; } $classname = $account['AccountClassName']; $rep->TextCol(0, 1, $account['account_code']); $rep->TextCol(1, 2, $account['account_name']); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($balance[$i], $dec)); $total[$i] += $balance[$i]; $total2[$i] += $balance[$i]; } $rep->NewLine(); if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) { $rep->Line($rep->row - 2); $rep->Header(); } } if ($account['AccountClassName'] != $classname) { if ($classname != '') { $closeclass = true; } } if ($account['AccountTypeName'] != $group) { if ($group != '') { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->TextCol(0, 2, tr('Total') . " " . $group); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total[$i], $dec)); } $rep->row -= $rep->lineHeight + 4; if ($closeclass) { $rep->Line($rep->row + 6); $rep->row -= 6; $rep->Font('bold'); $rep->TextCol(0, 2, tr('Total') . " " . $classname); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($total2[$i], $dec)); $calc[$i] = $sales[$i] + $total2[$i]; } $rep->row -= $rep->lineHeight + 8; $rep->TextCol(0, 2, tr('Calculated Return')); for ($i = 1; $i <= 12; $i++) { $rep->TextCol($i + 1, $i + 2, number_format2($calc[$i], $dec)); } $rep->Font(); $rep->NewLine(); } } } $rep->Line($rep->row); $rep->End(); }
function jmaketime($hour, $minute, $second, $jmonth, $jday, $jyear) { $basecheck = defined('_USE_LOCAL_NUM') && _USE_LOCAL_NUM; if ($basecheck) { $hour = icms_conv_local2nr($hour); $minute = icms_conv_local2nr($minute); $second = icms_conv_local2nr($second); $jmonth = icms_conv_local2nr($jday); $jyear = icms_conv_local2nr($jyear); } list($year, $month, $day) = jalali_to_gregorian($jyear, $jmonth, $jday); $i = mktime($hour, $minute, $second, $month, $day, $year); return $i; }
function formated_to_gregorian($source, $date_divider = '/', $time_sep = ' ') { //$source = '۱۳۹۴/۰۵/۳۱ ۱۳:۲۹:۵۸'; // echo '<br/><br/>----<br/>'; // var_dump($source); $source = number_to_en($source); if ($time_sep !== FALSE and strpos($source, $time_sep)) { // var_dump($source); list($jdate, $time) = explode($time_sep, $source); // var_dump($jdate); // var_dump($time); $time_sep = ' '; } else { $time = '00:00:00'; $jdate = $source; $time_sep = ' '; } // var_dump($time); // var_dump($time_sep); list($jY, $jM, $jD) = explode($date_divider, $jdate); list($y, $m, $d) = jalali_to_gregorian($jY, $jM, $jD); $return = $y . $date_divider . ($m > 9 ? $m : '0' . $m) . $date_divider . ($d > 9 ? $d : '0' . $d) . $time_sep . $time; // echo '<br/><br/>----<br/>'; // echo $return; return $return; // echo '<br/><br/>----<br/>'; }
function dateToGregDB($date) { $datetime = explode('-', $date); $year = $datetime[0]; $month = $datetime[1]; $day = $datetime[2]; $gdate = jalali_to_gregorian($year, $month, $day); return $gdate[0] . '-' . $gdate[1] . '-' . $gdate[2]; }
function print_cash_flow_statement() { global $path_to_root, $date_system, $comp_path; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $comments = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } else { if ($dim == 1) { $date = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $comments = $_POST['PARAM_2']; $destination = $_POST['PARAM_3']; } else { $date = $_POST['PARAM_0']; $comments = $_POST['PARAM_1']; $destination = $_POST['PARAM_2']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } if ($comments) { $comments .= ". - "; } $comments .= _("Balances in Home Currency"); $title = _("Cash Flow Statement"); $output_filename = "CashFlowStatement"; $fontsize = 7; $page_size = user_pagesize(); $page_orientation = 'L'; $margins = array('top' => 30, 'bottom' => 34, 'left' => 16, 'right' => 10); $excelColWidthFactor = 5; $rep = new FrontReport($title, $output_filename, $page_size, $fontsize, $page_orientation, $margins, $excelColWidthFactor); $enddate = end_month($date); $dec = user_price_dec(); // Lay out the columns for this report //$cols2 = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- $cols2 = array(0 => 0, 70); $endline = $rep->endLine - 20; $wi = ($endline - $cols2[1]) / 14; // 14 amount columns for ($i = 2; $i < 17; $i++) { $cols2[$i] = $cols2[$i - 1] + $wi; } $cols = $cols2; //---------------------------------------------------------------------------------------- $aligns2 = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers2 = array(); //$cols = array(0, 70, 127, 184, 232, 280, 328, 376, 424, 472, 520, 568, 616, 664, 712, 760); //-------------0--1---2----3----4----5----6----7----8----9----10---11---12---13---14---15- //---------------------------------------------------------------------------------------- $aligns = array('left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); $headers = array(); $date = begin_month($date); $date = add_months($date, -11); list($da, $mo, $yr) = explode_date_to_dmy($date); if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $headers2[0] = 'Account'; $headers[0] = ''; for ($i = 0; $i < 12; $i++) { $header_row[$i] = $rep->DatePrettyPrint($date, 0, 1); // Wrap at space between month & year $wrap_point = strpos($header_row[$i], ' '); if ($wrap_point) { $headers2[] = substr($header_row[$i], 0, $wrap_point); $headers[] = substr($header_row[$i], $wrap_point + 1); } else { $headers2[] = ''; $headers[] = $header_row[$i]; } $date = add_months($date, 1); } $header_row[] = _("Fiscal YTD"); $header_row[] = _("12 Mo. to Date"); for ($i = 12; $i < 14; $i++) { $wrapped_header_text = $rep->TextWrapCalc($header_row[$i], $cols[$i + 2] - $cols[$i + 1], true); $headers2[] = trim($wrapped_header_text[0]); $headers[] = trim($wrapped_header_text[1]); } if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => '', 'from' => '', 'to' => ''), 4 => array('text' => _("Dimension 1"), 'from' => get_dimension_string($dimension), 'to' => ''), 5 => array('text' => _("Dimension 2"), 'from' => get_dimension_string($dimension2), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate)), 2 => array('text' => '', 'from' => '', 'to' => ''), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Report Period"), 'from' => '', 'to' => $rep->DatePrettyPrint($enddate))); } } // Company logo setting $companylogoenable = true; // Footer Settings $footerenable = true; $footertext = _('For Management Purposes Only'); $rep->Font(); $rep->SetFillColor(240, 240, 240); $rep->scaleLogoWidth = true; $rep->lineHeight = 8; $rep->SetCellPadding(4); $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2, $companylogoenable, $footerenable, $footertext); $rep->SetHeaderType('Header3'); $rep->NewPage(); $rep->SetDrawColor(0, 0, 0); $rep->SetLineWidth(0.1); $rep->row += 8; display_bank_trans($yr, $mo, $dec, $rep, $dimension, $dimension2, $enddate); $rep->Font(); $rep->End(); }
function _process() { global $messageStack, $osC_Database, $osC_Language, $osC_Customer; $data = array(); $j_to_g = array(); if (DISPLAY_PRIVACY_CONDITIONS == '1') { if (isset($_POST['privacy_conditions']) === false || isset($_POST['privacy_conditions']) && $_POST['privacy_conditions'] != '1') { $messageStack->add($this->_module, $osC_Language->get('error_privacy_statement_not_accepted')); } } if (ACCOUNT_GENDER == '1') { if (isset($_POST['gender']) && ($_POST['gender'] == 'm' || $_POST['gender'] == 'f')) { $data['gender'] = $_POST['gender']; } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_gender_error')); } } else { $data['gender'] = isset($_POST['gender']) ? $_POST['gender'] : ''; } if (isset($_POST['firstname']) && strlen(trim($_POST['firstname'])) >= ACCOUNT_FIRST_NAME) { $data['firstname'] = $_POST['firstname']; } else { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_first_name_error'), ACCOUNT_FIRST_NAME)); } if (isset($_POST['lastname']) && strlen(trim($_POST['lastname'])) >= ACCOUNT_LAST_NAME) { $data['lastname'] = $_POST['lastname']; } else { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_last_name_error'), ACCOUNT_LAST_NAME)); } $data['newsletter'] = isset($_POST['newsletter']) && $_POST['newsletter'] == '1' ? 1 : 0; if (ACCOUNT_DATE_OF_BIRTH == '1') { if (isset($_POST['dob_days']) && isset($_POST['dob_months']) && isset($_POST['dob_years']) && jcheckdate($_POST['dob_months'], $_POST['dob_days'], $_POST['dob_years'])) { $j_to_g = jalali_to_gregorian($_POST['dob_years'], $_POST['dob_months'], $_POST['dob_days']); // tabdil shamsi be miladi $data['dob'] = mktime(0, 0, 0, $j_to_g['1'], $j_to_g['2'], $j_to_g['0']); } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_date_of_birth_error')); } } if (isset($_POST['email_address']) && strlen(trim($_POST['email_address'])) >= ACCOUNT_EMAIL_ADDRESS) { if (osc_validate_email_address($_POST['email_address'])) { if (osC_Account::checkDuplicateEntry($_POST['email_address']) === false) { $data['email_address'] = $_POST['email_address']; } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_email_address_exists_error')); } } else { $messageStack->add($this->_module, $osC_Language->get('field_customer_email_address_check_error')); } } else { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_email_address_error'), ACCOUNT_EMAIL_ADDRESS)); } if (isset($_POST['password']) === false || isset($_POST['password']) && strlen(trim($_POST['password'])) < ACCOUNT_PASSWORD) { $messageStack->add($this->_module, sprintf($osC_Language->get('field_customer_password_error'), ACCOUNT_PASSWORD)); } elseif (isset($_POST['confirmation']) === false || isset($_POST['confirmation']) && trim($_POST['password']) != trim($_POST['confirmation'])) { $messageStack->add($this->_module, $osC_Language->get('field_customer_password_mismatch_with_confirmation')); } else { $data['password'] = $_POST['password']; } if (ACTIVATE_CAPTCHA == '1') { if (isset($_POST['captcha_code']) && !empty($_POST['captcha_code'])) { $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $messageStack->add('create', $osC_Language->get('field_create_account_captcha_check_error')); } } else { $messageStack->add('create', $osC_Language->get('field_create_account_captcha_check_error')); } } if ($messageStack->size($this->_module) === 0) { if (osC_Account::createEntry($data)) { $messageStack->add_session('create', $osC_Language->get('success_account_updated'), 'success'); } osc_redirect(osc_href_link(FILENAME_ACCOUNT, 'create=success', 'SSL')); } }
function print_annual_expense_breakdown() { global $path_to_root, $date_system; $dim = get_company_pref('use_dimension'); $dimension = $dimension2 = 0; if ($dim == 2) { $year = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $dimension2 = $_POST['PARAM_2']; $tags = isset($_POST['PARAM_3']) ? $_POST['PARAM_3'] : -1; $comments = $_POST['PARAM_4']; $orientation = $_POST['PARAM_5']; $destination = $_POST['PARAM_6']; } else { if ($dim == 1) { $year = $_POST['PARAM_0']; $dimension = $_POST['PARAM_1']; $tags = isset($_POST['PARAM_2']) ? $_POST['PARAM_2'] : -1; $comments = $_POST['PARAM_3']; $orientation = $_POST['PARAM_4']; $destination = $_POST['PARAM_5']; } else { $year = $_POST['PARAM_0']; $tags = isset($_POST['PARAM_1']) ? $_POST['PARAM_1'] : -1; $comments = $_POST['PARAM_2']; $orientation = $_POST['PARAM_3']; $destination = $_POST['PARAM_4']; } } if ($destination) { include_once $path_to_root . "/reporting/includes/excel_report.inc"; } else { include_once $path_to_root . "/reporting/includes/pdf_report.inc"; } $orientation = $orientation ? 'L' : 'P'; $dec = 1; //$pdec = user_percent_dec(); $cols = array(0, 40, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510); //------------0--1---2----3----4----5----6----7----8----10---11---12---13---14---15- //$yr = date('Y'); //$mo = date('m'): // from now $sql = "SELECT begin, end, YEAR(end) AS yr, MONTH(end) AS mo FROM " . TB_PREF . "fiscal_year WHERE id=" . db_escape($year); $result = db_query($sql, "could not get fiscal year"); $row = db_fetch($result); $year = sql2date($row['begin']) . " - " . sql2date($row['end']); $yr = $row['yr']; $mo = $row['mo']; $da = 1; if ($date_system == 1) { list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da); } elseif ($date_system == 2) { list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da); } $per12 = strftime('%b', mktime(0, 0, 0, $mo, $da, $yr)); $per11 = strftime('%b', mktime(0, 0, 0, $mo - 1, $da, $yr)); $per10 = strftime('%b', mktime(0, 0, 0, $mo - 2, $da, $yr)); $per09 = strftime('%b', mktime(0, 0, 0, $mo - 3, $da, $yr)); $per08 = strftime('%b', mktime(0, 0, 0, $mo - 4, $da, $yr)); $per07 = strftime('%b', mktime(0, 0, 0, $mo - 5, $da, $yr)); $per06 = strftime('%b', mktime(0, 0, 0, $mo - 6, $da, $yr)); $per05 = strftime('%b', mktime(0, 0, 0, $mo - 7, $da, $yr)); $per04 = strftime('%b', mktime(0, 0, 0, $mo - 8, $da, $yr)); $per03 = strftime('%b', mktime(0, 0, 0, $mo - 9, $da, $yr)); $per02 = strftime('%b', mktime(0, 0, 0, $mo - 10, $da, $yr)); $per01 = strftime('%b', mktime(0, 0, 0, $mo - 11, $da, $yr)); $headers = array(_('Account'), _('Account Name'), $per01, $per02, $per03, $per04, $per05, $per06, $per07, $per08, $per09, $per10, $per11, $per12); $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); if ($dim == 2) { $params = array(0 => $comments, 1 => array('text' => _("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => _("Dimension") . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _("Dimension") . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''), 5 => array('text' => _('Info'), 'from' => _('Amounts in thousands'), 'to' => '')); } else { if ($dim == 1) { $params = array(0 => $comments, 1 => array('text' => _("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''), 4 => array('text' => _('Info'), 'from' => _('Amounts in thousands'), 'to' => '')); } else { $params = array(0 => $comments, 1 => array('text' => _("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => _('Tags'), 'from' => get_tag_names($tags), 'to' => ''), 3 => array('text' => _('Info'), 'from' => _('Amounts in thousands'), 'to' => '')); } } $rep = new FrontReport(_('Annual Expense Breakdown'), "AnnualBreakDown", user_pagesize(), 9, $orientation); if ($orientation == 'L') { recalculate_cols($cols); } $rep->Font(); $rep->Info($params, $cols, $headers, $aligns); $rep->NewPage(); $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $classresult = get_account_classes(false, 0); while ($class = db_fetch($classresult)) { $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $convert = get_class_type_convert($class["ctype"]); //Print Class Name $rep->Font('bold'); $rep->TextCol(0, 5, $class["class_name"]); $rep->Font(); $rep->NewLine(); //Get Account groups/types under this group/type with no parents $typeresult = get_account_types(false, $class['cid'], -1); while ($accounttype = db_fetch($typeresult)) { $classtotal = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2, $tags); for ($i = 1; $i <= 12; $i++) { $ctotal[$i] += $classtotal[$i]; } } //Print Class Summary $rep->row += 6; $rep->Line($rep->row); $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(0, 2, _('Total') . " " . $class["class_name"]); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol($i + 1, $i + 2, $ctotal[$i] * $convert, $dec); $sales[$i] += $ctotal[$i]; } $rep->Font(); $rep->NewLine(2); } $rep->Font('bold'); $rep->TextCol(0, 2, _("Calculated Return")); for ($i = 1; $i <= 12; $i++) { $rep->AmountCol($i + 1, $i + 2, $sales[$i] * -1, $dec); } $rep->Font(); $rep->NewLine(); $rep->Line($rep->row); $rep->NewLine(2); $rep->End(); }
function jmaketime($hour, $minute, $second, $jmonth, $jday, $jyear) { list($year, $month, $day) = jalali_to_gregorian($jyear, $jmonth, $jday); $i = mktime($hour, $minute, $second, $month, $day, $year); return $i; }
/** * pre get posts filter handler * @param object $post * @see wp-includes\query.php 2353 */ function ztjalali_pre_get_posts_filter_fn($query) { global $wpdb; $query_vars = $query->query; $year = $monthnum = $day = ""; if (isset($query_vars['m']) and !empty($query_vars['m'])) { $year = (int) substr($query_vars['m'], 0, 4); if ($year < 1700) { $monthnum = (int) substr($query_vars['m'], 4, 2); if (empty($monthnum)) { $start_date = jalali_to_gregorian($year, 1, 1); $end_date = jalali_to_gregorian($year, 12, jday_of_month($year, 12)); } else { $day = (int) substr($query_vars['m'], 6, 2); if (empty($day)) { $start_date = jalali_to_gregorian($year, $monthnum, 1); $end_date = jalali_to_gregorian($year, $monthnum, jday_of_month($year, $monthnum)); } else { $end_date = $start_date = jalali_to_gregorian($year, $monthnum, $day); } } $date_query = array(array('after' => array('year' => $start_date[0], 'month' => $start_date[1], 'day' => $start_date[2]), 'before' => array('year' => $end_date[0], 'month' => $end_date[1], 'day' => $end_date[2]), 'inclusive' => TRUE)); $query->set('date_query', $date_query); $query->set('m', ''); } return $query; } /* ------------------------------------------------------ */ if (isset($query_vars['year'])) { $year = $query_vars['year']; } if (isset($query_vars['monthnum'])) { $monthnum = $query_vars['monthnum']; } if (isset($query_vars['day'])) { $day = $query_vars['day']; } if ($year > 1700) { return $query; } if (isset($query_vars['name'])) { $post_date = $wpdb->get_var($wpdb->prepare("select post_date from {$wpdb->posts} where post_name=%s order by ID", $query_vars['name'])); $Date = explode('-', date('Y-m-d', strtotime($post_date))); $jDate = gregorian_to_jalali($Date[0], $Date[1], $Date[2]); if ($year == $jDate[0]) { $query->set('year', $Date[0]); } if ($monthnum == $jDate[1]) { $query->set('monthnum', $Date[1]); } if ($day == $jDate[2]) { $query->set('day', $Date[2]); } return $query; } if (isset($query_vars['post_id'])) { $post_date = $wpdb->get_var($wpdb->prepare("select post_date from {$wpdb->posts} where ID=%d", $query_vars['post_id'])); $cDate = getdate(strtotime($post_date)); if (!empty($year)) { $query->set('year', $cDate['year']); } if (!empty($monthnum)) { $query->set('monthnum', $cDate['mon']); } if (!empty($day)) { $query->set('day', $cDate['mday']); } return $query; } if (!empty($year) and !empty($monthnum) and !empty($day)) { $post_date = jalali_to_gregorian($year, $monthnum, $day); $query->set('year', $post_date[0]); $query->set('monthnum', $post_date[1]); $query->set('day', $post_date[2]); return $query; } if (!empty($year) and !empty($monthnum)) { $start_date = jalali_to_gregorian($year, $monthnum, 1); $end_date = jalali_to_gregorian($year, $monthnum, jday_of_month($year, $monthnum)); $date_query = array(array('after' => array('year' => $start_date[0], 'month' => $start_date[1], 'day' => $start_date[2]), 'before' => array('year' => $end_date[0], 'month' => $end_date[1], 'day' => $end_date[2]), 'inclusive' => TRUE)); $query->set('date_query', $date_query); $query->set('year', ''); $query->set('monthnum', ''); // $post_date = jalali_to_gregorian($year, $monthnum, 15); // $query->set('year', $post_date[0]); // $query->set('monthnum', $post_date[1]); return $query; } if (!empty($year)) { $start_date = jalali_to_gregorian($year, 1, 1); if (is_jalali_leap_year($year)) { $end_date = jalali_to_gregorian($year, 12, 30); } else { $end_date = jalali_to_gregorian($year, 12, 29); } $date_query = array(array('after' => array('year' => $start_date[0], 'month' => $start_date[1], 'day' => $start_date[2]), 'before' => array('year' => $end_date[0], 'month' => $end_date[1], 'day' => $end_date[2]), 'inclusive' => TRUE)); $query->set('date_query', $date_query); $query->set('year', ''); return $query; } return $query; }