Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addRequest() {
- //echo '<pre>'; print_r($_POST); echo '</pre>'; die();
- $message = $this->message();
- $sql1 = "SELECT * FROM `tenants` WHERE `id` = '".$_POST['user_id']."';";
- $res1 = $this->db->query($sql1);
- $row1 = $res1->fetch_assoc();
- $sql3 = "SELECT * FROM `properties` WHERE `id` = '".$_POST['property']."';";
- $res3 = $this->db->query($sql3);
- $row3 = $res3->fetch_assoc();
- if($row2['supervisor_id']) {
- $supervisor_id = $row2['supervisor_id'];
- } else {
- $supervisor_id = '';
- }
- $unit_ids = implode(",", $_POST['unit']);
- $phone = '+' . $_POST['countryCode'] .'-'. $_POST['mobile'];
- $start_date = strtotime($_POST['start']);
- $end_date = strtotime($_POST['end']);
- $i=0;
- if($_POST['request_type'] == 'General') { echo "Here -2";
- foreach($_POST['unit'] as $unitt) {
- $sql2 = "SELECT * FROM `unit_master` WHERE `id` = '".$unitt."';";
- $res2 = $this->db->query($sql2);
- $row2 = $res2->fetch_assoc();
- $manager = $this->getUser($row2['manager_id']);
- $supervisor = $this->getUser($row2['supervisor_id']);
- $sql = "INSERT INTO `quotation` SET
- `property_id` = '".$_POST['property']."',
- `pm_id` = '".$row2['manager_id']."',
- `supervisor_id` = '".$row2['supervisor_id']."',
- `property` = '".$row3['name']."' ,
- `user_id` = '".$_POST['user_id']."' ,
- `unit_id` = '".$unitt."' ,
- `nature` = 'General',
- `description` = '".$_POST['description']."' ,
- `unit_number` = '".$row2['ref']."' ,
- `unit` = '".$row2['unit_name']."' ,
- `mobile` = '".$_POST['mobile']."',
- `email` = '".$_POST['email']."',
- `status` = 'In Process',
- `request_type` = '".$_POST['request_type']."',
- `date_time` = '".date("d-m-Y")."';";
- $img_query = $this->db->query($sql);
- $req_id = $this->db->insert_id;
- $i++;
- }
- $this->sendManagerRequest($manager['name'],$manager['email'],$row1['name'],$row1['email'],$_POST['description']);
- }
- if($_POST['request_type'] == 'Maintenance') { echo "Here -1";
- foreach($_POST['unit'] as $unitt) {
- $sql2 = "SELECT * FROM `unit_master` WHERE `id` = '".$unitt."';";
- $res2 = $this->db->query($sql2);
- $row2 = $res2->fetch_assoc();
- $manager = $this->getUser($row2['manager_id']);
- $supervisor = $this->getUser($row2['supervisor_id']);
- foreach($_POST['req']['nature'] as $reqs) {
- $sql = "INSERT INTO `quotation` SET
- `property_id` = '".$_POST['property']."',
- `pm_id` = '".$row2['manager_id']."',
- `supervisor_id` = '".$row2['supervisor_id']."',
- `property` = '".$row3['name']."' ,
- `user_id` = '".$_POST['user_id']."' ,
- `unit_id` = '".$unitt."' ,
- `nature` = '".$_POST['req']['nature'][$i]."' ,
- `description` = '".$_POST['req']['descriptions'][$i]."' ,
- `unit_number` = '".$row2['ref']."' ,
- `unit` = '".$row2['unit_name']."' ,
- `mobile` = '".$_POST['mobile']."',
- `email` = '".$_POST['email']."',
- `status` = 'In Process',
- `request_type` = '".$_POST['request_type']."',
- `date_time` = '".date("d-m-Y")."';";
- $img_query = $this->db->query($sql);
- $req_id = $this->db->insert_id;
- $i++;
- }
- }
- }
- die();
- $mail = new PHPMailer();
- //$mail->isSMTP();
- $mail->Host = 'smtp.sendgrid.net';
- $mail->SMTPAuth = true;
- $mail->Username = 'takmeel'; // SMTP username
- $mail->Password = 'shineE065'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 25;
- $mail->From = $row1['email'];
- $mail->FromName = $row1['name'];
- $mail->AddAddress($manager['email'] , $manager['name']);
- $mail->AddCC($supervisor['email'] , $supervisor['name']);
- $mail->AddReplyTo($row1['email'] , $row1['name']);
- $mail->isHTML(true);
- $mail->Subject = "New Service Request From Tenant";
- $body_part_1 = 'This is notification email to inform you that there is new maintenance request for your property. Please login to your account to see the request detail.';
- $body_part_3 = '<tbody>
- <tr>
- <td align="center" style="margin:0;text-align:center"><a href="'.URL_SITE.'login.php" style="font-size:21px;line-height:22px;text-decoration:none;color:#ffffff;font-weight:bold;border-radius:2px;background-color:#c56648;padding:14px 40px;display:block;letter-spacing:1.2px" target="_blank">Login</a></td>
- </tr>
- </tbody>';
- /*$mail->Body .= "<b>Property Name: </b>" . $row3['name'] . '<br>';
- $mail->Body .= "<b>Unit Number: </b>" . $row2['ref'] . '<br>';
- $mail->Body .= "<b>Request Title: </b>" . $_POST['nature'] . '<br>';
- $mail->Body .= "<b>Description: </b>" . $_POST['description'] . '<br><br>';*/
- $mail->Body = $this->emailHeader($message,'','New Maintenance Request For Your Property',$body_part_1,'',$body_part_3);
- if($mail->Send()) {
- return true;
- }
- //}
- /*if($img_query) {
- return true;
- } else {
- return false;
- }*/
- $action = $_SESSION['name'] . ' ( ' . $_SESSION['type_name'] . ' ) submitted a new request.';
- $this->Userlog($_SESSION['id'] , $_SESSION['name'] , $_SESSION['email'] , $_SESSION['type_name'] , $action , $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
- $sent = $this->sendEmail($row1['email'],$row1['name'],$manager['email'],$manager['name'],$_POST['nature'],$row3['name'], $row2['ref'],$_POST['description']);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement