Commit ac6b7883 authored by Stan Dragnev's avatar Stan Dragnev

Cheque issue fixes; #46 #47

parent 51721385
......@@ -175,7 +175,7 @@ class CRM_Grant_BAO_GrantProgram extends CRM_Grant_DAO_GrantProgram {
}
public function getAddress($id, $locationTypeID = NULL) {
public function getAddress($id, $locationTypeID = NULL, $twoLines = false) {
$sql = "
SELECT civicrm_contact.id as contact_id,
civicrm_address.street_address as street_address,
......@@ -207,18 +207,33 @@ WHERE civicrm_contact.id = $id ";
$config = CRM_Core_Config::singleton();
while ($dao->fetch()) {
$address = '';
CRM_Utils_String::append(
$address, ', ',
array(
$dao->street_address,
$dao->supplemental_address_1,
$dao->supplemental_address_2,
$dao->city,
$dao->state,
$dao->postal_code,
$dao->country
)
);
if ($twoLines) {
CRM_Utils_String::append(
$address, ' ',
array(
$dao->street_address,
$dao->supplemental_address_1,
$dao->supplemental_address_2,
'<br />',
$dao->city,
$dao->state,
$dao->postal_code
)
);
} else {
CRM_Utils_String::append(
$address, ', ',
array(
$dao->street_address,
$dao->supplemental_address_1,
$dao->supplemental_address_2,
$dao->city,
$dao->state,
$dao->postal_code,
$dao->country
)
);
}
$location['address'] = addslashes($address);
}
return $location;
......
......@@ -179,11 +179,11 @@ class CRM_Grant_Form_Task_GrantPayment extends CRM_Core_Form
while( $dao->fetch() ) {
if ( !empty( $payment_details[$dao->id] ) ) {
$payment_details[$dao->id] .= '</td></tr><tr><td width="15%" >'.date("Y-m-d", strtotime($values['payment_date'])).'</td><td width="15%" >'.$dao->grant_id.'</td><td width="50%" >'.CRM_Grant_BAO_GrantProgram::getDisplayName( $dao->id ).'</td><td width="20%" >CAD :'.CRM_Utils_Money::format( $dao->total_amount,null, null,false );
$payment_details[$dao->id] .= '</td></tr><tr><td width="15%" >'.date("Y-m-d", strtotime($values['payment_date'])).'</td><td width="15%" >'.$dao->grant_id.'</td><td width="50%" >'.CRM_Grant_BAO_GrantProgram::getDisplayName( $dao->id ).'</td><td width="20%" >'.CRM_Utils_Money::format( $dao->total_amount,null, null,false );
} else {
$payment_details[$dao->id] = date("Y-m-d", strtotime($values['payment_date'])).'</td><td width="15%" >'.$dao->grant_id.'</td><td width="50%" >'.CRM_Grant_BAO_GrantProgram::getDisplayName( $dao->id ).'</td><td width="20%" >CAD :'.CRM_Utils_Money::format( $dao->total_amount,null, null,false );
$payment_details[$dao->id] = date("Y-m-d", strtotime($values['payment_date'])).'</td><td width="15%" >'.$dao->grant_id.'</td><td width="50%" >'.CRM_Grant_BAO_GrantProgram::getDisplayName( $dao->id ).'</td><td width="20%" >'.CRM_Utils_Money::format( $dao->total_amount,null, null,false );
}
if ( !empty( $details[$dao->id]['total_amount'] ) ) {
......@@ -223,7 +223,8 @@ class CRM_Grant_Form_Task_GrantPayment extends CRM_Core_Form
$grantPayment[$id]['payment_date' ] = date("Y-m-d", strtotime($values['payment_date']));
$grantPayment[$id]['payment_created_date'] = date('Y-m-d');
$grantPayment[$id]['payable_to_name' ] = CRM_Grant_BAO_GrantProgram::getDisplayName( $id );
$grantPayment[$id]['payable_to_address' ] = CRM_Utils_Array::value( 'address', CRM_Grant_BAO_GrantProgram::getAddress( $id ) );
$grantPayment[$id]['payable_to_address' ] =
CRM_Utils_Array::value('address', CRM_Grant_BAO_GrantProgram::getAddress($id, NULL, true));
$grantPayment[$id]['amount' ] = $details[$id]['total_amount'];
$grantPayment[$id]['currency' ] = $details[$id]['currency'];
$grantPayment[$id]['payment_status_id' ] = 1;
......
......@@ -4,59 +4,66 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
{foreach from=$grantPayment key=key item=data}
{foreach from=$grantPayment key=key item=data}
<body >
<div style="height:140px" >
<div style="float:right; text-align:right; margin-top:-40px;">{$data.payment_id}</div>
<table width="100%" cellpadding=0 cellspacing=0 ; style="margin-top:40px;">
<tr>
<td width="85%"></td><td width="15%" style="float:right; text-align:right;">{$data.payment_date}</td>
</tr>
<tr>
<td width="85%">{$data.total_in_words}</td><td width="15%" style="float:right; text-align:right;">{$data.amount|crmMoney:$data.currency}</td>
</tr>
</table>
</div>
<div style="height:60px" >
<table width="100%" cellpadding=0 cellspacing=0 ;">
<tr>
<td width="100%">{$data.payable_to_name}</td>
</tr>
<tr>
<td width="100%">{$data.payable_to_address}</td>
<!-- Stub 1 -->
<div style="height:300px; font-size: 11px;">
<div style="float:right; text-align:right;">{$data.payment_id}</div>
<table width="100%" cellpadding=0 cellspacing=0 style="font-size: 11px;">
<tr><td width="100%" colspan="4">RE: {$data.payment_reason}</td></tr>
<tr><td width="15%">Payment Date</td>
<td width="15%">Grant ID</td><td width="50%">Payee</td>
<td width="20%">Amount</td>
</tr>
<tr><td width="15%">{$data.payment_details}</td> </tr>
<tr>
<td width="15%"></td><td width="15%"></td><td width="50%" style="text-align:right;">Total Amount&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="15%">{$data.amount|crmMoney:$data.currency}</td>
</tr>
</table>
</div>
</div>
<!-- Cheque portion -->
<div style="height:100px" >
<table width="100%" cellpadding=0 cellspacing=0 ;>
<tr>
<td width="100%">RE: {$data.payment_reason}</td>
<table width="100%" cellpadding=0 cellspacing=0>
<tr style="height: 50px;">
<td width="85%"></td>
<td width="15%" style="text-align:right; vertical-align: top;">{$data.payment_date|date_format:"%d-%m-%Y"}</td>
</tr>
<tr style="height: 50px;">
<!-- Total in words and amount not quite aligned on cheque so... we HACK -->
<td width="85%;" style="padding-bottom: 18px;">{$data.total_in_words}</td>
<td width="15%" style="text-align:right; vertical-align: top;">{$data.amount|string_format:"%.2f"}</td>
</tr>
</table>
</div>
<div style="height:300px" >
<div style="float:right; text-align:right;">{$data.payment_id}</div>
<table width="100%" cellpadding=0 cellspacing=0 >
<tr><td width="100%" colspan="4">RE: {$data.payment_reason}</td></tr>
<tr><td width="15%">Payment Date</td><td width="15%">Grant ID</td><td width="50%">Payee</td><td width="20%">Amount</td></tr>
<tr><td width="15%">{$data.payment_details}</td> </tr>
</div>
<div style="height:260px" >
<table width="100%" cellpadding=0 cellspacing=0>
<tr>
<td width="15%"></td><td width="15%%"></td><td width="50%" style="text-align:right;" >Total Amount&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="15%" >CAD: {$data.amount|crmMoney:$data.currency}</td>
<td width="100%">{$data.payable_to_name}</td>
</tr>
</table>
</div>
<div style="height:265px" >
<div style="float:right; text-align:right;"> {$data.payment_id} </div>
<table width="100%" cellpadding=0 cellspacing=0 >
<tr>
<td width="100%">{$data.payable_to_address}</td>
</tr>
</table>
</div>
<!-- Stub 2 -->
<div style="page-break-after: always; font-size: 10px;" >
<div style="float:right; text-align:right;"> {$data.payment_id} </div>
<table width="100%" cellpadding=0 cellspacing=0 style="font-size: 11px;">
<tr><td width="100%" colspan="4">RE: {$data.payment_reason}</td></tr>
<tr><td width="15%">Payment Date</td><td width="15%">Grant ID</td><td width="50%">Payee</td><td width="20%">Amount</td></tr>
<tr><td width="15%">Payment Date</td><td width="15%">Grant ID</td><td width="50%">Payee</td>
<td width="20%">Amount</td></tr>
<tr><td width="15%">{$data.payment_details}</td>
</tr>
<tr>
<td width="15%"></td><td width="15%%"></td><td width="50%" style="text-align:right; ">Total Amount&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="20%" >CAD: {$data.amount|crmMoney:$data.currency}</td>
<td width="15%"></td><td width="15%"></td>
<td width="50%" style="text-align:right; ">Total Amount&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td width="20%">{$data.amount|crmMoney:$data.currency}</td>
</tr>
</table>
</div>
</div>
</body>
{/foreach}
</html>
\ No newline at end of file
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