idh63
Posts: 76
|
| Posted: 01/20/2008, 9:36 AM |
|
Hi Folks,
I havent been using CCS for about 18 months.
I have been using Zend Studio to test the work of hired programmers and the debugging features have really helped me learn a lot more about PHP.
Anyway, I have been having a frustrating time creating a ledger report with a Credits | Debits | Running Total.
The name of the page is account_details
Having read the logic in account_details.php I see exactly where i could customize the code so I have the running balance displayed in the r_balance field in the row.
$is_next_record = $this->DataSource->next_record();
$this->IsEmpty = ! $is_next_record;
while($is_next_record) {
$this->DataSource->SetValues();
$this->ex_date->SetValue($this->DataSource->ex_date->GetValue());
$this->ttype->SetValue($this->DataSource->ttype->GetValue());
$this->status->SetValue($this->DataSource->status->GetValue());
$this->deposit->SetValue($this->DataSource->deposit->GetValue());
$this->withdraw->SetValue($this->DataSource->withdraw->GetValue());
$this->r_balance->SetValue($this->DataSource->r_balance->GetValue());
$this->req_date->SetValue($this->DataSource->req_date->GetValue());
$this->TotalSum_deposit->SetValue($this->DataSource->TotalSum_deposit->GetValue());
$this->TotalSum_withdraw->SetValue($this->DataSource->TotalSum_withdraw->GetValue());
$this->Current_balance->SetValue("");
if (count($Groups->Groups) == 0) $Groups->OpenGroup("Report");
$Groups->AddItem();
$is_next_record = $this->DataSource->next_record();
}
Plus of course creating additional logic for adding to the $r_balance on each iteration.
So my question is, How the heck do you do this without customizing account_details.php?
There does not seem to be a way to add and update a variable within the associated account_details_events.php that would process within this loop.
I know i must be missing something? Help!
Thanks
David
|
 |
 |
idh63
Posts: 76
|
| Posted: 01/20/2008, 10:08 AM |
|
Just to add...I was originally going to achieve my results with the following mysql query which works fine outside of CCS, but unfortunately mySql ODBC 3.51 rejects sql variables.
SET @bal =0;
SELECT
transaction_type.`type`,
transaction_status.tstatus,
transaction.deposit,
transaction.withdraw,
transaction.req_date,
transaction.ex_date, @bal := @bal + (transaction.deposit - transaction.withdraw) as running_balance
FROM
transaction
Inner Join transaction_status ON transaction.`status` = transaction_status.tstatus_id
Inner Join transaction_type ON transaction.ttype = transaction_type.ttype_id
ORDER BY ex_date;
|
 |
 |
idh63
Posts: 76
|
| Posted: 01/20/2008, 11:59 AM |
|
ok I found a solution that works.
1. Add the debit and credit row values to a new column in mysql (say r_balance).
2. set the control source of the label to the name of the new mysql column.
3. Use the Sum function available in the labels properties.
Is it really this easy?
|
 |
 |
datadoit
|
| Posted: 01/20/2008, 5:21 PM |
|
idh63 wrote:
>
> Is it really this easy?
> ---------------------------------------
Don't tell anyone in human resources!
|
|
|
 |
|