@@ -37,6 +37,7 @@ class TicketsController extends Controller
3737 protected $ a_search_fields_text = ['subject ' , 'content ' , 'intervention ' ];
3838 protected $ a_search_fields_text_special = ['comments ' , 'attachment_name ' , 'any_text_field ' ];
3939 protected $ a_search_fields_date = ['start_date ' , 'limit_date ' , 'created_at ' , 'completed_at ' , 'updated_at ' ];
40+ protected $ a_search_fields_date_types = ['from ' , 'until ' , 'exact_year ' , 'exact_month ' , 'exact_day ' ];
4041
4142 public function __construct (Ticket $ tickets , \PanicHDMember $ member )
4243 {
@@ -799,7 +800,7 @@ public function search_form($parameters = null)
799800 // Decode strings in URL
800801 $ search_fields [$ key ] = urldecode ($ param );
801802
802- }elseif (in_array (str_replace ('_type ' , '' , $ key ), $ this ->a_search_fields_date )){
803+ }elseif (in_array (str_replace ('_type ' , '' , $ key ), $ this ->a_search_fields_date ) and in_array ( $ param , $ this -> a_search_fields_date_types ) ){
803804 // Get date field related type
804805 $ search_fields [$ key ] = $ param ;
805806 }
@@ -818,8 +819,8 @@ public function search_form($parameters = null)
818819
819820 foreach ($ this ->a_search_fields_date as $ field ){
820821 if (isset ($ search_fields [$ field ]) and !isset ($ search_fields [$ field . '_type ' ])){
821- // Unset date field if it's type is not specified
822- unset( $ search_fields [$ field]) ;
822+ // Set date field default type if not specified
823+ $ search_fields [$ field . ' _type ' ] = ' from ' ;
823824 }
824825 }
825826
@@ -851,7 +852,11 @@ public function search_form_defaults()
851852
852853 $ priorities = $ this ->getCacheList ('priorities ' );
853854
854- $ a_date_additional_types = ['until ' , 'exact_year ' , 'exact_month ' , 'exact_day ' ];
855+ // Date types except "from"
856+ $ a_date_additional_types = $ this ->a_search_fields_date_types ;
857+ if (($ key = array_search ('from ' , $ a_date_additional_types )) !== false ) {
858+ unset($ a_date_additional_types [$ key ]);
859+ }
855860
856861 $ a_categories = $ this ->member ->findOrFail (auth ()->user ()->id )->getEditTicketCategories ();
857862
0 commit comments