Index: trunk/kernel/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6093) +++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6583) @@ -319,7 +319,7 @@ ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $priority => $section_name) { if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue; - + $tab_data =& $sections_helper->getSectionData($section_name); $block_params['t'] = $tab_data['url']['t']; $block_params['title'] = $tab_data['label']; @@ -345,7 +345,8 @@ $block_params = Array('name' => $params['render_as']); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $prefix = $module_info['Var']; - if (in_array($prefix, $skip_prefixes)) continue; + + if (in_array($prefix, $skip_prefixes) || !$this->Application->getUnitOption($prefix, 'CatalogItem')) continue; if ($prefix == 'm' && $replace_main) $prefix = 'c'; $label = $this->Application->getUnitOption($prefix, $params['title_property']); $block_params['title'] = $label; @@ -376,7 +377,7 @@ return $oFCKeditor->CreateHtml(); } - + /** * Allows to construct link for opening any type of catalog item selector * @@ -390,39 +391,102 @@ $mode = $params['mode']; unset($params['mode']); } - + $params['t'] = 'item_selector/item_selector_'.$mode; - + $default_params = Array('no_amp' => 1, 'pass' => 'all,'.$params['prefix']); unset($params['prefix']); - + $pass_through = Array(); if (isset($params['tabs_dependant'])) { // {yes, no} $pass_through['td'] = $params['tabs_dependant']; unset($params['tabs_dependant']); } - + if (isset($params['selection_mode'])) { // {single, multi} $pass_through['tm'] = $params['selection_mode']; unset($params['selection_mode']); } - + if (isset($params['tab_prefixes'])) { // {all, none, Application->ProcessParsedTag('m', 't', $params); } + + function TimeFrame($params) + { + $w = adodb_date('w'); + $m = adodb_date('m'); + $y = adodb_date('Y'); + //FirstDayOfWeek is 0 for Sunday and 1 for Monday + $fdow = $this->Application->ConfigValue('FirstDayOfWeek'); + if ($fdow && $w == 0) $w = 7; + $today_start = adodb_mktime(0,0,0,adodb_date('m'),adodb_date('d'),$y); + $first_day_of_this_week = $today_start - ($w - $fdow)*86400; + $first_day_of_this_month = adodb_mktime(0,0,0,$m,1,$y); + $this_quater = ceil($m/3); + $this_quater_start = adodb_mktime(0,0,0,$this_quater*3-2,1,$y); + + switch ($params['type']) { + case 'last_week_start': + $timestamp = $first_day_of_this_week - 86400*7; + break; + case 'last_week_end': + $timestamp = $first_day_of_this_week - 1; + break; + + case 'last_month_start': + $timestamp = $m == 1 ? adodb_mktime(0,0,0,12,1,$y-1) : adodb_mktime(0,0,0,$m-1,1,$y); + break; + case 'last_month_end': + $timestamp = $first_day_of_this_month = adodb_mktime(0,0,0,$m,1,$y) - 1; + break; + + case 'last_quater_start': + $timestamp = $this_quater == 1 ? adodb_mktime(0,0,0,10,1,$y-1) : adodb_mktime(0,0,0,($this_quater-1)*3-2,1,$y); + break; + case 'last_quater_end': + $timestamp = $this_quater_start - 1; + break; + + case 'last_6_months_start': + $timestamp = $m <= 6 ? adodb_mktime(0,0,0,$m+6,1,$y-1) : adodb_mktime(0,0,0,$m-6,1,$y); + break; + + case 'last_year_start': + $timestamp = adodb_mktime(0,0,0,1,1,$y-1); + break; + case 'last_year_end': + $timestamp = adodb_mktime(23,59,59,12,31,$y-1); + break; + } + + + if (isset($params['format'])) { + $format = $params['format']; + if(preg_match("/_regional_(.*)/", $format, $regs)) + { + $lang =& $this->Application->recallObject('lang.current'); + $format = $lang->GetDBField($regs[1]); + } + return adodb_date($format, $timestamp); + } + + return $timestamp; + + } } ?> \ No newline at end of file