Просмотр исходного кода

Date and time format: exports finalization.

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4117 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 9 лет назад
Родитель
Сommit
7ac000db85

+ 2 - 0
core/csvbulkexport.class.inc.php

@@ -202,6 +202,8 @@ class CSVBulkExport extends TabularBulkExport
 <<<EOF
 $('#csv_custom_date_time_format').tooltip({content: function() { return $sJSTooltip; } });
 $('#form_part_csv_options').on('preview_updated', function() { FormatDatesInPreview('csv', 'csv'); });
+$('#csv_date_time_format_default').on('click', function() { FormatDatesInPreview('csv', 'csv'); });
+$('#csv_date_time_format_custom').on('click', function() { FormatDatesInPreview('csv', 'csv'); });
 $('#csv_custom_date_time_format').on('click', function() { $('#csv_date_time_format_custom').prop('checked', true); FormatDatesInPreview('csv', 'csv'); }).on('keyup', function() { FormatDatesInPreview('csv', 'csv'); });
 EOF
 				);

+ 4 - 4
core/datetimeformat.class.inc.php

@@ -59,18 +59,18 @@ class DateTimeFormat
 		return array(
 				// Days
 				'd' => array('regexpr' => '(0[1-9]|[1-2][0-9]||3[0-1])', 'datepicker' => 'dd', 'excel' => 'dd', 'moment' => 'DD'), // Day of the month: 2 digits (with leading zero)
-				'j' => array('regexpr' => '([1-9]|[1-2][0-9]||3[0-1])', 'datepicker' => 'd', 'excel' => '%d', 'moment' => 'D'), // Day of the month: 1 or 2 digits (without leading zero)
+				'j' => array('regexpr' => '([1-9]|[1-2][0-9]||3[0-1])', 'datepicker' => 'd', 'excel' => 'd', 'moment' => 'D'), // Day of the month: 1 or 2 digits (without leading zero)
 				// Months
 				'm' => array('regexpr' => '(0[1-9]|1[0-2])', 'datepicker' => 'mm', 'excel' => 'MM', 'moment' => 'MM' ), // Month on 2 digits i.e. 01-12
-				'n' => array('regexpr' => '([1-9]|1[0-2])', 'datepicker' => 'm', 'excel' => '%M', 'moment' => 'M'), // Month on 1 or 2 digits 1-12
+				'n' => array('regexpr' => '([1-9]|1[0-2])', 'datepicker' => 'm', 'excel' => 'm', 'moment' => 'M'), // Month on 1 or 2 digits 1-12
 				// Years
 				'Y' => array('regexpr' => '([0-9]{4})', 'datepicker' => 'yy', 'excel' => 'YYYY', 'moment' => 'YYYY'), // Year on 4 digits
 				'y' => array('regexpr' => '([0-9]{2})', 'datepicker' => 'y', 'excel' => 'YY', 'moment' => 'YY'), // Year on 2 digits
 				// Hours
 				'H' => array('regexpr' => '([0-1][0-9]|2[0-3])', 'datepicker' => 'HH', 'excel' => 'HH', 'moment' => 'HH'), // Hour 00..23
 				'h' => array('regexpr' => '(0[1-9]|1[0-2])', 'datepicker' => 'hh', 'excel' => 'hh', 'moment' => 'hh'), // Hour 01..12
-				'G' => array('regexpr' => '([1-9]|[1[0-9]|2[0-3])', 'datepicker' => 'H', 'excel' => '%H', 'moment' => 'H'), // Hour 0..23
-				'g' => array('regexpr' => '([1-9]|1[0-2])', 'datepicker' => 'h', 'excel' => '%h', 'moment' => 'h'), // Hour 1..12
+				'G' => array('regexpr' => '([1-9]|[1[0-9]|2[0-3])', 'datepicker' => 'H', 'excel' => 'H', 'moment' => 'H'), // Hour 0..23
+				'g' => array('regexpr' => '([1-9]|1[0-2])', 'datepicker' => 'h', 'excel' => 'h', 'moment' => 'h'), // Hour 1..12
 				'a' => array('regexpr' => '(am|pm)', 'datepicker' => 'tt', 'excel' => 'am/pm', 'moment' => 'a'),
 				'A' => array('regexpr' => '(AM|PM)', 'datepicker' => 'TT', 'excel' => 'AM/PM', 'moment' => 'A'),
 				// Minutes

+ 2 - 0
core/excelbulkexport.class.inc.php

@@ -115,6 +115,8 @@ class ExcelBulkExport extends TabularBulkExport
 <<<EOF
 $('#excel_custom_date_time_format').tooltip({content: function() { return $sJSTooltip; } });
 $('#form_part_xlsx_options').on('preview_updated', function() { FormatDatesInPreview('excel', 'xlsx'); });
+$('#excel_date_time_format_default').on('click', function() { FormatDatesInPreview('excel', 'xlsx'); });
+$('#excel_date_time_format_custom').on('click', function() { FormatDatesInPreview('excel', 'xlsx'); });
 $('#excel_custom_date_time_format').on('click', function() { $('#excel_date_time_format_custom').prop('checked', true); FormatDatesInPreview('excel', 'xlsx'); }).on('keyup', function() { FormatDatesInPreview('excel', 'xlsx'); });					
 EOF
 				);

