PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/public_html/orders_list.php

https://gitlab.com/Henaway/CLFC
PHP | 211 lines | 201 code | 8 blank | 2 comment | 17 complexity | 449ad9a916e6d302eb7385542475ae91 MD5 | raw file
  1. <?php
  2. include_once ("config_foodcoop.php");
  3. include_once ("general_functions.php");
  4. session_start();
  5. valid_auth('route_admin,member_admin,cashier,site_admin');
  6. $delivery_id = $_REQUEST['delivery_id'];
  7. $basket_id = $_REQUEST['basket_id'];
  8. $member_id = $_REQUEST['member_id'];
  9. if ( $_REQUEST['fin'] == 'unfinalize' && CurrentMember::auth_type('cashier'))
  10. {
  11. $sqlf = '
  12. UPDATE
  13. '.TABLE_BASKET_ALL.'
  14. SET
  15. finalized = "0"
  16. WHERE
  17. basket_id = "'.mysql_real_escape_string ($basket_id).'"
  18. AND member_id = "'.mysql_real_escape_string ($member_id).'"';
  19. $resultf = @mysql_query($sqlf, $connection) or die(mysql_error());
  20. }
  21. $hub = "";
  22. $sql = '
  23. SELECT
  24. '.TABLE_BASKET_ALL.'.basket_id AS big_basket_id,
  25. '.TABLE_BASKET_ALL.'.basket_id,
  26. '.TABLE_BASKET_ALL.'.member_id,
  27. '.TABLE_BASKET_ALL.'.delivery_id,
  28. '.TABLE_BASKET_ALL.'.delivery_id AS basket_delivery_id,
  29. '.TABLE_MEMBER.'.member_id,
  30. '.TABLE_BASKET_ALL.'.finalized,
  31. '.TABLE_MEMBER.'.last_name,
  32. '.TABLE_MEMBER.'.first_name,
  33. '.TABLE_MEMBER.'.business_name
  34. FROM
  35. '.TABLE_BASKET_ALL.'
  36. LEFT JOIN
  37. '.TABLE_MEMBER.' ON '.TABLE_MEMBER.'.member_id = '.TABLE_BASKET_ALL.'.member_id
  38. LEFT JOIN
  39. '.TABLE_DELCODE.' ON '.TABLE_DELCODE.'.delcode_id = '.TABLE_BASKET_ALL.'.delcode_id
  40. WHERE
  41. '.TABLE_BASKET_ALL.'.delivery_id = "'.mysql_real_escape_string ($delivery_id).'"
  42. GROUP BY
  43. '.TABLE_BASKET_ALL.'.member_id
  44. ORDER BY
  45. last_name ASC,
  46. '.TABLE_BASKET_ALL.'.basket_id DESC';
  47. $rs = @mysql_query($sql, $connection) or die(mysql_error());
  48. $num_orders = mysql_numrows($rs);
  49. while ( $row = mysql_fetch_array($rs) )
  50. {
  51. //$hub = $row['hub'];
  52. $basket_id = $row['big_basket_id'];
  53. $basket_delivery_id = $row['basket_delivery_id'];
  54. $member_id = $row['member_id'];
  55. $last_name = $row['last_name'];
  56. $first_name = $row['first_name'];
  57. $business_name = $row['business_name'];
  58. //$rte_confirmed = $row['rte_confirmed'];
  59. $finalized = $row['finalized'];
  60. include("../func/show_name_last.php");
  61. $subtotal = '';
  62. $display .= '<tr bgcolor="#FFFFFF">';
  63. $display .= '<td valign="top" align="right" id="'.$basket_id.'"># '.$member_id.'</td>';
  64. if ( $finalized != 1 )
  65. {
  66. $display .= '<td valign="top"><a href="orders.php?delivery_id='.$delivery_id.'&basket_id='.$basket_id.'&member_id='.$member_id.'">'.$show_name.'</a></td>';
  67. }
  68. else
  69. {
  70. $display .= '<td valign="top">'.$show_name.'</td>';
  71. }
  72. if ( $basket_delivery_id != $delivery_id )
  73. {
  74. $display .= '<td>*Need to <a href="orders_selectmember.php">create an invoice</a> for this cycle*</td>';
  75. }
  76. else
  77. {
  78. if ( $finalized != 1 )
  79. {
  80. $display .= '<td valign="top"><font size="2"><a href="customer_invoice.php?delivery_id='.$delivery_id.'&basket_id='.$basket_id.'&member_id='.$member_id.'">View Temp. Inv.</a></font></td>';
  81. }
  82. else
  83. {
  84. $display .= '<td></td>';
  85. }
  86. }
  87. if ( $basket_delivery_id != $delivery_id )
  88. {
  89. $display .= '<td valign="top" colspan="2">*Has a pre-ordered item in <a href="customer_invoice.php?delivery_id='.$basket_delivery_id.'&basket_id='.$basket_id.'&member_id='.$member_id.'">Basket '.$basket_id.'</a> for delivery this month*</td>';
  90. }
  91. else
  92. {
  93. if ( $finalized != 1 )
  94. {
  95. $display .= '<td valign="top" bgcolor="#AEDE86">Not saved as final version</td>';
  96. $display .= '<td valign="top"></td>';
  97. }
  98. else
  99. {
  100. $display .='<td valign="top"><a href="invoice.php?basket_id='.$basket_id.'&member_id='.$member_id.'">Final Invoice</a> (Mem# '.$member_id.') </td>';
  101. $display .= '<td valign="top"><font size=-2><a href="'.$PHP_SELF.'?fin=unfinalize&delivery_id='.$delivery_id.'&basket_id='.$basket_id.'&member_id='.$member_id.'#'.$basket_id.'">Unfinalize to Edit</a></font></td>';
  102. }
  103. }
  104. $display .= '</tr>';
  105. $member_id_list .= '#'.$member_id;
  106. }
  107. $sqlfd = '
  108. SELECT
  109. '.TABLE_BASKET_ALL.'.basket_id,
  110. '.TABLE_BASKET_ALL.'.member_id,
  111. '.TABLE_BASKET.'.future_delivery_id
  112. FROM
  113. '.TABLE_BASKET_ALL.',
  114. '.TABLE_DELCODE.',
  115. '.TABLE_BASKET.'
  116. WHERE
  117. '.TABLE_BASKET.'.future_delivery_id = "'.mysql_real_escape_string ($delivery_id).'"
  118. AND '.TABLE_BASKET_ALL.'.basket_id = '.TABLE_BASKET.'.basket_id
  119. AND '.TABLE_BASKET_ALL.'.delivery_id != "'.mysql_real_escape_string ($delivery_id).'"
  120. AND '.TABLE_BASKET_ALL.'.member_id != "'.mysql_real_escape_string ($member_id).'"
  121. GROUP BY
  122. '.TABLE_BASKET_ALL.'.member_id
  123. ORDER BY
  124. '.TABLE_BASKET_ALL.'.basket_id DESC';
  125. $rsf = @mysql_query($sqlfd, $connection) or die(mysql_error());
  126. while ( $row = mysql_fetch_array($rsf) )
  127. {
  128. $basket_id2 = $row['basket_id'];
  129. $member_id2 = $row['member_id'];
  130. $future_delivery_id2 = $row['future_delivery_id'];
  131. $member_id2 = '#'.$member_id2;
  132. $pos = strpos($member_id_list,$member_id2);
  133. if ( $pos === false )
  134. {
  135. $memneedinvoice .= ' <font color=#FF0000><b> '.$member_id2.'</b></font> &nbsp;';
  136. }
  137. else
  138. {
  139. $memneedinvoice .= '';
  140. }
  141. }
  142. include("../func/show_delivery_date.php");
  143. include("../func/convert_delivery_date.php");
  144. if ( $delivery_id==$current_delivery_id )
  145. {
  146. $delivery_date = $current_delivery_date;
  147. }
  148. $content_list = '
  149. <table width="100%">
  150. <tr>
  151. <td align="left">
  152. <h3>Saved Orders: '.$delivery_date.' ('.$num_orders.' Orders)</h3><!--
  153. Current Combined SUBTOTAL: <b>$'.number_format($bigtotal,2).'</b> (Subtotal $'.number_format($bigsubtotal,2).' + Adjustments $'.number_format($bigadj,2).')<br>
  154. (includes adjustments, doesn&#146;t include taxes and delivery charges)<br/>-->
  155. Click to finalize invoices for members id #:
  156. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1&mf=100">1-100</a> |
  157. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=101&mf=200">101-200</a> |
  158. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=201&mf=300">201-300</a> |
  159. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=301&mf=400">301-400</a> |
  160. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=401&mf=500">401-500</a> |
  161. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=501&mf=600">501-600</a> |
  162. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=601&mf=700">601-700</a> |
  163. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=701&mf=800">701-800</a> |
  164. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=801&mf=900">801-900</a> |
  165. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=901&mf=1000">901-1000</a> |
  166. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1001&mf=1100">1101-1200</a> |
  167. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1101&mf=1200">1101-1200</a> |
  168. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1201&mf=1300">1201-1300</a> |
  169. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1301&mf=1400">1301-1400</a> |
  170. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1401&mf=1500">1401-1500</a> |
  171. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1501&mf=1600">1501-1600</a> |
  172. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1601&mf=1700">1601-1700</a> |
  173. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1701&mf=1800">1701-1800</a> |
  174. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1801&mf=1900">1801-1900</a> |
  175. <a href="finalize.php?delivery_id='.$delivery_id.'&ms=1901&mf=2000">1901-2000</a>
  176. <br><br>
  177. '.($memneedinvoice ? '
  178. *Need to <a href="orders_selectmember.php">create an invoice</a> for this cycle for these members:'.$memneedinvoice.'<br><br>' : '' ).'
  179. <table width="100%" bgcolor="#dddddd" cellpadding="2" cellspacing="2" border="0">
  180. <tr bgcolor="#AEDE86">
  181. <!-- <th valign="bottom" bgcolor="#CC9900"><font face="arial" size="-2">Subtotal</th> -->
  182. <th>Mem. ID</th>
  183. <th>Member (Click to Edit Order)</th>
  184. <!-- <th>Order Completion</th> -->
  185. <th>Temp. Invoice</th>
  186. <!-- <th valign="bottom" bgcolor="#ADB6C6"><font face="arial" size="-2">Rte. Mgr<br>Confirmed</th> -->
  187. <th>Finalized After Delivery</th>
  188. <th>UnFinalize</th>
  189. </tr>
  190. '.$display.'
  191. </table>
  192. </td></tr>
  193. </table>';
  194. $page_title_html = '<span class="title">Delivery Cycle Functions</span>';
  195. $page_subtitle_html = '<span class="subtitle">Order List</span>';
  196. $page_title = 'Delivery Cycle Functions: Order List';
  197. $page_tab = 'cashier_panel';
  198. include("template_header.php");
  199. echo '
  200. <!-- CONTENT BEGINS HERE -->
  201. '.$content_list.'
  202. <!-- CONTENT ENDS HERE -->';
  203. include("template_footer.php");