index.php 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. if (cfr('CORPORATE')) {
  3. // here we show parent user and his controls
  4. if (isset($_GET['userlink'])) {
  5. $userlink=$_GET['userlink'];
  6. $parent_login=cu_GetParentUserLogin($userlink);
  7. $childusers=cu_GetAllChildUsers($userlink);
  8. $group_controls=wf_Link('?module=corporate&userlink='.$userlink.'&control=cash', 'Cash', false, 'ubButton');
  9. $group_controls.=wf_Link('?module=corporate&userlink='.$userlink.'&control=tariff', 'Tariff', false, 'ubButton');
  10. $group_controls.=wf_Link('?module=corporate&userlink='.$userlink.'&control=credit', 'Credit', false, 'ubButton');
  11. show_window(__('Group operations'),$group_controls);
  12. show_window(__('Linked users'), web_UserArrayShower($childusers));
  13. //show parent user profile by default
  14. if (!isset($_GET['control'])) {
  15. $profileObj=new UserProfile($parent_login);
  16. $default_profile=$profileObj->render();
  17. show_window(__('User profile'),$default_profile);
  18. } else {
  19. //show controls
  20. if ($_GET['control']=='cash') {
  21. //group cash operations
  22. $allchildusers=cu_GetAllChildUsers($userlink);
  23. //cash add form construct
  24. $cashtypes=zb_CashGetAllCashTypes();
  25. $cashinputs=wf_TextInput('newcash', 'New cash', '', true, 5);
  26. $cashinputs.=web_CashTypeSelector().' '.__('Cash type');
  27. $cashinputs.='<br>';
  28. $cashinputs.=wf_RadioInput('operation', 'Add cash', 'add', false, true);
  29. $cashinputs.=wf_RadioInput('operation', 'Correct saldo', 'correct', false, false);
  30. $cashinputs.=wf_RadioInput('operation', 'Mock payment', 'mock', false, false);
  31. $cashinputs.=wf_RadioInput('operation', 'Set cash', 'set', true, false);
  32. $cashinputs.=wf_TextInput('newpaymentnote', 'Payment note', '', true, 35);
  33. $cashinputs.='<br>';
  34. $cashinputs.=wf_Submit('Add cash');
  35. $cashform=wf_Form('', 'POST', $cashinputs, 'glamour');
  36. show_window(__('Add cash'),$cashform);
  37. show_window('', web_UserControls($parent_login));
  38. //if someone adds cash
  39. if (wf_CheckPost(array('newcash'))) {
  40. $operation=vf($_POST['operation']);
  41. $cashtype=vf($_POST['cashtype']);
  42. $cash=$_POST['newcash'];
  43. if (isset($_POST['newpaymentnote'])) {
  44. $note=mysql_real_escape_string($_POST['newpaymentnote']);
  45. }
  46. //add cash to parent user
  47. zb_CashAdd($parent_login, $cash, $operation, $cashtype, $note);
  48. // add cash to all child users
  49. if (!empty ($allchildusers)) {
  50. foreach ($allchildusers as $eachchild) {
  51. //adding cash
  52. if ($operation=='add') {
  53. $billing->addcash($eachchild,$cash);
  54. }
  55. //correcting balance
  56. if ($operation=='correct') {
  57. $billing->addcash($eachchild,$cash);
  58. }
  59. //setting cash
  60. if ($operation=='set') {
  61. $billing->setcash($eachchild,$cash);
  62. }
  63. log_register("GROUPBALANCE ".$eachchild." ".$operation." ON ".$cash);
  64. rcms_redirect("?module=corporate&userlink=".$userlink."&control=cash");
  65. }
  66. }
  67. }
  68. }
  69. //cash control end
  70. if ($_GET['control']=='tariff') {
  71. //group tariff operations
  72. $allchildusers=cu_GetAllChildUsers($userlink);
  73. //construct form
  74. $current_tariff=zb_UserGetStargazerData($parent_login);
  75. $current_tariff=$current_tariff['Tariff'];
  76. $tariffinputs='<h3>'.__('Current tariff').': '.$current_tariff.'</h3> <br>';
  77. $tariffinputs.=web_tariffselector('newtariff');
  78. $tariffinputs.='<br>';
  79. $tariffinputs.=wf_CheckInput('nextmonth', 'Next month', true, false);
  80. $tariffinputs.='<br>';
  81. $tariffinputs.=wf_Submit('Save');
  82. $tariffform=wf_Form('', 'POST', $tariffinputs, 'glamour');
  83. show_window(__('Edit tariff'),$tariffform);
  84. //if group tariff change
  85. if (wf_CheckPost(array('newtariff'))) {
  86. $alter_conf=rcms_parse_ini_file(CONFIG_PATH."alter.ini");
  87. $tariff=$_POST['newtariff'];
  88. if (!isset($_POST['nextmonth'])) {
  89. $billing->settariff($parent_login,$tariff);
  90. log_register('CHANGE Tariff '.$parent_login.' ON '.$tariff);
  91. //optional user reset
  92. if ($alter_conf['TARIFFCHGRESET']) {
  93. $billing->resetuser($parent_login);
  94. log_register('RESET User '.$parent_login);
  95. }
  96. } else {
  97. // next month parent user tariff change
  98. $billing->settariffnm($parent_login,$tariff);
  99. log_register('CHANGE TariffNM '.$parent_login.' ON '.$tariff);
  100. }
  101. //the same for all childs users
  102. if (!empty ($allchildusers)) {
  103. foreach ($allchildusers as $eachchild) {
  104. if (!isset($_POST['nextmonth'])) {
  105. $billing->settariff($eachchild,$tariff);
  106. log_register('CHANGE Tariff '.$eachchild.' ON '.$tariff);
  107. //optional user reset
  108. if ($alter_conf['TARIFFCHGRESET']) {
  109. $billing->resetuser($eachchild);
  110. log_register('RESET User '.$eachchild);
  111. }
  112. } else {
  113. // next month child user tariff change
  114. $billing->settariffnm($eachchild,$tariff);
  115. log_register('CHANGE TariffNM '.$eachchild.' ON '.$tariff);
  116. }
  117. }
  118. }
  119. rcms_redirect("?module=corporate&userlink=".$userlink."&control=tariff");
  120. }
  121. // end of newtariff checks
  122. }
  123. //tariffs end
  124. if ($_GET['control']=='credit') {
  125. //group credit operations
  126. $allchildusers=cu_GetAllChildUsers($userlink);
  127. $current_credit=zb_UserGetStargazerData($parent_login);
  128. $current_credit=$current_credit['Credit'];
  129. //construct form
  130. $creditinputs=wf_TextInput('newcredit', 'New credit', $current_credit, true, '10');
  131. $creditinputs.=wf_Submit('Save');
  132. $creditform=wf_Form('', 'POST', $creditinputs, 'glamour');
  133. show_window(__('Edit credit'),$creditform);
  134. //if group credit change
  135. if (isset($_POST['newcredit'])) {
  136. $credit=vf($_POST['newcredit']);
  137. //change credit for parent user
  138. $billing->setcredit($parent_login,$credit);
  139. log_register('CHANGE Credit '.$parent_login.' ON '.$credit);
  140. // set credit for all child users
  141. if (!empty ($allchildusers)) {
  142. foreach ($allchildusers as $eachchild) {
  143. $billing->setcredit($eachchild,$credit);
  144. log_register('CHANGE Credit '.$eachchild.' ON '.$credit);
  145. }
  146. }
  147. rcms_redirect("?module=corporate&userlink=".$userlink."&control=credit");
  148. }
  149. }
  150. //credits end
  151. }
  152. //controls if end
  153. }
  154. //userlink if-end
  155. } else {
  156. show_error(__('You cant control this module'));
  157. }
  158. ?>