From d88a033718de1450fcf7d00b14b51492000631f0 Mon Sep 17 00:00:00 2001 From: Pratiksha Dubey Date: Thu, 7 Aug 2014 10:58:18 +0530 Subject: [PATCH] VAT-578 Code indentation and new changes for tpl and php files --- CRM/Contribute/Form/Task/Invoice.php | 73 +++-- .../contribution_invoice_receipt_html.tpl | 255 ++++++++++-------- .../contribution_invoice_receipt_html.tpl | 255 ++++++++++-------- 3 files changed, 350 insertions(+), 233 deletions(-) diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index c2f581cc22..c5d4a469a2 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -393,15 +393,36 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $title = CRM_Utils_Array::value('title', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails)); } + $source = $contribution->source; $config = CRM_Core_Config::singleton(); - $config->doNotAttachPDFReceipt = 1; + if ($params['forPage'] != 'confirmpage') { + $config->doNotAttachPDFReceipt = 1; + } + + // get organization address + $domain = CRM_Core_BAO_Domain::getDomain(); + $locParams = array('contact_id' => $domain->id); + $locationDefaults = $defaults = CRM_Core_BAO_Location::getValues($locParams); + if (isset($locationDefaults['address'][1]['state_province_id'])) { + $stateProvinceAbbreviationDomain = CRM_Core_PseudoConstant::stateProvinceAbbreviation($locationDefaults['address'][1]['state_province_id']); + } + else { + $stateProvinceAbbreviationDomain = ''; + } + if (isset($locationDefaults['address'][1]['country_id'])) { + $countryDomain = CRM_Core_PseudoConstant::country($locationDefaults['address'][1]['country_id']); + } + else { + $countryDomain = ''; + } // parameters to be assign for template $tplParams = array( 'title' => $title, 'component' => $input['component'], 'id' => $contribution->id, + 'source' => $source, 'invoice_id' => $invoiceId, 'creditnote_id' => $creditNoteId, 'imageUploadURL' => $config->imageUploadURL, @@ -425,6 +446,16 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 'postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value($contribution->contact_id,$billingAddress)), 'is_pay_later' => $contribution->is_pay_later, 'organization_name' => $contribution->_relatedObjects['contact']->organization_name, + 'domain_organization' => $domain->name, + 'domain_street_address' => CRM_Utils_Array::value('street_address', CRM_Utils_Array::value('1', $locationDefaults['address'])), + 'domain_supplemental_address_1' => CRM_Utils_Array::value('supplemental_address_1', CRM_Utils_Array::value('1', $locationDefaults['address'])), + 'domain_supplemental_address_2' => CRM_Utils_Array::value('supplemental_address_2', CRM_Utils_Array::value('1', $locationDefaults['address'])), + 'domain_city' => CRM_Utils_Array::value('city', CRM_Utils_Array::value('1', $locationDefaults['address'])), + 'domain_postal_code' => CRM_Utils_Array::value('postal_code', CRM_Utils_Array::value('1', $locationDefaults['address'])), + 'domain_state' => $stateProvinceAbbreviationDomain, + 'domain_country' => $countryDomain, + 'domain_email' => CRM_Utils_Array::value('email', CRM_Utils_Array::value('1', $locationDefaults['email'])), + 'domain_phone' => CRM_Utils_Array::value('phone', CRM_Utils_Array::value('1', $locationDefaults['phone'])), ); $sendTemplateParams = array( @@ -457,17 +488,21 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // condition to check for download PDF Invoice or email Invoice if ($invoiceElements['createPdf']) { list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); - $mail = array( - 'subject' => $subject, - 'body' => $message, - 'html' => $html, - ); - - if ($mail['html']) { - $messageInvoice[] = $mail['html']; - } + if ($params['forPage'] == 'confirmpage') { + return $html; + } else { - $messageInvoice[] = nl2br($mail['body']); + $mail = array( + 'subject' => $subject, + 'body' => $message, + 'html' => $html, + ); + if ($mail['html']) { + $messageInvoice[] = $mail['html']; + } + else { + $messageInvoice[] = nl2br($mail['body']); + } } } elseif ($contribution->_component == 'contribute') { @@ -507,13 +542,17 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { } if ($invoiceElements['createPdf']) { - CRM_Utils_PDF_Utils::html2pdf($messageInvoice, 'Invoice.pdf', FALSE); + if ($params['forPage'] == 'confirmpage') { + return $html; + } + else { + CRM_Utils_PDF_Utils::html2pdf($messageInvoice, 'Invoice.pdf', FALSE, array('margin_top'=>10,'margin_left'=>65,'metric'=>'px')); + // functions call for adding activity with attachment + $fileName = self::putFile($html); + self::addActivities($subject, $contactIds, $fileName, $params['output']); - // functions call for adding activity with attachment - $fileName = self::putFile($html); - self::addActivities($subject, $contactIds, $fileName, $params['output']); - - CRM_Utils_System::civiExit(); + CRM_Utils_System::civiExit(); + } } else { if ($invoiceElements['suppressedEmails']) { diff --git a/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/contribution_invoice_receipt_html.tpl b/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/contribution_invoice_receipt_html.tpl index f1ee2a2a8c..c7f70bdb4b 100644 --- a/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/contribution_invoice_receipt_html.tpl +++ b/CRM/Upgrade/4.5.alpha1.msg_template/message_templates/contribution_invoice_receipt_html.tpl @@ -5,57 +5,76 @@ - +
- +
-

