PageRenderTime 37ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/public_html/producers_pending.php

https://gitlab.com/Henaway/CLFC
PHP | 199 lines | 189 code | 8 blank | 2 comment | 7 complexity | 00f67a3e731a183037551304cf734612 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. // THIS FILE IS MODIFIED FOR CLOVERBELT LOCAL FOOD COOPERATIVE
  7. if ( $_POST['pending'] )
  8. {
  9. foreach( $_POST['pending'] as $producer_id=>$value )
  10. {
  11. $query = '
  12. SELECT
  13. '.TABLE_PRODUCER.'.business_name,
  14. '.TABLE_MEMBER.'.first_name,
  15. '.TABLE_MEMBER.'.last_name,
  16. '.TABLE_MEMBER.'.email_address,
  17. '.TABLE_MEMBER.'.member_id,
  18. '.TABLE_MEMBER.'.auth_type
  19. FROM
  20. '.TABLE_PRODUCER.'
  21. LEFT JOIN '.TABLE_MEMBER.' ON '.TABLE_PRODUCER.'.member_id = '.TABLE_MEMBER.'.member_id
  22. WHERE
  23. producer_id = "'.mysql_real_escape_string($producer_id).'"';
  24. $sql = mysql_query($query, $connection) or die("Couldn't execute query 4.");
  25. $producer_info = mysql_fetch_object($sql);
  26. if ( $value == 'approve' )
  27. {
  28. $query = '
  29. UPDATE
  30. '.TABLE_PRODUCER.'
  31. SET
  32. pending="0"
  33. WHERE
  34. producer_id="'.mysql_real_escape_string($producer_id).'"';
  35. $sql = mysql_query($query);
  36. // Now send the confirmation email...
  37. if ( $producer_info )
  38. {
  39. // Now send the "Newly Activated" email notice
  40. $subject = 'Account status: '.SITE_NAME;
  41. $email_to = preg_replace ('/SELF/', $producer_info->email_address, PRODUCER_FORM_EMAIL);
  42. $headers = "From: ".MEMBERSHIP_EMAIL."\nReply-To: ".MEMBERSHIP_EMAIL."\n";
  43. $headers .= "Errors-To: ".GENERAL_EMAIL."\n";
  44. $headers .= "MIME-Version: 1.0\n";
  45. $headers .= "Content-type: text/plain; charset=us-ascii\n";
  46. $headers .= "Message-ID: <".md5(uniqid(time()))."@".DOMAIN_NAME.">\n";
  47. $headers .= "X-Mailer: PHP ".phpversion()."\n";
  48. $headers .= "X-Priority: 3\n";
  49. $headers .= 'X-AntiAbuse: This is a user-submitted email through the '.SITE_NAME." producer approval page.\n\n";
  50. $msg = "Dear ".$producer_info->first_name." ".$producer_info->last_name.",\n\n";
  51. $msg .= "Your producer account with ".SITE_NAME." has been activated. \n\n";
  52. $msg .= "When you log in to your regular member account, you will have a new section relating to ";
  53. $msg .= "producer functions. You may immediately begin adding new products to the system but they ";
  54. $msg .= "will not be available for ordering until an order is open. If, for some reason, you need ";
  55. $msg .= "to change a product listing during an order cycle, you will need to contact one of the site ";
  56. $msg .= "administrators at the Producer help address below to make your changes \"live\". Until that ";
  57. $msg .= "step is completed, your products and any changes you make will not show up on the public ";
  58. $msg .= "shopping pages (except changes to your inventory).\n\n";
  59. $msg .= "Producer help is available at: ".PRODUCER_CARE_EMAIL."\n";
  60. $msg .= "Other help is always available at: ".HELP_EMAIL."\n";
  61. $msg .= "Join in the fun, volunteer! ".VOLUNTEER_EMAIL."\n\n";
  62. $msg .= "If I can be of any help to you or you have any questions, please contact me. \n\n";
  63. // $msg .= AUTHORIZED_PERSON."\n";
  64. $msg .= 'Standards Committee'."\n";
  65. $msg .= STANDARDS_EMAIL;
  66. mail($email_to, $subject, $msg, $headers);
  67. }
  68. $content_pending .= '&nbsp;<b>'.$producer_info->business_name.'</b> (#'.$producer_id.') was updated.<br>';
  69. }
  70. else if ( $value == "remove" )
  71. {
  72. $query = '
  73. DELETE FROM
  74. '.TABLE_PRODUCER.'
  75. WHERE
  76. producer_id="'.mysql_real_escape_string($producer_id).'"';
  77. mysql_query($query);
  78. $query = '
  79. DELETE FROM
  80. '.TABLE_PRODUCER_REG.'
  81. WHERE
  82. producer_id="'.mysql_real_escape_string($producer_id).'"';
  83. mysql_query($query);
  84. if ( $producer_info )
  85. {
  86. //remove "producer" from auth_type
  87. $auth_type = explode(",", $producer_info->auth_type);
  88. foreach(array_keys($auth_type, 'producer') as $key) unset($auth_type[$key]);
  89. $auth_type = implode(",", $auth_type);
  90. $query = '
  91. UPDATE
  92. '.TABLE_MEMBER.'
  93. SET
  94. auth_type="'.mysql_real_escape_string($auth_type).'"
  95. WHERE
  96. member_id="'.mysql_real_escape_string($producer_info->member_id).'"';
  97. mysql_query($query);
  98. }
  99. $content_pending .= '&nbsp;<b>'.$producer_info->business_name.'</b> (#'.$producer_id.') was removed.<br>';
  100. }
  101. }
  102. }
  103. $display = '';
  104. $query = '
  105. SELECT
  106. producer_id,
  107. '.TABLE_PRODUCER.'.business_name,
  108. first_name,
  109. last_name,
  110. '.TABLE_PRODUCER.'.member_id,
  111. home_phone,
  112. email_address
  113. FROM
  114. '.TABLE_PRODUCER.',
  115. '.TABLE_MEMBER.'
  116. WHERE
  117. '.TABLE_PRODUCER.'.pending != "0"
  118. AND '.TABLE_PRODUCER.'.member_id = '.TABLE_MEMBER.'.member_id';
  119. $sql = mysql_query($query);
  120. while ( $row = mysql_fetch_array($sql) )
  121. {
  122. $display .= '
  123. <tr>
  124. <td style="white-space: nowrap">
  125. <input type="radio" name="pending['.$row['producer_id'].']" value="" checked>Pending<br>
  126. <input type="radio" name="pending['.$row['producer_id'].']" value="approve">Approve<br>
  127. <input type="radio" name="pending['.$row['producer_id'].']" value="remove">Remove
  128. </td>
  129. <td><b>'.$row['producer_id'].'</b></td>
  130. <td><a href="'.PATH.'prdcr_display_quest.php?pid='.$row['producer_id'].'" target="_blank">'.$row['business_name'].'</a></td>
  131. <td>'.$row['first_name'].'</td>
  132. <td>'.$row['last_name'].'</td>
  133. <td>'.$row['home_phone'].'</td>
  134. <td><a href="mailto:'.$row['email_address'].'">'.$row['email_address'].'</a></td>
  135. <td>'.$row['member_id'].'</td>
  136. </tr>
  137. ';
  138. }
  139. if ( !$display )
  140. {
  141. $display = '
  142. <tr>
  143. <td colspan="8" align="right">There are no pending producers.</td>
  144. </tr>';
  145. }
  146. else
  147. {
  148. $display .= '
  149. <tr>
  150. <td colspan="8" align="center"><input type="submit" name="submit" value="Submit"></td>
  151. </tr>';
  152. }
  153. $content_pending .= '
  154. <div align="center">
  155. <form name="pendingproducers" method="POST">
  156. <table>
  157. <tr>
  158. <th>Status</th>
  159. <th>Producer ID</th>
  160. <th>Business Name<br>
  161. <span style="font-size:60%;font-weight:normal">(click to view questionnaire)</span></th>
  162. <th>First Name</th>
  163. <th>Last Name</th>
  164. <th>Phone</th>
  165. <th>Email</th>
  166. <th>Member ID</th>
  167. </tr>
  168. '.$display.'
  169. </table>
  170. </form>
  171. </div>
  172. <br><br>
  173. ';
  174. $page_specific_css .= '
  175. <style type="text/css">
  176. table, td, th {
  177. border: 1px solid #CCCCCC;
  178. }
  179. </style>';
  180. $page_title_html = '<span class="title">Producer Membership Information</span>';
  181. $page_subtitle_html = '<span class="subtitle">Pending Producers</span>';
  182. $page_title = 'Producer Membership Information: Pending Producers';
  183. $page_tab = 'producer_admin_panel';
  184. include("template_header.php");
  185. echo '
  186. <!-- CONTENT BEGINS HERE -->
  187. '.$content_pending.'
  188. <!-- CONTENT ENDS HERE -->';
  189. include("template_footer.php");