+ 7 - 1
core/pdfbulkexport.class.inc.php

@@ -78,6 +78,8 @@ class PDFBulkExport extends HTMLBulkExport
 <<<EOF
 $('#pdf_custom_date_time_format').tooltip({content: function() { return $sJSTooltip; } });
 $('#form_part_pdf_options').on('preview_updated', function() { FormatDatesInPreview('pdf', 'html'); });
+$('#pdf_date_time_format_default').on('click', function() { FormatDatesInPreview('pdf', 'html'); });
+$('#pdf_date_time_format_custom').on('click', function() { FormatDatesInPreview('pdf', 'html'); });
 $('#pdf_custom_date_time_format').on('click', function() { $('#pdf_date_time_format_custom').prop('checked', true); FormatDatesInPreview('pdf', 'html'); }).on('keyup', function() { FormatDatesInPreview('pdf', 'html'); });					
 EOF
 				);
@@ -151,9 +153,13 @@ EOF
 	public function GetNextChunk(&$aStatus)
 	{
 		$oPrevFormat = AttributeDateTime::GetFormat();
-		AttributeDateTime::SetFormat(new DateTimeFormat($this->aStatusInfo['date_format']));
+		$oPrevDateFormat = AttributeDate::GetFormat();
+		$oDateTimeFormat = new DateTimeFormat($this->aStatusInfo['date_format']);
+		AttributeDateTime::SetFormat($oDateTimeFormat);
+		AttributeDate::SetFormat(new DateTimeFormat($oDateTimeFormat->ToDateFormat()));
 		$sData = parent::GetNextChunk($aStatus);
 		AttributeDateTime::SetFormat($oPrevFormat);
+		AttributeDate::SetFormat($oPrevDateFormat);
 		$hFile = @fopen($this->aStatusInfo['tmp_file'], 'ab');
 		if ($hFile === false)
 		{

+ 2 - 0
core/spreadsheetbulkexport.class.inc.php

@@ -74,6 +74,8 @@ class SpreadsheetBulkExport extends TabularBulkExport
 <<<EOF
 $('#spreadsheet_custom_date_time_format').tooltip({content: function() { return $sJSTooltip; } });
 $('#form_part_spreadsheet_options').on('preview_updated', function() { FormatDatesInPreview('spreadsheet', 'spreadsheet'); });
+$('#preadsheet_date_time_format_default').on('click', function() { FormatDatesInPreview('spreadsheet', 'spreadsheet'); });
+$('#preadsheet_date_time_format_custom').on('click', function() { FormatDatesInPreview('spreadsheet', 'spreadsheet'); });
 $('#spreadsheet_custom_date_time_format').on('click', function() { $('#spreadsheet_date_time_format_custom').prop('checked', true); });
 $('#spreadsheet_custom_date_time_format').on('click', function() { $('#spreadsheet_date_time_format_custom').prop('checked', true); FormatDatesInPreview('spreadsheet', 'spreadsheet'); }).on('keyup', function() { FormatDatesInPreview('spreadsheet', 'spreadsheet'); });											
 EOF

+ 1 - 1
webservices/export-v2.php

@@ -195,7 +195,7 @@ function DisplayForm(WebPage $oP, $sAction = '', $sExpression = '', $sQueryId =
 <<<EOF
 function FormatDatesInPreview(sRadioSelector, sPreviewSelector)
 {
-	if ($('#'+sRadioSelector+'_date_format_radio').prop('checked'))
+	if ($('#'+sRadioSelector+'_date_time_format_default').prop('checked'))
 	{
 		sPHPFormat = '$sJSDefaultDateTimeFormat';
 	}