- - - + - - - - + + {if $organization_name} - - {else} - + + {else} + {/if} - + + - + - - + + - + - + + - + - + + - + + + + + + + +
TAX INVOICETAX INVOICE Invoice Date:{$organization_name}Invoice Date:{$domain_organization}
{$display_name} ({$organization_name}){$display_name}{$display_name} ({$organization_name}){$display_name}{$invoice_date}{$invoice_date} + {if $domain_street_address } + {$domain_street_address} + {/if} + {if $domain_supplemental_address_1 }{$domain_supplemental_address_1}{/if}
{$street_address} {$supplemental_address_1}{$street_address} {$supplemental_address_1} Incoice Number:Incoice Number:{if $domain_supplemental_address_2 }{$domain_supplemental_address_2}{/if} + {if $domain_state }{$domain_state}{/if}
{$supplemental_address_2} {$stateProvinceAbbreviation}{$supplemental_address_2} {$stateProvinceAbbreviation} {$invoice_id}{$invoice_id}{if $domain_city} + {$domain_city} + {/if} + {if $domain_postal_code } + {$domain_postal_code} + {/if} +
{$city} {$postal_code}{$city} {$postal_code} Reference:Reference: {if $domain_country} + {$domain_country} + {/if}
{$title}{$source} {if $domain_phone}{$domain_phone}{/if}
{if $domain_email} + {$domain_email} + {/if}
- - +
{* FIXME: style this table so that it looks like the text version (justification, etc.) *} @@ -68,9 +87,9 @@ {foreach from=$lineItem item=value key=priceset name=taxpricevalue} {if $smarty.foreach.taxpricevalue.index eq 0} - + {else} - + {/if} {if $value.tax_amount != ''} - {else} - + {else} + {/if} - {/foreach} + {/foreach} - + {foreach from = $dataArray item = value key = priceset} {if $priceset} - + - {elseif $priceset == 0} - - + {elseif $priceset == 0} + + {/if} {/foreach} @@ -111,22 +130,20 @@ - + {if $is_pay_later == 0} - - - + - + {/if} + @@ -135,40 +152,41 @@ - - - - - + + {/if}


- - - - + +




@@ -80,27 +99,27 @@ {$value.unit_price|crmMoney:$currency} {$value.tax_rate}%No {$taxTerm}No {$taxTerm}{$value.subTotal|crmMoney:$currency}

Sub TotalSub Total {$subTotal|crmMoney:$currency}
TOTAL {$taxTerm} {$priceset}% TOTAL {$taxTerm} {$priceset}% {$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency}
TOTAL {$defaultCurrency}TOTAL {$defaultCurrency} {$amount|crmMoney:$currency}
- {if $contribution_status_id == $refundedStatusId} + + {if $contribution_status_id == $refundedStatusId} LESS Amount Credited - {else} + {else} LESS Amount Paid - {/if} - {$amount|crmMoney:$currency}
AMOUNT DUE: {$amountDue|crmMoney:$currency}AMOUNT DUE: {$amountDue|crmMoney:$currency}
DUE DATE: {$dueDate}
DUE DATE: {$dueDate}
-
- +
- -
PAYMENT ADVICE

To: - {$organization_name}

{$notes} +
PAYMENT ADVICE

To:
+ {$domain_organization}
+ {$domain_street_address} {$domain_supplemental_address_1}
+ {$domain_supplemental_address_2} {$domain_state}
+ {$domain_city} {$domain_postal_code}
+ {$domain_country}
+ {$domain_phone}
+ {$domain_email}
+


{$notes}
- +
+ @@ -208,59 +226,87 @@ {if $contribution_status_id == $refundedStatusId} -
Customer:
+
- +
-

