Created
November 20, 2014 10:44
-
-
Save piyuesh23/d379ba9fcdf9521936fc to your computer and use it in GitHub Desktop.
Logic to generate pdf from archived invoices stored in s3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CONSTANTS defined in whiteboard_migration.module. | |
// Will be accessible when this module is installed on whiteboard. | |
define('WHITEBOARD_INVOICE_HEADER_START_COMMENT', 'Header begins here for invoice #'); | |
define('WHITEBOARD_INVOICE_HEADER_END_COMMENT', 'Header ends here for invoice #'); | |
define('WHITEBOARD_INVOICE_BODY_START_COMMENT', 'Body begins here for invoice #'); | |
define('WHITEBOARD_INVOICE_BODY_END_COMMENT', 'Body ends here for invoice #'); | |
define('WHITEBOARD_INVOICE_FOOTER_START_COMMENT', 'Footer begins here for invoice #'); | |
define('WHITEBOARD_INVOICE_FOOTER_END_COMMENT', 'Footer ends here for invoice #'); | |
$header_start_comment = '<!--' . WHITEBOARD_INVOICE_HEADER_START_COMMENT . $invoice_vid . '-->'; | |
$header_end_comment = '<!--' . WHITEBOARD_INVOICE_HEADER_END_COMMENT . $invoice_vid . '-->'; | |
$body_start_comment = '<!--' . WHITEBOARD_INVOICE_BODY_START_COMMENT . $invoice_vid . '-->'; | |
$body_end_comment = '<!--' . WHITEBOARD_INVOICE_BODY_END_COMMENT_COMMENT . $invoice_vid . '-->'; | |
$footer_start_comment = '<!--' . WHITEBOARD_INVOICE_FOOTER_START_COMMENT . $invoice_vid . '-->'; | |
$footer_end_comment = '<!--' . WHITEBOARD_INVOICE_FOOTER_END_COMMENT . $invoice_vid . '-->'; | |
$invoice_node = node_load($nid, $vid); | |
$invoice_markup = file_get_contents($invoice_node->field_invoice_content_online[0]['value']); | |
preg_match('/' . $header_start_comment . '[a-z|A-Z|\s|\S|\d|\D]*' . $header_end_comment . '/', $invoice_markup, $header_matches); | |
preg_match('/' . $body_start_comment . '[a-z|A-Z|\s|\S|\d|\D]*' . $body_end_comment . '/', $invoice_markup, $body_matches); | |
preg_match('/' . $footer_start_comment . '[a-z|A-Z|\s|\S|\d|\D]*' . $footer_end_comment . '/', $invoice_markup, $footer_matches); | |
/** | |
* $header_matches[0]: will have the same content that should be in $headerHTML @L#2069 global.inc | |
* $body_matches[0]: will have the same content that should be in $htmlData @L#2068 global.inc | |
* $footer_matches[0]: will have the same content that should be in $footerHTML @L#2070 global.inc | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment