PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/public_html/shop/members/producer_form.php

https://github.com/traceyambrose/foodcoop
PHP | 838 lines | 739 code | 70 blank | 29 comment | 82 complexity | a1441d1211bf7b9fe4082a5c0de79b6d MD5 | raw file
  1. <?php
  2. $user_type = 'valid_m';
  3. include_once ("config_foodcoop.php");
  4. session_start();
  5. // validate_user(); Do not validate because non-members must access this form
  6. if ( $_SESSION['member_id'])
  7. {
  8. $member_id = $_SESSION['member_id'];
  9. }
  10. elseif ( $_POST['member_id'])
  11. {
  12. $member_id = $_SESSION['member_id'];
  13. }
  14. else
  15. {
  16. header( "Location: index.php");
  17. exit;
  18. }
  19. if ($_GET['action'] == 'from_member_form')
  20. {
  21. $error_message = 'Membership information has been accepted. In order to be considered as a producer
  22. for the '.ORGANIZATION_TYPE.', please fill out the form below. If you do not have time to fill out
  23. the form now, you may want to print it and return to the membership form at a later time.';
  24. $website = $_SESSION['website'];
  25. $business_name = $_SESSION['business_name'];
  26. unset ($_SESSION['website']);
  27. unset ($_SESSION['business_name']);
  28. }
  29. // SPECIAL NOTES ABOUT THIS PAGE: //////////////////////////////////////////////
  30. // //
  31. // This page MAY be accessed by visitors without logging in. However, it //
  32. // will only be accessed by visitors who either are already accepted members //
  33. // or who have already supplied an application for membership. //
  34. // //
  35. ////////////////////////////////////////////////////////////////////////////////
  36. ////////////////////////////////////////////////////////////////////////////////
  37. // //
  38. // PROCESS POSTED DATA //
  39. // //
  40. ////////////////////////////////////////////////////////////////////////////////
  41. // Get data from the $_POST variable that pertain to BOTH Submit (new members) and Update (existing members)
  42. if ($_POST['action'] == 'Submit')
  43. {
  44. $member_id = $_POST['member_id'];
  45. $producer_id = preg_replace ('/[^0-9A-Za-z\-\._]/','', $_POST['producer_id']); // Only: A-Z a-z 0-9 - . _
  46. $business_name = stripslashes ($_POST['business_name']);
  47. $products = stripslashes ($_POST['products']);
  48. $practices = stripslashes ($_POST['practices']);
  49. $general_practices = stripslashes ($_POST['general_practices']);
  50. $pest_management = stripslashes ($_POST['pest_management']);
  51. $productivity_management = stripslashes ($_POST['productivity_management']);
  52. $feeding_practices = stripslashes ($_POST['feeding_practices']);
  53. $soil_management = stripslashes ($_POST['soil_management']);
  54. $water_management = stripslashes ($_POST['water_management']);
  55. $land_practices = stripslashes ($_POST['land_practices']);
  56. $additional_information = stripslashes ($_POST['additional_information']);
  57. $licenses_insurance = stripslashes ($_POST['licenses_insurance']);
  58. $organic_products = stripslashes ($_POST['organic_products']);
  59. $certifying_agency = stripslashes ($_POST['certifying_agency']);
  60. $agency_phone = stripslashes ($_POST['agency_phone']);
  61. $agency_fax = stripslashes ($_POST['agency_fax']);
  62. $organic_cert = stripslashes ($_POST['organic_cert']);
  63. $producttypes = stripslashes ($_POST['producttypes']);
  64. $about = stripslashes ($_POST['about']);
  65. $ingredients = stripslashes ($_POST['ingredients']);
  66. $practices = stripslashes ($_POST['practices']);
  67. $highlights = stripslashes ($_POST['highlights']);
  68. $additional = stripslashes ($_POST['additional']);
  69. $pub_address = stripslashes ($_POST['pub_address']);
  70. $pub_email = stripslashes ($_POST['pub_email']);
  71. $pub_email2 = stripslashes ($_POST['pub_email2']);
  72. $pub_phoneh = stripslashes ($_POST['pub_phoneh']);
  73. $pub_phonew = stripslashes ($_POST['pub_phonew']);
  74. $pub_phonec = stripslashes ($_POST['pub_phonec']);
  75. $pub_phonet = stripslashes ($_POST['pub_phonet']);
  76. $pub_fax = stripslashes ($_POST['pub_fax']);
  77. $pub_web = stripslashes ($_POST['pub_web']);
  78. $liability_statement = stripslashes ($_POST['liability_statement']);
  79. // VALIDATE THE DATA
  80. $error_array = array ();
  81. if ( !$member_id ) array_push ($error_array, 'Member ID is unknown. You must access this form after logging in and/or submitting a <a href="member_form.php">membership form</a>');
  82. if ( !$producer_id ) array_push ($error_array, 'You must enter a unique producer ID for your business');
  83. if ( $producer_id && strlen ($producer_id) != 5 ) array_push ($error_array, 'Producer ID must be five unique alphanumeric characters');
  84. $query = '
  85. SELECT
  86. member_id
  87. FROM
  88. '.TABLE_PRODUCER.'
  89. WHERE producer_id = "'.mysql_real_escape_string ($producer_id).'"';
  90. $sql = @mysql_query($query, $connection) or die("You found a bug. <b>Error:</b> Check for existing member query " . mysql_error() . "<br><b>Error No: </b>" . mysql_errno());
  91. if ($row = mysql_fetch_object($sql))
  92. {
  93. if ($member_id == $row->member_id) array_push ($error_array, 'You are already registered with this Producer ID');
  94. if ($member_id != $row->member_id) array_push ($error_array, 'The Producer ID you have chosen is already in use, please select another value');
  95. }
  96. $query = '
  97. SELECT
  98. member_id
  99. FROM
  100. '.TABLE_PRODUCER.'
  101. WHERE member_id = "'.mysql_real_escape_string ($member_id).'"';
  102. $sql = @mysql_query($query, $connection) or die("You found a bug. <b>Error:</b> Check for existing member query " . mysql_error() . "<br><b>Error No: </b>" . mysql_errno());
  103. if ($row = mysql_fetch_object($sql)) array_push ($error_array, 'You are already registered as a Producer');
  104. if ( !$business_name ) array_push ($error_array, 'A business name is required in order to register as a producer');
  105. if ( $liability_statement != 1 ) array_push ($error_array, 'In order to be accepted as a producer, you must agree with the stated terms');
  106. }
  107. // Assemble any errors encountered so far
  108. if (count ($error_array) > 0) $error_message = '
  109. <p class="message">The information was not accepted. Please correct the following problems and
  110. resubmit.<ul class="error_list"><li>'.implode ("</li>\n<li>", $error_array).'</li></ul></p>';
  111. ////////////////////////////////////////////////////////////////////////////////
  112. // //
  113. // SET UP THE SELECT AND CHECKBOX FORMS FOR DISPLAY BASED UPON PRIOR VALUES //
  114. // //
  115. ////////////////////////////////////////////////////////////////////////////////
  116. if ($liability_statement == 1) $liability_statement_check = ' checked';
  117. if ($organic_cert == '1') $organic_cert_yes = ' checked';
  118. if ($organic_cert == '0') $organic_cert_no = ' checked';
  119. if ($pub_address == '1') $pub_address_check = ' checked';
  120. if ($pub_email == '1') $pub_email_check = ' checked';
  121. if ($pub_email2 == '1') $pub_email2_check = ' checked';
  122. if ($pub_phoneh == '1') $pub_phoneh_check = ' checked';
  123. if ($pub_phonew == '1') $pub_phonew_check = ' checked';
  124. if ($pub_phonec == '1') $pub_phonec_check = ' checked';
  125. if ($pub_phonet == '1') $pub_phonet_check = ' checked';
  126. if ($pub_fax == '1') $pub_fax_check = ' checked';
  127. if ($pub_web == '1') $pub_web_check = ' checked';
  128. if ($liability_statement != 1) $liability_statement = '0';
  129. if ($organic_cert != '1') $organic_cert = '0';
  130. if ($pub_address != '1') $pub_address = '0';
  131. if ($pub_email != '1') $pub_email = '0';
  132. if ($pub_email2 != '1') $pub_email2 = '0';
  133. if ($pub_phoneh != '1') $pub_phoneh = '0';
  134. if ($pub_phonew != '1') $pub_phonew = '0';
  135. if ($pub_phonec != '1') $pub_phonec = '0';
  136. if ($pub_phonet != '1') $pub_phonet = '0';
  137. if ($pub_fax != '1') $pub_fax = '0';
  138. if ($pub_web != '1') $pub_web = '0';
  139. ////////////////////////////////////////////////////////////////////////////////
  140. // //
  141. // DISPLAY THE INPUT FORM //
  142. // //
  143. ////////////////////////////////////////////////////////////////////////////////
  144. $display_form_top .= '
  145. <h1>'.date('Y').' '.SITE_NAME.'<br>Producer Registration</h1/><br/>
  146. <div style="margin:auto;width:90%;padding:1em;">';
  147. $display_form_text .= '
  148. Member ID: '.$member_id.'
  149. Producer ID: '.$producer_id.'
  150. Business Name: '.$business_name.'
  151. Website: '.$website.'
  152. The following checked items will be displayed on the site
  153. ['.strtr ($pub_address, " 01", " X").'] Publish Home Address
  154. ['.strtr ($pub_email, " 01", " X").'] Publish Email Address
  155. ['.strtr ($pub_email2, " 01", " X").'] Publish Email Address 2
  156. ['.strtr ($pub_phoneh, " 01", " X").'] Publish Home Phone No.
  157. ['.strtr ($pub_phonew, " 01", " X").'] Publish Work Phone No.
  158. ['.strtr ($pub_phonec, " 01", " X").'] Publish Mobile Phone No.
  159. ['.strtr ($pub_phonet, " 01", " X").'] Publish Toll-free Phone No.
  160. ['.strtr ($pub_fax, " 01", " X").'] Publish FAX No.
  161. ['.strtr ($pub_web, " 01", " X").'] Publish Web Page
  162. Product Types:
  163. '.str_replace ("\n", "\n ", wordwrap($producttypes, 71, "\n", true)).'
  164. About Us:
  165. '.str_replace ("\n", "\n ", wordwrap($about, 71, "\n", true)).'
  166. Ingredients:
  167. '.str_replace ("\n", "\n ", wordwrap($ingredients, 71, "\n", true)).'
  168. Practices:
  169. '.str_replace ("\n", "\n ", wordwrap($general_practices, 71, "\n", true)).'
  170. Additional Information:
  171. '.str_replace ("\n", "\n ", wordwrap($additional, 71, "\n", true)).'
  172. Highlights This Month:
  173. '.str_replace ("\n", "\n ", wordwrap($highlights, 71, "\n", true)).'
  174. Products:
  175. '.str_replace ("\n", "\n ", wordwrap($products, 71, "\n", true)).'
  176. Practices:
  177. '.str_replace ("\n", "\n ", wordwrap($practices, 71, "\n", true)).'
  178. Pest Management:
  179. '.str_replace ("\n", "\n ", wordwrap($pest_management, 71, "\n", true)).'
  180. Productivity Management:
  181. '.str_replace ("\n", "\n ", wordwrap($productivity_management, 71, "\n", true)).'
  182. Feeding Practices:
  183. '.str_replace ("\n", "\n ", wordwrap($feeding_practices, 71, "\n", true)).'
  184. Soil Management:
  185. '.str_replace ("\n", "\n ", wordwrap($soil_management, 71, "\n", true)).'
  186. Water Management:
  187. '.str_replace ("\n", "\n ", wordwrap($water_management, 71, "\n", true)).'
  188. Land Practices:
  189. '.str_replace ("\n", "\n ", wordwrap($land_practices, 71, "\n", true)).'
  190. Additional Information:
  191. '.str_replace ("\n", "\n ", wordwrap($additional_information, 71, "\n", true)).'
  192. Insurance, Licenses, and Tests:
  193. '.str_replace ("\n", "\n ", wordwrap($licenses_insurance, 71, "\n", true)).'
  194. Organic Products:
  195. '.str_replace ("\n", "\n ", wordwrap($organic_products, 71, "\n", true)).'
  196. Organic Certifying Agency:
  197. '.str_replace ("\n", "\n ", wordwrap($certifying_agency, 71, "\n", true)).'
  198. Certifying Agency Phone:
  199. '.str_replace ("\n", "\n ", wordwrap($agency_phone, 71, "\n", true)).'
  200. Certifying Agency FAX:
  201. '.str_replace ("\n", "\n ", wordwrap($agency_fax, 71, "\n", true)).'
  202. ['.strtr ($organic_cert, " 01", " X").'] I have available for inspection a copy of your current organic
  203. certificate.
  204. ['.strtr ($liability_statement, " 01", " X").'] '.str_replace ("\n", "\n ", wordwrap ('I affirm that all statements made about my farm and products in this application are true, correct and complete and I have given a truthful representation of my operation, practices, and origin of products. I understand that if questions arise about my operation I may be inspected (unannounced) by '.SITE_NAME.'. If I stated my operation is organic, then I am complying with the National Organic Program and will provide upon request a copy of my certification. I have read all of '.SITE_NAME."'".'s terms of service and fully understand and am willing to comply with them.', 75, "\n", true));
  205. $welcome_message .= '<p><em>Thank you for your interest in becoming a producer member of '.SITE_NAME.'. '.SITE_NAME.' customers and producers are interested in local foods and products produced with sustainable practices that demonstrate good stewardship of the environment. Upon approval this form will register you to sell products within '.SITE_NAME.'. Please read the <a href="'.TERMS_OF_SERVICE.'" target="_blank">Terms of Service</a>, and then complete the following information and click submit.</em></p>';
  206. $display_form_html .= '<p class="error_message">'.$error_message.'</p>
  207. <form action="'.$_SERVER['PHP_SELF'].'" name="delivery" method="post">
  208. <table cellspacing="15" cellpadding="2" width="100%" border="1" align="center">
  209. <tbody>
  210. <tr>
  211. <th class="memberform">Section 1: Credentials and Privacy</th>
  212. </tr>
  213. <tr>
  214. <td>
  215. <table>
  216. <tr>
  217. <td class="form_key"><strong>* Member&nbsp;ID:</strong></td>
  218. <td><input maxlength="6" size="10" name="disabled" value="'.$member_id.'" disabled/><input type="hidden" name="member_id" value="'.$member_id.'"/></td>
  219. <td class="form_key"><strong>** Producer&nbsp;ID:</strong></td>
  220. <td><input maxlength="6" size="10" name="producer_id" value="'.$producer_id.'"/></td>
  221. </tr>
  222. <tr>
  223. <td colspan="4">
  224. * Your member ID should already be filled in. It may not be changed.<br>
  225. ** Choose a unique 5-character Producer ID to represent your operation. May contain letters,
  226. numbers, dash, dot, or underline but it must be exactly five characters long.</td>
  227. </tr>
  228. </table>
  229. </td>
  230. </tr>
  231. <tr>
  232. <td>
  233. <table>
  234. <tr>
  235. <td class="form_key"><strong>Business&nbsp;Name:</strong></td>
  236. <td><input maxlength="50" size="45" name="business_name" value="'.htmlentities ($business_name, ENT_QUOTES).'"/></td>
  237. </tr>
  238. <tr>
  239. <td class="form_key"><strong>Website:</strong></td>
  240. <td><input maxlength="50" size="45" name="website" value="'.htmlentities ($website, ENT_QUOTES).'"/></td>
  241. </tr>
  242. </table>
  243. </td>
  244. </tr>
  245. <tr>
  246. <td>
  247. <table>
  248. <tr>
  249. <td class="form_key" colspan="4">The following privacy settings affect which of your
  250. membership information will be displayed publicly on your producer page.</td>
  251. </tr>
  252. <tr>
  253. <td align="right"><input type="checkbox" name="pub_address" value="1" '.$pub_address_check.'/></td>
  254. <td colspan="3" class="form_key"><strong>Publish Home Address</strong></td>
  255. </tr>
  256. <td align="right"><input type="checkbox" name="pub_email" value="1" '.$pub_email_check.'/></td>
  257. <td class="form_key"><strong>Publish Email Address</strong></td>
  258. <td align="right"><input type="checkbox" name="pub_email2" value="1" '.$pub_email2_check.'/></td>
  259. <td class="form_key"><strong>Publish Email Address 2</strong></td>
  260. <tr>
  261. </tr>
  262. <td align="right"><input type="checkbox" name="pub_phoneh" value="1" '.$pub_phoneh_check.'/></td>
  263. <td class="form_key"><strong>Publish Home Phone No.</strong></td>
  264. <td align="right"><input type="checkbox" name="pub_phonew" value="1" '.$pub_phonew_check.'/></td>
  265. <td class="form_key"><strong>Publish Work Phone No.</strong></td>
  266. <tr>
  267. </tr>
  268. <td align="right"><input type="checkbox" name="pub_phonec" value="1" '.$pub_phonec_check.'/></td>
  269. <td class="form_key"><strong>Publish Mobile Phone No.</strong></td>
  270. <td align="right"><input type="checkbox" name="pub_phonet" value="1" '.$pub_phonet_check.'/></td>
  271. <td class="form_key"><strong>Publish Toll-free Phone No.</strong></td>
  272. <tr>
  273. </tr>
  274. <td align="right"><input type="checkbox" name="pub_fax" value="1" '.$pub_fax_check.'/></td>
  275. <td class="form_key"><strong>Publish FAX No.</strong></td>
  276. <td align="right"><input type="checkbox" name="pub_web" value="1" '.$pub_web_check.'/></td>
  277. <td class="form_key"><strong>Publish Web Page</strong></td>
  278. <tr>
  279. </tr>
  280. </table>
  281. </td>
  282. </tr>
  283. <tr>
  284. <th class="memberform">Section 2: General Producer Information</th>
  285. </tr>
  286. <tr>
  287. <td>
  288. <table>
  289. <tr>
  290. <td class="form_key"><strong>Product Types:</strong><br>
  291. List keywords like lettuce, berries, buffalo, soap, etc.</td>
  292. </tr>
  293. <tr>
  294. <td><textarea cols="80" rows="5" name="producttypes">'.htmlentities ($producttypes, ENT_QUOTES).'</textarea></td>
  295. </tr>
  296. </table>
  297. </td>
  298. </tr>
  299. <tr>
  300. <td>
  301. <table>
  302. <tr>
  303. <td class="form_key"><strong>About Us:</strong><br>
  304. Use this space to describe your business, you, how you got started, etc.</td>
  305. </tr>
  306. <tr>
  307. <td><textarea cols="80" rows="5" name="about">'.htmlentities ($about, ENT_QUOTES).'</textarea></td>
  308. </tr>
  309. </table>
  310. </td>
  311. </tr>
  312. <tr>
  313. <td>
  314. <table>
  315. <tr>
  316. <td class="form_key"><strong>Ingredients:</strong><br>
  317. Use this space to outline ingredients if relevant.</td>
  318. </tr>
  319. <tr>
  320. <td><textarea cols="80" rows="5" name="ingredients">'.htmlentities ($ingredients, ENT_QUOTES).'</textarea></td>
  321. </tr>
  322. </table>
  323. </td>
  324. </tr>
  325. <tr>
  326. <td>
  327. <table>
  328. <tr>
  329. <td class="form_key"><strong>Practices:</strong><br>
  330. Use this space to describe your standards and practices. For example, if you use all
  331. natural products, etc.</td>
  332. </tr>
  333. <tr>
  334. <td><textarea cols="80" rows="5" name="general_practices">'.htmlentities ($general_practices, ENT_QUOTES).'</textarea></td>
  335. </tr>
  336. </table>
  337. </td>
  338. </tr>
  339. <tr>
  340. <td>
  341. <table>
  342. <tr>
  343. <td class="form_key"><strong>Additional Information:</strong><br>
  344. Use this space for anything that is not covered in these other sections.</td>
  345. </tr>
  346. <tr>
  347. <td><textarea cols="80" rows="5" name="additional">'.htmlentities ($additional, ENT_QUOTES).'</textarea></td>
  348. </tr>
  349. </table>
  350. </td>
  351. </tr>
  352. <tr>
  353. <td>
  354. <table>
  355. <tr>
  356. <td class="form_key"><strong>Highlights This Month:</strong><br>
  357. Use this section for notes that are relevant to the current month.</td>
  358. </tr>
  359. <tr>
  360. <td><textarea cols="80" rows="5" name="highlights">'.htmlentities ($highlights, ENT_QUOTES).'</textarea></td>
  361. </tr>
  362. </table>
  363. </td>
  364. </tr>
  365. <tr>
  366. <th class="memberform">Section 3: Production Specifics (Producer Questionnaire)</th>
  367. </tr>
  368. <tr>
  369. <td>
  370. <table>
  371. <tr>
  372. <td class="form_key"><strong>Products:</strong><br>
  373. List the types of products you intend to sell through '.SITE_NAME.'
  374. (e.g. meats, grains, jellies, crafts; also note if you have any heritage breeds).</td>
  375. </tr>
  376. <tr>
  377. <td><textarea cols="80" rows="5" name="products">'.htmlentities ($products, ENT_QUOTES).'</textarea></td>
  378. </tr>
  379. </table>
  380. </td>
  381. </tr>
  382. <tr>
  383. <td>
  384. <table>
  385. <tr>
  386. <td class="form_key"><strong>Practices:</strong><br>
  387. Describe your farming, processing and/or crafting practices.</td>
  388. </tr>
  389. <tr>
  390. <td><textarea cols="80" rows="5" name="practices">'.htmlentities ($practices, ENT_QUOTES).'</textarea></td>
  391. </tr>
  392. </table>
  393. </td>
  394. </tr>
  395. <tr>
  396. <td>
  397. <table>
  398. <tr>
  399. <td class="form_key"><strong>Pest Management:</strong><br>
  400. Describe your pest and disease management system.</td>
  401. </tr>
  402. <tr>
  403. <td><textarea cols="80" rows="5" name="pest_management">'.htmlentities ($pest_management, ENT_QUOTES).'</textarea></td>
  404. </tr>
  405. </table>
  406. </td>
  407. </tr>
  408. <tr>
  409. <td>
  410. <table>
  411. <tr>
  412. <td class="form_key"><strong>Productivity Management:</strong><br>
  413. Describe your herd health and productivity management (i.e. do you use any hormones,
  414. antibiotics, and/or steroids).</td>
  415. </tr>
  416. <tr>
  417. <td><textarea cols="80" rows="5" name="productivity_management">'.htmlentities ($productivity_management, ENT_QUOTES).'</textarea></td>
  418. </tr>
  419. </table>
  420. </td>
  421. </tr>
  422. <tr>
  423. <td>
  424. <table>
  425. <tr>
  426. <td class="form_key"><strong>Feeding Practices:</strong><br>
  427. Describe your feeding practices &ndash; grass-fed only, free-range, feed-lot, etc.</td>
  428. </tr>
  429. <tr>
  430. <td><textarea cols="80" rows="5" name="feeding_practices">'.htmlentities ($feeding_practices, ENT_QUOTES).'</textarea></td>
  431. </tr>
  432. </table>
  433. </td>
  434. </tr>
  435. <tr>
  436. <td>
  437. <table>
  438. <tr>
  439. <td class="form_key"><strong>Soil Management:</strong><br>
  440. Describe your soil and nutrient management. Do you compost, use fertilizers, green
  441. manures or animal manures?</td>
  442. </tr>
  443. <tr>
  444. <td><textarea cols="80" rows="5" name="soil_management">'.htmlentities ($soil_management, ENT_QUOTES).'</textarea></td>
  445. </tr>
  446. </table>
  447. </td>
  448. </tr>
  449. <tr>
  450. <td>
  451. <table>
  452. <tr>
  453. <td class="form_key"><strong>Water Management:</strong><br>
  454. Describe your water usage practices. If you irrigate, describe how (e.g. deep well,
  455. surface water, etc.), and explain how you conserve water or use best management practices.
  456. Describe how you are protecting your water source from contamination/erosion.</td>
  457. </tr>
  458. <tr>
  459. <td><textarea cols="80" rows="5" name="water_management">'.htmlentities ($water_management, ENT_QUOTES).'</textarea></td>
  460. </tr>
  461. </table>
  462. </td>
  463. </tr>
  464. <tr>
  465. <td>
  466. <table>
  467. <tr>
  468. <td class="form_key"><strong>Land Practices:</strong><br>
  469. Describe your conservation/land stewardship practices. E.g. do you plant
  470. windbreaks, maintain grass waterways, riparian buffers, use green manures
  471. for wind erosion, plant habitats for birds, improve soil quality, etc.</td>
  472. </tr>
  473. <tr>
  474. <td><textarea cols="80" rows="5" name="land_practices">'.htmlentities ($land_practices, ENT_QUOTES).'</textarea></td>
  475. </tr>
  476. </table>
  477. </td>
  478. </tr>
  479. <tr>
  480. <td>
  481. <table>
  482. <tr>
  483. <td class="form_key"><strong>Additional Information:</strong><br>
  484. Describe any additional information and/or sustainable practices about your operation
  485. that would be helpful to a potential customer in understanding your farm or operation better
  486. (e.g. if you are raising any heritage animals you might list breeds or list varieties of
  487. heirloom seeds. List the percentage of local ingredients in your processed items).</td>
  488. </tr>
  489. <tr>
  490. <td><textarea cols="80" rows="5" name="additional_information">'.htmlentities ($additional_information, ENT_QUOTES).'</textarea></td>
  491. </tr>
  492. </table>
  493. </td>
  494. </tr>
  495. <tr>
  496. <th class="memberform">Section 4: Certifications</th>
  497. </tr>
  498. <tr>
  499. <td>
  500. <table>
  501. <tr>
  502. <td class="form_key"><strong>Insurance, Licenses, and Tests:</strong><br>
  503. List your food liability insurance coverage, both general and product-related, as well as
  504. any licenses and tests that you have available. (if applicable). As this is required to
  505. market products through the Co-op, you will be required to provide copies of the above
  506. when you receive confirmation of approvale by '.SITE_NAME.'.</td>
  507. </tr>
  508. <tr>
  509. <td><textarea cols="80" rows="5" name="licenses_insurance">'.htmlentities ($licenses_insurance, ENT_QUOTES).'</textarea></td>
  510. </tr>
  511. </table>
  512. </td>
  513. </tr>
  514. <tr>
  515. <td>
  516. <table>
  517. <tr>
  518. <td class="form_key"><strong>Organic Products:</strong><br>
  519. List which products you are selling as organic.</td>
  520. </tr>
  521. <tr>
  522. <td><textarea cols="80" rows="5" name="organic_products">'.htmlentities ($organic_products, ENT_QUOTES).'</textarea></td>
  523. </tr>
  524. </table>
  525. </td>
  526. </tr>
  527. <tr>
  528. <td>
  529. <table>
  530. <tr>
  531. <td class="form_key"><strong>Organic Certifying Agency:</strong><br>
  532. List orgainic certifying agency&#146;s name and address.</td>
  533. </tr>
  534. <tr>
  535. <td><textarea cols="80" rows="5" name="certifying_agency">'.htmlentities ($certifying_agency, ENT_QUOTES).'</textarea></td>
  536. </tr>
  537. </table>
  538. </td>
  539. </tr>
  540. <tr>
  541. <td>
  542. <table>
  543. <tr>
  544. <td class="form_key"><strong>Certifying&nbsp;Agency&#146;s&nbsp;Phone:</strong></td>
  545. <td><input maxlength="20" size="15" name="agency_phone" value="'.htmlentities ($agency_phone, ENT_QUOTES).'"/></td>
  546. <td class="form_key"><strong>Certifying&nbsp;Agency&#146;s&nbsp;FAX:</strong></td>
  547. <td><input maxlength="20" size="15" name="agency_fax" value="'.htmlentities ($agency_fax, ENT_QUOTES).'"/></td>
  548. </tr>
  549. </table>
  550. </td>
  551. </tr>
  552. <tr>
  553. <td>
  554. <table>
  555. <tr>
  556. <td class="form_key"><strong>Do you have available for inspection a copy of your current organic certificate?</strong></td>
  557. <td><input type="radio" name="organic_cert" value="1"'.$organic_cert_yes.'/> Yes
  558. &nbsp; &nbsp; &nbsp; <input type="radio" name="organic_cert" value="0"'.$organic_cert_no.'/> No</td>
  559. </tr>
  560. </table>
  561. </td>
  562. </tr>
  563. <tr>
  564. <th class="memberform">Section 5: Terms and Agreement</th>
  565. </tr>
  566. <tr>
  567. <td>
  568. <table>
  569. <tr>
  570. <td>
  571. I affirm that all statements made about my farm and products in this application are true,
  572. correct and complete and I have given a truthful representation of my operation, practices,
  573. and origin of products. I understand that if questions arise about my operation I may be
  574. inspected (unannounced) by '.SITE_NAME.'. If I stated my operation is organic, then I am
  575. complying with the National Organic Program and will provide upon request a copy of my
  576. certification. I have read all of '.SITE_NAME.'&#146;s <a href="'.TERMS_OF_SERVICE.'" target="_blank">
  577. terms of service</a> and fully understand and am willing to comply with them.
  578. </td>
  579. </tr>
  580. <tr>
  581. <td align="center"><input type="checkbox" name="liability_statement" value="1"'.$liability_statement_check.'/> I agree</td>
  582. </tr>
  583. </table>
  584. </td>
  585. </tr>
  586. ';
  587. $display_form_html .= '
  588. <tr>
  589. <td align="center">
  590. <input type="submit" name="action" value="Submit"/>
  591. </td>
  592. </tr>
  593. </tbody>
  594. </table>
  595. </form></div>';
  596. ////////////////////////////////////////////////////////////////////////////////
  597. // //
  598. // ADD OR CHANGE INFORMATION IN THE DATABASE FOR THIS MEMBER //
  599. // //
  600. ////////////////////////////////////////////////////////////////////////////////
  601. // If everything validates, then we can post to the database...
  602. if (count ($error_array) == 0 && $_POST['action'] == 'Submit') // For new members
  603. {
  604. // Everything validates correctly so do the INSERT and send the EMAIL
  605. // Do the database insert with the relevant data (producers table)
  606. $query = '
  607. UPDATE
  608. '.TABLE_MEMBER.'
  609. SET
  610. auth_type = CONCAT_WS(",", auth_type, "producer"),
  611. business_name = "'.mysql_escape_string ($business_name).'"
  612. WHERE
  613. member_id = "'.mysql_escape_string ($member_id).'"';
  614. $result = @mysql_query($query,$connection) or die("You found a bug. <b>Error:</b>
  615. Member insert Query " . mysql_error() . "<br><b>Error No: </b>" . mysql_errno());
  616. // Do the database insert with the relevant data (producers table)
  617. $query = '
  618. INSERT INTO
  619. '.TABLE_PRODUCER.'
  620. SET
  621. member_id = '.mysql_escape_string ($member_id).',
  622. producer_id = "'.mysql_escape_string ($producer_id).'",
  623. pending = "'.NEW_PRODUCER_PENDING.'",
  624. donotlist_producer = "1",
  625. producttypes = "'.mysql_escape_string ($producttypes).'",
  626. about = "'.mysql_escape_string ($about).'",
  627. ingredients = "'.mysql_escape_string ($ingredients).'",
  628. general_practices = "'.mysql_escape_string ($general_practices).'",
  629. additional = "'.mysql_escape_string ($additional).'",
  630. highlights = "'.mysql_escape_string ($highlights).'",
  631. liability_statement = "'.mysql_escape_string ($liability_statement).'",
  632. pub_address = "'.mysql_escape_string ($pub_address).'",
  633. pub_email = "'.mysql_escape_string ($pub_email).'",
  634. pub_email2 = "'.mysql_escape_string ($pub_email2).'",
  635. pub_phoneh = "'.mysql_escape_string ($pub_phoneh).'",
  636. pub_phonew = "'.mysql_escape_string ($pub_phonew).'",
  637. pub_phonec = "'.mysql_escape_string ($pub_phonec).'",
  638. pub_phonet = "'.mysql_escape_string ($pub_phonet).'",
  639. pub_fax = "'.mysql_escape_string ($pub_fax).'",
  640. pub_web = "'.mysql_escape_string ($pub_web).'"';
  641. $result = @mysql_query($query,$connection) or die("You found a bug. <b>Error:</b>
  642. Member insert Query " . mysql_error() . "<br><b>Error No: </b>" . mysql_errno());
  643. // Do the database insert with the relevant data (producers_registration table)
  644. $query = '
  645. INSERT INTO
  646. '.TABLE_PRODUCER_REG.'
  647. SET
  648. member_id = '.mysql_escape_string ($member_id).',
  649. producer_id = "'.mysql_escape_string ($producer_id).'",
  650. business_name = "'.mysql_escape_string ($business_name).'",
  651. website = "'.mysql_escape_string ($website).'",
  652. date_added = now(),
  653. products = "'.mysql_escape_string ($products).'",
  654. practices = "'.mysql_escape_string ($practices).'",
  655. pest_management = "'.mysql_escape_string ($pest_management).'",
  656. productivity_management = "'.mysql_escape_string ($productivity_management).'",
  657. feeding_practices = "'.mysql_escape_string ($feeding_practices).'",
  658. soil_management = "'.mysql_escape_string ($soil_management).'",
  659. water_management = "'.mysql_escape_string ($water_management).'",
  660. land_practices = "'.mysql_escape_string ($land_practices).'",
  661. additional_information = "'.mysql_escape_string ($additional_information).'",
  662. licenses_insurance = "'.mysql_escape_string ($licenses_insurance).'",
  663. organic_products = "'.mysql_escape_string ($organic_products).'",
  664. certifying_agency = "'.mysql_escape_string ($certifying_agency).'",
  665. agency_phone = "'.mysql_escape_string ($agency_phone).'",
  666. agency_fax = "'.mysql_escape_string ($agency_fax).'",
  667. organic_cert = "'.mysql_escape_string ($organic_cert).'"';
  668. $result = @mysql_query($query,$connection) or die("You found a bug. <b>Error:</b>
  669. Member insert Query " . mysql_error() . "<br><b>Error No: </b>" . mysql_errno());
  670. // Set the session variable so the member has immediate access to producer functions
  671. $_SESSION['producer_id_you'] = mysql_escape_string ($producer_id);
  672. // Get the producer's email address so we can send them a notification
  673. $query = '
  674. SELECT
  675. email_address
  676. FROM
  677. '.TABLE_MEMBER.'
  678. WHERE member_id = "'.mysql_real_escape_string ($member_id).'"';
  679. $sql = @mysql_query($query, $connection) or die("You found a bug. <b>Error:</b> Check for existing member query " . mysql_error() . "<br><b>Error No: </b>" . mysql_errno());
  680. if ($row = mysql_fetch_object($sql))
  681. {
  682. $email_address = $row->email_address;
  683. }
  684. // Now send email notification(s)
  685. $email_to = preg_replace ('/SELF/', $email_address, PRODUCER_FORM_EMAIL);
  686. $email_subject = 'New producer: Welcome to '.SITE_NAME;
  687. $boundary = uniqid();
  688. // Set up the email preamble...
  689. $email_preamble = '<p>Following is a copy of the producer information you submitted to '.SITE_NAME.'.</p>';
  690. $email_preamble .= $welcome_message;
  691. // Disable all form elements for emailing
  692. $html_version = preg_replace ('/<(input|select|textarea)/', '<\1 disabled', $welcome_message.$display_form_html);
  693. $email_headers = "From: ".STANDARDS_EMAIL."\r\n";
  694. $email_headers .= "Reply-To: ".STANDARDS_EMAIL."\r\n";
  695. $email_headers .= "Errors-To: web@".DOMAIN_NAME."\r\n";
  696. $email_headers .= "MIME-Version: 1.0\r\n";
  697. $email_headers .= "Content-type: multipart/alternative; boundary=\"$boundary\"\r\n";
  698. $email_headers .= "Message-ID: <".md5(uniqid(time()))."@".DOMAIN_NAME.">\r\n";
  699. $email_headers .= "X-Mailer: PHP ".phpversion()."\r\n";
  700. $email_headers .= "X-Priority: 3\r\n";
  701. $email_headers .= "X-AntiAbuse: This is a machine-generated response to a user-submitted form at ".SITE_NAME.".\r\n";
  702. $email_body .= "\r\n--".$boundary;
  703. $email_body .= "\r\nContent-Type: text/plain; charset=us-ascii";
  704. $email_body .= "\r\n\r\n".wordwrap (strip_tags ($welcome_message), 75, "\n", true)."\n".$display_form_text;
  705. $email_body .= "\r\n--".$boundary;
  706. $email_body .= "\r\nContent-Type: text/html; charset=us-ascii";
  707. $email_body .= "\r\n\r\n--".$html_version;
  708. $email_body .= "\r\n--".$boundary.'--';
  709. mail ($email_to, $email_subject, $email_body, $email_headers);
  710. $file = fopen (FILE_PATH.'/public_html/shop/producers/'.strtolower($producer_id).".php", "w");
  711. if($file)
  712. {
  713. $filetext = "<?php include('../template_prdcr.php'); ?>";
  714. fwrite ($file, $filetext);
  715. $display_form_html = '<p class="error_message">Producer information has been accepted.</p>';
  716. }
  717. else
  718. {
  719. $display_form_html = '<p class="error_message">Producer information was accepted but there
  720. was an error creating the producer file</p>';
  721. }
  722. $display_form_message .= '
  723. <p class="message">Your producer application will be reviewed by an administrator and you will be notified when
  724. it becomes active. Until then, you will not have producer access or be able to enter products into the system.</p>';
  725. }
  726. include ("template_hdr_orders.php");
  727. echo $display_form_top;
  728. echo $display_form_message;
  729. echo $display_form_html;
  730. include("template_footer_orders.php");