api.ponizerlegacy.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <?php
  2. /**
  3. * Ponizer legacy all-in-one-page renderer
  4. */
  5. class PONizerLegacy extends PONizer {
  6. protected $json = '';
  7. public function __construct() {
  8. parent::__construct();
  9. $this->json = new wf_JqDtHelper();
  10. }
  11. /**
  12. * Renders json formatted data for jquery data tables list
  13. *
  14. * @return void
  15. */
  16. public function ajaxOnuData($OltId = '') {
  17. foreach ($this->allOltDevices as $OltId => $eachOltData) {
  18. $OnuByOLT = $this->getOnuArrayByOltID($OltId);
  19. $allRealnames = zb_UserGetAllRealnames();
  20. $allAddress = zb_AddressGetFulladdresslistCached();
  21. $allTariffs = zb_TariffsGetAllUsers();
  22. if ($this->altCfg['ADCOMMENTS_ENABLED']) {
  23. $adcomments = new ADcomments('PONONU');
  24. $adc = true;
  25. } else {
  26. $adc = false;
  27. }
  28. $this->loadSignalsCache();
  29. $distCacheAvail = $this->oltData->isDistancesAvailable();
  30. if (!empty($distCacheAvail)) {
  31. $distCacheAvail = true;
  32. $this->loadDistanceCache();
  33. } else {
  34. $distCacheAvail = false;
  35. }
  36. $intCacheAvail = $this->oltData->isInterfacesAvailable();
  37. if (!empty($intCacheAvail)) {
  38. $intCacheAvail = true;
  39. $this->loadInterfaceCache();
  40. } else {
  41. $intCacheAvail = false;
  42. }
  43. $lastDeregCacheAvail = $this->oltData->isDeregsAvailable();
  44. if (!empty($lastDeregCacheAvail)) {
  45. $lastDeregCacheAvail = true;
  46. $this->loadLastDeregCache();
  47. } else {
  48. $lastDeregCacheAvail = false;
  49. }
  50. if (!empty($OnuByOLT)) {
  51. foreach ($OnuByOLT as $io => $each) {
  52. $userTariff = '';
  53. $ONUIsOffline = false;
  54. if (!empty($each['login'])) {
  55. $userLogin = trim($each['login']);
  56. $userLink = wf_Link('?module=userprofile&username=' . $userLogin, web_profile_icon() . ' ' . @$allAddress[$userLogin], false);
  57. @$userRealName = $allRealnames[$userLogin];
  58. //tariff data
  59. if (isset($allTariffs[$userLogin])) {
  60. $userTariff = $allTariffs[$userLogin];
  61. }
  62. } else {
  63. $userLink = '';
  64. $userRealName = '';
  65. }
  66. //checking adcomments availability
  67. if ($adc) {
  68. $indicatorIcon = $adcomments->getCommentsIndicator($each['id']);
  69. } else {
  70. $indicatorIcon = '';
  71. }
  72. $actLinks = wf_Link('?module=ponizer&editonu=' . $each['id'], web_edit_icon(), false);
  73. $actLinks .= ' ' . $indicatorIcon;
  74. //coloring signal
  75. if (isset($this->signalCache[$each['mac']])) {
  76. $signal = $this->signalCache[$each['mac']];
  77. if (($signal > 0) OR ( $signal < -25)) {
  78. $sigColor = self::COLOR_BAD;
  79. } else {
  80. $sigColor = self::COLOR_OK;
  81. }
  82. if ($signal == self::NO_SIGNAL) {
  83. $ONUIsOffline = true;
  84. $signal = __('No');
  85. $sigColor = self::COLOR_NOSIG;
  86. }
  87. } elseif (isset($this->signalCache[$each['serial']])) {
  88. $signal = $this->signalCache[$each['serial']];
  89. if (($signal > 0) OR ( $signal < -25)) {
  90. $sigColor = self::COLOR_BAD;
  91. } else {
  92. $sigColor = self::COLOR_OK;
  93. }
  94. if ($signal == self::NO_SIGNAL) {
  95. $ONUIsOffline = true;
  96. $signal = __('No');
  97. $sigColor = self::COLOR_NOSIG;
  98. }
  99. } else {
  100. $ONUIsOffline = true;
  101. $signal = __('No');
  102. $sigColor = self::COLOR_NOSIG;
  103. }
  104. $data[] = $each['id'];
  105. if ($this->altCfg['PONIZER_LEGACY_VIEW'] == 2) {
  106. $data[] = $this->allOltNames[$each['oltid']];
  107. }
  108. if ($intCacheAvail) {
  109. $data[] = @$this->interfaceCache[$each['mac']];
  110. }
  111. $data[] = $this->getModelName($each['onumodelid']);
  112. if ($this->ipColumnVisible) {
  113. $data[] = $each['ip'];
  114. }
  115. $data[] = $each['mac'];
  116. $data[] = wf_tag('font', false, '', 'color=' . $sigColor . '') . $signal . wf_tag('font', true);
  117. if ($distCacheAvail) {
  118. if (isset($this->distanceCache[$each['mac']])) {
  119. $data[] = @$this->distanceCache[$each['mac']];
  120. } else {
  121. $data[] = @$this->distanceCache[$each['serial']];
  122. }
  123. }
  124. if ($lastDeregCacheAvail) {
  125. if ($ONUIsOffline) {
  126. $data[] = @$this->lastDeregCache[$each['mac']];
  127. } else {
  128. $data[] = '';
  129. }
  130. }
  131. $data[] = $userLink;
  132. $data[] = $userRealName;
  133. $data[] = $userTariff;
  134. $data[] = $actLinks;
  135. $this->json->addRow($data);
  136. unset($data);
  137. }
  138. }
  139. }
  140. $this->json->getJson();
  141. }
  142. /**
  143. * Renders available ONU JQDT list container
  144. *
  145. * @return string
  146. */
  147. public function renderOnuList() {
  148. $distCacheAvail = $this->oltData->isDistancesAvailable();
  149. $intCacheAvail = $this->oltData->isInterfacesAvailable();
  150. $lastDeregCacheAvail = $this->oltData->isDeregsAvailable();
  151. $distCacheAvail = !empty($distCacheAvail) ? true : false;
  152. $intCacheAvail = !empty($intCacheAvail) ? true : false;
  153. $lastDeregCacheAvail = !empty($lastDeregCacheAvail) ? true : false;
  154. $oltOnuCounters = $this->getOltOnuCounts();
  155. $columns = array('ID');
  156. if (@$this->altCfg['PONIZER_LEGACY_VIEW'] == 2) {
  157. $columns[] = __('OLT');
  158. }
  159. if ($intCacheAvail) {
  160. $columns[] = __('Interface');
  161. }
  162. $columns[] = 'Model';
  163. if ($this->ipColumnVisible) {
  164. if (@$this->altCfg['PON_ONUIPASIF']) {
  165. $columns[] = 'Interface';
  166. } else {
  167. $columns[] = 'IP';
  168. }
  169. }
  170. $columns[] = 'MAC';
  171. $columns[] = 'Signal';
  172. if ($distCacheAvail) {
  173. $columns[] = __('Distance') . ' (' . __('m') . ')';
  174. }
  175. if ($lastDeregCacheAvail) {
  176. $columns[] = __('Last dereg reason');
  177. }
  178. $columns[] = 'Address';
  179. $columns[] = 'Real Name';
  180. $columns[] = 'Tariff';
  181. $columns[] = 'Actions';
  182. $opts = '"order": [[ 0, "desc" ]]';
  183. $result = '';
  184. $AjaxURLStr = '' . self::URL_ME . '&ajaxonu=true&legacyView=true';
  185. $result .= show_window('', wf_JqDtLoader($columns, $AjaxURLStr, false, 'ONU', 100, $opts));
  186. return ($result);
  187. }
  188. }