PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/public_html/printprod_new.php

https://gitlab.com/Henaway/CLFC
PHP | 201 lines | 199 code | 2 blank | 0 comment | 3 complexity | 04ba2982e27fcfb17051a09b2083d7de MD5 | raw file
  1. <?php
  2. include_once ("config_foodcoop.php");
  3. include_once ("general_functions.php");
  4. session_start();
  5. valid_auth('producer_admin,site_admin');
  6. $date_today = date("F Y");
  7. $font = '<font face=arial size=-1>';
  8. $font2 = '<font face=arial size=-2>';
  9. $display .= '
  10. <table border="0" cellpadding="0" cellspacing="0" width="100%">';
  11. $sql = '
  12. SELECT
  13. '.TABLE_CATEGORY.'.*,
  14. '.TABLE_SUBCATEGORY.'.*,
  15. '.TABLE_PRODUCT_PREP.'.subcategory_id,
  16. '.TABLE_PRODUCT_PREP.'.donotlist,
  17. '.TABLE_PRODUCT_PREP.'.new
  18. FROM
  19. '.TABLE_CATEGORY.',
  20. '.TABLE_SUBCATEGORY.',
  21. '.TABLE_PRODUCT_PREP.',
  22. '.TABLE_PRODUCER.'
  23. WHERE
  24. '.TABLE_CATEGORY.'.category_id = '.TABLE_SUBCATEGORY.'.category_id
  25. AND '.TABLE_SUBCATEGORY.'.subcategory_id = '.TABLE_PRODUCT_PREP.'.subcategory_id
  26. AND '.TABLE_PRODUCT_PREP.'.donotlist != "1"
  27. AND '.TABLE_PRODUCT_PREP.'.new = "1"
  28. GROUP BY
  29. '.TABLE_PRODUCT_PREP.'.subcategory_id
  30. ORDER BY
  31. sort_order ASC,
  32. subcategory_name ASC';
  33. $rs = @mysql_query($sql, $connection) or die("Couldn't execute category query: ".mysql_error());
  34. while ( $row = mysql_fetch_array($rs) )
  35. {
  36. $category_id = $row['category_id'];
  37. $category_name = $row['category_name'];
  38. $subcategory_id = $row['subcategory_id'];
  39. $subcategory_name = $row['subcategory_name'];
  40. if ( $current_category_id < 0 )
  41. {
  42. $current_category_id = $row['category_id'];
  43. }
  44. while ( $current_category_id != $category_id )
  45. {
  46. $current_category_id = $category_id;
  47. $display .= '
  48. <tr>
  49. <td colspan="4"><font face=arial size="+2"><b>'.$category_name.'</b> </font></td>
  50. </tr>';
  51. }
  52. $display .= '
  53. <tr>
  54. <td colspan="4"><b><font size="+1">'.$subcategory_name.'</b> </font></td>
  55. </tr>
  56. <tr>
  57. <th align="center" width="30">'.$font.'
  58. <div style="border: solid 0 #000; border-top-width:2px; border-bottom-width:2px; padding-left:0.0ex">#</div>
  59. </th>
  60. <th align="left">'.$font.'
  61. <div style="border: solid 0 #000; border-top-width:2px; border-bottom-width:2px; padding-left:0.0ex"> Product</div>
  62. </th>
  63. <th align="center">'.$font.'
  64. <div style="border: solid 0 #000; border-top-width:2px; border-bottom-width:2px; padding-left:0.0ex;text-align:center;">Price</div>
  65. </th>
  66. <th align="right">'.$font.'
  67. <div style="border: solid 0 #000; border-top-width:2px; border-bottom-width:2px; padding-left:0.0ex;text-align:center;">Type</div>
  68. </th>
  69. </tr>';
  70. $sqlp = '
  71. SELECT
  72. '.TABLE_PRODUCT_PREP.'.subcategory_id,
  73. '.TABLE_PRODUCT_PREP.'.producer_id,
  74. '.TABLE_PRODUCER.'.producer_id,
  75. '.TABLE_PRODUCER.'.member_id,
  76. '.TABLE_MEMBER.'.member_id,
  77. '.TABLE_MEMBER.'.business_name,
  78. '.TABLE_MEMBER.'.first_name,
  79. '.TABLE_MEMBER.'.last_name,
  80. '.TABLE_PRODUCT_PREP.'.donotlist,
  81. '.TABLE_PRODUCT_PREP.'.new
  82. FROM
  83. '.TABLE_PRODUCT_PREP.'
  84. LEFT JOIN
  85. '.TABLE_PRODUCER.' ON '.TABLE_PRODUCER.'.producer_id = '.TABLE_PRODUCT_PREP.'.producer_id
  86. LEFT JOIN
  87. '.TABLE_MEMBER.' ON '.TABLE_MEMBER.'.member_id = '.TABLE_PRODUCER.'.member_id
  88. WHERE
  89. '.TABLE_PRODUCT_PREP.'.subcategory_id = "'.mysql_real_escape_string ($subcategory_id).'"
  90. AND '.TABLE_PRODUCT_PREP.'.donotlist != "1"
  91. AND '.TABLE_PRODUCT_PREP.'.new = "1"
  92. AND '.TABLE_PRODUCER.'.donotlist_producer = "0"
  93. GROUP BY
  94. '.TABLE_PRODUCT_PREP.'.producer_id
  95. ORDER BY
  96. '.TABLE_MEMBER.'.business_name';
  97. $resultp = @mysql_query($sqlp, $connection) or die("Couldn't execute query 2.");
  98. while ( $row = mysql_fetch_array($resultp) )
  99. {
  100. $producer_id = $row['producer_id'];
  101. $business_name = $row['business_name'];
  102. $first_name = $row['first_name'];
  103. $last_name = $row['last_name'];
  104. if ( !$business_name )
  105. {
  106. $business_name = "$first_name $last_name";
  107. }
  108. $display .= '
  109. <tr>
  110. <td colspan="4"><font size="+1"><b>'.$business_name.'</b></td>
  111. </tr>';
  112. $sql = '
  113. SELECT
  114. *
  115. FROM
  116. '.TABLE_PRODUCT_PREP.'
  117. LEFT JOIN
  118. '.TABLE_PRODUCT_TYPES.' ON '.TABLE_PRODUCT_TYPES.'.prodtype_id = '.TABLE_PRODUCT_PREP.'.prodtype_id
  119. WHERE
  120. '.TABLE_PRODUCT_PREP.'.subcategory_id = "'.mysql_real_escape_string ($subcategory_id).'"
  121. AND '.TABLE_PRODUCT_PREP.'.producer_id = "'.mysql_real_escape_string ($producer_id).'"
  122. AND '.TABLE_PRODUCT_PREP.'.donotlist != "1"
  123. AND '.TABLE_PRODUCT_PREP.'.new = "1"
  124. ORDER BY
  125. product_name ASC,
  126. unit_price ASC';
  127. $result = @mysql_query($sql, $connection) or die("Couldn't execute search query: " . mysql_error());
  128. while ( $row = mysql_fetch_array($result) )
  129. {
  130. $product_id = $row['product_id'];
  131. $product_name = $row['product_name'];
  132. $unit_price = $row['unit_price'];
  133. $pricing_unit = $row['pricing_unit'];
  134. $ordering_unit = $row['ordering_unit'];
  135. $prodtype_id = $row['prodtype_id'];
  136. $prodtype = $row['prodtype'];
  137. $extra_charge = $row['extra_charge'];
  138. $donotlist = $row['donotlist'];
  139. $detailed_notes = $row['detailed_notes'];
  140. if ( $current_product_id < 0 )
  141. {
  142. $current_product_id = $row['product_id'];
  143. }
  144. if ( $prodtype_id != 5 )
  145. {
  146. $show_type = $prodtype;
  147. }
  148. else
  149. {
  150. $show_type = '';
  151. }
  152. $price_display = '';
  153. if ($unit_price != 0)
  154. {
  155. $price_display .= '$ '.number_format($unit_price, 2).'/'.Inflect::singularize ($pricing_unit);
  156. }
  157. if ($unit_price != 0 && $extra_charge != 0)
  158. {
  159. $price_display .= '<br>';
  160. }
  161. if ($extra_charge != 0)
  162. {
  163. $price_display .= '$ '.number_format($extra_charge, 2).'/'.Inflect::singularize ($ordering_unit);
  164. }
  165. $show_details = $detailed_notes;
  166. while ( $current_product_id != $product_id )
  167. {
  168. $current_product_id = $product_id;
  169. $display .= '
  170. <tr>
  171. <td valign="top">'.$font2.' <b>'.$product_id.'</b></td>
  172. <td valign="top">'.$font2.' <b>'.$product_name.'</b> - Order number of '.Inflect::pluralize ($ordering_unit).' '.$show_details.'</font></td>
  173. <td valign="top" align=center>'.$font2.$price_display.'</font></td>
  174. <td valign="top" align="center">'.$font.' '.$show_type.'</font></td>
  175. </tr>';
  176. }
  177. }
  178. }
  179. }
  180. $display .= '
  181. </table>';
  182. $content = '
  183. <hr color="#000000" noshade size="2" width="100%">
  184. <font size="+3">'.ucfirst (SITE_NAME).' '.$date_today.' List of New Products Since Last Cycle</font>
  185. <hr color="#000000" noshade size="2" width="100%">
  186. '.$display;
  187. $page_title_html = '<span class="title">Printable Product Lists</span>';
  188. $page_subtitle_html = '<span class="subtitle">New Products</span>';
  189. $page_title = 'Printable Product Lists: New Products';
  190. $page_tab = 'producer_admin_panel';
  191. include("template_header.php");
  192. echo '
  193. <!-- CONTENT BEGINS HERE -->
  194. '.$content.'
  195. <!-- CONTENT ENDS HERE -->';
  196. include("template_footer.php");