Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ==========================================================================================================================================
- Eingefügter Teil/Inserted Part (A):
- ==========================================================================================================================================
- */
- $attachment_path = "";
- $sFilename = "";
- $soxId = $order->oxorder__oxid->value;
- if ( $soxId != "-1" && isset( $soxId))
- {
- // load object
- $oOrder2 = oxNew( "oxorder" );
- $oOrder2->load( $soxId);
- // make file name harder to guess by adding md5(element)
- $sFilename = $oOrder2->oxorder__oxordernr->value.'-'.$oOrder2->oxorder__oxbilllname->value.'-'.md5($oOrder2->oxorder__oxbilllname->value).'.pdf';
- ob_start();
- $language = \OxidEsales\Eshop\Core\Registry::getLang();
- $orderLanguage = $language->getObjectTplLanguage();
- // Please note: cust_lang.php has to be extended manually with the content of
- // /source/modules/oe/invoicepdf/views/admin/de/invoicepdf_lang.php
- // (ORDER_OVERVIEW_PDF* placeholders)
- $oOrder2->genPDF($sFilename, $orderLanguage);
- $sPDF = ob_get_contents();
- ob_end_clean();
- $sAttPath = "inv/";
- //$attachment_path = oxRegistry::get("oxUtilsFile")->normalizeDir($sAttPath);
- $attachment_path = "/srv/www/####YOURVHOSTHERE###/source/out/media/"; //try hard coded first, you may want to specify a different folder
- $fp = fopen($attachment_path.$sFilename,"w+");
- fwrite($fp, $sPDF);
- fclose($fp);
- // PDF is created, attach to e-mail further below...
- // remove dated invoice pdf files
- $days = 0.5;
- $dir = substr($attachment_path, 0, strlen($attachment_path)-1);
- if ($handle = opendir($dir))
- {
- while (false !== ($file = readdir($handle)))
- {
- if ($file[0] == '.' || is_dir($dir.'/'.$file))
- {
- continue;
- }
- $ext = substr(strrchr($file, '.'), 1);
- if ($ext == "pdf" && (time() - filemtime($dir.'/'.$file)) > ($days *86400))
- {
- error_log("deleting dated invoice file: " . $dir.'/'.$file);
- unlink($dir.'/'.$file);
- }
- }
- closedir($handle);
- }
- // /remove dated invoice pdf files
- /*
- ==========================================================================================================================================
- Eingefügter Teil/Inserted Part (B):
- ==========================================================================================================================================
- */
- if ($sFilename != "")
- {
- $sFullPath = $attachment_path.$sFilename;
- if ( @is_readable( $sFullPath ) && @is_file( $sFullPath ) )
- {
- parent::addAttachment( $sFullPath );
- error_log ("OK, attached PDF to e-mail!");
- } else {
- error_log ("problems attaching invoice pdf to mail - file not found: " . $sFullPath);
- }
- }
- ================================================================================================================================================================
Add Comment
Please, Sign In to add comment