|
34 | 34 | third party library |
35 | 35 |
|
36 | 36 | TODO : |
37 | | - - improve selectors (what if 10+ devices) |
38 | | - - table isnt displaying selected devices (?) |
39 | | -
|
40 | | - THINK HARDER : |
41 | | - - autocompleted inputs vs dropdown selectors ? |
42 | | - in case 1 vs 15 > cant display 15 selectors but two autocompleted inputs could do |
43 | | -
|
44 | | - - php-diff only displays diff 1vs1 |
45 | | - - php-diff table are not (yet) collapsable |
| 37 | + - allow multiple comparison |
46 | 38 | */ |
47 | 39 | require_once('create_XML.php'); |
48 | 40 | include ('/usr/share/ocsinventory-reports/ocsreports/vendor/jfcherng/php-diff/example/demo_base.php'); |
|
65 | 57 | color: #fb0; |
66 | 58 | font-weight: normal; |
67 | 59 | }"; |
68 | | - |
69 | | -echo DiffHelper::getStyleSheet(); |
70 | | -echo "</style><br><br>"; |
| 60 | +// get custom css style sheet (columns width set to 50%) |
| 61 | +include '/usr/share/ocsinventory-reports/ocsreports/extensions/compare_devices/table_css/diff_table.css'; |
| 62 | +echo "</style>"; |
71 | 63 |
|
72 | 64 |
|
73 | 65 | printEnTete($l->g(23150)); |
|
79 | 71 |
|
80 | 72 |
|
81 | 73 | echo open_form($form_name, '', 'enctype="multipart/form-data"', 'form-horizontal'); |
82 | | -echo '<div class="col col-md-10" >'; |
| 74 | +echo '<div class="col col-md-12" >'; |
83 | 75 |
|
84 | | -// req to select from |
| 76 | +// get selection of devices available for comparison |
85 | 77 | $link = $_SESSION['OCS']["readServer"]; |
86 | 78 | $result = mysql2_query_secure("SELECT ID, DEVICEID FROM hardware WHERE deviceid <> '_SYSTEMGROUP_' AND deviceid <>'_DOWNLOADGROUP_'", $link); |
87 | 79 | $result = mysqli_fetch_all($result, MYSQLI_ASSOC); |
88 | 80 |
|
89 | | -// prepare array for selection |
| 81 | +// deviceid will be displayed by selectors |
90 | 82 | foreach ($result as $key => $value) { |
91 | 83 | $display[$key] = $value['DEVICEID']; |
92 | 84 | } |
93 | 85 |
|
94 | 86 | echo "<div> |
95 | 87 | <div>"; |
96 | | -// select main device and other devices |
97 | | -formGroup('select', 'main_device', 'Main device to compare :', '', '', '', '', $result, $display, "required"); |
98 | | -formGroup('select', 'other_device', 'Other device to compare :', '', '', '', '', $result, $display, "required"); |
99 | | -// submit values |
100 | | -echo "<input type='submit' name='compare' id='compare' class='btn btn-success' value='Compare devices'>"; |
101 | | -echo "</div> |
102 | | - </div>"; |
103 | | - |
104 | | - |
105 | | -// Display table of selected devices |
106 | | -$list_fields = array( |
107 | | - 'ID' => 'ID', |
108 | | - 'DEVICE ID' => 'DEVICEID', |
109 | | -); |
110 | | -$list_fields['SUP'] = 'ID'; |
111 | | -$tab_options['LBL_POPUP']['SUP'] = 'TYPE_NAME'; |
112 | | -$default_fields = $list_fields; |
113 | | -$list_col_cant_del = $list_fields; |
114 | | - |
115 | | -$devices = array($result[$protectedPost['main_device']]['ID'], $result[$protectedPost['other_device']]['ID']); |
116 | | -$in = implode(",", $devices); |
117 | | -// query for table display |
118 | | -$queryDetails = "SELECT ID, DEVICEID FROM hardware WHERE deviceid <> '_SYSTEMGROUP_' AND deviceid <>'_DOWNLOADGROUP_' AND id IN (".$in.")"; |
119 | | -ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); |
| 88 | +// selectors for main device and other devices |
| 89 | +formGroup('select', 'main_device', $l->g(23153), '', '', (int)$protectedPost['main_device'], '', $result, $display, "required"); |
| 90 | +formGroup('select', 'other_device', $l->g(23154), '', '', (int)$protectedPost['other_device'], '', $result, $display, "required"); |
120 | 91 |
|
| 92 | +$time_delay_text = $l->g(23152); |
| 93 | +$button_text = $l->g(23151); |
| 94 | +echo "<br><p>$time_delay_text</p><br>"; |
| 95 | +// submit values |
| 96 | +echo "<input type='submit' name='compare' id='compare' class='btn btn-success' value='$button_text'>"; |
121 | 97 | echo "</div> |
122 | 98 | </div>"; |
123 | 99 | echo close_form(); |
|
126 | 102 | // TRAITEMENT XML ------------------------------------------------- |
127 | 103 | $xml = new DeviceXML(); |
128 | 104 |
|
129 | | -// createXML acutally only creates xml structure in a string |
| 105 | +// get main device and other device as xml structured STRINGS |
130 | 106 | $main_device = $xml->createXML($result[$protectedPost['main_device']]['ID']); |
131 | 107 | $other_device = $xml->createXML($result[$protectedPost['other_device']]['ID']); |
132 | 108 |
|
133 | | -// demo the no-inline-detail diff |
| 109 | +// get differences between previously generated strings |
134 | 110 | $inlineResult = DiffHelper::calculate( |
135 | 111 | $main_device, |
136 | 112 | $other_device, |
|
140 | 116 | // detail levels : word, line, char, none |
141 | 117 | ['detailLevel' => 'none'] + $rendererOptions |
142 | 118 | ); |
143 | | -echo "<div class='col col-md-10' style='overflow-y: auto; height:300px;'><br><br>$inlineResult</div>"; |
| 119 | +echo "<div class='col col-md-12'><br><br>$inlineResult</div>"; |
144 | 120 | // ----------------------------------------------------------------- |
145 | 121 |
|
146 | 122 | if (AJAX) { |
|
0 commit comments