PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/coopcoffeebeans/Customer/product_maint.php

https://github.com/gypsyfarm/gypsyfarm
PHP | 278 lines | 164 code | 104 blank | 10 comment | 16 complexity | 0342d87af59f136690354368e4febc4d 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. function set_last_maint($action = "x",$key = 0,$user_name = "y") {
  8. global $tbl_coop_item_last_maint;
  9. global $db_conn;
  10. $current_date = date("m/d/y") ;
  11. if ($action == 'Update') {
  12. $query = "insert into $tbl_coop_item_last_maint
  13. (item_id, updated_by, action, maint_date)
  14. values ($key, '$user_name', '$action', CURDATE())";
  15. }
  16. if ($action == 'Add') {
  17. $query = "insert into $tbl_coop_item_last_maint
  18. (item_id, updated_by, action, maint_date)
  19. values ($key, '$user_name', '$action', CURDATE())";
  20. $LastMaintInfo=new UpdateLastMaint($key,"add");
  21. }
  22. # echo "<br>$query<br>";
  23. $result = mysql_query($query, $db_conn);
  24. if (!$result){
  25. echo "<font size=2>Add Failed";
  26. }
  27. }
  28. ?>
  29. <html>
  30. <head>
  31. <title>Cooperative Coffees - Order and Contact Database system</title>
  32. <link REL="stylesheet" TYPE="text/css" HREF="../general.css">
  33. <!-- changed #228B22 to #9bbcc2 -->
  34. </head>
  35. <!-- Javascript Routines -->
  36. <script language="Javascript">
  37. function saveRec() {
  38. if ( confirm("Are you Sure you want to change this record?")) {
  39. document.frmMain.action_type.value = "Update";
  40. document.frmMain.submit();
  41. }
  42. else {
  43. document.frmMain.submit();
  44. }
  45. }
  46. function delRec() {
  47. if ( confirm("Are you Sure you want to Delete this record?")) {
  48. document.frmMain.action_type.value = "Delete";
  49. document.frmMain.submit();
  50. }
  51. }
  52. </script>
  53. <?
  54. #require("../left_menu.php");
  55. $current_item_id= stripslashes($_GET['item_id']);
  56. echo '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
  57. echo '<tr>';
  58. echo '<td width="150" valign="top">';
  59. echo '<table border="1" width="140" cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">';
  60. echo '<tr>';
  61. echo '<td width="100%" bordercolor="#228B22" bgcolor="#228B22"><font face="Verdana" size="1" color="#FFFFFF"><b>::';
  62. echo "<a href=\"javascript:poptastic('Help.php?x=47A$menu_user_type');\"><font face='Verdana' size='1' color='#FFFFFF'>help</font</a>";
  63. echo '</tr>';
  64. echo '<tr>';
  65. echo '<td width="600" bordercolor="#228B22" bgcolor="#FFFFFF">';
  66. echo '<font face="Verdana" size="1">*<a href="../index.php">Back to Main Menu</a></font><br>';
  67. echo '<hr>';
  68. echo '<font face="Verdana" size="1">*<a href="cooporder.php">Create a new Order</a></font><br>';
  69. echo '<hr>';
  70. echo '<font face="Verdana" size="1">*<a href="reports/index.php">View Reports</a></font><br>';
  71. echo '<hr>';
  72. echo '<font face="Verdana" size="1">*<a href="../Contact_Search/contact_start.php">Contact Database</a></font><br>';
  73. echo '<hr>';
  74. echo '<font face="Verdana" size="1">*<a href="product_start.php">Lot Review</a></font><br>';
  75. echo '<hr>';
  76. echo '<font face="Verdana" size="1">*<a href="cupping_maint.php?item_id='.$current_item_id.'">Add Cupping Notes </a></font><br>';
  77. echo '<hr>';
  78. echo '<font face="Verdana" size="1">*<a href="password.php">Change Password</a></font><br>';
  79. echo '<hr>';
  80. echo '<font face="Verdana" size="1">*<a href="../logout.php">Log out</a></font><br>';
  81. echo '</td>';
  82. echo '</tr>';
  83. echo '</table>';
  84. echo '</td>';
  85. echo '<td valign="top">';
  86. echo '<table border="1" width="100%" bordercolor="#FFFFFF" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">';
  87. echo '<tr>';
  88. echo '<td width="100%" bordercolor="#228B22" bgcolor="#228B22"><font face="Verdana" size="1" color="#FFFFFF"><b>::';
  89. echo 'ยค ';
  90. $current_date = date('Y-m-d H:i:s');
  91. echo date('H:i, jS F');
  92. echo '</font>';
  93. echo '</td>';
  94. echo '</tr>';
  95. echo '<tr>';
  96. echo '<td width="100%" bordercolor="#228B22" bgcolor="#FFFFFF">';
  97. //********Present the Menus*********************************************
  98. if (isset($_SESSION['contact_id'])) {
  99. $form_message = '';
  100. # set up connection string to database.
  101. $db_conn = mysql_connect('mysql.coopcoffeesbeans.com', 'greenbeans3', 'annh401');
  102. mysql_select_db('cbeans', $db_conn);
  103. if (!$db_conn)
  104. {
  105. echo 'Error: Could not connect to database. Please try again later.';
  106. exit;
  107. }
  108. $action=$_REQUEST['form_action'];
  109. $action_type = $_REQUEST['action_type'];
  110. echo '<form name=frmMain method=post action="product_maint.php?item_id='.$current_item_id.'">';
  111. //**********************************Gets the DataSet************************************
  112. mysql_select_db($tbl_coop_item);
  113. $query = "select ci.item_id, ci.item_code, ci.lot_ship, ci.warehouse,
  114. ci.item_description, id.item_description as generic_description, ci.member_price, ci.non_member_price,
  115. ci.mark, ci.warehouse_code, ci.cost, ci.quantity, ci.transfer_in, ci.transfer_out,
  116. id.weight as bag_lbs,ci.green_cb, ci.spot_available, ci.green_comment,
  117. ci.STATUS, ci.ship_date, ci.arrival_date, ci.ft_item, ci.org_item,
  118. ci.contract_date, ci.sample_shipped, ci.sample_approved, ci.container,
  119. ci.document, ci.fda_confirm, ci.fda_date, ci.customs_clear_date,
  120. ci.item_notes, ci.item_active, id.rank, ci.fixed_date, ci.fixed_price, ci.nyc, ci.prefinance, ci.prefinance_amount, ci.flo_id, ci.scribd_id, ci.guid
  121. from $tbl_coop_item ci, $tbl_item_description id
  122. where ci.item_id = $current_item_id
  123. and ci.item_code = id.item_code ";
  124. # echo "<br>$query<br>";
  125. $result = mysql_query($query, $db_conn);
  126. $num_results = mysql_num_rows($result);
  127. $row = mysql_fetch_array($result);
  128. # start
  129. $key_to_use = $row['item_id'];
  130. $query2 = "SELECT max( seq ) as seq FROM $tbl_coop_item_last_maint WHERE item_id = '$key_to_use'";
  131. $result2 = mysql_query($query2, $db_conn);
  132. $row2 = mysql_fetch_array($result2);
  133. $record_to_get = $row2['seq'];
  134. $query2 = "SELECT * FROM $tbl_coop_item_last_maint WHERE seq = '$record_to_get'";
  135. $result2 = mysql_query($query2, $db_conn);
  136. $row2 = mysql_fetch_array($result2);
  137. echo 'Last Maint by: '.$row2['updated_by'].' &nbsp;&nbsp;&nbsp;';
  138. echo 'Date: '.$row2['maint_date'].' &nbsp;&nbsp;&nbsp;';
  139. echo 'Type: '.$row2['action'].' &nbsp;&nbsp;&nbsp;';
  140. echo '<a href="javascript:poptastic(\'last_maint_detail.php?key_to_use='.$key_to_use.'\');"><font face="Verdana" size="1" color="#000000">Last Maint Detail</font></a>';
  141. #end
  142. echo '<input type=hidden name=action_type size=10 value="transfer">';
  143. echo '<input type="hidden" name="r_action" value="';
  144. if ($num_results == 0) {
  145. echo 'Add';
  146. }
  147. else {
  148. echo 'Update';
  149. }
  150. echo '">';
  151. echo "<h1>Review</h1>";
  152. require("product_fields.php");
  153. }
  154. else {
  155. if (isset($userid)) {
  156. // if they've tried and failed to log in
  157. echo 'Could not log you in';
  158. }
  159. else {
  160. // they have not tried to log in yet or have logged out
  161. echo '<font size=4 color=black>You are not logged in, please enter a valid userid and password.</font>';
  162. }
  163. }
  164. echo '</form>';
  165. ?>
  166. <hr noshade size="1" color="#228B22">
  167. </td>
  168. </tr>
  169. </table>
  170. </td>
  171. </tr>
  172. </table>
  173. </body>
  174. </html>