PageRenderTime 71ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/calls.php

https://github.com/joodtelecom/opencallshop
PHP | 186 lines | 153 code | 26 blank | 7 comment | 20 complexity | 1d68823e0f273bac6d9c7e0648d14f74 MD5 | raw file
  1. <?php
  2. include('../admin/constant.php');
  3. $refreshtime=REFRESHTIME;
  4. include('topheader.php');
  5. include('nnpclass.php');
  6. $usertype=$_SESSION['usertype'];
  7. $username=$_SESSION['username'];
  8. ?>
  9. <tr>
  10. <td><table border="0" cellspacing="0" cellpadding="0" class="tablebg">
  11. <tr>
  12. <td width="100%" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="10">
  13. <tr>
  14. <td>
  15. <?php
  16. print("</BR>");
  17. print("<LABEL onClick=\"OpenLink('exportexcel');\" style='cursor:hand;'><u>Export Results to Excel</u> | </LABEL>");
  18. print("<LABEL onClick=\"OpenLink('exportcsv');\" style='cursor:hand;'><u>Export Results to CSV</u> | </LABEL>");
  19. print("<LABEL onClick=\"OpenLink('calls');\" style='cursor:hand;'><u>Calls</u> | </LABEL>");
  20. print("<LABEL onClick=\"OpenLink('recharges');\" style='cursor:hand;'><u>Recharges</u> | </LABEL>");
  21. print("<LABEL onClick=\"OpenLink('searchcalls');\" style='cursor:hand;'><u>Search Calls</u></LABEL>");
  22. print("<form ID='frmProcessLogin' METHOD=POST ACTION=\"\">");
  23. print("<INPUT TYPE=hidden name='username' ID='username' VALUE='" . $username . "'>");
  24. print("<INPUT TYPE=hidden name='usertype' ID='usertype' VALUE='" . $usertype . "'>");
  25. print("<INPUT TYPE=hidden name='op' ID='op' VALUE='calls'>");
  26. print("<INPUT TYPE=hidden name='page_size' ID='page_size'>");
  27. print("</form><br>");
  28. switch($usertype)
  29. {
  30. case 0:
  31. $sub_sql = "select id_client from clientsip where login='" . $username . "'";
  32. break;
  33. case 1:
  34. $sub_sql = "select id_client from clientshearlink where login='" . $username . "'";
  35. break;
  36. case 2:
  37. $sub_sql = "select id_client from clientse164 where login='" . $username . "'";
  38. break;
  39. case 8:
  40. $sub_sql = "select id_client from clientspin where login='" . $username . "'";
  41. break;
  42. }
  43. $sql = "select calls.call_start, calls.called_number, tariffdesc as tarriff_description, calls.duration, calls.call_start as diff1, calls.call_end as diff2, calls.cost as cost from calls as calls where id_client = (" . $sub_sql . ") AND client_type=". $usertype;
  44. // for undefined page value, set it to 1
  45. if ( $_REQUEST["pg_no"] == "")
  46. {
  47. $_REQUEST["pg_no"] = 1;
  48. }
  49. //$result_set = mysql_query($sql, $con);
  50. $result_set = execute($sql, 1);
  51. $total_records = mysql_num_rows($result_set);
  52. if ( $_REQUEST["page_size"] == "" || $_REQUEST["page_size"] == null)
  53. {
  54. $pg_size = 10;
  55. } else {
  56. $pg_size = $_REQUEST["page_size"];
  57. }
  58. $no_of_pgs = ceil($total_records / $pg_size);
  59. $lower_limit = ((($_REQUEST["pg_no"] * $pg_size) - $pg_size) < 0 ? 0 : (($_REQUEST["pg_no"] * $pg_size) - $pg_size));
  60. $upper_limit = $pg_size;
  61. $sql = "select calls.caller_id, calls.call_start, calls.called_number, tariffdesc as tarriff_description, (select voice_rate from tariffs where id_tariff=calls.id_tariff and prefix=calls.tariff_prefix group by prefix,id_tariff having tariffs.voice_rate = max(tariffs.voice_rate)) as cost_per_min, (select resolution from tariffsnames where id_tariff=calls.id_tariff) as resolution, calls.duration, calls.cost as cost from calls as calls where id_client = (" . $sub_sql . ") AND client_type=". $usertype . " order by calls.call_end desc limit " . $lower_limit . "," . $upper_limit;
  62. //$result_set = mysql_query($sql, $con);
  63. $result_set = execute($sql, 1);
  64. if ( mysql_num_rows($result_set) > 0 )
  65. {
  66. print("<table width=\"95%\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\" style=\"border-collapse: collapse\">");
  67. print("<TR>");
  68. // print("<TH>Caller ID</TD>");
  69. print("<td class=\"topt\">Call Start</TD>");
  70. print("<td class=\"topt\">Called Number</TD>");
  71. print("<td class=\"topt\">Country name</TD>");
  72. print("<td class=\"topt\">Duration</TD>");
  73. // print("<TH>Pulse Rate</TD>");
  74. print("<td class=\"topt\">Rate/min</TD>");
  75. print("<td class=\"topt\">Time</TH>");
  76. print("<td class=\"topt\" STYLE='color:#FF0000;'>Minutes</TD>");
  77. print("<td class=\"topt\" style='color:#FF0000;'>Cost</TD>");
  78. print("</TR>");
  79. $row_counter = 0;
  80. $total_duration = 0;
  81. $total_cost = 0;
  82. while ( $data_row = mysql_fetch_array($result_set, MYSQL_ASSOC))
  83. {
  84. if ( $row_counter % 2 == 0)
  85. {
  86. $row_class = "even_row";
  87. } else {
  88. $row_class = "odd_row";
  89. }
  90. if ( $data_row["resolution"] == 0 )
  91. {
  92. continue;
  93. }
  94. $pulse = ceil($data_row["duration"]/$data_row["resolution"]);
  95. $billed_mins = ceil($data_row["duration"]/60);
  96. $min_pulse_ratio = 60/$data_row["resolution"];
  97. $min_part = floor($pulse / $min_pulse_ratio);
  98. $sec_part = $pulse % $min_pulse_ratio;
  99. $sec_part = $sec_part * $data_row["resolution"];
  100. print("<TR class='" . $row_class . "'>");
  101. // print("<TD>" . $data_row["caller_id"] . "</TD>");
  102. print("<TD>" . $data_row["call_start"] . "</TD>");
  103. print("<TD>" . $data_row["called_number"] . "</TD>");
  104. print("<TD>&nbsp;" . $data_row["tarriff_description"] . "</TD>");
  105. print("<TD>" . $data_row["duration"] . "</TD>");
  106. // print("<TD>" . $data_row["resolution"] . "</TD>");
  107. print("<TD>" . $data_row["cost_per_min"] . "</TD>");
  108. print("<TD>" . $min_part . " mins " . $sec_part . " secs" . "</TD>");
  109. print("<TD STYLE='color:#FF0000;'>" . $billed_mins . "</TD>");
  110. sprintf("%01.2f", $money);
  111. $fammount = sprintf("%01.4f",(($data_row["cost_per_min"]*($data_row["resolution"]/60)) * $pulse));
  112. print("<TD style='color:#FF0000;'>" . $fammount . "</TD>");
  113. print("</TR>");
  114. $total_duration += $data_row["duration"];
  115. $total_cost += (($data_row["cost_per_min"]*($data_row["resolution"]/60)) * $pulse);
  116. $row_counter++;
  117. }
  118. $total_mins = floor($total_duration / 60 );
  119. $total_secs = $total_duration % 60 ;
  120. print("<TR>");
  121. print("<TD class=\"topt\" COLSPAN=6 style='text-align:right;'><B>" . $total_mins . " mins " . $total_secs . " secs</B></TD>");
  122. $ftotal = sprintf("%01.4f",$total_cost);
  123. print("<TD class=\"topt\" COLSPAN=2 style='color:#FF0000; text-align:right;'><B>".$ftotal."</B></TD>");
  124. print("</TR>");
  125. print("</TABLE>");
  126. } else {
  127. print("<DIV STYLE='font-family:verdana; font-size:10px; font-weight:bold; color:red;'>No records found</DIV>");
  128. }
  129. print("</BR></BR>");
  130. print("<INPUT TYPE=text name='pg_size' ID='pg_size' VALUE='".$pg_size."' size='1' maxlength='3'>&nbsp;&nbsp;");
  131. print("<INPUT TYPE=button name='btnPageSize' ID='btnPageSize' VALUE='Go' onClick='ChangePageSize();'>");
  132. $pipe = "";
  133. if ($no_of_pgs > 10 )
  134. {
  135. $no_of_pgs = 10;
  136. }
  137. for ($pg_no = 1; $pg_no <= $no_of_pgs; $pg_no++)
  138. {
  139. if ($pg_no == $_REQUEST["pg_no"])
  140. {
  141. print($pipe."<LABEL onClick='GotoPage(".$pg_no.")' style=\"cursor:pointer;\"><B>&nbsp;".$pg_no."</B></LABEL>&nbsp;");
  142. } else {
  143. print($pipe."<LABEL onClick='GotoPage(".$pg_no.")' style=\"cursor:pointer;\">&nbsp;".$pg_no."</LABEL>&nbsp;");
  144. }
  145. $pipe = "|";
  146. }
  147. ?>
  148. </td>
  149. </tr>
  150. </table>
  151. </td>
  152. </tr>
  153. </table></td>
  154. </tr>
  155. <tr>
  156. <td><?php include('footer.php');?></td>
  157. </tr>
  158. </table>
  159. </body>
  160. </html>