I am experiencing some strange behavior when using json_encode.
This is my code:
if($_POST["action"] == 'profile')
{
sleep(2);
$error = '';
$success = '';
$admin_name = '';
$admin_contact_no = '';
$admin_email = '';
$admin_profile = '';
$data = array(
':admin_email' => $_POST["admin_email"],
':admin_id' => $_POST['hidden_id']
);
$visitor->query = "
SELECT * FROM admin_table
WHERE admin_email = :admin_email
AND admin_id != :admin_id
";
$visitor->execute($data);
if($visitor->row_count() > 0)
{
$error = '<div class="alert alert-danger">User Email Already Exists</div>';
}
else
{
$user_image = $_POST["hidden_user_image"];
if($_FILES["user_image"]["name"] != '')
{
$user_image = upload_image();
}
$admin_name = $visitor->clean_input($_POST["admin_name"]);
$admin_contact_no = $_POST["admin_contact_no"];
$admin_email = $_POST["admin_email"];
$admin_profile = $user_image;
$data = array(
':admin_name' => $admin_name,
':admin_contact_no' => $admin_contact_no,
':admin_email' => $admin_email,
':admin_profile' => $admin_profile
);
$visitor->query = "
UPDATE admin_table
SET admin_name = :admin_name,
admin_contact_no = :admin_contact_no,
admin_email = :admin_email,
admin_profile = :admin_profile
WHERE admin_id = '".$_POST['hidden_id']."'
";
$visitor->execute($data);
$success = '<div class="alert alert-success">User Details Updated</div>';
}
$output = array(
'error' => $error,
'success' => $success,
'admin_name' => $admin_name,
'admin_contact_no' => $admin_contact_no,
'admin_email' => $admin_email,
'admin_profile' => $admin_profile
);
echo json_encode($output);
}
Alert message for $error displays accordingly while alert message for $success does not.
If I swap positions between $error = '<div class="alert alert-danger">User Email Already Exists</div>'; and $success = '<div class="alert alert-success">User Details Updated</div>';, $error still works while $success still does not, which deeply confuses me.
I know I can avoid all this trouble by using echo, but I really want to find out what the issue is here.
Thank you for your help.
It was just a spelling error, wrote "succes" instead of "success".
I apologize for the trouble and thank you for your help.
Related
I am using CodeIgniter, I am displaying the fields dynamically. Now I have to insert the data in the database. So I tried below code.
$order = $this->input->post('order[]');
$partner = $this->input->post('parner[]');
$bankname = $this->input->post('newpartner[]');
$status = $this->input->post('filestatus[]');
$user_id = $this->input->post('user_id');
$order_length = sizeof($order);
for ($j = 0; $j < $order_length; $j++) {
if (($status = 1) || ($status = 3)) {
$remark = $this->input->post('remark[]');
} else {
$remark = "";
}
if (($status = 2) || ($status = 4))) {
$reasonDate = $this->input-> post('reasonDate[]');
$remark = $this->input-> post('remark[]');
} else {
$reasonDate = "";
$remark = "";
}
if ($status = 7) {
$reasonAmt = $this->input->post('reasonAmt[]');
$reason = $this->input->post('reason[]');
} else {
$reasonAmt = "";
$reason = "";
}
$data['row'] = array(
'order' => $order[$j],
'bankname' => $bankname[$j],
'status' => $status[$j],
'lead_id' => $user_id,
'remark' => $remark[$j],
'reasonDate' => $reasonDate[$j],
'reasonAmt' => $reasonAmt[$j],
'reason' => $reason[$j]
);
$save = array(
'b_orderno' => $data['row']['order'],
'b_bankname' => $data['row']['bankname'],
'b_filestatus' => $data['row']['status'],
'p_id' => $data['row']['pid'],
'lead_id' => $data['row']['lead_id'],
'b_remark' => $data['row']['remark'],
'b_date' => $data['row']['reasonDate'],
'b_amt' => $data['row']['reasonAmt'],
'b_reason' => $data['row']['reason']
);
$afterxss = $this->security-> xss_clean($save);
if ($afterxss) {
$this - > db - > insert('tbl_bankdata', $afterxss);
$response['error'] = "true";
$response['msg'] = "added successfully";
} else {
$response['error'] = "false";
$response['msg'] = "Sometning wrong! please check the internet connection and try again";
}
}
echo json_encode($response);
I am getting the issue on the status field because depending upon the status value input field will display. Also, I used If the condition in logic for the status field. Each row has a unique status field.
You will find my HTML and script in below link.
https://jsfiddle.net/08phzue3/
This is my UI screenshot. Ignore the value that is only for testing purpose.
1)Onload this will display
2) If user select the status
3) If multiple row
Would you help me out with this?
Actually you are not comparing here:
if (($status = 1) || ($status = 3)) {
You are assigning the values to your $status variable
this should be:
if (($status == 1) || ($status == 3)) {
Side note: same for other conditions as well.
Edit:
As you mentioned you are getting array in $status so using comparison is not a correct logic here, there are multiple solution available,
You can use in_array() like:
if(in_array(1, $status) || in_array(3, $status)){
$remark = $this->input->post('remark[]');
}
else{
$remark = "";
}
Final Solutions (04-07-2019):
After changing the $save and $data arrays, issue has been resolved for OP:
$save['b_orderno'] = $order[$j];
$save['b_bankname'] = $bankname[$j];
$save['b_filestatus'] = $status[$j];
$save['p_id'] = $partner[$j];
$save['lead_id'] = $user_id;
if(!empty($remark[$j])){
$save['b_remark'] = $remark[$j];
}
if(!empty($reasonDate[$j])){
$save['b_date'] = $reasonDate[$j];
}
if(!empty($message[$j])){
$save['b_message'] = $message[$j];
}
if(!empty($reasonAmt[$j])){
$save['b_amt'] = $reasonAmt[$j];
}
if(!empty($reason[$j])){
$save['b_reason'] = $reason[$j];
}
$data['row']['order'] = $order[$j];
$data['row']['bankname'] = $bankname[$j];
$data['row']['status'] = $status[$j];
$data['row']['lead_id'] = $user_id;
$data['row']['remark'] = $remark[$j];
$data['row']['reasonDate'] = $reasonDate[$j];
if(!empty($reasonAmt[$j])){
$data['row']['reasonAmt'] = $reasonAmt[$j];
}
if(!empty($reason[$j])){
$data['row']['reason'] = $reason[$j];
}
I wasn't entirely sure how to search for this question, so if it has been asked before please send me in the right direction.
I have a validation function with an array. Inside my array I have set up errors to be displayed if one of the form fields doesn't validate. If the user fills a field out wrong, they should get an error of which field was wrong and the form should be still present. However, they get a blank page with only the generic error (the one I echo when I called the function) and not the field-specific error. Can someone please tell me where I went wrong?
$output_form = 1; //control if form displays - yes
$error_text = '';
//declare form elements (empty first load)
$fname = '';
$valid_fname = 0;
$fname_regex = '/^([A-Z]|[a-z]){2,15}$/';
$fname_error_message = 'First name must be 2-15 alphabetic characters only.<br>';
$lname = '';
$valid_lname = 0;
$lname_regex = '/^([A-Z]|[a-z]){2,15}$/';
$lname_error_message = 'Last name must be 2-15 alphabetic characters only.<br>';
$phone = '';
$valid_phone = 0;
$phone_regex = '/^\(\d{3}\)\d{3}-\d{4}$/';
$phone_error_message = 'Phone number must be in (xxx)xxx-xxxx format.<br>';
$city = '';
$valid_city = 0;
$city_regex = '/^([A-Z]|[a-z]){2,15}$/';
$city_error_message = 'City must be 2-15 alphabetic characters only.<br>';
$state = '';
$valid_state = 0;
$state_regex = '/^([A-Z]|[a-z]){2}$/';
$state_error_message = 'State must be 2 alphabetic characters only.<br>';
//data posted
if (isset($_POST['submit'])) {
if ($debug) {
echo "<pre>";
print_r($_POST);
echo "</pre>";
}//end debug
$fname = trim($_POST['fname']);
$lname = trim($_POST['lname']);
$phone = trim($_POST['phone']);
$city = trim($_POST['city']);
$state = trim($_POST['state']);
$phone_replace = preg_replace('/[\(\)\-\s]/', '', $phone);
function validate_form($fields, &$errors = []) {
$errors = [];
foreach ($fields as $name => $field) {
if (!preg_match ($field['regex'], $field['value'])) {
$errors[$name] = $field['error'];
$output_form = 1;
}
}
return empty($errors); //returns true/false
}
$fields = [
'fname' => ['regex' => $fname_regex, 'value' => $fname, 'error' => $fname_error_message],
'lname' => ['regex' => $lname_regex, 'value' => $lname, 'error' => $lname_error_message],
'phone' => ['regex' => $phone_regex, 'value' => $phone, 'error' => $fname_error_message],
'city' => ['regex' => $city_regex, 'value' => $city, 'error' => $city_error_message],
'state' => ['regex' => $state_regex, 'value' => $state, 'error' => $state_error_message],
];
$errors = [];
if (!validate_form($fields, $errors)) {
echo "<p>One of your fields is invalid. Please check and re-submit.</p>";
$output_form = 1;
return (false);
}
else {
$output_form = 0;
}
foreach($errors as $error) echo "<p>$error</p>";
Actually outputting stuff usually helps ;)
I take data from Gmail with this code
<?php $data = array(
// email account
'email' => array(
'hostname' => '{imap.gmail.com:993/imap/ssl}INBOX',
'username' => $emailAddress,
'password' => $emailPassword
),
// inbox pagination
'pagination' => array(
'sort' => $sortBy,
'limit' => 10,
'offset' => $offset
)
);
$result = array();
$imap = imap_open($data['email']['hostname'], $data['email']['username'], $data['email']['password']) or die ('Cannot connect to yourdomain.com: ' . imap_last_error());
$read = imap_search($imap, 'ALL');
$overview = imap_fetch_overview($imap, $read[$i], 0);
$header = imap_headerinfo($imap, $read[$i], 0);
$mail = $header->from[0]->mailbox . '#' . $header->from[0]->host;
$image = '';
$structure = imap_fetchstructure($imap, $read[$i]);
if(isset($structure->parts) && is_array($structure->parts) && isset($structure->parts[1])) {
$part = $structure->parts[1];
if($part->encoding == 3) {
$message = imap_fetchbody($imap,$read[$i],1.2);
$message = imap_qprint($message);
} else if($part->encoding == 1) {
$message = imap_8bit($message);
} else {
$message = imap_fetchbody($imap,$read[$i],2);
$message = imap_qprint($message);
}
}else{
$message = imap_body($imap, $read[$i],0);
}
?>
All data I receive correctly, however when I enter Email list page, the received emails turn to read.
It worked fine before, after using for some time, this issue appeared.
Any idea what can be the reason?
In imap_fetchbody, add the FT_PEEK flag to prevent clearing the \Seen flag automatically.
imap_fetchbody($imap, $read[$i], 1.2, FT_PEEK);
See option flag documentation at the official site.
I have written an application in CakePHP. I am facing an issue. Sometimes it happens that when an order is placed, it's not reflecting in database, but I am both getting an email and it's reflecting in my PayU account dashboard that someone has placed an order with x amount.
Below is my code. What is wrong?
if(!empty($this->data)){
$data = $this->data;
$userInfo = $this->User->find('first',array('conditions'=>array('User.id'=>$userID)));
$sales_rep_email = $userInfo["User"]["sales_rep_email"];
$user_email = $userInfo["User"]["primary_contact_email"];
$virtual_account = $userInfo["User"]["virtual_account"];
if($data['payment_method']=="RTGS Payment"){
$orderData['Order']['invoice_no'] = 0;
$orderData['Order']['invoice_prefix'] = "INV-2015-00";
$orderData['Order']['user_id'] = $userInfo['User']['id'];
$orderData['Order']['name'] = $userInfo['User']['name'];
$orderData['Order']['email'] = $userInfo['User']['primary_contact_email'];
$orderData['Order']['phone'] = $userInfo['User']['primary_contact_number'];
$orderData['Order']['billing_address'] = $userInfo['User']['address'].", ".$userInfo['User']['city'].", ".$userInfo['User']['district'].", ".$userInfo['User']['state']."-".$userInfo['User']['pin_code'];
$orderData['Order']['order_item_count'] = $shop['Order']['quantity'];
$orderData['Order']['shipping'] = $data['shipping_method'];
$orderData['Order']['total'] = $shop['Order']['total'];
$orderData['Order']['payment_method'] = $data['payment_method'];
if($data['shipping_method']=="Express Delivery"){
$orderData['Order']['delivery_charges'] = 400;
}
if($data['payment_method']=="RTGS Payment"){
$orderData['Order']['status'] = 'open';
$orderData['Order']['temp_status'] = 'rtgs';
}else if($data['payment_method']=="COD"){
$orderData['Order']['status'] = 'open';
$orderData['Order']['temp_status'] = 'cod';
$orderData['Order']['customer_status'] = 'unconfirmed';
}else{
$orderData['Order']['status'] = 'open';
$orderData['Order']['temp_status'] = 'open';
}
$this->Order->save($orderData);
$id = $this->Order->getLastInsertId();
$orderupdateData['Order']['orderid'] = date("Y").date("m").'-'.$id;
$orderupdateData['Order']['temporary_order'] = "TO".'-'.$id;
$orderupdateData['Order']['id'] = $id;
$this->Order->save($orderupdateData);
$orderItemData = array();
foreach($shop['OrderItem'] as $key=>$item){
$quantityNewCheckOut = 0;
if(!empty($data['payment_method'])){
$this->manageInventory($item['Product']['smb_code'],$item['quantity']);
}
$orderItemData['OrderItem']['order_id'] = $id;
$orderItemData['OrderItem']['sku_id'] = $key;
$inventoryData = $this->Inventory->find("first",array("conditions"=>array("Inventory.smb_item_code"=>$item['Product']['smb_code'])));
$quantityNewCheckOut = (int)$inventoryData["Inventory"]["quantity"];
if($quantityNewCheckOut<=0){
$orderItemData["OrderItem"]["mod_name"] = "back";
}else if($quantityNewCheckOut>0){
$orderItemData["OrderItem"]["mod_name"] = "available";
}
$orderItemData['OrderItem']['name'] = $item['Product']['smb_code'];
$orderItemData['OrderItem']['quantity'] = $item['quantity'];
$orderItemData['OrderItem']['price'] = $item['price'];
if(!empty($item['discount_amount'])){
$orderItemData['OrderItem']['discount_amount'] = $item['discount_amount'];
}
$orderItemData['OrderItem']['subtotal'] = $item['subtotal'];
$orderItemData['OrderItem']['status'] = "open";
$this->OrderItem->save($orderItemData);
$this->OrderItem->create();
unset($orderItemData);
}
$orderDetails = $this->OrderItem->find("all",array("conditions"=>array("OrderItem.order_id"=>$id),'recursive'=>2));
$content = "<b>Order Date:</b>".date("d F Y H:i:s")."<br/>";
$content .= "<b>Temporary Order Number:</b>"."TO".'-'.$id."<br/><br/><br/>";
$content .= "<table border='1'><thead><th>Company Name</th><th>Brand</th><th>SMB Item Code</th><th>Mfg Code</th><th>Product Description</th><th>UOM</th><th>MRP</th><th>Unit Price</th><th>Qty</th><th>Subtotal</th><th>Tax%</th><th>Total</th></thead><tbody>";
foreach($orderDetails as $orderItem){
$content .= "<tr>";
$content .= "<td>".$orderItem["Sku"]["Company"]["name"]."</td>";
$content .= "<td>".$orderItem["Sku"]["Brand"]["name"]."</td>";
$content .= "<td>".$orderItem["Sku"]["smb_code"]."</td>";
$content .= "<td>".$orderItem["Sku"]["title"]."</td>";
$content .= "<td>".$orderItem["Sku"]["description"]."</td>";
$content .= "<td>".$orderItem["Sku"]["uom"]."</td>";
$content .= "<td>"."Rs.".$orderItem["Sku"]["mrp"]."</td>";
$content .= "<td>"."Rs.".$orderItem["OrderItem"]["price"]."</td>";
$content .= "<td>".$orderItem["OrderItem"]["quantity"]."</td>";
$content .= "<td>"."Rs.".sprintf('%01.2f', $orderItem["OrderItem"]["price"] * $orderItem["OrderItem"]["quantity"])."</td>";
$content .= "<td>".$orderItem["Sku"]["Product"]["tax"]."</td>";
$content .= "<td>"."Rs.".$orderItem["OrderItem"]["subtotal"]."</td>";
$content.= "</tr>";
}
if($data['shipping_method']=="Express Delivery"){
$totalAmount = ($orderItem["Order"]["total"])+400;
$content .= "<tr><td style='text-align:right' colspan='10'>Delivery Charges:</td><td style='text-align:right'colspan='2'>"."Rs. 400</td></tr>";
$content .= "<tr><td style='text-align:right' colspan='10'>Grand Total:</td><td style='text-align:right'colspan='2'>"."Rs. ".$totalAmount."</td></tr>";
}else{
$content .= "<tr><td style='text-align:right' colspan='10'>Grand Total:</td><td style='text-align:right'colspan='2'>"."Rs. ".$orderItem["Order"]["total"]."</td></tr>";
}
$content .= "</tbody></table>";
$emailTemplate = $this->EmailTemplate->find('first',array('conditions'=>array('EmailTemplate.id'=>'23')));
$emailContent = $emailTemplate['EmailTemplate']['html_content'];
$subject = $emailTemplate['EmailTemplate']['subject']."TO".'-'.$id;
$template_info = str_replace(array('$temp_order','$virtual_id','$content','$salesrep'),array("TO".'-'.$id,$virtual_account,$content,$sales_rep_email),$emailContent);
$email = new CakeEmail();
$email->template('email_template');
$email->emailFormat('both');
$email->viewVars(array('emailContent' => $template_info));
$to = array($user_email);//$to = '';
$from = '';
$email->to($to);
$email->bcc("");
$email->cc($sales_rep_email);
$email->from(array($from=>''));
$email->subject($subject);
$email->smtpOptions = array(
'port'=>'25',
'timeout'=>'30',
'host' => '',
'username'=>'',
'password'=>'',
);
//Set delivery method
$email->delivery = 'smtp';
//pry($email);
$email->send();
$this->redirect(array('action'=>"successOrderRTGS"));
}else{
$paymentMethod = $data['payment_method'];
$shippingMethod = $data['shipping_method'];
if(!empty($paymentMethod)){
$this->Session->write("User.payment_method",$paymentMethod);
$this->Session->write("User.shipping_method",$shippingMethod);
}
$orderData['Order']['total'] = $shop['Order']['total'];
if($data['shipping_method']=="Express Delivery"){
$orderData['Order']['delivery_charges'] = 400;
$amount =($shop['Order']['total'])+400;
}else{
$amount =($shop['Order']['total']);
}
$this->pay_page( array ( 'key' => '', 'txnid' => uniqid( 'test' ), 'amount' => $amount,
'firstname' => $userInfo['User']['name'], 'email' => $userInfo['User']['primary_contact_email'], 'phone' => $userInfo['User']['primary_contact_number'],
'productinfo' => 'Product Info', 'surl' => 'payment_success', 'furl' => 'payment_failure'), '' );
}
}
The reason your code is sending out the email despite not saving the Order data in the database is because you are not checking whether the save() is successful or not. It's probably failing due to validation errors, but your code won't do anything about it.
The proper way of handling this is by wrapping the save() method inside an if condition:
if ($this->Order->save($orderData)) {
//send email
//redirect
} else {
Debugger::log($this->Order->validationErrors);
$this->Flash->set('Order could not be saved');
}
You should also refactor your action to reduce its size. The main purpose of using a MVC framework is to make life easier by separating business logic, control logic and views. If you find yourself writing HTML in your controller, you are probably doing something wrong.
Interesting read: Fat models, skinny controllers and the MVC design pattern
Re-visiting this problem specified in my previous question, I tried and tried, also with different accounts (I tried gmail, as well as outlook), but the problem still persists. The error I get is the following if I try to access my google account
Error: Unable to get imap_thread after 4 retries. 'Can't open mailbox {imap.gmail.com:993/ssl/imap/tls/novalidate-cert}INBOX: invalid remote specification'
if I try accessing email on my outlook account, the error is the same :
Error: Unable to get imap_thread after 4 retries. 'Can't open mailbox {outlook.office365.com:993/ssl/imap/tls/novalidate-cert}INBOX: invalid remote specification'
My setup is as follows :
public $emailTicket = array(
'datasource' => 'ImapSource',
'server' => 'outlook.office365.com',
'connect' => 'imap/tls/novalidate-cert',
'username' => 'my email here',
'password' => 'my password here',
'port' => '993', //incoming port
'ssl' => true,
'encoding' => 'UTF-8',
'error_handler' => 'php',
'auto_mark_as' => array(
'Seen',
// 'Answered',
// 'Flagged',
// 'Deleted',
// 'Draft',
),
);
I am working on a local machine, does anyone know if this might be the problem or not? Has anyone ever tried this and worked for him/her? I am open to all input!
I can't seem to find what's wrong here, I've been at this for about 2days now, so if anyone can help, I appreciate it!
Also here's the link for the plugin i'm using, by Nicolas Ramy..
You can use the following implemented code to fulfill your requirements:
public function generate_email_response_pdf()
{
$this->layout = false;
$this->autoRender = false;
$username = EMP_SMTP_MAIL_FROM;
$password = EMP_SMTP_MAIL_PASSWORD;
$imap = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', $username, $password);
$emails = imap_search($imap, 'ALL');
if(!empty($emails))
{
//put the newest emails on top
rsort($emails);
foreach($emails as $email_number)
{
$flag = 0;
$mail_data = array();
$file_name = array();
$output = array();
$savefilename = null;
$filename = null;
$overview = imap_fetch_overview($imap, $email_number, 0);
//initialize the subject index with -000, considering not receving this will not be received in
//subject line of email
$output['subject'] = '-000x';
if(isset($overview[0] -> subject))
{
$output['subject'] = $overview[0] -> subject;
}
$structure = imap_fetchstructure($imap, $email_number);
if(property_exists($structure, 'parts'))
{
$flag = 1;
$flattened_parts = $this->flatten_parts($structure->parts);
foreach($flattened_parts as $part_number => $part)
{
switch($part->type)
{
case 0:
//the HTML or plain text part of the email
if((isset($part->subtype)=='HTML')&&(isset($part->disposition)=='ATTACHMENT'))
{
$part_number = 1.2;
}
else if(isset($part->subtype)=='HTML')
{
$part_number = $part_number;
}
else
{
$part_number = $part_number;
}
$message = $this->get_part($imap, $email_number, $part_number, $part->encoding);
//now do something with the message, e.g. render it
break;
case 1:
// multi-part headers, can ignore
break;
case 2:
// attached message headers, can ignore
break;
case 3: // application
case 4: // audio
case 5: // image
case 6: // video
case 7: // other
break;
}
if(isset($part->disposition))
{
$filename = $this->get_filename_from_part($part);
if($filename)
{
// it's an attachment
$attachment = $this->get_part($imap, $email_number, $part_number, $part->encoding);
$file_info = pathinfo($filename);
$savefilename = RESPONSE_ATTACHMENT_PREFIX.$file_info['filename'].'_'.$this->_getRandId(4).'.'.$file_info['extension'];
$file_name[] = $savefilename;
$attachment_file_name = $this->save_attachment($attachment, $savefilename, $directory_path);
//imap_fetchbody($imap, $email_number, 2); //This marks message as read
}
else
{
// don't know what it is
}
}
}
}
else
{
$encoding = $structure->encoding;
$message = imap_fetchbody($imap, $email_number, 1.2);
//echo $message; die;
if($message == "")
{
$message = imap_body($imap, $email_number);
if($encoding == 3)
{
$message = base64_decode($message);
}
else if($encoding == 4)
{
$message = quoted_printable_decode($message);
}
}
}
$header = imap_headerinfo($imap, $email_number);
$from_email = $header->from[0]->mailbox."#".$header->from[0]->host;
$to_email = $header->to[0]->mailbox."#".$header->to[0]->host;
$reply_to_email = $header->reply_to[0]->mailbox."#".$header->reply_to[0]->host;
$cc_email = array();
if(isset($header->cc))
{
foreach($header->cc as $ccmail)
{
$cc_email[] = $ccmail->mailbox.'#'.$ccmail->host;
}
$cc_email = implode(", ", $cc_email);
}
$output['to'] = $to_email;
$output['from'] = $from_email;
$output['reply_to'] = $reply_to_email;
$output['cc'] = $cc_email;
$formatted_date = date('D, d M Y h:i A', strtotime($overview[0] -> date));
$output['date'] = $formatted_date;
$output['message'] = $message;
$output['flag'] = $flag;
$mail_data['Attachment'] = $file_name;
$mail_data['Data'] = $output;
$this->set('response_data', $mail_data);
$mail_content = null;
if(!empty($mail_data))
{
$this->viewPath = 'Elements/default';
$mail_content = $this->render('pdf_content');
}
$header = null;
$footer = null;
$html = preg_replace(array('/[^\r\n\t\x20-\x7E\xA0-\xFF]*/'), '', $mail_content);
$pdfFile = $this->_generateWkPdf($html, $directory_path, $new_file_name, $header, $footer);
$image_type = EXT_JPG;
$response_files_array = $this->_generateImagesFromPdf($directory_path.$pdfFile, $directory_path, $new_file_name, $image_type);
}
}
imap_close($imap);
}