PokazOfertyView.php 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  1. <?php
  2. class PokazOfertyView {
  3. private $args = array();
  4. public function set($k, $v) {
  5. $this->args[$k] = $v;
  6. }
  7. public function get($k) {
  8. return V::get($k, null, $this->args);
  9. }
  10. function print_css() {
  11. $col_silver = "#faf2f2";
  12. $col_silver_0 = "#ddd";//"#F2F2F2";
  13. $col_silver_1 = "#e6e6e6";//"#fff";
  14. $col_hover = "#daf9da";
  15. $col_sub_hover = "#ffe5b5";
  16. return '<style type="text/css">' . "
  17. body{font-family:arial; font-size:12px;}
  18. .tbl-view{}
  19. .tbl-view th,
  20. .tbl-view td{ padding:0 2px; font-size:12px; }
  21. .tbl-view thead th{ background:#F3F3F3; }
  22. #tbl-oferty {width:98%; margin-top:3px; border-color:#aaa;}
  23. #tbl-oferty th,
  24. #tbl-oferty td{font-size:12px;}
  25. #tbl-oferty th{background-color:#C7C7E5; border-color:#aaa;}
  26. #tbl-oferty .tbl-row {cursor:pointer; margin:0;}
  27. #tbl-oferty .tbl-row-0 td{background-color:$col_silver_0;}
  28. #tbl-oferty .tbl-row-1 td{background-color:$col_silver_1;}
  29. #tbl-oferty .cell-id{width:3%; font-size:14px; font-weight:bold; font-family:monospace;}
  30. #tbl-oferty .active td.cell-id{background-color:$col_hover; border-bottom:none;}
  31. #tbl-oferty .sub td{background-color:$col_hover;}
  32. #tbl-oferty .tbl-row:hover td{background-color:$col_hover;}
  33. #tbl-oferty .sub-oferty{width:95%; margin:0 0 0 auto; padding:0; border:none;}
  34. #tbl-oferty .sub-oferty tr.selected,
  35. #tbl-oferty .sub-oferty tr:hover td{background-color:$col_sub_hover;color:#444;}
  36. #tbl-oferty .sub-oferty-wrap{padding:0; border-top:none; border-bottom:1px solid #333;}
  37. #tbl-oferty .sub-0 .sub-oferty-wrap{background-color:$col_hover;}
  38. #tbl-oferty .sub-1 .sub-oferty-wrap{background-color:$col_hover;}
  39. #tbl-oferty .sub-oferty th{background-color:#f1f1f1; border-color:#aaa; color:#000;}
  40. #tbl-oferty .sub-oferty td{background-color:#fff; border-color:#aaa; color:#444;}
  41. #tbl-oferty code{padding:0 2px;color:#666; font-size:10px;}
  42. #tbl-oferty .cell-suma_1 {text-align:right; white-space:nowrap;}
  43. #tbl-oferty .cell-suma_2 {text-align:right; white-space:nowrap;}
  44. #tbl-oferty .cell-cost {text-align:right; white-space:nowrap;}
  45. #tbl-oferty .cell-zysk {border-left:2px solid red; background:#FFB5B5; text-align:right; white-space:nowrap;}
  46. #tbl-oferty .row-oferty-opcje td {background:#FBFFCF; color:#aaa;}
  47. #tbl-oferty .row-oferty-opcje-selected td {background:#fff; color:#444;}
  48. #tbl-oferty tbody.hide_options .row-oferty-opcje {display:none}
  49. .podglad-users2_deals td.DATA_DOK,
  50. .podglad-users2_deals td.P_DEAL_DATE_NEW,
  51. .podglad-users2_deals td.P_DEALTERM_NEW,
  52. .podglad-users2_deals td.P_DEAL_DATE_OLD,
  53. .podglad-users2_deals td.P_DEALTERM_OLD,
  54. .podglad-users2_deals td.P_DEALDATE,
  55. .podglad-users2_deals td.P_DEALDATE_TERM {white-space:nowrap;}
  56. .podglad-users2_deals .old-deal {display:none;}
  57. .podglad-users2_deals .old-deal td {background:#eee;}
  58. " . '</style>';
  59. }
  60. function print_jquery_ui() {
  61. $out = '<link rel="stylesheet" type="text/css" href="stuff/jquery-ui-smoothness/jquery-ui-1.10.1.custom.min.css">' . "\n";
  62. $out .= '<script type="text/javascript" src="stuff/jquery-ui.custom.min.js"></script>' . "\n";
  63. return $out;
  64. }
  65. function print_ui_widget_info($title, $msg = '') {
  66. $out .= '<div class="ui-widget">';
  67. $out .= '<div class="ui-state-highlight ui-corner-all" style="margin-top:20px; padding:0 .7em;">';
  68. $out .= '<p><span class="ui-icon ui-icon-info" style="float:left; margin-right:.3em;"></span>';
  69. $out .= '<strong></strong> ' . $title . '</p>';
  70. if (!empty($msg)) {
  71. $out .= '<p>' . $msg . '</p>';
  72. }
  73. $out .= '</div>';
  74. $out .= '</div>';
  75. return $out;
  76. }
  77. function print_ui_widget_ok($title, $msg = '') {
  78. $out .= '<div class="ui-widget">';
  79. $out .= '<div class="ui-state-highlight ui-corner-all" style="margin-top:20px; padding:0 .7em;">';
  80. $out .= '<p><span class="ui-icon ui-icon-check" style="float:left; margin-right:.3em;"></span>';
  81. $out .= '<strong></strong> ' . $title . '</p>';
  82. if (!empty($msg)) {
  83. $out .= '<p>' . $msg . '</p>';
  84. }
  85. $out .= '</div>';
  86. $out .= '</div>';
  87. return $out;
  88. }
  89. function print_ui_widget_errors($title, $errors_arr = array()) {
  90. $out = '';
  91. $out .= '<div class="ui-widget">';
  92. $out .= '<div class="ui-state-error ui-corner-all" style="padding:0 .7em;">';
  93. $out .= '<p><span class="ui-icon ui-icon-alert" style="float:left; margin-right:.3em;"></span>';
  94. $out .= '<strong>Error:</strong> ' . $title . '</p>';
  95. if (!empty($errors_arr)) {
  96. $out .= '<ul style="color:red"><li>' . implode('</li><li>', $errors_arr) . '</li></ul>';
  97. }
  98. $out .= '</div>';
  99. $out .= '</div>';
  100. return $out;
  101. }
  102. function print_simple_tbl_header($cols, $caption = '') {
  103. if (!empty($caption)) echo '<caption>' . $caption . '</caption>';
  104. $is_ID = in_array('ID', $cols);
  105. echo '<thead><tr>';
  106. if ($is_ID) {
  107. echo '<th>' . "ID" . '</th>';
  108. }
  109. foreach ($cols as $v_field_name) {
  110. if ($is_ID && $v_field_name == 'ID') continue;
  111. echo '<th>' . str_replace('_', ' ', $v_field_name) . '</th>';
  112. }
  113. echo '</tr></thead>';
  114. }
  115. function print_simple_tbl_body_row($obj, $cols, $params = array()) {
  116. $is_ID = in_array('ID', $cols);
  117. $cls = V::get('class', '', $params);
  118. if (!empty($cls)) $cls = ' class="' . $cls . '"';
  119. echo '<tr' . $cls . '>';
  120. if ($is_ID) {
  121. if (isset($obj->ID)) {
  122. echo '<td>' . $obj->ID . '</td>';
  123. } else {
  124. echo '<td>' . "&nbsp;" . '</td>';
  125. }
  126. }
  127. foreach ($cols as $v_field_name) {
  128. if ($is_ID && $v_field_name == 'ID') continue;
  129. if (isset($obj->$v_field_name)) {
  130. echo '<td>';
  131. if (strlen($obj->$v_field_name) > 20) {
  132. echo '<span title="' . htmlspecialchars($obj->$v_field_name) . '">' . substr($obj->$v_field_name, 0, 20) . "..." . '</span>';
  133. } else {
  134. echo $obj->$v_field_name;
  135. }
  136. echo '</td>';
  137. } else {
  138. echo '<td>' . "&nbsp;" . '</td>';
  139. }
  140. }
  141. echo '</tr>';
  142. }
  143. function print_simple_tbl($obj, $cols, $caption = '') {
  144. echo '<table cellspacing="0" cellpadding="0" border="1" class="tbl-view">';
  145. if (!empty($caption)) echo '<caption>' . $caption . '</caption>';
  146. PokazOfertyView::print_simple_tbl_header($cols);
  147. echo '<tbody>';
  148. PokazOfertyView::print_simple_tbl_body_row($obj, $cols);
  149. echo '</tbody>';
  150. echo '</table>';
  151. }
  152. function printServices($user, $active_deals_by_id) {
  153. ?>
  154. <h4>Aktualne umowy</h4>
  155. <div style="padding:6px; border-left:1px solid silver;">
  156. <?php if (empty($active_deals_by_id)) : ?>
  157. Brak aktualnych umów
  158. <?php else : ?>
  159. <table cellspacing="0" cellpadding="0" border="1" class="tbl-view-wrap" id="tbl-user-deals-info">
  160. <?php
  161. $has_not_active = false;
  162. foreach ($active_deals_by_id as $k_id_deal => $v_deal) {
  163. if (!empty($v_deal->services)) {
  164. foreach ($v_deal->services as $k_p_service => $v_srv_arr) {
  165. foreach ($v_srv_arr as $k_srv_id => $v_srv) {
  166. if ($v_srv->_status != 'NORMAL') {
  167. $has_not_active = true;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. if ($has_not_active) : ?>
  174. <caption class="tbl-actions">
  175. <button class="all">Pokaż wszystkie usługi</button>
  176. <button class="active_only">Pokaż tylko aktywne usługi</button>
  177. </caption>
  178. <?php endif; ?>
  179. <thead><tr>
  180. <th>ID</th>
  181. <th>Numer umowy</th>
  182. <th>Data umowy</th>
  183. <th>Termin</th>
  184. <th>Adres</th>
  185. <th>Pakiet</th>
  186. </tr></thead>
  187. <tbody>
  188. <?php
  189. foreach ($active_deals_by_id as $k_id_deal => $v_deal) {
  190. echo '<tr class="tbl-row-0">';
  191. echo '<th>' . $v_deal->ID_DEALS . '</th>';
  192. echo '<td>' . "Numer: " . $v_deal->P_DEALNUMBER . '</td>';
  193. echo '<td>' . "Data: " . $v_deal->P_DEALDATE . '</td>';
  194. echo '<td>' . "Termin: " .$v_deal->P_DEALDATE_TERM . '</td>';
  195. echo '<td>' . $v_deal->SERVICES_S_ADDRESS_STREET . '</td>';
  196. echo '<td>' . "Pakiet: " . (($v_deal->ID_OFFERS_GROUP > 0)? $v_deal->ID_OFFERS_GROUP : '<span style="color:red">' . "nieznany" . '</span>') . '</td>';
  197. echo '</tr>';
  198. if (empty($v_deal->services)) {
  199. echo '<tr class="tbl-row-1"><td colspan="6">' . "Brak przypisanych usług" . '</td></tr>';
  200. } else {
  201. echo '<tr class="tbl-row-1">';
  202. echo '<td>' . "&nbsp;" . '</td>';
  203. echo '<td colspan="6" style="padding:0 0 7px 0;">';
  204. echo '<table cellspacing="0" cellpadding="0" border="1" class="tbl-view">';
  205. echo '<thead>';
  206. echo '<tr>';
  207. echo '<th>' . "ID" . '</th>';
  208. echo '<th>' . "P_SERVICE" . '</th>';
  209. echo '<th>' . "ABONAMENT_VALUE" . '</th>';
  210. echo '<th>' . "ID_OFFERS" . '</th>';
  211. echo '<th>' . "description" . '</th>';
  212. echo '<th>' . "parametry (ses_x_a)" . '</th>';
  213. echo '<th>' . "T WHEN CONNECTED" . '</th>';
  214. echo '<th>' . "STATUS" . '</th>';
  215. echo '<th>' . "HANGUP" . '</th>';
  216. echo '</tr>';
  217. echo '</thead>';
  218. echo '<tbody>';
  219. foreach ($v_deal->services as $k_p_service => $v_srv_arr) {
  220. foreach ($v_srv_arr as $k_srv_id => $v_srv) {
  221. $ses_x_a = null;
  222. if (!array_key_exists($k_srv_id, $v_deal->ses_x_a)) {
  223. echo 'brak danych';
  224. } else {
  225. $ses_x_a = $v_deal->ses_x_a[$k_srv_id];
  226. }
  227. echo '<tr class="tbl-row-1 srv-status-' . $v_srv->_status . '">';
  228. echo '<td>' . $v_srv->ID . '</td>';
  229. echo '<td>' . $v_srv->P_SERVICE . '</td>';
  230. echo '<td>' . $v_srv->ABONAMENT_VALUE . '</td>';
  231. echo '<td>' . $v_srv->ID_OFFERS . '</td>';
  232. echo '<td>' . $v_srv->description . '</td>';
  233. echo '<td>';
  234. if ($ses_x_a) {
  235. // show params
  236. $srv_params = array();
  237. if ($v_srv->NAME_LIST_SERVICES == 'USERS2') {
  238. $srv_params []= '<span title="' . "Początkowa prędkość dostępu (dla danej uslugi) - P_SERVICE_QUOTA" . '">' . $ses_x_a->P_SERVICE_QUOTA . "kbit" . '</span>';
  239. if ($ses_x_a->CONN_DIV == 'YES') {
  240. $srv_params []= '<span title="' . "podział łącza" . '">' . "CONN_DIV" . '</span>';
  241. }
  242. if ($ses_x_a->S_PUBLIC_IP == 'YES') {
  243. $srv_params []= '<span title="' . "Zewnętrzne IP" . '">' . "S_PUBLIC_IP" . '</span>';
  244. }
  245. if ($ses_x_a->S_E_PORT_1293 == 'YES') {
  246. $srv_params []= '<span title="' . "Przekierowanie portu TCP/IP" . '">' . "PORT" . '</span>';
  247. }
  248. if ($ses_x_a->S_SOHO_WIFI_ROUTER_1292 == 'YES') {
  249. $srv_params []= '<span title="' . "Dzierżawa urządzenia WIFI z ROUTEREM" . '">' . "WIFI ROUTER" . '</span>';
  250. }
  251. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TV (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($ses_x_a);echo'</pre>';
  252. }
  253. else if ($v_srv->NAME_LIST_SERVICES == 'TV') {
  254. $srv_params []= '<span title="' . "Typ usługi TV do ustalenia w systemie" . '">' . $ses_x_a->P_SERVICE_CLASS . '</span>';
  255. if ($ses_x_a->P_DEVICE != 'BRAK') {
  256. $srv_params []= '<span title="' . "Dzierżawa urządzenia do odbioru TV" . '">' . $ses_x_a->P_DEVICE . '</span>';
  257. }
  258. if ($ses_x_a->P_SERVICE_SOCKETS_AMMOUNT_1298 > 0) {
  259. $srv_params []= '<span title="' . "Ilość dodatkowych gniazd analogowych do zainstalowania u klienta" . '">' . "Dodatkowe gniazda: " . $ses_x_a->P_SERVICE_SOCKETS_AMMOUNT_1298 . '</span>';
  260. }
  261. if ($ses_x_a->ID_DOMAINS_PACKET_ID > 0) {
  262. $srv_params []= '<span title="' . "Numer pakietu/cennika z zewnętrznego systemu" . '">' . $ses_x_a->ID_DOMAINS . ": " . $ses_x_a->ID_DOMAINS_PACKET_ID . '</span>';
  263. }
  264. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TV (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($ses_x_a);echo'</pre>';
  265. }
  266. else if ($v_srv->NAME_LIST_SERVICES == 'VOIP') {
  267. if (!empty($ses_x_a->S_PHONE_NUMBER)) {
  268. $srv_params []= '<span title="' . "Numer tel" . '">' . $ses_x_a->S_PHONE_NUMBER . '</span>';
  269. }
  270. if (!empty($ses_x_a->ID_DOMAINS)) {
  271. $srv_params []= '<span title="' . "Numer pakietu/cennika z zewnętrznego systemu" . '">' . $ses_x_a->ID_DOMAINS . ": " . $ses_x_a->ID_DOMAINS_PACKET_ID . '</span>';
  272. }
  273. }
  274. if (empty($srv_params)) {
  275. echo 'brak danych';
  276. } else {
  277. echo implode(', ', $srv_params);
  278. }
  279. }
  280. echo '</td>';
  281. echo '<td>';
  282. if ($ses_x_a) {
  283. echo $ses_x_a->T_WHEN_CONNECTED;
  284. }
  285. echo '</td>';
  286. echo '<td class="col-A_STATUS_DESC-'.$v_srv->_status.'">';
  287. echo ($v_srv->A_STATUS_DESC)? $v_srv->A_STATUS_DESC : $v_srv->_status;
  288. echo '</td>';
  289. echo '<td>';
  290. if ($v_srv->HANGUP_FROM || $v_srv->HANGUP_TILL) {
  291. if ($v_srv->HANGUP_STATUS) {
  292. echo ' <em>' . $v_srv->HANGUP_STATUS . '</em>';
  293. }
  294. echo ' (';
  295. echo ($v_srv->HANGUP_FROM)? $v_srv->HANGUP_FROM : '0000-00-00';
  296. echo ' - ';
  297. echo ($v_srv->HANGUP_TILL)? $v_srv->HANGUP_TILL : '0000-00-00';
  298. echo ')';
  299. }
  300. echo '</td>';
  301. echo '</tr>' . "\n";
  302. }
  303. }
  304. echo '</tbody>';
  305. echo '</table>';
  306. echo '</td>';
  307. echo '</tr>';
  308. }
  309. }
  310. ?>
  311. </tbody>
  312. </table>
  313. <?php endif; ?>
  314. </div>
  315. <?php
  316. }
  317. function user_with_services($user, $active_deals_by_id) {
  318. ?>
  319. <style type="text/css">
  320. .tbl-view-wrap {}
  321. .tbl-view-wrap tr {background:#fff;}
  322. #tbl-user-deals-info {}
  323. #tbl-user-deals-info .tbl-actions {text-align:left;}
  324. #tbl-user-deals-info th,
  325. #tbl-user-deals-info td {padding:0 2px; text-align:left;}
  326. #tbl-user-deals-info td {border-color:#eee;}
  327. #tbl-user-deals-info thead th,
  328. #tbl-user-deals-info thead td {background:#f3f3f3;}
  329. #tbl-user-deals-info tr.tbl-row-0 {background:#f3f3f3;}
  330. #tbl-user-deals-info tr.tbl-row-1 {background:#fff;}
  331. #tbl-user-deals-info .tbl-actions .all {display:none;}
  332. #tbl-user-deals-info .tbl-actions .with_offers_only {display:inline;}
  333. #tbl-user-deals-info.active_only .tbl-actions .all {display:inline;}
  334. #tbl-user-deals-info.active_only .tbl-actions .active_only {display:none;}
  335. #tbl-user-deals-info.active_only .srv-status- {display:none;}
  336. #tbl-user-deals-info.active_only .srv-status-WAITING {display:none;}
  337. #tbl-user-deals-info.active_only .srv-status-NORMAL {}
  338. #tbl-user-deals-info.active_only .srv-status-OFF_SOFT {display:none;}
  339. #tbl-user-deals-info.active_only .srv-status-OFF_HARD {display:none;}
  340. #tbl-user-deals-info .col-A_STATUS_DESC-OFF_HARD {background-color:#FFBABA;}
  341. #tbl-user-deals-info .col-A_STATUS_DESC-OFF_SOFT {background-color:#D6D6D6;}
  342. #tbl-user-deals-info .col-A_STATUS_DESC-NORMAL {background-color:#BDFDBD;}
  343. </style>
  344. <script type="text/javascript">
  345. jQuery(document).ready(function(){
  346. jQuery('#tbl-user-deals-info').find('.tbl-actions button').click(function(e){
  347. console.log(e);
  348. var n=jQuery(e.target);
  349. if (n.hasClass('active_only')) {
  350. jQuery('#tbl-user-deals-info').removeClass('all');
  351. jQuery('#tbl-user-deals-info').addClass('active_only');
  352. } else {
  353. jQuery('#tbl-user-deals-info').removeClass('active_only');
  354. jQuery('#tbl-user-deals-info').addClass('all');
  355. }
  356. })
  357. });
  358. </script>
  359. <div style="margin:10px 0;padding:6px 10px;border:1px solid blue;background:#C0DDFC;">
  360. <table cellspacing="0" cellpadding="0" border="0"><tr>
  361. <?php if ($user) : ?>
  362. <th style="text-align:left">
  363. Dane klienta <?php echo $user->ID_BILLING_USERS . (($user->is_firma)? ' <b style="color:red">' . "(firma)" . '</b>' : ''); ?>
  364. <?php if ($user->BILLING_OWNER == 1) : ?>
  365. <em style="float:right;padding:0 10px;">BIALL-NET</em>
  366. <?php elseif ($user->BILLING_OWNER == 2) : ?>
  367. <em style="float:right;padding:0 10px;">NETDAY</em>
  368. <?php endif; ?>
  369. </th>
  370. <?php endif; ?>
  371. <th style="padding:0 0 0 10px; text-align:left; border-left:1px solid silver">
  372. Aktualne umowy
  373. </th>
  374. </tr><tr>
  375. <?php $t = 0; if ($user) : ?>
  376. <td style="padding:0 10px 0 0; vertical-align:top;">
  377. <table cellspacing="0" cellpadding="0" border="1" class="tbl-view">
  378. <tr class="tbl-row-<?php echo ($t = 1 - $t); ?>"><td>Imię i nazwisko</td><td><b><?php echo $user->P_NAME . " " . $user->P_NAME_SECOND; ?></b></td></tr>
  379. <tr class="tbl-row-<?php echo ($t = 1 - $t); ?>"><td>adres</td><td>ul. <?php echo $user->P_ADDRESS_STREET . " " . $user->P_ADDRESS_HOUSE . "/" . $user->P_ADDRESS_HOME . ", " . $user->P_ADDRESS_POST_CODE . " " . $user->P_ADDRESS_CITY; ?></td></tr>
  380. <tr class="tbl-row-<?php echo ($t = 1 - $t); ?>"><td>tel.</td><td><?php echo $user->P_PHONE; ?></td></tr>
  381. <tr class="tbl-row-<?php echo ($t = 1 - $t); ?>"><td>mail</td><td><?php echo $user->user_mail_contact; ?></td></tr>
  382. </table>
  383. </td>
  384. <?php endif; ?>
  385. <td style="padding:0 0 0 10px; vertical-align:top; border-left:1px solid silver">
  386. <?php if (empty($active_deals_by_id)) : ?>
  387. Brak aktualnych umów
  388. <?php else : ?>
  389. <table cellspacing="0" cellpadding="0" border="1" class="tbl-view-wrap" id="tbl-user-deals-info">
  390. <?php
  391. $has_not_active = false;
  392. foreach ($active_deals_by_id as $k_id_deal => $v_deal) {
  393. if (!empty($v_deal->services)) {
  394. foreach ($v_deal->services as $k_p_service => $v_srv_arr) {
  395. foreach ($v_srv_arr as $k_srv_id => $v_srv) {
  396. if ($v_srv->_status != 'NORMAL') {
  397. $has_not_active = true;
  398. }
  399. }
  400. }
  401. }
  402. }
  403. if ($has_not_active) : ?>
  404. <caption class="tbl-actions">
  405. <button class="all">Pokaż wszystkie usługi</button>
  406. <button class="active_only">Pokaż tylko aktywne usługi</button>
  407. </caption>
  408. <?php endif; ?>
  409. <thead><tr>
  410. <th>ID</th>
  411. <th>Numer umowy</th>
  412. <th>Data umowy</th>
  413. <th>Termin</th>
  414. <th>Adres</th>
  415. <th>Pakiet</th>
  416. </tr></thead>
  417. <tbody>
  418. <?php
  419. foreach ($active_deals_by_id as $k_id_deal => $v_deal) {
  420. echo '<tr class="tbl-row-0">';
  421. echo '<th>' . $v_deal->ID_DEALS . '</th>';
  422. echo '<td>' . "Numer: " . $v_deal->P_DEALNUMBER . '</td>';
  423. echo '<td>' . "Data: " . $v_deal->P_DEALDATE . '</td>';
  424. echo '<td>' . "Termin: " .$v_deal->P_DEALDATE_TERM . '</td>';
  425. echo '<td>' . $v_deal->SERVICES_S_ADDRESS_STREET . '</td>';
  426. echo '<td>' . "Pakiet: " . (($v_deal->ID_OFFERS_GROUP > 0)? $v_deal->ID_OFFERS_GROUP : '<span style="color:red">' . "nieznany" . '</span>') . '</td>';
  427. echo '</tr>';
  428. if (empty($v_deal->services)) {
  429. echo '<tr class="tbl-row-1"><td colspan="6">' . "Brak przypisanych usług" . '</td></tr>';
  430. } else {
  431. echo '<tr class="tbl-row-1">';
  432. echo '<td>' . "&nbsp;" . '</td>';
  433. echo '<td colspan="6" style="padding:0 0 7px 0;">';
  434. echo '<table cellspacing="0" cellpadding="0" border="1" class="tbl-view">';
  435. echo '<thead>';
  436. echo '<tr>';
  437. echo '<th>' . "ID" . '</th>';
  438. echo '<th>' . "P_SERVICE" . '</th>';
  439. echo '<th>' . "ABONAMENT_VALUE" . '</th>';
  440. echo '<th>' . "ID_OFFERS" . '</th>';
  441. echo '<th>' . "description" . '</th>';
  442. echo '<th>' . "parametry (ses_x_a)" . '</th>';
  443. echo '<th>' . "T WHEN CONNECTED" . '</th>';
  444. echo '<th>' . "STATUS" . '</th>';
  445. echo '<th>' . "HANGUP" . '</th>';
  446. echo '</tr>';
  447. echo '</thead>';
  448. echo '<tbody>';
  449. foreach ($v_deal->services as $k_p_service => $v_srv_arr) {
  450. foreach ($v_srv_arr as $k_srv_id => $v_srv) {
  451. $ses_x_a = null;
  452. if (!array_key_exists($k_srv_id, $v_deal->ses_x_a)) {
  453. echo 'brak danych';
  454. } else {
  455. $ses_x_a = $v_deal->ses_x_a[$k_srv_id];
  456. }
  457. echo '<tr class="tbl-row-1 srv-status-' . $v_srv->_status . '">';
  458. echo '<td>' . $v_srv->ID . '</td>';
  459. echo '<td>' . $v_srv->P_SERVICE . '</td>';
  460. echo '<td>' . $v_srv->ABONAMENT_VALUE . '</td>';
  461. echo '<td>' . $v_srv->ID_OFFERS . '</td>';
  462. echo '<td>' . $v_srv->description . '</td>';
  463. echo '<td>';
  464. if ($ses_x_a) {
  465. // show params
  466. $srv_params = array();
  467. if ($v_srv->NAME_LIST_SERVICES == 'USERS2') {
  468. $srv_params []= '<span title="' . "Początkowa prędkość dostępu (dla danej uslugi) - P_SERVICE_QUOTA" . '">' . $ses_x_a->P_SERVICE_QUOTA . "kbit" . '</span>';
  469. if ($ses_x_a->CONN_DIV == 'YES') {
  470. $srv_params []= '<span title="' . "podział łącza" . '">' . "CONN_DIV" . '</span>';
  471. }
  472. if ($ses_x_a->S_PUBLIC_IP == 'YES') {
  473. $srv_params []= '<span title="' . "Zewnętrzne IP" . '">' . "S_PUBLIC_IP" . '</span>';
  474. }
  475. if ($ses_x_a->S_E_PORT_1293 == 'YES') {
  476. $srv_params []= '<span title="' . "Przekierowanie portu TCP/IP" . '">' . "PORT" . '</span>';
  477. }
  478. if ($ses_x_a->S_SOHO_WIFI_ROUTER_1292 == 'YES') {
  479. $srv_params []= '<span title="' . "Dzierżawa urządzenia WIFI z ROUTEREM" . '">' . "WIFI ROUTER" . '</span>';
  480. }
  481. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TV (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($ses_x_a);echo'</pre>';
  482. }
  483. else if ($v_srv->NAME_LIST_SERVICES == 'TV') {
  484. $srv_params []= '<span title="' . "Typ usługi TV do ustalenia w systemie" . '">' . $ses_x_a->P_SERVICE_CLASS . '</span>';
  485. if ($ses_x_a->P_DEVICE != 'BRAK') {
  486. $srv_params []= '<span title="' . "Dzierżawa urządzenia do odbioru TV" . '">' . $ses_x_a->P_DEVICE . '</span>';
  487. }
  488. if ($ses_x_a->P_SERVICE_SOCKETS_AMMOUNT_1298 > 0) {
  489. $srv_params []= '<span title="' . "Ilość dodatkowych gniazd analogowych do zainstalowania u klienta" . '">' . "Dodatkowe gniazda: " . $ses_x_a->P_SERVICE_SOCKETS_AMMOUNT_1298 . '</span>';
  490. }
  491. if ($ses_x_a->ID_DOMAINS_PACKET_ID > 0) {
  492. $srv_params []= '<span title="' . "Numer pakietu/cennika z zewnętrznego systemu" . '">' . $ses_x_a->ID_DOMAINS . ": " . $ses_x_a->ID_DOMAINS_PACKET_ID . '</span>';
  493. }
  494. //echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">TV (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($ses_x_a);echo'</pre>';
  495. }
  496. else if ($v_srv->NAME_LIST_SERVICES == 'VOIP') {
  497. if (!empty($ses_x_a->S_PHONE_NUMBER)) {
  498. $srv_params []= '<span title="' . "Numer tel" . '">' . $ses_x_a->S_PHONE_NUMBER . '</span>';
  499. }
  500. if (!empty($ses_x_a->ID_DOMAINS)) {
  501. $srv_params []= '<span title="' . "Numer pakietu/cennika z zewnętrznego systemu" . '">' . $ses_x_a->ID_DOMAINS . ": " . $ses_x_a->ID_DOMAINS_PACKET_ID . '</span>';
  502. }
  503. }
  504. if (empty($srv_params)) {
  505. echo 'brak danych';
  506. } else {
  507. echo implode(', ', $srv_params);
  508. }
  509. }
  510. echo '</td>';
  511. echo '<td>';
  512. if ($ses_x_a) {
  513. echo $ses_x_a->T_WHEN_CONNECTED;
  514. }
  515. echo '</td>';
  516. echo '<td class="col-A_STATUS_DESC-'.$v_srv->_status.'">';
  517. echo ($v_srv->A_STATUS_DESC)? $v_srv->A_STATUS_DESC : $v_srv->_status;
  518. echo '</td>';
  519. echo '<td>';
  520. if ($v_srv->HANGUP_FROM || $v_srv->HANGUP_TILL) {
  521. if ($v_srv->HANGUP_STATUS) {
  522. echo ' <em>' . $v_srv->HANGUP_STATUS . '</em>';
  523. }
  524. echo ' (';
  525. echo ($v_srv->HANGUP_FROM)? $v_srv->HANGUP_FROM : '0000-00-00';
  526. echo ' - ';
  527. echo ($v_srv->HANGUP_TILL)? $v_srv->HANGUP_TILL : '0000-00-00';
  528. echo ')';
  529. }
  530. echo '</td>';
  531. echo '</tr>' . "\n";
  532. }
  533. }
  534. echo '</tbody>';
  535. echo '</table>';
  536. echo '</td>';
  537. echo '</tr>';
  538. }
  539. }
  540. ?>
  541. </tbody>
  542. </table>
  543. <?php endif; ?>
  544. </td></tr></table>
  545. </div>
  546. <?php
  547. }
  548. function print_js_umowa($cols = null) {
  549. $cols = (!$cols)? 10 : $cols;
  550. return '<script type="text/javascript">' . "
  551. function show_opcje(cell_id, service){
  552. var n=jQuery('#' + cell_id);
  553. if (!n) return;
  554. if (n.find('tr').length === 1) {// init, fetch data
  555. var tbody_opcje=jQuery('#oferty-opcje-service-' + service).find('tr');
  556. if (tbody_opcje.length > 0) {
  557. for (var i = 0; i < tbody_opcje.length; i++) {
  558. n.append(jQuery(tbody_opcje[i]).clone());
  559. }
  560. } else {
  561. n.append('<tr class=\"row-oferty-opcje\"><td colspan=\"{$cols}\">Brak danych</td></tr>');
  562. }
  563. } else {
  564. if (!n.hasClass('hide_options')) {
  565. n.addClass('hide_options');
  566. // remove selected rows and checked inputs
  567. n.find('.row-oferty-opcje-selected').removeClass('row-oferty-opcje-selected');
  568. n.find('input[type=\'checkbox\']:checked').attr('checked', false);
  569. } else {
  570. n.removeClass('hide_options');
  571. }
  572. }
  573. return false;
  574. }
  575. function select_option(n){
  576. n=jQuery(n);
  577. n.parents('tr:first').toggleClass('row-oferty-opcje-selected');
  578. }
  579. function print_umowa(n){
  580. var add='';
  581. n=jQuery(n);
  582. n.parents('table').find('input[type=\'checkbox\']:checked').each(function(ind, o){
  583. if (o.value > 0) {
  584. add += '&' + o.name + '=' + o.value;
  585. }
  586. });
  587. n.attr('href', n.attr('href_base') + add);
  588. return true;
  589. }
  590. " . '</script>';
  591. }
  592. function get_oferty_opcje_visible_cols() {
  593. $cols = array();
  594. $cols ['ID'] = 'ID oferty';
  595. //$cols ['ID_PROCES' ] = '';
  596. $cols ['S_OTHER_INFO' ] = '<b title="' . "Uwagi" . '">&nbsp;!&nbsp;</b>';
  597. $cols ['P_SERVICE_NAME' ] = 'Nazwa oferty';
  598. $cols ['P_INSTALL_QUOTE' ] = 'Promocyjna cena instalacji (brutto)';
  599. $cols ['P_PROMO_MONTH_PRICE' ] = 'Wartość abonamentu w promocyjnych miesiącach (brutto)';
  600. $cols ['P_CONTRACT_PRICE' ] = 'Wartość abonamentu po promocji (brutto)';
  601. $cols ['P_DEAL_PROMO_MONTHS' ] = 'Ilość promocyjnych miesięcy';
  602. //$cols ['P_DEALTERM_MONTHS' ] = '';
  603. $cols ['P_NORMAL_PRICE' ] = 'Nominalna wartość abonamentu (brutto)';
  604. $cols ['srednia'] = 'Średnia (brutto)';
  605. $cols ['upust'] = 'Upust od ceny normalnej do wyliczeń kary (brutto)';
  606. $cols ['koszt'] = 'Koszt (netto)';
  607. return $cols;
  608. }
  609. function print_js_show_hide_groups() {
  610. return '<script type="text/javascript">' . "
  611. jQuery(document).ready(function(){
  612. jQuery('#tbl-oferty').on('click', '.tbl-row', function(event){
  613. jQuery(this).toggleClass('active');
  614. jQuery(this).next('tr').toggle();
  615. });
  616. jQuery('#tbl-oferty-rowin-all').on('click', function(event){
  617. jQuery('#tbl-oferty .tbl-row').addClass('active');
  618. jQuery('#tbl-oferty .sub').show();
  619. });
  620. jQuery('#tbl-oferty-zwin-all').on('click', function(event){
  621. jQuery('#tbl-oferty .tbl-row').removeClass('active');
  622. jQuery('#tbl-oferty .sub').hide();
  623. });
  624. jQuery('#tbl-oferty .tbl-row').removeClass('active');
  625. jQuery('#tbl-oferty .sub').hide();
  626. });
  627. " . '</script>';
  628. }
  629. function print_groups_info_header($params = array()) {
  630. echo self::print_js_umowa();
  631. $show_zysk = V::get('show_zysk', $this->get('show_zysk'), $params);
  632. $show_www = V::get('show_www', $this->get('show_www'), $params);
  633. $show_status = V::get('show_status', $this->get('show_status'), $params);
  634. $show_rewir = V::get('show_rewir', $this->get('show_rewir'), $params);
  635. echo '<table cellspacing="0" cellpadding="0" border="1" class="tbl tbl-hover" id="tbl-oferty">';
  636. echo '<thead><tr>';
  637. echo '<th class="cell-id">' . "ID <code>0_1380</code>" . '</th>';
  638. if ($show_www) echo '<th>' . '<nobr>' . "www" . $show_www . '</nobr>' . '</th>';
  639. if ($show_status) echo '<th>' . '<nobr>' . "status" . $show_status . '</nobr>' . '</th>';
  640. if ($show_rewir) echo '<th>' . "rewir" . '</th>';
  641. echo '<th>' . "nazwa promocji <code>0_451</code>" . '</th>';
  642. echo '<th>' . "okres umowy <code>0_456</code>" . '</th>';
  643. echo '<th>' . "suma opłat instalacyjnych (brutto)" . '</th>';
  644. echo '<th>' . "suma abonamentów w promocyjnych miesiącach / po promocji (brutto)" . '</th>';
  645. echo '<th>' . "średnia kwota (brutto)" . '</th>';
  646. if ($show_zysk) {
  647. echo '<th>' . "suma kosztów (netto)" . '</th>';
  648. echo '<th>' . "zysk (netto)" . '</th>';
  649. }
  650. echo '</tr></thead>';
  651. echo '<tbody>';
  652. }
  653. function print_groups_info_footer() {
  654. echo '</tbody>';
  655. echo '</table>';
  656. }
  657. function print_group_info($group, $params = array()) {
  658. $deal_add_opcje_frm = V::get('DealAddOptionsForm', null, $params);
  659. $deal_rm_opcje_frm = V::get('DealRmOptionsForm', null, $params);
  660. $hide_header = V::get('hide_header', null, $params);
  661. $show_zysk = V::get('show_zysk', $this->get('show_zysk'), $params);
  662. $show_www = V::get('show_www', $this->get('show_www'), $params);
  663. $show_status = V::get('show_status', $this->get('show_status'), $params);
  664. $show_rewir = V::get('show_rewir', $this->get('show_rewir'), $params);
  665. $opcje_cols = $this->get_oferty_opcje_visible_cols();
  666. if (isset($opcje_cols['koszt'])) {
  667. unset($opcje_cols['koszt']);
  668. }
  669. if (!$hide_header) {
  670. $this->print_groups_info_header();
  671. }
  672. echo '<tr class="tbl-row tbl-row-1">';
  673. echo '<td class="cell-id">' . $group->get('ID') . '</td>';
  674. if ($show_www) echo '<td>' . '<nobr>' . $group->get('OFERTA_WWW') . $show_www . '</nobr>' . '</td>';
  675. if ($show_status) echo '<td>' . '<nobr>' . $group->get('A_STATUS') . $show_status . '</nobr>' . '</td>';
  676. if ($show_rewir) echo '<td>' . $group->get('M_REWIR') . '</td>';
  677. echo '<td>' . $group->get('S_ALIAS') . ' <em style="color:#555;">(' . $group->get('P_PROMOTION_NAME') . ')</em></td>';
  678. echo '<td>' . $group->get('P_DEALTERM_MONTHS') . '</td>';
  679. echo '<td class="cell-suma_1">' . number_format($group->suma_P_PROMO_INSTALL_PRICE, 2, ',', ' ') . " zł" . '</td>';
  680. echo '<td class="cell-suma_2">' . "<b>" . number_format($group->suma_P_PROMO_MONTH_PRICE, 2, ',', ' ') . "</b> zł" . " / " . number_format($group->suma_P_CONTRACT_PRICE, 2, ',', ' ') . " zł" . '</td>';
  681. echo '<td class="cell-srednia">' . "" . number_format($group->suma_P_OFFER_SREDNIA, 2, ',', ' ') . " zł" . '</td>';
  682. if ($show_zysk) {
  683. echo '<td class="cell-cost">' . "" . number_format($group->suma_P_OFFER_COSTS, 2, ',', ' ') . " zł" . '</td>';
  684. echo '<td class="cell-zysk">' . "" . number_format($group->suma_P_OFFER_SREDNIA_NETTO - $group->suma_P_OFFER_COSTS, 2, ',', ' ') . " zł" . '</td>';
  685. }
  686. echo '</tr>';
  687. echo '<tr class="sub sub-0">';
  688. echo '<td colspan="' . 99 . '" class="sub-oferty-wrap">';
  689. echo '<table class="sub-oferty" cellspacing="0" cellpadding="0" border="1">';
  690. echo '<thead>';
  691. echo '<tr>';
  692. echo '<th>';
  693. if (!V::get('hide_print', '', $params)) {
  694. $link_href = "./odt2xhtml/1379.umowa.php";
  695. $link_href .= "?id_group=" . $group->get('ID');
  696. if (($user_id = V::get('user_id', 0, $params, 'int')) > 0) {
  697. $link_href .= "&id_user={$user_id}";
  698. }
  699. $js = "return print_umowa(this);";
  700. echo '<a href="' . $link_href . '" href_base="' . $link_href . '" title="' . "Drukuj umowę [1379]" . '" target="_blank" onclick="' . $js . '">' . '<img src="icon/print.gif" height="24" />' . '</a>';
  701. }
  702. echo '</th>';
  703. foreach ($opcje_cols as $k_zasob_id => $v_label) {
  704. echo '<th>' . $v_label . '</th>';
  705. }
  706. echo '</tr>';
  707. echo '</thead>';
  708. foreach ($group->get_offers() as $k_p_service => $v_offers_arr) {
  709. foreach ($v_offers_arr as $k_offer_id => $v_offer) {
  710. echo '<tbody>';
  711. echo '<tr>';
  712. echo '<td>';
  713. echo $v_offer->P_SERVICE;
  714. echo '</td>';
  715. foreach ($opcje_cols as $k_field_name => $v_label) {
  716. echo '<td>' . $v_offer->$k_field_name . '</td>';
  717. }
  718. echo '</tr>';
  719. echo '</tbody>';
  720. $oferta_opcje = $group->get_options_by_service($v_offer->P_SERVICE);
  721. if (!empty($oferta_opcje)) {
  722. foreach ($oferta_opcje as $v_offer_opcja_id => $v_opcja) {
  723. echo '<tr class="row-oferty-opcje' . (($deal_add_opcje_frm)? ' row-oferty-opcje-selected' : '') . '">';
  724. echo '<td>' . "&nbsp;";
  725. if (!$deal_add_opcje_frm) {
  726. if ($deal_rm_opcje_frm) {
  727. echo '<input type="checkbox" name="id_options_'.$v_offer->P_SERVICE.'[]" value="' . $v_opcja->ID . '">';
  728. } else {
  729. echo '<span style="display:none">';
  730. echo '<input type="checkbox" name="id_options_'.$v_offer->P_SERVICE.'[]" value="' . $v_opcja->ID . '" checked="checked">';
  731. echo '</span>';
  732. }
  733. }
  734. echo '</td>';
  735. foreach ($opcje_cols as $k_field => $v_type_label) {
  736. if ($k_field == 'koszt') {
  737. echo '<td>' . number_format($v_opcja->$k_field, 2, ',', ' ') . '</td>';
  738. } else {
  739. echo '<td>' . $v_opcja->$k_field . '</td>';
  740. }
  741. }
  742. /*
  743. echo '<td>' . $v_opcja->P_SERVICE_NAME . '</td>';
  744. echo '<td>' . $v_opcja->P_INSTALL_QUOTE . '</td>';
  745. echo '<td>' . $v_opcja->P_PROMO_MONTH_PRICE . '</td>';
  746. echo '<td>' . $v_opcja->P_CONTRACT_PRICE . '</td>';
  747. echo '<td>' . ((isset($v_opcja->P_DEAL_PROMO_MONTHS))? $v_opcja->P_DEAL_PROMO_MONTHS : 0) . '</td>';
  748. echo '<td>' . $v_opcja->P_NORMAL_PRICE . '</td>';
  749. echo '<td></td>';// Średnia
  750. echo '<td></td>';// Upust od ceny normalnej do wyliczeń kary
  751. //echo '<td></td>';
  752. */
  753. echo '</tr>';
  754. }
  755. }
  756. if ($deal_add_opcje_frm) {
  757. $add_oferty_opcje = $deal_add_opcje_frm->get_oferty_opcje_by_service($v_offer->P_SERVICE);
  758. foreach ($add_oferty_opcje as $k_id => $v_oferta) {
  759. if (array_key_exists($k_id, $oferta_opcje)) {
  760. continue;
  761. }
  762. echo '<tr class="row-oferty-opcje' . (($deal_add_opcje_frm->has_option($v_offer->P_SERVICE, $k_id))? ' row-oferty-opcje-selected' : '') . '">';
  763. echo '<td>';
  764. $chck = ($deal_add_opcje_frm->has_option($v_offer->P_SERVICE, $k_id))? ' checked="checked"' : '';
  765. $option_name = 'id_options_' . $v_offer->P_SERVICE . '[]';
  766. echo '<input type="checkbox" name="'.$option_name.'" value="' . $k_id . '" onclick="return select_option(this);" '.$chck.' />';
  767. echo '</td>';
  768. foreach ($opcje_cols as $k_field => $v_type_label) {
  769. if ($k_field == 'koszt') {
  770. echo '<td>' . number_format($v_oferta->$k_field, 2, ',', ' ') . '</td>';
  771. } else {
  772. echo '<td>' . $v_oferta->$k_field . '</td>';
  773. }
  774. }
  775. echo '</tr>';
  776. }
  777. }
  778. }
  779. }
  780. echo '</table>';
  781. echo '</td>';
  782. echo '</tr>';
  783. if (!$hide_header) {
  784. $this->print_groups_info_footer();
  785. }
  786. }
  787. function print_options_tree($options_tree, $cols, $title = 'Wybrane opcje') {
  788. echo '<table cellspacing="0" cellpadding="0" border="1" class="tbl-view">';
  789. echo '<caption style="text-align:left;">' . $title . ':</caption>';
  790. echo '<thead>';
  791. echo '<tr>';
  792. echo '<td></td>';
  793. foreach ($cols as $k_field => $v_label) {
  794. echo '<td>' . $v_label . '</td>';
  795. }
  796. echo '</tr>';
  797. echo '</thead>';
  798. foreach ($options_tree as $k_service => $v_options) {
  799. echo '<tr>';
  800. echo '<td>';
  801. echo $k_service;
  802. echo '</td>';
  803. echo '<td colspan="' . count($cols) . '">';
  804. echo '</td>';
  805. echo '</tr>';
  806. foreach ($v_options as $v_option) {
  807. echo '<tr>';
  808. echo '<td></td>';
  809. foreach ($cols as $k_field => $v_label) {
  810. echo '<td>' . $v_option->$k_field . '</td>';
  811. }
  812. echo '</tr>';
  813. }
  814. }
  815. echo '</table>';
  816. }
  817. }