Advertisement
Guest User

Untitled

a guest
Mar 21st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.29 KB | None | 0 0
  1. <?php
  2. include 'includes/initial.php';
  3. require_once 'PHPMailer-master/PHPMailerAutoload.php';
  4.  
  5. $category =$_GET['category'];
  6. ?>
  7.  
  8. <div id="maincontentFull">
  9. <?php
  10.  
  11. if($category=="apply") // form user
  12. {
  13. include 'application/addForm.php';
  14. }
  15.  
  16. else if($category=="applyAdd") // query for users
  17. {
  18. //FOR SEND EMAIL
  19.  
  20. //from users table
  21. $dept = $user_data['department'];
  22. $type = $user_data['type'];
  23. $staffId = $user_data['staff_id'];
  24.  
  25. // from users name ,employment, department/division , designation , company
  26. $sql2= "SELECT * FROM users WHERE staff_id='$staffId'";
  27. $result2 = mysql_query($sql2);
  28. $row2=mysql_fetch_array($result2);
  29.  
  30.  
  31. // from form refno, type , facility, apptime, systemapp, user remark
  32. $sql3 = "SELECT * FROM form WHERE id AND staff_id IN (SELECT staff_id FROM users WHERE staff_id='$staffId')";
  33. //$sql3 = "SELECT * FROM form WHERE staff_id='$staffId'";
  34. $result3 = mysql_query($sql3);
  35. $row3 = mysql_fetch_array($result3);
  36.  
  37.  
  38. //1 is for HOD and 7 is puan Jun as HOD
  39. $sql = "SELECT * FROM users WHERE (type='1' OR type='7') AND department='$dept'";
  40. $result = mysql_query($sql);
  41.  
  42. while($row = mysql_fetch_assoc($result)){
  43. //$row = mysql_fetch_row($result);
  44. $penerima = $row['email'];
  45. $namapenerima = $row['name'];
  46.  
  47.  
  48. $name = $row2['name'];
  49. $email = $row2['email'];
  50. $employment = $row2['employment'];
  51. $department = $row2['department'];
  52. $division = $row2['division'];
  53. $designation = $row2['designation'];
  54. $company = $row2['company'];
  55. $ext = $row2['ext'];
  56.  
  57.  
  58.  
  59. $ref_no = $row3['ref_no'];
  60. $type = $row3['type'];
  61. $facility = $row3['facility'];
  62. $system_app = $row3['system_app'];
  63. $user_remark = $row3['user_remark'];
  64. $app_time = $row3['app_time'];
  65.  
  66.  
  67.  
  68. $mail = new PHPMailer;
  69.  
  70. //$mail->SMTPDebug = 3; // Enable verbose debug output
  71.  
  72. $mail->isSMTP(); // Set mailer to use SMTP
  73. $mail->Host = 'smtp'; // Specify main and backup SMTP servers
  74. $mail->SMTPAuth = true; // Enable SMTP authentication
  75. $mail->Username = 'done'; // SMTP username
  76. $mail->Password = 'aaaa'; // SMTP password
  77. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  78. $mail->Port = 25; // TCP port to connect to
  79.  
  80. $mail->setFrom('sender@p.com.my', 'sender');
  81. $mail->addAddress($penerima, $namapenerima); // Add a recipient
  82. $mail->addCC($email, $name);
  83. $mail->isHTML(true); // Set email format to HTML
  84.  
  85. $mail->Subject = 'E-FORMS TEST EMAIL';
  86. $mail->Body = 'Please be informed that an User Application Form has been submitted by the following staff and is now <b> awaiting your approval.</b><br><br>
  87.  
  88. //****---------------from users table---------------+****//
  89. Name :' .$name.' <br>
  90. Type of Employment :' .$employment.' <br>
  91. Department/Division :' .$department.' / '.$division.' <br>
  92. Designation/Company :' .$designation.' / '.$company.' <br>
  93.  
  94. //*****---------------from form table---------------******//
  95. Apply Date & Time :' .$app_time.' <br><br>
  96. Ref No :' .$ref_no.' <br>
  97. Type of Application :' .$type.' <br>
  98. Type of Facility :' .$facility.' <br>
  99. System Application :' .$system_app.' <br>
  100. Remarks :' .$user_remark.' <br>';
  101. $mail->AltBody = 'Email Testing';
  102.  
  103. if(!$mail->send()) {
  104. echo 'Message could not be sent.';
  105. echo 'Mailer Error: ' . $mail->ErrorInfo;
  106. } else {
  107. echo 'Message has been sent';
  108. }
  109. }
  110.  
  111. //
  112.  
  113. extract($_POST);
  114.  
  115. $ref_no1 = $session_user_id.date("mdHs");
  116. $user_id = $user_data['staff_id'];
  117. $app_date = date("Y-m-d");
  118. $all_facility = implode(";",$_POST['facility']);
  119. $all_return = implode(";",$_POST['return']);
  120. $all_system = implode(";",$_POST['system']);
  121. $all_service = implode(";",$_POST['service']);
  122. //$user_remark = implode(";",$_POST['user_remark']);
  123. $user_remark = $_POST['user_remark'];
  124.  
  125. mysql_query("INSERT INTO form (ref_no, staff_id, app_date, type,facility,returned, system_app, service, user_remark)
  126. VALUES ('$ref_no1', '$user_id','$app_date','$type','$all_facility','$all_return','$all_system','$all_service','$user_remark')");
  127.  
  128. endorsedBy($user_data['department'], $ref_no1);
  129. approvedBy($ref_no1);
  130.  
  131.  
  132. header('Location: application_statusUSER.php');
  133.  
  134. }
  135.  
  136. ?>
  137. </div>
  138.  
  139. <?php
  140. include 'includes/footer.php';
  141. ?>
  142.  
  143. <?php
  144.  
  145. ob_start();
  146. ob_clean();
  147. session_start();
  148. error_reporting(0);
  149. //error_reporting(E_ALL);
  150.  
  151. require_once 'includes/connect.php';
  152. require_once 'includes/general.php';
  153. require_once 'includes/users.php';
  154.  
  155. $current_file = explode('/', $_SERVER['SCRIPT_NAME']);
  156. $current_file = end($current_file);
  157.  
  158. if (logged_in() === true){
  159. $session_user_id = $_SESSION['user_id'];
  160. //$session_user_id2 = $_SESSION['id'];
  161. $user_data = user_data($session_user_id,'user_id','staff_id','name','password','date_birth','employment','department','division','designation','company','email','ext','type','active');
  162. //$user_data2 = user_data2($session_user_id2,'id','staff_id');
  163.  
  164. //echo $user_data['first_name'];
  165. //echo $user_data['last_name'];
  166.  
  167. if (user_active($user_data['staff_id']) === false) {
  168. session_destroy();
  169. //header('Location: logout.php');
  170. header('Location: index.php');
  171. exit();
  172. }
  173.  
  174. if($current_file !== 'changepassword.php' && $current_file !== 'logout.php' && $user_data['password_recover'] == 1){
  175. header('Location: changepassword.php?force');
  176. exit();
  177. }
  178. }
  179.  
  180. //echo $user_date['type'];
  181.  
  182. $errors = array();
  183. ?>
  184.  
  185. <form action="application_index.php?category=applyAdd" method="post">
  186.  
  187. <h1 class="underlineLongest">FORM</h1>
  188.  
  189. <table>
  190. <tr><td valign="top" width='80%' >Application Services Required: <i>(Please tick &#10004;)</i></td>
  191. <td width='20%'><?php
  192. echo "Date: " . date("Y-m-d") . "<br>";
  193. echo "Day: " . date("l"). "<br>";?>
  194. </td>
  195. </tr>
  196. </table>
  197.  
  198. <h2>Type of Application</h2>
  199. <?php
  200.  
  201. $result = mysql_query(" SELECT * FROM type ORDER BY type_code");
  202. while($row=mysql_fetch_array($result))
  203. { ?>
  204.  
  205. <input name="type" type="radio" value="<?php echo $row['type_code'];?>" >
  206. <?php echo $row['description']; ?><br>
  207. <?php }?>
  208.  
  209. <br>
  210. <h1 class="underlineLongest"></h1>
  211. <table>
  212. <tr>
  213. <td valign="top" style="padding:0px 12px" width="250">
  214.  
  215. <h2>Type of Facility</h2>
  216. <?php
  217. $result2 = mysql_query("SELECT * FROM facility");
  218. while($row2=mysql_fetch_array($result2)) // <input type="checkbox" name="games[]" value="1" ><label>Football</label><br>
  219. { ?>
  220. <input name="facility[]" type="checkbox" value="<?php echo $row2['fac_code'];?>"> <label><?php echo $row2['fac_name']; ?></label>
  221.  
  222. <?php
  223. if($row2['fac_code']=='F09'){
  224. $result7 = mysql_query(" SELECT * FROM form");
  225. ?>
  226.  
  227. Others : <input type="text" name="facility[]" value="<?php echo $row2['facility'] ?>">
  228.  
  229. <?php } ?><br>
  230.  
  231. <?php } ?>
  232.  
  233. <br><br><br>
  234.  
  235. <h2>Requester to Remark</h2>
  236. <!-- <textarea name="user_remark" id="user_remark" value="<//?php echo $_POST['user_remark'] ?>" ></textarea> -->
  237. <textarea name="user_remark" id="user_remark" ></textarea>
  238.  
  239. </td>
  240. <td valign="top" style="padding:0px 0px">
  241.  
  242. <h2>System Application</h2>
  243. <?php
  244. $result4 = mysql_query(" SELECT * FROM system_app");
  245. while($row4=mysql_fetch_array($result4))
  246. { ?>
  247. <input name="system[]" type="checkbox" value="<?php echo $row4['sys_code'];?>"> <label><?php echo $row4['description']; ?></label>
  248.  
  249.  
  250. <?php
  251. if($row4['sys_code']=='Others'){
  252. $result8 = mysql_query(" SELECT * FROM form");
  253. ?>
  254.  
  255. Others : <input type="text" name="system[]" value="<?php echo $row4['system_app'] ?>">
  256.  
  257. <?php } ?><br>
  258. <?php } ?>
  259.  
  260. <br><br><br><br>
  261.  
  262. <h2>Services Required</h2>
  263. <?php
  264. $result5 = mysql_query(" SELECT * FROM service");
  265. while($row5=mysql_fetch_array($result5))
  266. { ?>
  267. <input name="service[]" type="checkbox" value="<?php echo $row5['ser_code'];?>"> <label><?php echo $row5['description']; ?></label>
  268. <!--<td width="60px"><?php echo $row['ser_code']; ?></td>-->
  269. <?php
  270. if($row5['description']=='Specify Module'){?>
  271. : <input type="text" name="service_module" value="">
  272. <?php }
  273. else if($row5['description']=='Others'){?>
  274. :&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="service_other" value="">
  275. <?php } ?><br>
  276. <?php } ?>
  277. <i><b>Note: </b>Users are strongly advised to change their password
  278. immediately after the first time login to the system</i>
  279. </td>
  280. </tr>
  281. <tr>
  282. <td colspan="2" align="center">
  283. <br><br>
  284. <p><input class="btnSuccess" type ="submit" name="addApply" value="Add" >
  285. &nbsp;&nbsp;<input class="btnEdit" type="button" name="btnCancel" value="Cancel" onclick="window.location.href='index.php'" > </p>
  286. </td>
  287. </tr>
  288. </table>
  289.  
  290. </form>
  291.  
  292. <script>
  293. function goBack() {
  294. window.history.back();
  295. }
  296. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement