Browse Source

dev 2020-08

Max F 5 years ago
parent
commit
fccfa313b1
3 changed files with 34 additions and 0 deletions
  1. 7 0
      src/Database/Sql/SqlTable.php
  2. 4 0
      src/helpers/helpers_array.php
  3. 23 0
      src/helpers/helpers_default.php

+ 7 - 0
src/Database/Sql/SqlTable.php

@@ -316,6 +316,13 @@ class SqlTable
 		return empty($row['nb']) ? 0 : $row['nb'];
 	}
 
+
+	public function one($where=null, $options=[])
+	{
+		// Alias of getOne
+		return $this->getOne($where, $options);
+	}
+
 	public function selectOne($where=null, $options=[])
 	{
 		// Alias of getOne

+ 4 - 0
src/helpers/helpers_array.php

@@ -82,6 +82,10 @@ if (! function_exists('arrayToList')) {
 if (! function_exists('import_xls')) {
 	function import_xls($filepath, $fields=[], $encode_utf8=false) {
 		$spreadsheet = PhpSpreadsheetIOFactory::load($filepath);
+
+		//$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
+		//$reader->setReadDataOnly(true);
+		//$spreadsheet = $reader->load($filepath);
 		
 		$sheetData = $spreadsheet->getActiveSheet()->toArray();
 		//pre($sheetData, 1);

+ 23 - 0
src/helpers/helpers_default.php

@@ -177,6 +177,9 @@ if (! function_exists('getRouteUrl')) {
 
 if (! function_exists('date_us_to_fr')) {
 	function date_us_to_fr($date_us, $include_time=false) {
+		if (empty($date_us)) {
+			return null;
+		}
 		$time = ($include_time) ? substr($date_us, 10) : "";
 		$date_us = substr($date_us, 0, 10);
 		$parts = explode('-', $date_us);
@@ -184,8 +187,28 @@ if (! function_exists('date_us_to_fr')) {
 	}
 }
 
+if (! function_exists('date_us2_to_fr')) {
+	function date_us2_to_fr($date_us, $include_time=false) {
+		if (empty($date_us)) {
+			return null;
+		}
+		$time = ($include_time) ? substr($date_us, 10) : "";
+		$date_us = substr($date_us, 0, 10);
+		$parts = explode('/', $date_us);
+		$parts2 = [
+			substr('00' . $parts[1], -2),
+			substr('00' . $parts[0], -2),
+			$parts[2],
+		];
+		return implode('/', $parts2) . $time;
+	}
+}
+
 if (! function_exists('date_fr_to_us')) {
 	function date_fr_to_us($date_fr, $include_time=false) {
+		if (empty($date_fr)) {
+			return null;
+		}
 		$time = ($include_time) ? substr($date_fr, 10) : "";
 		$date_fr = substr($date_fr, 0, 10);
 		$parts = explode('/', $date_fr);