PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/coopcoffeebeans/Customer/cupping_maint.php

https://github.com/gypsyfarm/gypsyfarm
PHP | 276 lines | 167 code | 87 blank | 22 comment | 18 complexity | be48f98184552fc6993fd0e7ab279afe MD5 | raw file
  1. <?php
  2. require("../functions.php");
  3. require("../tables.php");
  4. session_start();
  5. require("../check_login.php");
  6. require("../phpclasses.php");
  7. ?>
  8. <html>
  9. <head>
  10. <title>Cooperative Coffees - Order and Contact Database system</title>
  11. <link REL="stylesheet" TYPE="text/css" HREF="../general.css">
  12. <!-- changed #228B22 to #9bbcc2 -->
  13. </head>
  14. <!-- Javascript Routines -->
  15. <script language="Javascript">
  16. function saveRec() {
  17. if ( confirm("Are you Sure you want to update this record?")) {
  18. document.frmMain.action_type.value = "Update";
  19. document.frmMain.submit();
  20. }
  21. else {
  22. document.frmMain.submit();
  23. }
  24. }
  25. </script>
  26. <?
  27. #require("../left_menu.php");
  28. echo '<td valign="top">';
  29. /*
  30. echo " valid_user = ".$_SESSION['valid_user']." <br>\n";
  31. echo " contact_id = ".$_SESSION['contact_id']." <br> \n";
  32. echo " auth_contact_id = ".$_SESSION['auth_contact_id']." <br> \n";
  33. echo " user_type = ".$_SESSION['user_type']." <br> \n";
  34. echo "userid = ".$_SESSION_['userid']." <br> \n";
  35. */
  36. echo '<table border="1" width="100%" bordercolor="#FFFFFF" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">';
  37. echo '<tr>';
  38. echo '<td width="100%" bordercolor="#228B22" bgcolor="#228B22"><font face="Verdana" size="1" color="#FFFFFF"><b>::';
  39. echo 'ยค ';
  40. $current_date = date('Y-m-d H:i:s');
  41. echo date('H:i, jS F');
  42. echo '</font>';
  43. echo '</td>';
  44. echo '</tr>';
  45. echo '<tr>';
  46. echo '<td width="100%" bordercolor="#228B22" bgcolor="#FFFFFF">';
  47. //********Present the Menus*********************************************
  48. if (isset($_SESSION['contact_id'])) {
  49. $form_message = '';
  50. # set up connection string to database.
  51. $db_conn = mysql_connect('mysql.coopcoffeesbeans.com', 'greenbeans3', 'annh401');
  52. mysql_select_db('greenbeans', $db_conn);
  53. if (!$db_conn)
  54. {
  55. echo 'Error: Could not connect to database. Please try again later.';
  56. exit;
  57. }
  58. $current_item_id= stripslashes($_REQUEST['item_id']);
  59. $action=$_REQUEST['form_action'];
  60. $action_type = $_REQUEST['action_type'];
  61. #$action = $action_type;
  62. # Ok now do cupping notes:
  63. $contact_id = $_SESSION['contact_id'];
  64. if ($action == "Update" || $action == "Add") {
  65. #check if need to add or update cupping notes:
  66. mysql_select_db($tbl_cupping_info);
  67. $query = "select count(*) as nbr_recs
  68. from $tbl_cupping_info
  69. where lot_key = $current_item_id and rec_type = 2 and roaster = '$contact_id' ";
  70. # echo "<br>$query<br>";
  71. $checkCnt = mysql_query($query, $db_conn);
  72. $Checkrow = mysql_fetch_array($checkCnt);
  73. $fragrance = $_REQUEST[fragrance];
  74. $aroma = $_REQUEST[aroma];
  75. $acidity = $_REQUEST[acidity];
  76. $body = $_REQUEST[body];
  77. $flavor = $_REQUEST[flavor];
  78. $aftertaste = $_REQUEST[aftertaste];
  79. $moisture = $_REQUEST[moisture];
  80. $density = $_REQUEST[density];
  81. $color = $_REQUEST[color];
  82. $screen = $_REQUEST[screen];
  83. $cupping_notes = $_REQUEST[cupping_notes];
  84. $roast_profile = $_REQUEST[roast_profile];
  85. $roast_behavior = $_REQUEST[roast_behavior];
  86. $appearance_defects = $_REQUEST[appearance_defects];
  87. if ($Checkrow['nbr_recs'] > 0 ) {
  88. $cupping_action = "Update";
  89. $query = "update $tbl_cupping_info set ".
  90. " fragrance = '".$fragrance."',".
  91. " aroma = '".$aroma."',".
  92. " acidity = '".$acidity."',".
  93. " body = '".$body."',".
  94. " flavor = '".$flavor."',".
  95. " aftertaste = '".$aftertaste."',".
  96. " moisture = '".$moisture."',".
  97. " density = '".$density."',".
  98. " color = '".$color."',".
  99. " screen = '".$screen."',".
  100. " roast_profile = '".$roast_profile."',".
  101. " roast_behavior = '".$roast_behavior."',".
  102. " appearance_defects = '".$appearance_defects."',".
  103. " cupping_notes = '".$cupping_notes."' ".
  104. " where lot_key =".$current_item_id ." and rec_type = 2 and roaster = $contact_id ";
  105. # echo "<br>$query<br>";
  106. $result = mysql_query($query, $db_conn);
  107. if (!$result)
  108. $form_message = "<font size=2><br>Cupping Info was not updated";
  109. }
  110. else {
  111. $cupping_action = "Add";
  112. $query = "insert into $tbl_cupping_info
  113. ( seq, rec_type, lot_key, roaster, fragrance, aroma,
  114. acidity, body, flavor, aftertaste,
  115. moisture, density, color, screen, cupping_notes, roast_profile,
  116. roast_behavior, appearance_defects)
  117. values ( NULL, 2, $current_item_id, '$contact_id', '$fragrance','$aroma',
  118. '$acidity','$body','$flavor','$aftertaste',
  119. '$moisture','$density','$color', '$screen','$cupping_notes', '$roast_profile',
  120. '$roast_behavior', '$appearance_defects')";
  121. # echo "<br>$query <br>";
  122. $result = mysql_query($query, $db_conn);
  123. if (!$result) {
  124. $form_message = "<font size=2>Cupping Info Add Failed";
  125. }
  126. }
  127. }
  128. echo '<form name=frmMain method=post action="cupping_maint.php?item_id='.$current_item_id.'">';
  129. #echo "<br> current item is '$current_item_id' <br>";
  130. echo "<table width='80%'><tr><td align='left'>";
  131. echo '<h1 align=left><INPUT TYPE="SUBMIT" name="form_action" value="Update"></h1>';
  132. echo "</td><td align='right'>";
  133. echo "<a href='product_maint.php?item_id=$current_item_id'>Return to Item </a>";
  134. echo "</td></tr></table>";
  135. # echo '&nbsp;&nbsp;&nbsp;'.$form_message;
  136. //**********************************Gets the DataSet************************************
  137. mysql_select_db($tbl_coop_item);
  138. $query = "select ci.item_id, ci.item_code, ci.lot_ship, ci.warehouse,
  139. ci.item_description, id.item_description as generic_description, ci.member_price, ci.non_member_price,
  140. ci.mark, ci.warehouse_code, ci.cost, ci.quantity, ci.transfer_in, ci.transfer_out,
  141. id.weight as bag_lbs,ci.green_cb, ci.spot_available, ci.green_comment,
  142. ci.STATUS, ci.ship_date, ci.arrival_date, ci.ft_item, ci.org_item,
  143. ci.contract_date, ci.sample_shipped, ci.sample_approved, ci.container,
  144. ci.document, ci.fda_confirm, ci.fda_date, ci.customs_clear_date,
  145. ci.item_notes, ci.item_active, id.rank, ci.fixed_date, ci.fixed_price, ci.nyc, ci.prefinance, ci.prefinance_amount,
  146. ci.flo_id, ci.scribd_id, ci.guid,
  147. c.fragrance, c.aroma, c.acidity, c.body, c.flavor,
  148. c.aftertaste, c.moisture, c.density, c.color, c.screen, c.cupping_notes, c.roast_profile,
  149. c.roast_behavior, c.appearance_defects
  150. from $tbl_item_description id, $tbl_coop_item ci
  151. LEFT JOIN cupping_info c ON c.rec_type = 2 and roaster = '$contact_id' and c.lot_key = ci.item_id
  152. where ci.item_id = $current_item_id
  153. and ci.item_code = id.item_code ";
  154. #echo "<br>$query<br>";
  155. $result = mysql_query($query, $db_conn);
  156. $num_results = mysql_num_rows($result);
  157. $row = mysql_fetch_array($result);
  158. echo '<input type=hidden name=action_type size=10 value="transfer">';
  159. echo '<input type="hidden" name="r_action" value="';
  160. if ($num_results == 0) {
  161. echo 'Add';
  162. }
  163. else {
  164. echo 'Update';
  165. }
  166. echo '">';
  167. require("cupping_fields.php");
  168. }
  169. else {
  170. if (isset($userid)) {
  171. // if they've tried and failed to log in
  172. echo 'Could not log you in';
  173. }
  174. else {
  175. // they have not tried to log in yet or have logged out
  176. echo '<font size=4 color=black>You are not logged in, please enter a valid userid and password.</font>';
  177. }
  178. }
  179. echo '</form>';
  180. ?>
  181. <hr noshade size="1" color="#228B22">
  182. </td>
  183. </tr>
  184. </table>
  185. </td>
  186. </tr>
  187. </table>
  188. </body>
  189. </html>