497a3564 by vanisha

table generation

1 parent dc218ee6
...@@ -19,13 +19,12 @@ ...@@ -19,13 +19,12 @@
19 19
20 <div class="container"> 20 <div class="container">
21 <table id="view_logs_entries_table" class="compact table table-bordered table-striped table-hover"> 21 <table id="view_logs_entries_table" class="compact table table-bordered table-striped table-hover">
22 <thead><tr><th class="center-class">Sno</th><th class="center-class">Cron file</th><th class="center-class">Cron timing</th><th class="center-class">Cron log</th></tr></thead> 22 <thead><tr><th class="center-class">Sno</th><th class="center-class">Cron file</th><th class="center-class">Cron log</th></tr></thead>
23 <tbody> 23 <tbody>
24 {{#tablecontents}} 24 {{#tablecontents}}
25 <tr> 25 <tr>
26 <td class="center-class">{{sno}}</td> 26 <td class="center-class">{{sno}}</td>
27 <td class="center-class">{{{name}}}</td> 27 <td class="center-class">{{{name}}}</td>
28 <td>{{{time}}}</td>
29 <td class="center-class">{{log}}</td> 28 <td class="center-class">{{log}}</td>
30 </tr> 29 </tr>
31 {{/tablecontents}} 30 {{/tablecontents}}
......
...@@ -42,6 +42,7 @@ $PAGE->set_heading($pluginname); ...@@ -42,6 +42,7 @@ $PAGE->set_heading($pluginname);
42 42
43 echo $OUTPUT->header(); 43 echo $OUTPUT->header();
44 44
45 $date = date('d-m-y');
45 46
46 $templatecontext = array(); 47 $templatecontext = array();
47 48
...@@ -53,7 +54,24 @@ $configpaths = get_config('block_log', 'block_log_path_info'); ...@@ -53,7 +54,24 @@ $configpaths = get_config('block_log', 'block_log_path_info');
53 $isadmin = has_capability('block/log:manageall', context_system::instance()); 54 $isadmin = has_capability('block/log:manageall', context_system::instance());
54 55
55 if($isadmin) { 56 if($isadmin) {
56 $templatecontext['tablecontents'] = ''; 57 $table_content_array = array(); $i =1;
58 $split_paths = explode(",",$configpaths);
59 foreach($split_paths as $split_path) {
60 $files = scandir($split_path);
61 foreach($files as $file) {
62 if($file === '.' || $file === '..') {continue;}
63 if( (str_contains($file, $date)) && (str_contains($file, '.log'))) {
64 $array = array();
65 $array['sno'] = $i;
66 $array['name'] = $file;
67 $array['log'] = file_get_contents($split_path.'/'.$file);
68 $table_content_array[] = $array;
69 }
70 }
71 }
72
73
74 $templatecontext['tablecontents'] = $table_content_array;
57 75
58 echo $OUTPUT->render_from_template('block_log/cron_logs_view', $templatecontext); 76 echo $OUTPUT->render_from_template('block_log/cron_logs_view', $templatecontext);
59 } 77 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!