superedit-ANALIZA_WIDOKOW_RAPORT_DAILY.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <?php
  2. function ANALIZA_WIDOKOW_RAPORT_DAILY() {
  3. global $result;
  4. SE_Layout::menu();
  5. $_GET['F_LIMIT'] = V::get('F_LIMIT', 50, $_GET, 'int');
  6. $_GET['TABLES_LIKE'] = V::get('TABLES_LIKE', '', $_GET);
  7. $__install = V::get('__install', '', $_GET);
  8. $db = DB::getDB();
  9. Lib::LoadClass('InstallerHelper') ;
  10. if(!empty($__install)) {
  11. //TODO example
  12. $installer=new InstallerHelper(); //('new_parent_option','NEW_TABLE');
  13. $new_MYSQL_SCHEMA = $installer->new_child('MYSQL_SCHEMA');
  14. $new_table = $new_MYSQL_SCHEMA->new_child('TABLES');
  15. $new_table->set_option('Table_type','BASE TABLE');
  16. $new_table->set_option('NAME','_ANALIZA_WIDOKOW_RAPORT_DAILY');
  17. $new_table_field = $new_table->new_child('FIELDS');
  18. $new_table_field->set_option('Field','ID');
  19. $new_table_field->set_option('Null','NO');
  20. $new_table_field->set_option('Key','PRI');
  21. $new_table_field->set_option('Default','');
  22. $new_table_field->set_option('Extra','auto_increment');
  23. $new_table_field_id = $new_table_field->new_child('Type');
  24. $new_table_field_id_int = $new_table_field_id->new_child('int');
  25. $new_table_field_id_int->set_option('M','11');
  26. DEBUG_S(-3,'new_table_field',$new_table_field);
  27. // unset($new_table_field);unset($new_table_field_id);unset($new_table_field_id_int);
  28. $new_table_field = $new_table->new_child('FIELDS');
  29. $new_table_field->set_option('Field','TABLE_NAME');
  30. $new_table_field->set_option('Null','NO');
  31. $new_table_field->set_option('Key','');
  32. $new_table_field->set_option('Default','');
  33. $new_table_field->set_option('Extra','auto_increment');
  34. $new_table_field_id = $new_table_field->new_child('Type');
  35. $new_table_field_id_int = $new_table_field_id->new_child('varchar');
  36. $new_table_field_id_int->set_option('M','255');
  37. DEBUG_S(-3,'new_table_field',$new_table_field);
  38. $new_table_field = $new_table->new_child('FIELDS');
  39. $new_table_field->set_option('Field','COUNT');
  40. $new_table_field->set_option('Null','NO');
  41. $new_table_field->set_option('Key','');
  42. $new_table_field->set_option('Default','');
  43. $new_table_field->set_option('Extra','auto_increment');
  44. $new_table_field_id = $new_table_field->new_child('Type');
  45. $new_table_field_id_int = $new_table_field_id->new_child('int');
  46. $new_table_field_id_int->set_option('M','11');
  47. $new_table_field = $new_table->new_child('FIELDS');
  48. $new_table_field->set_option('Field','FIELD');
  49. $new_table_field->set_option('Null','NO');
  50. $new_table_field->set_option('Key','');
  51. $new_table_field->set_option('Default','');
  52. $new_table_field->set_option('Extra','auto_increment');
  53. $new_table_field_id = $new_table_field->new_child('Type');
  54. $new_table_field_id_int = $new_table_field_id->new_child('varchar');
  55. $new_table_field_id_int->set_option('M','255');
  56. $new_table_field = $new_table->new_child('FIELDS');
  57. $new_table_field->set_option('Field','VALUE');
  58. $new_table_field->set_option('Null','NO');
  59. $new_table_field->set_option('Key','');
  60. $new_table_field->set_option('Default','');
  61. $new_table_field->set_option('Extra','auto_increment');
  62. $new_table_field_id = $new_table_field->new_child('Type');
  63. $new_table_field_id_int = $new_table_field_id->new_child('text');
  64. $new_table_field = $new_table->new_child('FIELDS');
  65. $new_table_field->set_option('Field','A_RECORD_CREATE_DATE');
  66. $new_table_field->set_option('Null','NO');
  67. $new_table_field->set_option('Key','');
  68. $new_table_field->set_option('Default','');
  69. $new_table_field->set_option('Extra','auto_increment');
  70. $new_table_field_id = $new_table_field->new_child('Type');
  71. $new_table_field_id_int = $new_table_field_id->new_child('varchar');
  72. $new_table_field_id_int->set_option('M','30');
  73. $new_table_index = $new_table->new_child('INDEX');
  74. $new_table_index->set_option('Key_name','TABLE_NAME');
  75. $new_table_index_col = $new_table_index->new_child('Column_name');
  76. $new_table_index_col->set_option('column','TABLE_NAME');
  77. $new_table_index_col = $new_table_index->new_child('Column_name');
  78. $new_table_index_col->set_option('column','VALUE');
  79. $new_table_index_col = $new_table_index->new_child('Column_name');
  80. $new_table_index_col->set_option('column','FIELD');
  81. $new_table_index_col = $new_table_index->new_child('Column_name');
  82. $new_table_index_col->set_option('column','A_RECORD_CREATE_DATE');
  83. // $new_table_index = $new_table->new_child('INDEX');
  84. // $new_table_field = $new_table_field->set_option('TABLE_FIELD_TYPE','INT');
  85. //
  86. // $new_table_field = $new_table->new_child('TABLE_FIELD');
  87. // $new_table_field = $new_table_field->set_option('TABLE_FIELD_NAME','A_RECORD_UPDATE_DATE');
  88. // $new_table_field = $new_table_field->set_option('TABLE_FIELD_TYPE','VARCHAR');
  89. // $new_table_field = $new_table_field->set_option('TABLE_FIELD_LENGHT','100');
  90. // $new_table->NEW_TABLE('dupa');
  91. DEBUG_S(-3,'installer',$installer);
  92. DEBUG_S(-3,'new_MYSQL_SCHEMA',$new_MYSQL_SCHEMA);
  93. DEBUG_S(-3,'new_table',$new_table);
  94. DEBUG_S(-3,'new_table_field',$new_table_field);
  95. // DEBUG_S(-3,'new_table',$new_table);
  96. //$install->__add_req_option('table');
  97. $installer->__install(); //@2016-08-05 TODO bindera - dla czego to sie nie wykonalo???
  98. //$table->get_options_status();
  99. //var_dump($install);
  100. //InstallerHelper::__install();
  101. // die('umarlem');
  102. }
  103. Lib::loadClass('ProcesHelper');
  104. $zasob_tabeli_hist=ProcesHelper::getZasobTableID('ANALIZA_WIDOKOW_RAPORT_DAILY');
  105. ?>
  106. ANALIZA_WIDOKOW_RAPORT_DAILY <form action='' METHOD='GET'>
  107. <input type="hidden" name="ADD" value="ADD">
  108. <input type="hidden" name="MENU_INIT" value="ANALIZA_WIDOKOW_RAPORT_DAILY">
  109. <a href=index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $zasob_tabeli_hist; ?> >Przeglądanie</a>
  110. <br>Czy zainstalować moduł ANALIZA_WIDOKOW_RAPORT_DAILY ?<input type="checkbox" name="__install">
  111. <table border=1>
  112. <tr>
  113. <td>Uruchomienie analizy statusow</td>
  114. </tr>
  115. <tr>
  116. <td colspan=1><input type="submit" name="ANALIZA_WIDOKOW_RAPORT_DAILY" value="ANALIZA_WIDOKOW_RAPORT_DAILY"></td>
  117. </tr>
  118. </table>
  119. <?php
  120. $RAPORT['IGNORE_TABLES'][] = "AUTOSHAPE";
  121. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_group_to_init_view";
  122. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_table_to_proces_grouped_view";
  123. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_table_to_proces_perms_view";
  124. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_table_to_proces_view";
  125. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_table_to_user_view";
  126. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_tables_info_view";
  127. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_url_to_proces_view";
  128. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_user_to_init_view";
  129. $RAPORT['IGNORE_TABLES'][] = "_TASKS_INFO_trigger";
  130. $RAPORT['IGNORE_TABLES'][] = "budget_project_to_realization_view";
  131. $RAPORT['IGNORE_TABLES'][] = "crm_proces_idx_user_to_proces_view";
  132. $RAPORT['IGNORE_TABLES'][] = "CRM_PROCES_idx_GROUP_to_PROCES";
  133. $RAPORT['IGNORE_TABLES'][] = "CRM_AUTH_PROFILE";
  134. $RAPORT['IGNORE_TABLES'][] = "CRM_CONFIG";
  135. $RAPORT['IGNORE_TABLES'][] = "CRM_CZYNNOSCI";
  136. $RAPORT['IGNORE_TABLES'][] = "CRM_IMPORT_TRANSLATE";
  137. $RAPORT['IGNORE_TABLES'][] = "CRM_PROCES_idx_GROUP_to_PROCES";
  138. $RAPORT['IGNORE_TABLES'][] = "CRM_PROCES_idx_GROUP_to_PROCES_PERM";
  139. $RAPORT['IGNORE_TABLES'][] = "CRM_PROCES_idx_TEMP";
  140. $RAPORT['IGNORE_TABLES'][] = "CRM_PRZYPADEK";
  141. $RAPORT['IGNORE_TABLES'][] = "CRM_UI_MSGS__EXEC_LOG";
  142. $RAPORT['IGNORE_TABLES'][] = "CRM_UI_MSGS";
  143. $RAPORT['IGNORE_TABLES'][] = "DEVICES_GROUP";
  144. $RAPORT['IGNORE_TABLES'][] = "GRAFIK_PRACY_view";
  145. $RAPORT['IGNORE_TABLES'][] = "ITEM_LINKS";
  146. $RAPORT['IGNORE_TABLES'][] = "KONTAKTY_view";
  147. $RAPORT['IGNORE_TABLES'][] = "ITEM_LINK_TYPES";
  148. $RAPORT['IGNORE_TABLES'][] = "LDAP_GROUPS";
  149. $RAPORT['IGNORE_TABLES'][] = "NETWORKS_SERVERS";
  150. $RAPORT['IGNORE_TABLES'][] = "_CRM_PROCES_GOTO_CACHE";
  151. $RAPORT['IGNORE_TABLES'][] = "_CRM_PROCES_STATS_proc_wiev";
  152. $RAPORT['IGNORE_TABLES'][] = "_SYNC_FILE_PERMS";
  153. $RAPORT['IGNORE_TABLES'][] = "_project_path_idx";
  154. $RAPORT['IGNORE_TABLES'][] = "BILLING_USERS_ADD_OLD";
  155. $RAPORT['IGNORE_TABLES'][] = "CRM_LISTA_ZASOBOW_ACL";
  156. $RAPORT['IGNORE_TABLES'][] = "CRM_LISTA_ZASOBOW_test";
  157. $RAPORT['IGNORE_TABLES'][] = "CRM_PROCES_idx_USER_to_PROCES_VIEW";
  158. $RAPORT['IGNORE_TABLES'][] = "CRM_PROCES_idx_USER_to_INIT_VIEW";
  159. $RAPORT['IGNORE_TABLES'][] = "DEALS_TABLE_2015_03_17_zest_dla_zubryka";
  160. $RAPORT['IGNORE_TABLES'][] = "_PLUGIN_MANAGER";
  161. $RAPORT['IGNORE_TABLES'][] = "_PRZYPOMNIJ_CACHE";
  162. // $RAPORT['IGNORE_TABLES'][] = "";
  163. //echo statystyka pracy historyczna w systemie
  164. $dbTbls = array();
  165. $ZAP_SQL = " SHOW FULL TABLES "; //-- WHERE TABLE_TYPE LIKE 'VIEW'
  166. if (!empty($_GET['TABLES_LIKE'])) {
  167. $ZAP_SQL .= " like '{$_GET['TABLES_LIKE']}' ";
  168. }
  169. echo "<br>Jade zapytanie ".$ZAP_SQL;
  170. $res = $db->query($ZAP_SQL);
  171. while($R = $db->fetch_array($res)) {
  172. $dbTbls[] = $R;
  173. }
  174. echo "<br> Widoki : ".print_r($dbTbls);
  175. DEBUG_S(-1,'widoki ',$dbTbls,__FILE__,__FUNCTION__,__LINE__);
  176. foreach ($dbTbls as $R) {
  177. if (!in_array($R[0], $RAPORT['IGNORE_TABLES'])) {
  178. if(!strstr($R[0], '_HIST'))
  179. $RAPORT['TABLES_ALL'][] = $R[0];
  180. }
  181. }
  182. echo "<br> TABLES_ALL : ".print_r($RAPORT['TABLES_ALL']);
  183. unset($dbTbls);
  184. $ZAP_SQL = array();
  185. foreach ($RAPORT['TABLES_ALL'] as $RTH_I=>$RTH_A) {
  186. $sql="select A_STATUS as VALUE, count(ID) as COUNT from ".$RTH_A." group by A_STATUS ";
  187. $res = $db->query($sql);
  188. //$r2 = $db->fetch_array($res);
  189. echo "<br> jade raport dla tabeli ".$RTH_A." sql:".$sql." print_r r2".print_r($r2) ;
  190. while($h=$db->fetch($res)) {
  191. if (isset($h->VALUE)) {
  192. //dobudowanie tabeli _ANALIZA_HISTORII_ALL
  193. $sql="insert ignore into _ANALIZA_WIDOKOW_RAPORT_DAILY( TABLE_NAME, COUNT,FIELD,VALUE,A_RECORD_CREATE_DATE ) values (
  194. '{$RTH_A}','{$h->COUNT}','A_STATUS','{$h->VALUE}',now())";
  195. echo "<br>".$sql;
  196. DB::query($sql) or die($sql);
  197. }
  198. }
  199. //teraz the_geom
  200. $sql="select if(the_geom like '_%',1,0) as VALUE, count(ID) as COUNT from ".$RTH_A." group by if(the_geom like '_%',1,0) ";
  201. $res = $db->query($sql);
  202. //$r2 = $db->fetch_array($res);
  203. echo "<br> jade raport dla tabeli ".$RTH_A." sql:".$sql." print_r r2".print_r($r2) ;
  204. while($h=$db->fetch($res)) {
  205. if (isset($h->VALUE)) {
  206. //dobudowanie tabeli _ANALIZA_HISTORII_ALL
  207. $sql="insert ignore into _ANALIZA_WIDOKOW_RAPORT_DAILY( TABLE_NAME, COUNT,FIELD,VALUE,A_RECORD_CREATE_DATE ) values (
  208. '{$RTH_A}','{$h->COUNT}','the_geom','{$h->VALUE}',now())";
  209. echo "<br>".$sql;
  210. DB::query($sql) or die($sql);
  211. }
  212. }
  213. }
  214. }