I am using a free extension of opencart which allows me to download invoice in PDF to my local system (Downloads folder).
I want two things to happen
I want to download PDF file in my root. (if I am working on localhost I want the file to download in root\abc\ )
The other thing i want is that there is an email textbox and email button what I want is that I want to send email to user(eAddress written in textbox) with auto attachment of that downloaded pdf file located in(root\abc)
CODE :
$pdf = (isset($this->request->get['pdf'])) ? true : false;
$eFlag= (isset($this->request->get['email'])) ? true : false;
if ($pdf){
$this->response->setOutput(pdf($this->render(),$this->data['orders']));
}
elseif ($eFlag) {
$fp = fopen(DIR_DOWNLOAD . "meeru.pdf","wb");
$dataHtml = $this->render();
$name = $this->data['orders'];
if (count($name) > 1) {
$name = "Orders";
}else{
$name = 'Order_'.$name[0]['order_id'];
}
$pdf = new DOMPDF;
$pdf->load_html($dataHtml );
$pdf->render();
fwrite($fp , $pdf->output( array("compress" => 0) ));
fclose($fp );
$this->response->setOutput("File Saved");
}
else{
$this->response->setOutput($this->render());
}
Its downloading just one time (for the first time in root/download)