@@ -96,6 +96,21 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
9696 }
9797 }
9898
99+ if (GETPOST ('search_name ' )) {
100+ $ fileList = array_filter ($ fileList , function ($ file ) {
101+ return strpos ($ file ['name ' ], GETPOST ('search_name ' )) !== false ;
102+ });
103+ }
104+
105+ if (GETPOST ('search_date ' )) {
106+ $ search_date = GETPOST ('search_date ' );
107+ $ fileList = array_filter ($ fileList , function ($ file ) use ($ search_date ) {
108+ $ file_date = date ('Y-m-d ' , $ file ['date ' ]);
109+ return $ file_date === $ search_date ;
110+ });
111+ }
112+
113+
99114 $ fileList = dol_sort_array ($ fileList , $ sortfield , $ sortorder );
100115
101116 $ page = GETPOST ('page ' , 'int ' ) ?: 1 ;
@@ -289,12 +304,23 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
289304 }
290305 $ out .= '</tr> ' ;
291306 $ out .= '<tr class="liste_titre"> ' ;
307+ $ out .= get_document_title_search ('text ' , 'Name ' );
308+ $ out .= '<td></td> ' ;
309+ $ out .= get_document_title_search ('date ' , 'Date ' , 'right ' );
310+ $ out .= '<td></td> ' ;
311+ $ out .= '<td class="right "> ' ;
312+ $ out .= '<i class="saturne-search-button fas fa-search" style="cursor: pointer;"></i> ' ;
313+ $ out .= ' ' ;
314+ $ out .= '<i class="saturne-cancel-button fas fa-times" style="cursor: pointer;"></i> ' ;
315+ $ out .= '</td> ' ;
316+
317+ $ out .= '</tr> ' ;
318+ $ out .= '<tr class="liste_titre"> ' ;
292319 $ out .= get_document_title_field ($ sortfield , $ sortorder , 'Name ' );
293320 $ out .= get_document_title_field ($ sortfield , $ sortorder , 'Size ' , true , 'right ' );
294321 $ out .= get_document_title_field ($ sortfield , $ sortorder , 'Date ' , true , 'right ' );
295322 $ out .= get_document_title_field ($ sortfield , $ sortorder , 'PDF ' , false , 'right ' );
296323 $ out .= get_document_title_field ($ sortfield , $ sortorder , 'Action ' , false , 'right ' );
297- // $out .= '</th>';
298324 $ out .= '</tr> ' ;
299325
300326 // Execute hooks
@@ -467,6 +493,16 @@ function saturne_show_documents(string $modulepart, $modulesubdir, $filedir, str
467493 return $ out ;
468494}
469495
496+ /**
497+ * Get document title field
498+ *
499+ * @param string $sortfield
500+ * @param string $sortorder
501+ * @param string $name
502+ * @param bool $sortable
503+ * @param string $morehtml
504+ * @return string
505+ */
470506function get_document_title_field (string $ sortfield , string $ sortorder , string $ name , bool $ sortable = true , string $ morehtml = '' ): string {
471507 global $ langs ;
472508
@@ -483,6 +519,23 @@ function get_document_title_field(string $sortfield, string $sortorder, string $
483519 $ out .= '</a> ' ;
484520 }
485521 $ out .='</th> ' ;
522+
523+ return $ out ;
524+ }
525+
526+ /**
527+ * Get document title search
528+ *
529+ * @param string $type
530+ * @param string $name
531+ * @param string $morehtml
532+ * @return string
533+ */
534+ function get_document_title_search (string $ type , string $ name , string $ morehtml = '' ): string
535+ {
536+ $ out = '<td class=" ' . $ morehtml .'"> ' ;
537+ $ out .= '<input class="saturne-search" id="search_ ' . strtolower ($ name ) . '" type=" ' . $ type .'" name="search_ ' . strtolower ($ name ) . '" value=" ' . GETPOST ('search_ ' . strtolower ($ name )) . '"> ' ;
538+ $ out .= '</td> ' ;
486539 return $ out ;
487540}
488541
0 commit comments