Commit c4825c57 authored by Monish Deb's avatar Monish Deb

Refactored 'Reprint grant payment' task form

parent 8ce39eb9
...@@ -37,8 +37,9 @@ ...@@ -37,8 +37,9 @@
class CRM_Grant_BAO_GrantPayment extends CRM_Grant_DAO_GrantPayment { class CRM_Grant_BAO_GrantPayment extends CRM_Grant_DAO_GrantPayment {
const const
STOP = 1, STOP = 100,
REPRINT = 2; REPRINT = 200,
WITHDRAW = 300;
/** /**
* static field for all the grant information that we can potentially export * static field for all the grant information that we can potentially export
* @var array * @var array
......
This diff is collapsed.
...@@ -236,20 +236,24 @@ class CRM_Grant_Form_PaymentSearch extends CRM_Core_Form { ...@@ -236,20 +236,24 @@ class CRM_Grant_Form_PaymentSearch extends CRM_Core_Form {
$this->add('select', 'payment_status_id', ts('Status'), $this->add('select', 'payment_status_id', ts('Status'),
array('' => ts('- select -')) + $paymentStatus); array('' => ts('- select -')) + $paymentStatus);
$this->addElement('text', 'payment_batch_number', ts('Batch Number'), array('size' => 8, 'maxlength' => 8)); $this->add('select', 'payment_batch_number',
ts('Batch'),
// CRM-19325
['' => ts('None')] + CRM_Contribute_PseudoConstant::batch(),
FALSE, array('class' => 'crm-select2')
);
$this->addElement('text', 'payment_number', ts('Payment Number'), array('size' => 10, 'maxlength' => 10)); $this->addElement('text', 'payment_number', ts('Payment Number'), array('size' => 10, 'maxlength' => 10));
$this->addDate('payment_created_date_low', ts('From'), FALSE, array('formatType' => 'searchDate')); CRM_Core_Form_Date::buildDateRange($this, 'payment_created_date', 1, '_low', '_high', ts('From:'), FALSE);
$this->addDate('payment_created_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
$this->addElement('text', 'payable_to_name', ts('Payee name'), CRM_Core_DAO::getAttribute('CRM_Grant_DAO_GrantPayment', 'payable_to_name')); $this->addElement('text', 'payable_to_name', ts('Payee name'), CRM_Core_DAO::getAttribute('CRM_Grant_DAO_GrantPayment', 'payable_to_name'));
$this->add('text', 'amount', ts('Amount'), array('size' => 8, 'maxlength' => 8)); $this->add('text', 'amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
/* $this->addRule('amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money');
* add form checkboxes for each row. This is needed out here to conform to QF protocol
* of all elements being declared in builQuickForm $this->add('text', 'amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
*/ $this->addRule('amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money');
$rows = $this->get('rows'); $rows = $this->get('rows');
...@@ -339,7 +343,7 @@ class CRM_Grant_Form_PaymentSearch extends CRM_Core_Form { ...@@ -339,7 +343,7 @@ class CRM_Grant_Form_PaymentSearch extends CRM_Core_Form {
if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) { if ($buttonName == $this->_actionButtonName || $buttonName == $this->_printButtonName) {
// check actionName and if next, then do not repeat a search, since we are going to the next page // check actionName and if next, then do not repeat a search, since we are going to the next page
// hack, make sure we reset the task values // hack, make sure we reset the task values
$stateMachine =& $this->controller->getStateMachine(); $stateMachine = $this->controller->getStateMachine();
$formName = $stateMachine->getTaskFormName(); $formName = $stateMachine->getTaskFormName();
$this->controller->resetPage($formName); $this->controller->resetPage($formName);
return; return;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
/** /**
* This class generates task actions for CiviEvent * This class generates task actions for CiviEvent
* *
*/ */
class CRM_Grant_Form_PaymentTask extends CRM_Core_Form { class CRM_Grant_Form_PaymentTask extends CRM_Core_Form {
/** /**
...@@ -80,7 +80,7 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form { ...@@ -80,7 +80,7 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form {
static function preProcessCommon(&$form, $useTable = FALSE) { static function preProcessCommon(&$form, $useTable = FALSE) {
$form->_grantIds = array(); $form->_grantIds = array();
if (!CRM_Utils_Array::value('prid', $_GET )) { if (!CRM_Utils_Array::value('prid', $_GET )) {
$values = $form->controller->exportValues('PaymentSearch'); $values = $form->controller->exportValues('PaymentSearch');
} }
...@@ -97,18 +97,18 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form { ...@@ -97,18 +97,18 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form {
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN); $ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
} }
} }
} }
else { else {
$queryParams = $form->get('queryParams'); $queryParams = $form->get('queryParams');
$query = new CRM_Grant_BAO_PaymentSearch( $query = new CRM_Grant_BAO_PaymentSearch(
$queryParams, $queryParams,
NULL, NULL,
NULL, NULL,
FALSE, FALSE,
FALSE, FALSE,
CRM_Grant_BAO_PaymentSearch::MODE_GRANT_PAYMENT CRM_Grant_BAO_PaymentSearch::MODE_GRANT_PAYMENT
); );
$query->_distinctComponentClause = " civicrm_payment.id"; $query->_distinctComponentClause = " civicrm_payment.id";
$query->_groupByComponentClause = " GROUP BY civicrm_payment.id "; $query->_groupByComponentClause = " GROUP BY civicrm_payment.id ";
$result = $query->searchQuery(0, 0, NULL); $result = $query->searchQuery(0, 0, NULL);
...@@ -123,7 +123,7 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form { ...@@ -123,7 +123,7 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form {
implode(',', $ids) . ' ) '; implode(',', $ids) . ' ) ';
$form->assign('totalSelectedGrants', count($ids)); $form->assign('totalSelectedGrants', count($ids));
} }
$form->_grantPaymentIds = $form->_componentIds = $ids; $form->_grantPaymentIds = $form->_componentIds = $ids;
//set the context for redirection for any task actions //set the context for redirection for any task actions
...@@ -142,30 +142,8 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form { ...@@ -142,30 +142,8 @@ class CRM_Grant_Form_PaymentTask extends CRM_Core_Form {
*/ */
public function setContactIDs() { public function setContactIDs() {
$this->_contactIds =& CRM_Core_DAO::getContactIDsFromComponent($this->_grantIds, $this->_contactIds =& CRM_Core_DAO::getContactIDsFromComponent($this->_grantIds,
'civicrm_grant' 'civicrm_grant'
); );
} }
/**
* simple shell that derived classes can call to add buttons to
* the form with a customized title for the main Submit
*
* @param string $title title of the main button
* @param string $type button type for the form after processing
* @return void
* @access public
*/
function addDefaultButtons($title, $nextType = 'next', $backType = 'back') {
$this->addButtons(array(
array (
'type' => $nextType,
'name' => $title,
'isDefault' => TRUE),
array (
'type' => $backType,
'name' => ts('Back')),
)
);
}
} }
This diff is collapsed.
This diff is collapsed.
...@@ -148,7 +148,7 @@ class CRM_Grant_Selector_PaymentSearch extends CRM_Core_Selector_Base implements ...@@ -148,7 +148,7 @@ class CRM_Grant_Selector_PaymentSearch extends CRM_Core_Selector_Base implements
$context = 'search' $context = 'search'
) { ) {
// submitted form values // submitted form values
$this->_queryParams =& $queryParams; $this->_queryParams = $queryParams;
$this->_single = $single; $this->_single = $single;
...@@ -197,19 +197,19 @@ class CRM_Grant_Selector_PaymentSearch extends CRM_Core_Selector_Base implements ...@@ -197,19 +197,19 @@ class CRM_Grant_Selector_PaymentSearch extends CRM_Core_Selector_Base implements
'qs' => 'reset=1&id=%%id%%&action=view&context=%%cxt%%&selectedChild=grant' . $extraParams, 'qs' => 'reset=1&id=%%id%%&action=view&context=%%cxt%%&selectedChild=grant' . $extraParams,
'title' => ts('View Grant'), 'title' => ts('View Grant'),
), ),
121 => array( CRM_Grant_BAO_GrantPayment::STOP => array(
'name' => ts('Stop'), 'name' => ts('Stop'),
'url' => 'civicrm/grant/payment', 'url' => 'civicrm/grant/payment',
'qs' => 'reset=1&action=stop&id=%%id%%&context=%%cxt%%' . $extraParams, 'qs' => 'reset=1&action=stop&id=%%id%%&context=%%cxt%%' . $extraParams,
'title' => ts('Edit Grant'), 'title' => ts('Edit Grant'),
), ),
1212 => array( CRM_Grant_BAO_GrantPayment::REPRINT => array(
'name' => ts('Reprint'), 'name' => ts('Reprint'),
'url' => 'civicrm/grant/payment', 'url' => 'civicrm/grant/payment',
'qs' => 'reset=1&action=reprint&id=%%id%%&context=%%cxt%%' . $extraParams, 'qs' => 'reset=1&action=reprint&id=%%id%%&context=%%cxt%%' . $extraParams,
'title' => ts('Edit Grant'), 'title' => ts('Edit Grant'),
), ),
12121 => array( CRM_Grant_BAO_GrantPayment::WITHDRAW => array(
'name' => ts('Withdraw'), 'name' => ts('Withdraw'),
'url' => 'civicrm/grant/payment', 'url' => 'civicrm/grant/payment',
'qs' => 'reset=1&action=withdraw&id=%%id%%&context=%%cxt%%' . $extraParams, 'qs' => 'reset=1&action=withdraw&id=%%id%%&context=%%cxt%%' . $extraParams,
...@@ -377,7 +377,7 @@ class CRM_Grant_Selector_PaymentSearch extends CRM_Core_Selector_Base implements ...@@ -377,7 +377,7 @@ class CRM_Grant_Selector_PaymentSearch extends CRM_Core_Selector_Base implements
'direction' => CRM_Utils_Sort::DONTCARE, 'direction' => CRM_Utils_Sort::DONTCARE,
), ),
array( array(
'name' => ts('Check Number'), 'name' => ts('Payment Number'),
'sort' => 'payment_number', 'sort' => 'payment_number',
'direction' => CRM_Utils_Sort::DONTCARE, 'direction' => CRM_Utils_Sort::DONTCARE,
), ),
......
...@@ -48,18 +48,18 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine { ...@@ -48,18 +48,18 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine {
*/ */
function __construct($controller, $action = CRM_Core_Action::NONE) { function __construct($controller, $action = CRM_Core_Action::NONE) {
parent::__construct($controller, $action); parent::__construct($controller, $action);
$this->_pages = array(); $this->_pages = array();
$this->_pages['CRM_Grant_Form_PaymentSearch'] = NULL; $this->_pages['CRM_Grant_Form_PaymentSearch'] = NULL;
list($task, $result) = $this->taskName($controller, 'PaymentSearch'); list($task, $result) = $this->taskName($controller, 'PaymentSearch');
$this->_task = $task; $this->_task = $task;
if (is_array($task)) { if (is_array($task)) {
foreach ($task as $t) { foreach ($task as $t) {
$this->_pages[$t] = NULL; $this->_pages[$t] = NULL;
} }
} }
elseif (!empty($task)) { elseif (!empty($task)) {
$this->_pages[$task] = NULL; $this->_pages[$task] = NULL;
} }
...@@ -69,7 +69,7 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine { ...@@ -69,7 +69,7 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine {
} }
$this->addSequentialPages($this->_pages, $action); $this->addSequentialPages($this->_pages, $action);
} }
/** /**
* Determine the form name based on the action. This allows us * Determine the form name based on the action. This allows us
* to avoid using conditional state machine, much more efficient * to avoid using conditional state machine, much more efficient
...@@ -84,8 +84,8 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine { ...@@ -84,8 +84,8 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine {
// total hack, check POST vars and then session to determine stuff // total hack, check POST vars and then session to determine stuff
// fix value if print button is pressed // fix value if print button is pressed
if (CRM_Utils_Array::value( '_qf_' . $formName . '_next_print', $_POST)) { if (CRM_Utils_Array::value( '_qf_' . $formName . '_next_print', $_POST)) {
$value = CRM_Grant_Task::PRINT_GRANTS; $value = CRM_Grant_Task::TASK_PRINT;
} }
else { else {
$value = CRM_Utils_Array::value('task', $_POST); $value = CRM_Utils_Array::value('task', $_POST);
} }
...@@ -93,10 +93,10 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine { ...@@ -93,10 +93,10 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine {
$value = $this->_controller->get('task'); $value = $this->_controller->get('task');
} }
$this->_controller->set('task', $value); $this->_controller->set('task', $value);
return CRM_Grant_PaymentTask::getTask($value); return CRM_Grant_PaymentTask::getTask($value);
} }
/** /**
* return the form name of the task * return the form name of the task
* *
...@@ -107,4 +107,3 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine { ...@@ -107,4 +107,3 @@ class CRM_Grant_StateMachine_PaymentSearch extends CRM_Core_StateMachine {
return CRM_Utils_String::getClassName($this->_task); return CRM_Utils_String::getClassName($this->_task);
} }
} }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<div class="crm-block crm-form-block crm-search-form-block"> <div class="crm-block crm-form-block crm-search-form-block">
<div class="crm-accordion-wrapper crm-member_search_form-accordion {if $rows}crm-accordion-closed{else}crm-accordion-open{/if}"> <div class="crm-accordion-wrapper crm-member_search_form-accordion {if $rows}crm-accordion-closed{else}crm-accordion-open{/if}">
<div class="crm-accordion-header crm-master-accordion-header"> <div class="crm-accordion-header crm-master-accordion-header">
<div class="icon crm-accordion-pointer"></div> <div class="icon crm-accordion-pointer"></div>
{ts}Edit Search Criteria{/ts} {ts}Edit Search Criteria{/ts}
</div><!-- /.crm-accordion-header --> </div><!-- /.crm-accordion-header -->
<div class="crm-accordion-body"> <div class="crm-accordion-body">
...@@ -37,38 +37,44 @@ ...@@ -37,38 +37,44 @@
</div> </div>
<table class="form-layout"> <table class="form-layout">
<tr> <tr>
<td class="font-size12pt" colspan="4"> <td class="font-size12pt">
{$form.payable_to_name.label}&nbsp;&nbsp;{$form.payable_to_name.html|crmReplace:class:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}<br /> {$form.payable_to_name.label}&nbsp;&nbsp;{$form.payable_to_name.html}<br />
</td> </td>
<td>
{$form.payment_status_id.label}&nbsp;&nbsp;
{$form.payment_status_id.html}
</td>
<td>
<table>
<tr>
<td>
<label>{ts}Payment Created:{/ts}</label>
</td>
{include file="CRM/Core/DateRange.tpl" fieldName="payment_created_date" from='_low' to='_high'}
</tr>
</table>
</td>
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td >
{$form.payment_status_id.label}&nbsp;&nbsp;
{$form.payment_status_id.html}
</td>
<td colspan="2">
{$form.payment_batch_number.label}&nbsp;&nbsp; {$form.payment_batch_number.label}&nbsp;&nbsp;
{$form.payment_batch_number.html} {$form.payment_batch_number.html}
</td> </td>
<td colspan="2"> <td>
{$form.payment_number.label}&nbsp;&nbsp; {$form.payment_number.label}&nbsp;&nbsp;
{$form.payment_number.html} {$form.payment_number.html}
</td>
</tr>
<tr>
<td colspan="2">
{$form.payment_created_date_low.label}&nbsp;&nbsp;
{include file="CRM/common/jcalendar.tpl" elementName=payment_created_date_low}
</td>
<td colspan="2">
{$form.payment_created_date_high.label}&nbsp;&nbsp;
{include file="CRM/common/jcalendar.tpl" elementName=payment_created_date_high}
</td>
<td colspan="2">
{$form.amount.label}&nbsp;&nbsp;
{$form.amount.html}
</td> </td>
</tr> <td colspan="3">
{ts}Amounts{/ts}</label> <br />
{$form.amount_low.label}
{$form.amount_low.html} &nbsp;&nbsp;
{$form.amount_high.label}
{$form.amount_high.html}
</td>
</tr>
<tr>
<td colspan="2">{$form.buttons.html}</td>
</tr>
</table> </table>
{/strip} {/strip}
</div><!-- /.crm-accordion-body --> </div><!-- /.crm-accordion-body -->
...@@ -81,7 +87,7 @@ ...@@ -81,7 +87,7 @@
</div> </div>
{/if} {/if}
{if $rows} {if $rows}
{* Search request has returned 1 or more matching rows. Display results and collapse the search criteria fieldset. *} {* Search request has returned 1 or more matching rows. Display results and collapse the search criteria fieldset. *}
<div class="crm-results-block"> <div class="crm-results-block">
{* This section handles form elements for action task select and submit *} {* This section handles form elements for action task select and submit *}
<div class="crm-search-tasks"> <div class="crm-search-tasks">
...@@ -94,20 +100,8 @@ ...@@ -94,20 +100,8 @@
</div><!-- /.crm-results-block --> </div><!-- /.crm-results-block -->
{/if} {/if}
</div><!-- /.crm-content-block --> </div><!-- /.crm-content-block -->
{if $download}
<div id ="download">
<a href={$download} class="download" "style="text-decoration: none;" >Download</a>
</div>
{/if}
{literal}
<script type="text/javascript"> <script type="text/javascript">
var download = "{/literal}{$download}{literal}"; {* this function is called to change the color of selected row(s) *}
if ( download ) { var fname = "{$form.formName}";
cj("#download").hide(); on_load_init_checkboxes(fname);
window.location.href = cj(".download").attr('href');
}
cj(function() {
cj().crmAccordions();
});
</script> </script>
{/literal}
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
*} *}
{* this template is used for adding/editing/deleting financial type *} {* this template is used for adding/editing/deleting financial type *}
<h2>{ts}Pay Grants{/ts}</h2>
<div class="crm-block crm-form-block crm-contribution_type-form-block"> <div class="crm-block crm-form-block crm-contribution_type-form-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div> <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class="form-layout-compressed"> <table class="form-layout-compressed">
......
...@@ -24,39 +24,6 @@ ...@@ -24,39 +24,6 @@
+--------------------------------------------------------------------+ +--------------------------------------------------------------------+
*} *}
{* Confirmation of Grant pay *} {* Confirmation of Grant pay *}
{if $payments} {if $recordFound}
<h3>{ts}Reprint Payments{/ts}</h3> {include file="CRM/Grant/Form/Task/GrantPayment.tpl"}
<div class="crm-block crm-form-block crm-contribution_type-form-block">
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
<table class="form-layout-compressed">
<tr class="crm-grant_payment-form-block-contribution_type_id">
<td class="label">{$form.financial_type_id.label}</td>
<td class="html-adjust">{$form.financial_type_id.html}</td>
</tr>
<tr class="crm-grant_payment-form-block-payment_batch_number">
<td class="label">{$form.payment_batch_number.label}</td>
<td class="html-adjust">{$form.payment_batch_number.html}</td>
</tr>
<tr class="crm-grant_payment-form-block-payment_number">
<td class="label">{$form.payment_number.label}</td>
<td class="html-adjust">{$form.payment_number.html}</td>
</tr>
<tr class="crm-grant_payment-form-block-payment_date">
<td class="label">{$form.payment_date.label}</td>
<td>
{if $hideCalendar neq true}
{include file="CRM/common/jcalendar.tpl" elementName=payment_date}
{else}
{$form.payment_date.html|crmDate}
{/if}
</td>
</tr>
<tr class="crm-grant_payment-form-block-csv">
<td class="label">{$form.download_file.label}</td>
<td class="html-adjust">{$form.download_file.html}</td>
</tr>
</table>
</div>
{/if} {/if}
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="botttom"}</div>
\ No newline at end of file
...@@ -58,16 +58,11 @@ ...@@ -58,16 +58,11 @@
<tr> <tr>
<td colspan="2"> <td colspan="2">
{if $printButtonName}
{$form.$printButtonName.html} &nbsp; &nbsp;
{else}
{$form._qf_PaymentSearch_next_print.html} &nbsp; &nbsp;
{/if}
{$form.task.html} {$form.task.html}
{if $actionButtonName} {if $actionButtonName}
{$form.$actionButtonName.html} &nbsp; &nbsp; {$form.$actionButtonName.html} &nbsp; &nbsp;
{else} {else}
{$form._qf_PaymentSearch_next_action.html} {$form._qf_PaymentSearch_next_action.html}
{/if} {/if}
</td> </td>
</tr>{/if} </tr>{/if}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment