dever 5 rokov pred
rodič
commit
995277d91b
2 zmenil súbory, kde vykonal 44 pridanie a 17 odobranie
  1. 25 5
      src/Database.php
  2. 19 12
      src/Lib/Input.php

+ 25 - 5
src/Database.php

@@ -551,14 +551,22 @@ class Database
 
                 if (isset($v['search']) && is_string($v['search'])) {
 
-                    if (strpos($v['search'], 'time') !== false) {
-                        $config['manage']['search']['time'][$k] = $v['name'];
+                    if (strpos($v['search'], 'time') !== false || strpos($v['search'], 'day') !== false) {
+                        $config['manage']['search']['day'][$k] = $v['name'];
                     }
 
                     if (strpos($v['search'], 'date') !== false) {
                         $config['manage']['search']['date'][$k] = $v['name'];
                     }
 
+                    if (strpos($v['search'], 'year') !== false) {
+                        $config['manage']['search']['year'][$k] = $v['name'];
+                    }
+
+                    if (strpos($v['search'], 'month') !== false) {
+                        $config['manage']['search']['month'][$k] = $v['name'];
+                    }
+
                     if (strpos($v['search'], 'exp') !== false) {
                         $config['manage']['search']['exp'][$k] = $v['name'];
                     }
@@ -1110,9 +1118,9 @@ class Database
                 }
             }
 
-            if (isset($config['manage']['search']['time'])) {
-                foreach ($config['manage']['search']['time'] as $k => $v) {
-                    $this->list_search_time($result, $search, $prefix, $k, $v);
+            if (isset($config['manage']['search']['day'])) {
+                foreach ($config['manage']['search']['day'] as $k => $v) {
+                    $this->list_search_time($result, $search, $prefix, $k, $v, 'day');
                 }
             }
 
@@ -1122,6 +1130,18 @@ class Database
                 }
             }
 
+            if (isset($config['manage']['search']['year'])) {
+                foreach ($config['manage']['search']['year'] as $k => $v) {
+                    $this->list_search_time($result, $search, $prefix, $k, $v, 'year');
+                }
+            }
+
+            if (isset($config['manage']['search']['month'])) {
+                foreach ($config['manage']['search']['month'] as $k => $v) {
+                    $this->list_search_time($result, $search, $prefix, $k, $v, 'month');
+                }
+            }
+
             if (isset($config['manage']['search']['select'])) {
                 $this->list_search_br($result);
                 foreach ($config['manage']['search']['select'] as $k => $v) {

+ 19 - 12
src/Lib/Input.php

@@ -1113,17 +1113,24 @@ class Input
      *
      * @return string
      */
-    public static function _date($param, $key = 'date', $parse = 'Y-m-d H:i:s')
+    public static function _date($param, $type = true, $key = 'date', $parse = 'Y-m-d H:i:s')
     {
-        $time = '';
+        $time = $value = '';
         if ((isset($param['value']) && $param['value'] > 0)) {
             $time = $param['value'];
         } elseif ((isset($param['default']) && $param['default'] > 0)) {
             $time = $param['default'];
-        } else {
+        } elseif($type) {
             $time = time();
         }
-        $value = date($parse, $time);
+        if ($time) {
+            if (strlen($time) >= 10) {
+                $value = date($parse, $time);
+            } else {
+                $value = $time;
+            }
+        }
+        
         return '<input type="text" value="' . $value . '" placeholder="' . (isset($param['lang']) ? $param['lang'] : '') . '" name="' . $param['name'] . '" class="manage_'.$key.' update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" autocomplete="off"/>';
     }
 
@@ -1132,9 +1139,9 @@ class Input
      *
      * @return string
      */
-    public static function _time($param)
+    public static function _time($param, $type = true)
     {
-        return self::_day($param);
+        return self::_day($param, $type);
     }
 
     /**
@@ -1142,9 +1149,9 @@ class Input
      *
      * @return string
      */
-    public static function _day($param)
+    public static function _day($param, $type = true)
     {
-        return self::_date($param, 'day', 'Y-m-d');
+        return self::_date($param, $type, 'day', 'Y-m-d');
     }
 
     /**
@@ -1152,9 +1159,9 @@ class Input
      *
      * @return string
      */
-    public static function _year($param)
+    public static function _year($param, $type = true)
     {
-        return self::_date($param, 'year', 'Y');
+        return self::_date($param, $type, 'year', 'Y');
     }
 
     /**
@@ -1162,9 +1169,9 @@ class Input
      *
      * @return string
      */
-    public static function _month($param)
+    public static function _month($param, $type = true)
     {
-        return self::_date($param, 'year', 'Y-m');
+        return self::_date($param, $type, 'month', 'Y-m');
     }
 
     /**