sugarwidgetfielddatetime.php
来自「SugarCRM5.1 开源PHP客户关系管理系统」· PHP 代码 · 共 907 行 · 第 1/3 页
PHP
907 行
// i guess qualifier and column_function are the same.. if ($this->reporter->db->dbType == 'mssql'){ //do nothing if this is for mssql, do not run group by } elseif (!empty ($layout_def['qualifier'])) { $func_name ='queryGroupBy'.$layout_def['qualifier']; if (method_exists($this, $func_name)) { return $this-> $func_name ($layout_def)."\n"; } } $order_by = parent :: queryOrderBy($layout_def)."\n"; return $order_by; } function displayListPlain($layout_def) { global $timedate; $content = parent:: displayListPlain($layout_def); // Get the time context of the date, important to calculate DST if(substr_count($layout_def['name'], 'date') > 0) { $date=$this->get_date_part($content); $layout_def_time = $layout_def; $layout_def_time['name'] = str_replace('date', 'time', $layout_def_time['name']); $time = $this->displayListPlainHelper($layout_def_time); if(!empty($time)) { // able to get the time context of the date $time=$this->get_time_part($time); $td = explode(' ', $timedate->to_display_date_time($date . ' ' . $time)); return $td[0]; } else { // assume there is no time context // awu: this if condition happens only in Reports where group by month comes back as YYYY-mm format if (count(explode('-',$content)) == 2){ return $content; } else{ $td = $timedate->to_display_date($content, false); // avoid php notice of returing by reference return $td; } } } if(substr_count($layout_def['name'], 'time') > 0) { $time=$this->get_time_part($content); $layout_def_date = $layout_def; $layout_def_date['name'] = str_replace('time', 'date', $layout_def_date['name']); $date = $this->displayListPlainHelper($layout_def_date); if(!empty($date)) { // able to get the time context of the date $date=$this->get_date_part($date); $td = explode(' ', $timedate->to_display_date_time($date . ' ' . $time)); return $td[1]; } else { // assume there is no date context $td = $timedate->to_display_time($content, false); // avoid php notice of returing by reference return $td; } } }function displayListPlainHelper($layout_def) { global $timedate; $content = parent:: displayListPlain($layout_def); if($layout_def['type']=='datetime' and count(explode(' ', $content)) == 2) return $timedate->to_display_date_time($content); else return $content;}function get_date_part($date_time_value){ $date_parts=explode(' ', $date_time_value); if (count($date_parts) == 2) { $date=$date_parts[0]; } else { $date=$date_time_value; } return $date;}function get_time_part($date_time_value) { $date_parts=explode(' ', $date_time_value); if (count($date_parts) == 2) { $time=$date_parts[1]; } else { $time=$date_time_value; } return $time;} function displayList($layout_def) { global $timedate; // i guess qualifier and column_function are the same.. if (!empty ($layout_def['column_function'])) { $func_name = 'displayList'.$layout_def['column_function']; if (method_exists($this, $func_name)) { return $this-> $func_name ($layout_def); } } $content = parent :: displayListPlain($layout_def); return $timedate->to_display_date_time($content); } function querySelect(& $layout_def) { // i guess qualifier and column_function are the same.. if (!empty ($layout_def['column_function'])) { $func_name = 'querySelect'.$layout_def['column_function']; if (method_exists($this, $func_name)) { return $this-> $func_name ($layout_def)." \n"; } } return parent :: querySelect($layout_def)." \n"; } function & displayListyear(& $layout_def) { global $app_list_strings; $match = array(); if (preg_match('/(\d{4})/', $this->displayListPlain($layout_def), $match)) { return $match[1]; } $temp = null; // avoid notices return $temp; } function & displayListmonth(& $layout_def) { global $app_list_strings; $display = ''; $match = array(); if (preg_match('/(\d{4})-(\d\d)/', $this->displayListPlain($layout_def), $match)) { $match[2] = preg_replace('/^0/', '', $match[2]); $display = $app_list_strings['dom_cal_month_long'][$match[2]]." {$match[1]}"; } return $display; } function querySelectmonth(& $layout_def) { if ($this->reporter->db->dbType == 'oci8') { }elseif($this->reporter->db->dbType == 'mssql') { //return "LEFT( ".$this->_get_column_select($layout_def).",6 ) ".$this->_get_column_alias($layout_def)." \n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ",121),7)".$this->_get_column_alias($layout_def)." \n"; } else { return "LEFT( ".$this->_get_column_select($layout_def).",7 ) ".$this->_get_column_alias($layout_def)." \n"; } } function queryGroupByMonth($layout_def) { if ($this->reporter->db->dbType == 'oci8') { }elseif($this->reporter->db->dbType == 'mssql') { //return "LEFT(".$this->_get_column_select($layout_def).", 6) \n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ", 121),7) \n"; }else { return "LEFT(".$this->_get_column_select($layout_def).", 7) \n"; } } function queryGroupByDay($layout_def) { if ($this->reporter->db->dbType == 'oci8') { }elseif($this->reporter->db->dbType == 'mssql') { //return "LEFT(".$this->_get_column_select($layout_def).", 6) \n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ", 121),10) \n"; }else { return "LEFT(".$this->_get_column_select($layout_def).", 10) \n"; } } function querySelectyear(& $layout_def) { if ($this->reporter->db->dbType == 'oci8') { }elseif($this->reporter->db->dbType == 'mssql') { //return "LEFT( ".$this->_get_column_select($layout_def).",5 ) ".$this->_get_column_alias($layout_def)." \n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ",121),10) ".$this->_get_column_alias($layout_def)." \n"; } else { return "LEFT( ".$this->_get_column_select($layout_def).",10 ) ".$this->_get_column_alias($layout_def)." \n"; } } function queryGroupByYear($layout_def) { if ($this->reporter->db->dbType == 'oci8') { }elseif($this->reporter->db->dbType == 'mssql') { //return "LEFT(".$this->_get_column_select($layout_def).", 5) \n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ",121),10) \n"; } else { return "LEFT(".$this->_get_column_select($layout_def).", 10) \n"; } } function querySelectquarter(& $layout_def) { if ($this->reporter->db->dbType == 'oci8') { } elseif ($this->reporter->db->dbType == 'mysql') { return "CONCAT(LEFT(".$this->_get_column_select($layout_def).", 4), '-', QUARTER(".$this->_get_column_select($layout_def).") )".$this->_get_column_alias($layout_def)."\n"; } elseif ($this->reporter->db->dbType == 'mssql') { //return "LEFT(".$this->_get_column_select($layout_def).", 4) + '-' + convert(varchar(20), DatePart(q," . $this->_get_column_select($layout_def).") ) ".$this->_get_column_alias($layout_def)."\n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ",121),4)+ '-' + convert(varchar(20), DatePart(q," . $this->_get_column_select($layout_def).") ) ".$this->_get_column_alias($layout_def)."\n"; } } function displayListquarter(& $layout_def) { $match = array(); if (preg_match('/(\d{4})-(\d)/', $this->displayListPlain($layout_def), $match)) { return "Q".$match[2]." ".$match[1]; } return ''; } function queryGroupByQuarter($layout_def) { $this->getReporter(); if ($this->reporter->db->dbType == 'oci8') { }elseif ($this->reporter->db->dbType == 'mysql') { return "CONCAT(LEFT(".$this->_get_column_select($layout_def).", 4), '-', QUARTER(".$this->_get_column_select($layout_def).") )\n"; } elseif ($this->reporter->db->dbType == 'mssql') { //return "LEFT(".$this->_get_column_select($layout_def).", 4) + '-' + convert(varchar(20), DatePart(q," . $this->_get_column_select($layout_def).") )\n"; return "LEFT(CONVERT (varchar(20), ". $this->_get_column_select($layout_def). ",121),4) + '-' + convert(varchar(20), DatePart(q," . $this->_get_column_select($layout_def).") )\n"; } } function displayInput(&$layout_def) { global $timedate, $image_path, $current_language, $app_strings; $home_mod_strings = return_module_language($current_language, 'Home'); $filterTypes = array(' ' => $app_strings['LBL_NONE'], 'TP_today' => $home_mod_strings['LBL_TODAY'], 'TP_yesterday' => $home_mod_strings['LBL_YESTERDAY'], 'TP_tomorrow' => $home_mod_strings['LBL_TOMORROW'], 'TP_this_month' => $home_mod_strings['LBL_THIS_MONTH'], 'TP_this_year' => $home_mod_strings['LBL_THIS_YEAR'], 'TP_last_30_days' => $home_mod_strings['LBL_LAST_30_DAYS'], 'TP_last_7_days' => $home_mod_strings['LBL_LAST_7_DAYS'], 'TP_last_month' => $home_mod_strings['LBL_LAST_MONTH'], 'TP_last_year' => $home_mod_strings['LBL_LAST_YEAR'], 'TP_next_30_days' => $home_mod_strings['LBL_NEXT_30_DAYS'], 'TP_next_7_days' => $home_mod_strings['LBL_NEXT_7_DAYS'], 'TP_next_month' => $home_mod_strings['LBL_NEXT_MONTH'], 'TP_next_year' => $home_mod_strings['LBL_NEXT_YEAR'], ); $cal_dateformat = $timedate->get_cal_date_format(); $str = "<select name='type_{$layout_def['name']}'>"; $str .= get_select_options_with_id($filterTypes, (empty($layout_def['input_name0']) ? '' : $layout_def['input_name0']));// foreach($filterTypes as $value => $label) {// $str .= '<option value="' . $value . '">' . $label. '</option>';// } $str .= "</select>";/* $str .= "<input id='jscal_field{$layout_def['name']}' name='date_{$layout_def['name']}' onblur='parseDate(this, \"{$cal_dateformat}\");' tabindex='1' size='11' maxlength='10' type='text' value='{$layout_def['input_name0']}'> <img src='themes/default/images/jscalendar.gif' alt='{$cal_dateformat}' id='jscal_trigger' align='absmiddle'> <script type='text/javascript'> Calendar.setup ({ inputField : 'jscal_field{$layout_def['name']}', ifFormat : '{$cal_dateformat}', onClose: function(cal) { cal.hide();}, showsTime : false, button : 'jscal_trigger', singleClick : true, step : 1 }); </script>";*/ return $str; }}?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?