protected function postSubmitActions() { # generate HTML content from submitted data $prods = DataHolder::getInstance('products')->getSavedFormValues(); $prods = isset($prods['valitud tooted']) ? $prods['valitud tooted'] : array(-1); $htmlContent = $this->getPartial('query/pdfView', array('contact' => DataHolder::getInstance('contact')->getSavedFormValues(), 'dimensions' => DataHolder::getInstance('dimensions')->getSavedFormValues(), 'profiles' => DataHolder::getInstance('profiles')->getSavedFormValues(), 'attachments' => DataHolder::getInstance('attachments')->getSavedFormValues(), 'configuration' => $this->configuration, 'products' => array('savedValues' => DataHolder::getInstance('products')->getSavedFormValues(), 'products' => Doctrine::getTable('Product')->createQuery()->from('Product')->whereIn('id', $prods)->execute()))); // echo $htmlContent; // exit; # create TMP HTML file $absoluteInvoicePath = tempnam(sfConfig::get('sf_web_dir') . '/queries', 'query_') . '.html'; @mkdir(dirname($absoluteInvoicePath), 0777, true); // put html in file file_put_contents($absoluteInvoicePath, $htmlContent); # generate pdf file $site = $this->getRequest()->getHost() . '/queries/' . basename($absoluteInvoicePath); # ask html2pdf converter to convert HTML to PDF $url = "http://" . $this->getRequest()->getHost() . "/html2pdf/demo/html2ps.php?process_mode=single&URL=" . $site . "&proxy=&pixels=1024&scalepoints=1&renderimages=1&renderlinks=1&renderfields=1&media=Letter&cssmedia=Screen&leftmargin=30&rightmargin=15&topmargin=15&bottommargin=15&encoding=&headerhtml=&footerhtml=&watermarkhtml=&toc-location=before&smartpagebreak=1&pslevel=3&method=fpdf&pdfversion=1.3&output=0&convert=Convert+File"; $pdfContent = file_get_contents($url); # mail PDF fail to site admin and user sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Variable')); //send site administrator an email of query $this->sendMail(variable('system email', '*****@*****.**'), $pdfContent); // send user email if he wants it if (DataHolder::getInstance('contact')->sendCopyToUser()) { $this->sendMail(DataHolder::getInstance('contact')->getUserEmail(), $pdfContent); } }
public function getSavedFormValues() { return DataHolder::getInstance($this->getHolderName())->getSavedFormValues(); }