+ - - - - - + + - - - - + + {if $organization_name} - + {else} - + {/if} - + + - - - - - + + + + - + - + + - + - + + - + + + + + + + +
CREDIT NOTE
CREDIT NOTE Date:{$organization_name}Date:{$domain_organization}
{$display_name} ({$organization_name}){$display_name} ({$organization_name}){$display_name}{$display_name}{$invoice_date}{$invoice_date} + {if $domain_street_address } + {$domain_street_address} + {/if} + {if $domain_supplemental_address_1 } + {$domain_supplemental_address_1} + {/if}
{$street_address} {$supplemental_address_1}Credit Note Number:{$street_address} {$supplemental_address_1}Credit Note Number:{if $domain_supplemental_address_2 } + {$domain_supplemental_address_2} + {/if} + {if $domain_state } + {$domain_state} + {/if} +
{$supplemental_address_2} {$stateProvinceAbbreviation}{$supplemental_address_2} {$stateProvinceAbbreviation} {$creditnote_id}{$creditnote_id}{if $domain_city} + {$domain_city} + {/if} + {if $domain_postal_code } + {$domain_postal_code} + {/if} +
{$city} {$postal_code}{$city} {$postal_code} Reference:Reference: {if $domain_country} + {$domain_country} + {/if}
{$title}{$source} {if $domain_phone} + {$domain_phone} + {/if}
{if $domain_email} + {$domain_email} + {/if}
- +
{* FIXME: style this table so that it looks like the text version (justification, etc.) *} @@ -285,10 +331,10 @@ {if $value.tax_amount != ''} - {else} - + {else} + {/if} - + {/foreach} @@ -303,9 +349,9 @@ {if $priceset} - {elseif $priceset == 0} - - + {elseif $priceset == 0} + + {/if} {/foreach} @@ -322,10 +368,8 @@ {if $is_pay_later == 0} - - - - + + @@ -333,11 +377,9 @@ - - - - - + + + {/if} @@ -346,9 +388,7 @@ - - - +
{$value.unit_price|crmMoney:$currency} {$value.tax_rate}%No {$taxTerm}No {$taxTerm}{$value.subTotal|crmMoney:$currency}{$value.subTotal|crmMoney:$currency}

TOTAL {$taxTerm} {$priceset}% {$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency}
LESS Credit to invoice(s)LESS Credit to invoice(s) {$amount|crmMoney:$currency}

REMAINING CREDIT{$amountDue|crmMoney:$currency}REMAINING CREDIT{$amountDue|crmMoney:$currency}
@@ -362,13 +402,12 @@
- - +
- -
CREDIT ADVICE

Please do not pay on this advice. Deduct the amount of this Credit Note -from your next payment to us

{$notes}
- + +
CREDIT ADVICE

Please do not pay on this advice. Deduct the amount of this Credit Note +from your next payment to us

+ diff --git a/xml/templates/message_templates/contribution_invoice_receipt_html.tpl b/xml/templates/message_templates/contribution_invoice_receipt_html.tpl index f1ee2a2a8c..c7f70bdb4b 100644 --- a/xml/templates/message_templates/contribution_invoice_receipt_html.tpl +++ b/xml/templates/message_templates/contribution_invoice_receipt_html.tpl @@ -5,57 +5,76 @@ -
Customer:
+
- +
-

- - - + - - - - + + {if $organization_name} - - {else} - + + {else} + {/if} - + + - + - - + + - + - + + - + - + + - + + + + + + + +
TAX INVOICETAX INVOICE Invoice Date:{$organization_name}Invoice Date:{$domain_organization}
{$display_name} ({$organization_name}){$display_name}{$display_name} ({$organization_name}){$display_name}{$invoice_date}{$invoice_date} + {if $domain_street_address } + {$domain_street_address} + {/if} + {if $domain_supplemental_address_1 }{$domain_supplemental_address_1}{/if}
{$street_address} {$supplemental_address_1}{$street_address} {$supplemental_address_1} Incoice Number:Incoice Number:{if $domain_supplemental_address_2 }{$domain_supplemental_address_2}{/if} + {if $domain_state }{$domain_state}{/if}
{$supplemental_address_2} {$stateProvinceAbbreviation}{$supplemental_address_2} {$stateProvinceAbbreviation} {$invoice_id}{$invoice_id}{if $domain_city} + {$domain_city} + {/if} + {if $domain_postal_code } + {$domain_postal_code} + {/if} +
{$city} {$postal_code}{$city} {$postal_code} Reference:Reference: {if $domain_country} + {$domain_country} + {/if}
{$title}{$source} {if $domain_phone}{$domain_phone}{/if}
{if $domain_email} + {$domain_email} + {/if}
- - +
{* FIXME: style this table so that it looks like the text version (justification, etc.) *} @@ -68,9 +87,9 @@ {foreach from=$lineItem item=value key=priceset name=taxpricevalue} {if $smarty.foreach.taxpricevalue.index eq 0} - + {else} - + {/if} {if $value.tax_amount != ''} - {else} - + {else} + {/if} - {/foreach} + {/foreach} - + {foreach from = $dataArray item = value key = priceset} {if $priceset} - + - {elseif $priceset == 0} - - + {elseif $priceset == 0} + + {/if} {/foreach} @@ -111,22 +130,20 @@ - + {if $is_pay_later == 0} - - - + - + {/if} + @@ -135,40 +152,41 @@ - - - - - + + {/if}


