Last active
August 29, 2015 14:10
-
-
Save piyuesh23/9499e5b1c3cd97734e37 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 . '-->'; | |
// Fetch list of archived invoice nids. | |
$query_archived_invoices = "SELECT DISTINCT invoice_nid FROM {whiteboard_migration_map}"; | |
while ($row = db_fetch_array($result)) { | |
$archived_invoice_nids[] = $result['invoice_nid']; | |
} | |
// Check if the current invoice being generated is archived. | |
if (in_array($nid, $archived_invoice_nids) { | |
$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 | |
* We need to prefix CSS being appended in the pdf generator function to this file as well. | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment