@@ -33,7 +33,7 @@ class FileManager implements ManagerInterface
3333{
3434 /**
3535 * Gestione "filelist_and_upload".
36- * Esempio: {( "name": "filelist_and_upload", "id_module": "2", "id_record": "1", "readonly": "false", "category": "", "upload_only": "false", "disable_edit": "false" )}.
36+ * Esempio: {( "name": "filelist_and_upload", "id_module": "2", "id_record": "1", "readonly": "false", "category": "", "upload_only": "false", "disable_edit": "false", "key": "table:1" )}.
3737 *
3838 * @param array $options
3939 *
@@ -52,11 +52,12 @@ public function manage($options)
5252 $ options ['disable_edit ' ] = ($ options ['disable_edit ' ] === true || $ options ['disable_edit ' ] === 'true ' || $ options ['disable_edit ' ] === '1 ' ) ? true : false ;
5353
5454 $ options ['id_plugin ' ] = !empty ($ options ['id_plugin ' ]) ? $ options ['id_plugin ' ] : null ;
55+ $ options ['key ' ] = !empty ($ options ['key ' ]) ? $ options ['key ' ] : null ;
5556
5657 $ id_categoria = $ options ['category ' ] ? Categoria::where ('name ' , $ options ['category ' ])->first ()->id : null ;
5758
5859 // ID del form
59- $ attachment_id = 'attachments_ ' .$ options ['id_module ' ].'_ ' .$ options ['id_plugin ' ].($ id_categoria ? '_ ' .$ id_categoria : '' );
60+ $ attachment_id = 'attachments_ ' .$ options ['id_module ' ].'_ ' .$ options ['id_plugin ' ].($ id_categoria ? '_ ' .$ id_categoria : '' ).( $ options [ ' key ' ] ? ' _ ' . md5 ( $ options [ ' key ' ]) : '' ) ;
6061
6162 if (ini_get ('upload_max_filesize ' ) < ini_get ('post_max_size ' )) {
6263 $ upload_max_filesize = ini_get ('upload_max_filesize ' );
@@ -72,7 +73,7 @@ public function manage($options)
7273
7374 // Codice HTML
7475 $ result = '
75- <div class="gestione-allegati" id=" ' .$ attachment_id .'" data-id_module=" ' .$ options ['id_module ' ].'" data-id_plugin=" ' .$ options ['id_plugin ' ].'" data-id_record=" ' .$ options ['id_record ' ].'" data-max_filesize=" ' .$ upload_max_filesize .'" data-id_category=" ' .$ id_categoria .'" data-upload_only=" ' .($ options ['upload_only ' ] ? 'true ' : 'false ' ).'" data-disable_edit=" ' .($ options ['disable_edit ' ] ? 'true ' : 'false ' ).'"> ' ;
76+ <div class="gestione-allegati" id=" ' .$ attachment_id .'" data-id_module=" ' .$ options ['id_module ' ].'" data-id_plugin=" ' .$ options ['id_plugin ' ].'" data-id_record=" ' .$ options ['id_record ' ].'" data-max_filesize=" ' .$ upload_max_filesize .'" data-id_category=" ' .$ id_categoria .'" data-upload_only=" ' .($ options ['upload_only ' ] ? 'true ' : 'false ' ).'" data-disable_edit=" ' .($ options ['disable_edit ' ] ? 'true ' : 'false ' ).'" data-key=" ' . $ options [ ' key ' ]. ' " > ' ;
7677
7778 if (!empty ($ options ['showcard ' ])) {
7879 $ result .= '
@@ -87,7 +88,14 @@ public function manage($options)
8788
8889 $ count = 0 ;
8990
90- $ where = '`id_module` ' .(!empty ($ options ['id_module ' ]) && empty ($ options ['id_plugin ' ]) ? '= ' .prepare ($ options ['id_module ' ]) : 'IS NULL ' ).' AND `id_plugin` ' .(!empty ($ options ['id_plugin ' ]) ? '= ' .prepare ($ options ['id_plugin ' ]) : 'IS NULL ' ).' AND `key` IS NULL ' ;
91+ $ where = '`id_module` ' .(!empty ($ options ['id_module ' ]) && empty ($ options ['id_plugin ' ]) ? '= ' .prepare ($ options ['id_module ' ]) : 'IS NULL ' ).' AND `id_plugin` ' .(!empty ($ options ['id_plugin ' ]) ? '= ' .prepare ($ options ['id_plugin ' ]) : 'IS NULL ' );
92+
93+ // Filtrare per key se specificata
94+ if (!empty ($ options ['key ' ])) {
95+ $ where .= ' AND `key` = ' .prepare ($ options ['key ' ]);
96+ } else {
97+ $ where .= ' AND (`key` IS NULL OR `key` = "") ' ;
98+ }
9199
92100 // Limitare alle categorie specificate
93101 if (!empty ($ id_categoria )) {
@@ -281,39 +289,39 @@ public function manage($options)
281289// Estraggo le righe spuntate
282290function getSelectFiles() {
283291 let data=new Array();
284- $(".files").find(".check_files:checked").each(function (){
292+ $("# ' . $ attachment_id . ' .files").find(".check_files:checked").each(function (){
285293 data.push($(this).closest("tr").data("id"));
286294 });
287295
288296 return data;
289297}
290298
291- $(".check_files").on("change", function() {
299+ $("# ' . $ attachment_id . ' .check_files").on("change", function() {
292300 let checked = 0;
293- $(".check_files").each(function() {
301+ $("# ' . $ attachment_id . ' .check_files").each(function() {
294302 if ($(this).is(":checked")) {
295303 checked = 1;
296304 }
297305 });
298306
299307 if (checked) {
300- $("#zip_files").removeClass("disabled");
301- $("#modifica_files").removeClass("disabled");
308+ $("# ' . $ attachment_id . ' # zip_files").removeClass("disabled");
309+ $("# ' . $ attachment_id . ' # modifica_files").removeClass("disabled");
302310 } else {
303- $("#zip_files").addClass("disabled");
304- $("#modifica_files").addClass("disabled");
311+ $("# ' . $ attachment_id . ' # zip_files").addClass("disabled");
312+ $("# ' . $ attachment_id . ' # modifica_files").addClass("disabled");
305313 }
306314});
307315
308- $("#check_all_files").click(function(){
316+ $("# ' . $ attachment_id . ' # check_all_files").click(function(){
309317 if( $(this).is(":checked") ){
310- $(".check_files").each(function(){
318+ $("# ' . $ attachment_id . ' .check_files").each(function(){
311319 if( !$(this).is(":checked") ){
312320 $(this).trigger("click");
313321 }
314322 });
315323 }else{
316- $(".check_files").each(function(){
324+ $("# ' . $ attachment_id . ' .check_files").each(function(){
317325 if( $(this).is(":checked") ){
318326 $(this).trigger("click");
319327 }
0 commit comments