- - - - + +




@@ -80,27 +99,27 @@ {$value.unit_price|crmMoney:$currency} {$value.tax_rate}%No {$taxTerm}No {$taxTerm}{$value.subTotal|crmMoney:$currency}

Sub TotalSub Total {$subTotal|crmMoney:$currency}
TOTAL {$taxTerm} {$priceset}% TOTAL {$taxTerm} {$priceset}% {$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency}
TOTAL {$defaultCurrency}TOTAL {$defaultCurrency} {$amount|crmMoney:$currency}
- {if $contribution_status_id == $refundedStatusId} + + {if $contribution_status_id == $refundedStatusId} LESS Amount Credited - {else} + {else} LESS Amount Paid - {/if} - {$amount|crmMoney:$currency}
AMOUNT DUE: {$amountDue|crmMoney:$currency}AMOUNT DUE: {$amountDue|crmMoney:$currency}
DUE DATE: {$dueDate}
DUE DATE: {$dueDate}
-
- +
- -
PAYMENT ADVICE

To: - {$organization_name}

{$notes} +
PAYMENT ADVICE

To:
+ {$domain_organization}
+ {$domain_street_address} {$domain_supplemental_address_1}
+ {$domain_supplemental_address_2} {$domain_state}
+ {$domain_city} {$domain_postal_code}
+ {$domain_country}
+ {$domain_phone}
+ {$domain_email}
+


{$notes}
- +
+ @@ -208,59 +226,87 @@ {if $contribution_status_id == $refundedStatusId} -
Customer:
+
- +
-

+ - - - - - + + - - - - + + {if $organization_name} - + {else} - + {/if} - + + - - - - - + + + + - + - + + - + - + + - + + + + + + + +
CREDIT NOTE
CREDIT NOTE Date:{$organization_name}Date:{$domain_organization}
{$display_name} ({$organization_name}){$display_name} ({$organization_name}){$display_name}{$display_name}{$invoice_date}{$invoice_date} + {if $domain_street_address } + {$domain_street_address} + {/if} + {if $domain_supplemental_address_1 } + {$domain_supplemental_address_1} + {/if}
{$street_address} {$supplemental_address_1}Credit Note Number:{$street_address} {$supplemental_address_1}Credit Note Number:{if $domain_supplemental_address_2 } + {$domain_supplemental_address_2} + {/if} + {if $domain_state } + {$domain_state} + {/if} +
{$supplemental_address_2} {$stateProvinceAbbreviation}{$supplemental_address_2} {$stateProvinceAbbreviation} {$creditnote_id}{$creditnote_id}{if $domain_city} + {$domain_city} + {/if} + {if $domain_postal_code } + {$domain_postal_code} + {/if} +
{$city} {$postal_code}{$city} {$postal_code} Reference:Reference: {if $domain_country} + {$domain_country} + {/if}
{$title}{$source} {if $domain_phone} + {$domain_phone} + {/if}
{if $domain_email} + {$domain_email} + {/if}
- +
{* FIXME: style this table so that it looks like the text version (justification, etc.) *} @@ -285,10 +331,10 @@ {if $value.tax_amount != ''} - {else} - + {else} + {/if} - + {/foreach} @@ -303,9 +349,9 @@ {if $priceset} - {elseif $priceset == 0} - - + {elseif $priceset == 0} + + {/if} {/foreach} @@ -322,10 +368,8 @@ {if $is_pay_later == 0} - - - - + + @@ -333,11 +377,9 @@ - - - - - + + + {/if} @@ -346,9 +388,7 @@ - - - +
{$value.unit_price|crmMoney:$currency} {$value.tax_rate}%No {$taxTerm}No {$taxTerm}{$value.subTotal|crmMoney:$currency}{$value.subTotal|crmMoney:$currency}

TOTAL {$taxTerm} {$priceset}% {$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency} TOTAL NO {$taxTerm}{$value|crmMoney:$currency}
LESS Credit to invoice(s)LESS Credit to invoice(s) {$amount|crmMoney:$currency}

REMAINING CREDIT{$amountDue|crmMoney:$currency}REMAINING CREDIT{$amountDue|crmMoney:$currency}
@@ -362,13 +402,12 @@
- - +
- -
CREDIT ADVICE

Please do not pay on this advice. Deduct the amount of this Credit Note -from your next payment to us

{$notes}
- + +
CREDIT ADVICE

Please do not pay on this advice. Deduct the amount of this Credit Note +from your next payment to us

+ -- 2.25.1
Customer: