From 56ed0b01e5dcee044e08d89ce467a10859bf7dec Mon Sep 17 00:00:00 2001 From: Parag Bhilkar Date: Thu, 26 Jun 2014 20:29:23 +0530 Subject: [PATCH 1/2] VAT-416 Added display option for button on display preferences page. Populate the download option on click of Print Invoice button. --- CRM/Contact/Page/View/UserDashBoard.php | 3 +++ CRM/Contribute/xml/Menu/Contribute.xml | 18 +++++++++++++ CRM/Financial/Page/AJAX.php | 12 +++++++++ css/civicrm.css | 18 +++++++++++++ .../CRM/Contribute/Form/ContributionView.tpl | 26 +++++++++++++++++++ .../CRM/Contribute/Page/UserDashboard.tpl | 17 ++++++++++++ xml/templates/civicrm_data.tpl | 4 +++ 7 files changed, 98 insertions(+) diff --git a/CRM/Contact/Page/View/UserDashBoard.php b/CRM/Contact/Page/View/UserDashBoard.php index 135e70ddb167..d749af8e6161 100644 --- a/CRM/Contact/Page/View/UserDashBoard.php +++ b/CRM/Contact/Page/View/UserDashBoard.php @@ -185,6 +185,9 @@ function buildUserDashBoard() { usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc')); $this->assign('dashboardElements', $dashboardElements); + // return true when 'Invoices / Credit Notes' checkbox is checked + $this->assign('invoices', $this->_userOptions['Invoices / Credit Notes']); + if (!empty($this->_userOptions['Groups'])) { $this->assign('showGroup', TRUE); //build group selector diff --git a/CRM/Contribute/xml/Menu/Contribute.xml b/CRM/Contribute/xml/Menu/Contribute.xml index eb4550badc2f..9dc6a30d15b6 100644 --- a/CRM/Contribute/xml/Menu/Contribute.xml +++ b/CRM/Contribute/xml/Menu/Contribute.xml @@ -300,4 +300,22 @@ access CiviContribute,administer CiviCRM CiviContribute + + civicrm/contribute/invoice + CiviContributePdf + CRM_Financial_Page_AJAX::getPrintPDF + access CiviContribute + 1 + 620 + CiviContribute + + + civicrm/contribute/invoice/email + CiviContributePdf + CRM_Contribute_Form_Task_Invoice + access CiviContribute + 1 + 630 + CiviContribute + diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index c1777b80de24..4ee56a744d12 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -507,4 +507,16 @@ static function getBatchSummary() { echo json_encode($batchSummary); CRM_Utils_System::civiExit(); } + + /** + * Callback to perform action on Print Invoice button. + */ + static function getPrintPDF() { + + $contribIDs = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); + $contributionIDs = array('0' => $contribIDs); + $contactIds = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); + $params = array('output' => 'pdf_invoice'); + CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs , $params, $contactIds); + } } diff --git a/css/civicrm.css b/css/civicrm.css index fa558723e69e..25dbe5f28463 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -4672,3 +4672,21 @@ span.crm-status-icon { .crm-container .survey-completed { text-decoration: line-through; } + +.crm-printButton { + padding-left: 469px; +} + +.crm-invoiceButton { + text-shadow: 0 1px 0 black; + background: #70716B url(../i/crm-button-bg.gif) repeat-x top left; + color: #FFFFFF !important; + font-size: 13px; + font-weight: normal; + margin-right: 16px; + padding: 2px 6px; + text-decoration: none; + cursor: pointer; + border: 1px solid #3e3e3e; + border-radius: 3px 3px 3px 3px; +} \ No newline at end of file diff --git a/templates/CRM/Contribute/Form/ContributionView.tpl b/templates/CRM/Contribute/Form/ContributionView.tpl index d13cf73fb3e0..d6f32ccf6b6d 100644 --- a/templates/CRM/Contribute/Form/ContributionView.tpl +++ b/templates/CRM/Contribute/Form/ContributionView.tpl @@ -47,6 +47,17 @@ {/if} {include file="CRM/common/formButtons.tpl" location="top"} + {assign var='emailUrlParams' value="reset=1&id=$id&cid=$contact_id&select=email"} + {assign var='invoiceUrlParams' value="reset=1&id=$id&cid=$contact_id"} + {if $contribution_status != 'Refunded'} +
+ {ts}Print Invoice{/ts} + + {ts}Email Invoice{/ts}
+ {else} +
+ {ts}Print invoice and Credit note{/ts}
+ {/if} @@ -81,6 +92,12 @@ {/if} + {if $tax_amount} + + + + + {/if} {if $non_deductible_amount} @@ -306,5 +323,14 @@ class="icon delete-icon">{ts}Delete{/ts} {/if} {include file="CRM/common/formButtons.tpl" location="bottom"} + {if $contribution_status != 'Refunded'} +
+ {ts}Print Invoice{/ts} + + {ts}Email Invoice{/ts}
+ {else} +
+ {ts}Print invoice and Credit note{/ts}
+ {/if} diff --git a/templates/CRM/Contribute/Page/UserDashboard.tpl b/templates/CRM/Contribute/Page/UserDashboard.tpl index c1841e8ab25a..76e488059d5b 100644 --- a/templates/CRM/Contribute/Page/UserDashboard.tpl +++ b/templates/CRM/Contribute/Page/UserDashboard.tpl @@ -34,6 +34,9 @@ + {if $invoices} + + {/if} {foreach from=$contribute_rows item=row} @@ -47,6 +50,20 @@ + {if $invoices} + + {/if} {/foreach}
{ts}Total Tax Amount{/ts}{$tax_amount|crmMoney:$currency}
{ts}Non-deductible Amount{/ts} {ts}Received date{/ts} {ts}Receipt Sent{/ts} {ts}Status{/ts}
{$row.receive_date|truncate:10:''|crmDate} {$row.receipt_date|truncate:10:''|crmDate} {$row.contribution_status} + {assign var='id' value=$row.contribution_id} + {assign var='contact_id' value=$row.contact_id} + {assign var='urlParams' value="reset=1&id=$id&cid=$contact_id"} + + {if $row.contribution_status != 'Refunded'} + {ts}Print Invoice{/ts} + {else} + {ts}Print Credit Note{/ts} + {/if} + +
diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 0d2c57dec0d9..100e157fe380 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -369,6 +369,9 @@ VALUES -- for selection changes (@option_group_id_act, '{ts escape="sql"}Change Registration{/ts}', 48, 'Change Registration', NULL, 1, NULL, 48, '{ts escape="sql"}Changes to an existing event registration.{/ts}', 0, 1, 1, @eventCompId, NULL), + -- for Print or Email Contribution Invoices + (@option_group_id_act, '{ts escape="sql"}Downloaded Invoice{/ts}', 49, 'Downloaded Invoice', NULL, 1, NULL, 49, '{ts escape="sql"}Downloaded Invoice.{/ts}',0, 1, 1, NULL, NULL), + (@option_group_id_act, '{ts escape="sql"}Emailed Invoice{/ts}', 50, 'Emailed Invoice', NULL, 1, NULL, 50, '{ts escape="sql"}Emailed Invoice.{/ts}',0, 1, 1, NULL, NULL), (@option_group_id_gender, '{ts escape="sql"}Female{/ts}', 1, 'Female', NULL, 0, NULL, 1, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_gender, '{ts escape="sql"}Male{/ts}', 2, 'Male', NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL), @@ -507,6 +510,7 @@ VALUES (@option_group_id_udOpt, '{ts escape="sql"}Pledges{/ts}' , 7, 'CiviPledge', NULL, 0, NULL, 7, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_udOpt, '{ts escape="sql"}Personal Campaign Pages{/ts}' , 8, 'PCP', NULL, 0, NULL, 8, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_udOpt, '{ts escape="sql"}Assigned Activities{/ts}' , 9, 'Assigned Activities', NULL, 0, NULL, 9, NULL, 0, 0, 1, NULL, NULL), + (@option_group_id_udOpt, '{ts escape="sql"}Invoices / Credit Notes{/ts}' , 10, 'Invoices / Credit Notes', NULL, 0, NULL, 10, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_acsOpt, '{ts escape="sql"}Email Address{/ts}' , 2, 'email' , NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL), (@option_group_id_acsOpt, '{ts escape="sql"}Phone{/ts}' , 3, 'phone' , NULL, 0, NULL, 3, NULL, 0, 0, 1, NULL, NULL), From 316c9cd0b960704edb0c96aa9f0e9679e7da7b49 Mon Sep 17 00:00:00 2001 From: Parag Bhilkar Date: Tue, 1 Jul 2014 16:11:06 +0530 Subject: [PATCH 2/2] VAT-416 Remove extra used variables. --- CRM/Financial/Page/AJAX.php | 2 +- templates/CRM/Contribute/Page/UserDashboard.tpl | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 4ee56a744d12..ee1c0241c3bf 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -514,7 +514,7 @@ static function getBatchSummary() { static function getPrintPDF() { $contribIDs = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); - $contributionIDs = array('0' => $contribIDs); + $contributionIDs = array($contribIDs); $contactIds = CRM_Utils_Request::retrieve('cid', 'Positive', $this, FALSE); $params = array('output' => 'pdf_invoice'); CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs , $params, $contactIds); diff --git a/templates/CRM/Contribute/Page/UserDashboard.tpl b/templates/CRM/Contribute/Page/UserDashboard.tpl index 76e488059d5b..04ee6b6e4f1b 100644 --- a/templates/CRM/Contribute/Page/UserDashboard.tpl +++ b/templates/CRM/Contribute/Page/UserDashboard.tpl @@ -52,9 +52,7 @@ {$row.contribution_status} {if $invoices} - {assign var='id' value=$row.contribution_id} - {assign var='contact_id' value=$row.contact_id} - {assign var='urlParams' value="reset=1&id=$id&cid=$contact_id"} + {assign var='urlParams' value="reset=1&id=$row.contribution_id&cid=$row.contact_id"} {if $row.contribution_status != 'Refunded'} {ts}Print Invoice{/ts}