Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'includes/initial.php';
- require_once 'PHPMailer-master/PHPMailerAutoload.php';
- $category =$_GET['category'];
- ?>
- <div id="maincontentFull">
- <?php
- if($category=="apply") // form user
- {
- include 'application/addForm.php';
- }
- else if($category=="applyAdd") // query for users
- {
- //FOR SEND EMAIL
- //from users table
- $dept = $user_data['department'];
- $type = $user_data['type'];
- $staffId = $user_data['staff_id'];
- // from users name ,employment, department/division , designation , company
- $sql2= "SELECT * FROM users WHERE staff_id='$staffId'";
- $result2 = mysql_query($sql2);
- $row2=mysql_fetch_array($result2);
- // from form refno, type , facility, apptime, systemapp, user remark
- $sql3 = "SELECT * FROM form WHERE id AND staff_id IN (SELECT staff_id FROM users WHERE staff_id='$staffId')";
- //$sql3 = "SELECT * FROM form WHERE staff_id='$staffId'";
- $result3 = mysql_query($sql3);
- $row3 = mysql_fetch_array($result3);
- //1 is for HOD and 7 is puan Jun as HOD
- $sql = "SELECT * FROM users WHERE (type='1' OR type='7') AND department='$dept'";
- $result = mysql_query($sql);
- while($row = mysql_fetch_assoc($result)){
- //$row = mysql_fetch_row($result);
- $penerima = $row['email'];
- $namapenerima = $row['name'];
- $name = $row2['name'];
- $email = $row2['email'];
- $employment = $row2['employment'];
- $department = $row2['department'];
- $division = $row2['division'];
- $designation = $row2['designation'];
- $company = $row2['company'];
- $ext = $row2['ext'];
- $ref_no = $row3['ref_no'];
- $type = $row3['type'];
- $facility = $row3['facility'];
- $system_app = $row3['system_app'];
- $user_remark = $row3['user_remark'];
- $app_time = $row3['app_time'];
- $mail = new PHPMailer;
- //$mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'done'; // SMTP username
- $mail->Password = 'aaaa'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 25; // TCP port to connect to
- $mail->setFrom('sender@p.com.my', 'sender');
- $mail->addAddress($penerima, $namapenerima); // Add a recipient
- $mail->addCC($email, $name);
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'E-FORMS TEST EMAIL';
- $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>
- //****---------------from users table---------------+****//
- Name :' .$name.' <br>
- Type of Employment :' .$employment.' <br>
- Department/Division :' .$department.' / '.$division.' <br>
- Designation/Company :' .$designation.' / '.$company.' <br>
- //*****---------------from form table---------------******//
- Apply Date & Time :' .$app_time.' <br><br>
- Ref No :' .$ref_no.' <br>
- Type of Application :' .$type.' <br>
- Type of Facility :' .$facility.' <br>
- System Application :' .$system_app.' <br>
- Remarks :' .$user_remark.' <br>';
- $mail->AltBody = 'Email Testing';
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- }
- //
- extract($_POST);
- $ref_no1 = $session_user_id.date("mdHs");
- $user_id = $user_data['staff_id'];
- $app_date = date("Y-m-d");
- $all_facility = implode(";",$_POST['facility']);
- $all_return = implode(";",$_POST['return']);
- $all_system = implode(";",$_POST['system']);
- $all_service = implode(";",$_POST['service']);
- //$user_remark = implode(";",$_POST['user_remark']);
- $user_remark = $_POST['user_remark'];
- mysql_query("INSERT INTO form (ref_no, staff_id, app_date, type,facility,returned, system_app, service, user_remark)
- VALUES ('$ref_no1', '$user_id','$app_date','$type','$all_facility','$all_return','$all_system','$all_service','$user_remark')");
- endorsedBy($user_data['department'], $ref_no1);
- approvedBy($ref_no1);
- header('Location: application_statusUSER.php');
- }
- ?>
- </div>
- <?php
- include 'includes/footer.php';
- ?>
- <?php
- ob_start();
- ob_clean();
- session_start();
- error_reporting(0);
- //error_reporting(E_ALL);
- require_once 'includes/connect.php';
- require_once 'includes/general.php';
- require_once 'includes/users.php';
- $current_file = explode('/', $_SERVER['SCRIPT_NAME']);
- $current_file = end($current_file);
- if (logged_in() === true){
- $session_user_id = $_SESSION['user_id'];
- //$session_user_id2 = $_SESSION['id'];
- $user_data = user_data($session_user_id,'user_id','staff_id','name','password','date_birth','employment','department','division','designation','company','email','ext','type','active');
- //$user_data2 = user_data2($session_user_id2,'id','staff_id');
- //echo $user_data['first_name'];
- //echo $user_data['last_name'];
- if (user_active($user_data['staff_id']) === false) {
- session_destroy();
- //header('Location: logout.php');
- header('Location: index.php');
- exit();
- }
- if($current_file !== 'changepassword.php' && $current_file !== 'logout.php' && $user_data['password_recover'] == 1){
- header('Location: changepassword.php?force');
- exit();
- }
- }
- //echo $user_date['type'];
- $errors = array();
- ?>
- <form action="application_index.php?category=applyAdd" method="post">
- <h1 class="underlineLongest">FORM</h1>
- <table>
- <tr><td valign="top" width='80%' >Application Services Required: <i>(Please tick ✔)</i></td>
- <td width='20%'><?php
- echo "Date: " . date("Y-m-d") . "<br>";
- echo "Day: " . date("l"). "<br>";?>
- </td>
- </tr>
- </table>
- <h2>Type of Application</h2>
- <?php
- $result = mysql_query(" SELECT * FROM type ORDER BY type_code");
- while($row=mysql_fetch_array($result))
- { ?>
- <input name="type" type="radio" value="<?php echo $row['type_code'];?>" >
- <?php echo $row['description']; ?><br>
- <?php }?>
- <br>
- <h1 class="underlineLongest"></h1>
- <table>
- <tr>
- <td valign="top" style="padding:0px 12px" width="250">
- <h2>Type of Facility</h2>
- <?php
- $result2 = mysql_query("SELECT * FROM facility");
- while($row2=mysql_fetch_array($result2)) // <input type="checkbox" name="games[]" value="1" ><label>Football</label><br>
- { ?>
- <input name="facility[]" type="checkbox" value="<?php echo $row2['fac_code'];?>"> <label><?php echo $row2['fac_name']; ?></label>
- <?php
- if($row2['fac_code']=='F09'){
- $result7 = mysql_query(" SELECT * FROM form");
- ?>
- Others : <input type="text" name="facility[]" value="<?php echo $row2['facility'] ?>">
- <?php } ?><br>
- <?php } ?>
- <br><br><br>
- <h2>Requester to Remark</h2>
- <!-- <textarea name="user_remark" id="user_remark" value="<//?php echo $_POST['user_remark'] ?>" ></textarea> -->
- <textarea name="user_remark" id="user_remark" ></textarea>
- </td>
- <td valign="top" style="padding:0px 0px">
- <h2>System Application</h2>
- <?php
- $result4 = mysql_query(" SELECT * FROM system_app");
- while($row4=mysql_fetch_array($result4))
- { ?>
- <input name="system[]" type="checkbox" value="<?php echo $row4['sys_code'];?>"> <label><?php echo $row4['description']; ?></label>
- <?php
- if($row4['sys_code']=='Others'){
- $result8 = mysql_query(" SELECT * FROM form");
- ?>
- Others : <input type="text" name="system[]" value="<?php echo $row4['system_app'] ?>">
- <?php } ?><br>
- <?php } ?>
- <br><br><br><br>
- <h2>Services Required</h2>
- <?php
- $result5 = mysql_query(" SELECT * FROM service");
- while($row5=mysql_fetch_array($result5))
- { ?>
- <input name="service[]" type="checkbox" value="<?php echo $row5['ser_code'];?>"> <label><?php echo $row5['description']; ?></label>
- <!--<td width="60px"><?php echo $row['ser_code']; ?></td>-->
- <?php
- if($row5['description']=='Specify Module'){?>
- : <input type="text" name="service_module" value="">
- <?php }
- else if($row5['description']=='Others'){?>
- :             <input type="text" name="service_other" value="">
- <?php } ?><br>
- <?php } ?>
- <i><b>Note: </b>Users are strongly advised to change their password
- immediately after the first time login to the system</i>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <br><br>
- <p><input class="btnSuccess" type ="submit" name="addApply" value="Add" >
- <input class="btnEdit" type="button" name="btnCancel" value="Cancel" onclick="window.location.href='index.php'" > </p>
- </td>
- </tr>
- </table>
- </form>
- <script>
- function goBack() {
- window.history.back();
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement