Advertisement
SlickSocials

Untitled

Apr 16th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1. <?php
  2. require_once('./files/header.php');
  3. ?>
  4.  
  5. <link href="js/advanced-datatable/css/demo_page.css" rel="stylesheet" />
  6. <link href="js/advanced-datatable/css/demo_table.css" rel="stylesheet" />
  7.  
  8. <section id="main-content">
  9. <section class="wrapper">
  10. <?php
  11. $stmt = $pdo->prepare('SELECT * FROM news ORDER BY NewsID DESC LIMIT 1');
  12. $stmt->execute();
  13.  
  14. if($stmt->rowCount() > 0) {
  15. ?>
  16. <div class="row">
  17. <div class="col-md-12">
  18. <div class="mini-stat clearfix">
  19. <span>
  20. <?php
  21. foreach($stmt->fetchAll() as $row) {
  22. echo '<a href="news.php"><strong style="font-size: 14px; color: #1ca59e;">'.$row['NewsTitle'].'</strong></a>';
  23. echo '<br>';
  24. echo $row['NewsContent'];
  25. echo '<hr>';
  26. }
  27. ?>
  28. </span>
  29. </div>
  30. </div>
  31. </div>
  32. <?php
  33. }
  34. ?>
  35.  
  36. <!--mini statistics end-->
  37. <div class="row">
  38. <div class="col-md-12">
  39. <section class="panel">
  40. <header class="panel-heading">
  41. Account Order History
  42. <span class="tools pull-right">
  43. <a href="javascript:;" class="fa fa-chevron-down"></a>
  44. <a href="javascript:;" class="fa fa-times"></a>
  45. </span>
  46. </header>
  47. <div class="panel-body">
  48. <div class="adv-table">
  49. <div class="space15"></div>
  50. <?php
  51. $UserID = $user->GetData('UserID');
  52.  
  53. $stmt = $pdo->prepare('SELECT * FROM orders WHERE OrderUserID = :OrderUserID ORDER BY OrderID DESC');
  54. $stmt->execute(array(':OrderUserID' => $UserID));
  55.  
  56. if($stmt->rowCount() > 0) {
  57. ?>
  58. <section id="unseen">
  59. <table cellpadding="0" cellspacing="0" border="0" class="table table-bordered table-striped table-condensed" id="dynamic-orders">
  60. <thead>
  61. <tr>
  62. <th>Ordered Service</th>
  63. <th>Order Type</th>
  64. <th>Order Quantity</th>
  65. <th>Order Amount</th>
  66. <th>Order Link</th>
  67. <th>Order Ad. Content</th>
  68. <th>Order Date</th>
  69. <th>Order Status</th>
  70. <th>Order Remains</th>
  71. <th>Order Start Count</th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <?php
  76. $html = '';
  77.  
  78. foreach($stmt->fetchAll() as $row) {
  79. if(empty($row['OrderAPIID'])) {
  80. $status = $row['OrderStatus'];
  81. $start_count = 0;
  82. $remains = 0;
  83. } else if($row['OrderStatus'] == 'In Process') {
  84. $stmt = $pdo->prepare('SELECT * FROM products WHERE ProductID = :ProductID');
  85. $stmt->execute(array(':ProductID' => $row['OrderProductID']));
  86. $service_api = $stmt->fetch();
  87.  
  88. $parts = parse_url($service_api['ProductAPI']);
  89. parse_str($parts['query'], $query);
  90. $api_key = $query['key'];
  91.  
  92. $current_url = explode("?", $service_api['ProductAPI']);
  93. $url = $current_url[0].'?key='.$api_key.'&action=status&order='.$row['OrderAPIID'];
  94.  
  95. $curl = curl_init();
  96. curl_setopt_array($curl, array(
  97. CURLOPT_RETURNTRANSFER => 1,
  98. CURLOPT_URL => $url,
  99. CURLOPT_USERAGENT => 'Enigma SMM API Caller'
  100. ));
  101.  
  102. $resp = curl_exec($curl);
  103. curl_close($curl);
  104.  
  105. $response = json_decode($resp);
  106. if(isset($response->status))
  107. $status = $response->status;
  108. else
  109. $status = 'Completed';
  110. if(isset($response->remains))
  111. $remains = $response->remains;
  112. else
  113. $remains = 0;
  114. if(isset($response->start_count) && empty($row['OrderStartCount']))
  115. $start_count = $response->start_count;
  116. else if(!isset($response->start_count) && !empty($row['OrderStartCount']))
  117. $start_count = $row['OrderStartCount'];
  118. else if(isset($response->start_count) && !empty($row['OrderStartCount']))
  119. $start_count = $row['OrderStartCount'];
  120. else
  121. $start_count = 0;
  122.  
  123. $UserFunds = $user->GetData('UserFunds');
  124.  
  125. if($status == 'Completed') {
  126. $stmt = $pdo->prepare('UPDATE orders SET OrderStatus = "Completed" WHERE OrderID = :OrderID');
  127. $stmt->execute(array(':OrderID' => $row['OrderID']));
  128. } else if($status == 'Canceled' || $status == 'Refunded') {
  129. if($status == 'Canceled') {
  130. $stmt = $pdo->prepare('UPDATE orders SET OrderStatus = "Removed" WHERE OrderID = :OrderID');
  131. $stmt->execute(array(':OrderID' => $row['OrderID']));
  132. } else if($status == 'Refunded') {
  133. $stmt = $pdo->prepare('UPDATE orders SET OrderStatus = "Refunded" WHERE OrderID = :OrderID');
  134. $stmt->execute(array(':OrderID' => $row['OrderID']));
  135. }
  136.  
  137. $stmt = $pdo->prepare('UPDATE users SET UserFunds = :UserFunds WHERE UserID = :UserID');
  138. $stmt->execute(array(':UserFunds' => $row['OrderAmount'] + $UserFunds, ':UserID' => $UserID));
  139. }
  140. } else {
  141. $status = $row['OrderStatus'];
  142. $start_count = 0;
  143. $remains = 0;
  144. }
  145.  
  146. if(empty($row['OrderAdditional'])) {
  147. $additional = 'No comments/hashtags/usernames.';
  148. } else {
  149. $additional = $row['OrderAdditional'];
  150. $additional = str_replace('\r\n',',', $additional);
  151. $additional = str_replace('\n',',', $additional);
  152. }
  153.  
  154. $html .= '<tr class="">';
  155. $html .= '<td>'.$product->GetData($row['OrderProductID'], 'ProductName').'</td>';
  156. $html .= '<td style="color: #1fb5ad;">'.ucfirst($row['OrderType']).'</td>';
  157. $html .= '<td>'.$row['OrderQuantity'].'</td>';
  158. $html .= '<td>'.$currency.round($row['OrderAmount'], 2).'</td>';
  159. $html .= '<td>'.$row['OrderLink'].'</td>';
  160. $html .= '<td style="color: #1fb5ad;">'.$additional.'</td>';
  161. $html .= '<td>'.date('d M, Y h:I:s', $row['OrderDate']).'</td>';
  162. $html .= '<td class="center">'.$status.'.</td>';
  163. $html .= '<td class="center">'.$remains.'</td>';
  164. $html .= '<td class="center">'.$start_count.'</td>';
  165. $html .= '</tr>';
  166. }
  167.  
  168. echo $html;
  169. ?>
  170. </tbody>
  171. </table>
  172. </section>
  173. <?php
  174. } else {
  175. $display->ReturnInfo('Your account does not have any orders at this time.');
  176. }
  177. ?>
  178. </div>
  179. </div>
  180. </section>
  181. <button type="submit" id="page-refresh" class="btn btn-primary pull-right fa fa-refresh"></button>
  182. </div>
  183. </div>
  184. </section>
  185. </section>
  186. <?php
  187. require_once('./files/footer.php');
  188. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement