michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2003-12-01 20:22
Návrat hore
Odpovedať s citátom
|
query for list mode is constructed on line about 1870 after '* Main list_table() query' in '$query = $this->query_make($qparts);'
you can save this query, or better save (with aditional line $this->qparts = $qparts;) and use 'function query_make($parts)' from line 460 to make your own query.
you will probably want to change $qparts['select'] to 'SUM(col_name)' and maybe throw away 'limit' part in this array.
then call $query = MyForm->query_make($qparts); in your file and echo the $query result.
1 line change in the source code, plus 5 lines in your config file should do the job.
please let me know if it's working
|
Amit
Založený: 16.05.2004
Príspevky: 22
Zaslal: 2004-06-26 17:37
Návrat hore
Odpovedať s citátom
|
Michal, I tried to setup a virtual field which would keep totalling the Amount field in each row as follows:
| Kód: |
$opts['fdd']['Balance'] = array(
'name' => 'Balance',
'select' => 'N',
'maxlen' => 14,
'sql' => 'SUM(Amount)',
'sort' => false
);
|
Unfortunately PME does not like this structure. Balance is expected to be a virtual field as it does not exist in the table.
the ideal sql statement for me would be :
| Kód: |
| 'sql' => 'Balance + Amount' |
'Amount' is defined as a field in the table. Any ideas?
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2004-06-28 08:03
Návrat hore
Odpovedať s citátom
|
Amit, your code should produce the same number (total of all displayed columns) for each row. afaik, with sql option there is no way to do per row summing of values. (something like balance(0) = balance(-1) + amount(0); )
when i came to similar situation i had to make a custom php option adding all values up to date in the row. it ignored any sorting or filters and displayed just balance at that date. it made a sql query at each row so i wasn't a lot efficient too :)
after finishing university stuff, we will hopefully commit several patches which should make this easier...
|
Amit
Založený: 16.05.2004
Príspevky: 22
Zaslal: 2004-06-28 11:32
Návrat hore
Odpovedať s citátom
|
Michal
Need your help with one more item. I have defined the following filter (which works):
| Kód: |
$acc = "DebitAccount = '".$book."' OR CreditAccount = '".$book."'";
$daterange = "Date BETWEEN '".$from_date."' AND '".$to_date."'";
$opts['filters'] = "(".$acc.") AND ".$daterange; |
But before showing me all the records I want to calculate the Opening Balance, i.e. the sum of all records with Date < $from_date but with all other terms in the filter remaining the same. Can you suggest some way in which I can modify the filter and generate the query, do the sum and get the result of the query?
Thanks for your help.
|
vistep
Založený: 02.05.2003
Príspevky: 3
Zaslal: 2006-02-02 16:41
Návrat hore
Odpovedať s citátom
|
Dear all!
What is current status of implementation
"column total features"?
(not worked lines 2294-2336 in phpmyedit 5.5 v.1.167)
thanks,
Vistep
|
moi
Založený: 21.01.2005
Príspevky: 12
Zaslal: 2006-02-13 18:20
Návrat hore
Odpovedať s citátom
|
Column totals would be a really good feature. I'm still scratching my head trying to find a custom alternative.
|
vistep
Založený: 02.05.2003
Príspevky: 3
Zaslal: 2006-08-06 12:40
Návrat hore
Odpovedať s citátom
|
| vistep Napísal: |
Dear all!
What is current status of implementation
"column total features"?
(not worked lines 2294-2336 in phpmyedit 5.5 v.1.167)
|
Dear all!
I implemented column total feature.
Code must be put on lines 2303-2345 phpmyedit 5.5 v.1.181
-------------------------
/*
* Display and accumulate column aggregation info, do totalling query
* XXX this feature does not work yet!!!
*/
if ($this->display['total'] && (((intval($this->fm / $this->inc) + 1)==( max(1, ceil($total_recs / abs($this->inc))))) or ($this->inc<0))) {
$qp = array();
$qp['type'] = 'select';
$qp['select']='';
for ($k=0;$k<$this->num_fds;$k++) {
$fd = $this->fds[$k];
if (isset($this->fdd[$fd]['total'])) {
if ($qp['select']!='') {
$qp['select'].=',';
}
if (isset($this->fdd[$fd]['sql'])) {
$qp['select'].= $this->fdd[$fd]['total'].'(PMEtable0.'.$this->fdd[$fd]['sql'].') as tot_'.$k;
} else {
$qp['select'].= $this->fdd[$fd]['total'].'(PMEtable0.'.$this->fds[$k].') as tot_'.$k;
}
}
}
if ($qp['select']!='') {
$qp['from'] = $this->get_SQL_join_clause();
$qp['where'] = $this->get_SQL_where_from_query_opts();
// $qp['limit'] = $this->fm.','.$this->inc;
$tot_query = $this->get_SQL_query($qp);
// print 'tc='.$tot_query;
$totals_result = $this->myquery($tot_query,__LINE__);
$tot_row = mysql_fetch_array($totals_result, MYSQL_ASSOC);
}
echo "\n",'<tr class="pme-row-total">',"\n",'<td colspan='.$sys_col_count.'class="pme-total">'.$this->total_label.'</td>',"\n";
// display the results
for ($k=0;$k<$this->num_fds;$k++) {
$fd = $this->fds[$k];
if (stristr($this->fdd[$fd]['options'],'L') or !isset($this->fdd[$fd]['options'])) {
echo '<td class="pme-cell-total">';
if (isset($this->fdd[$fd]['total'])) {
print $tot_row['tot_'.$k];
} else {
echo ' ';
}
echo '</td>',"\n";
}
}
echo '</tr>',"\n";
}
------------------------
After line 3077 phpmyedit 5.5 v.1.181
insert next code
-------------------------
$this->total_label = isset($opts['total_label'])
? @$opts['total_label']:'Total';
$this->display['total'] = @$opts['display']['total'];
-------------------------
Also need add sys_col_count var after line 2188
$sys_col_count=0;
and after line 2207
$sys_col_count++;
and after line 2271
$sys_col_count++;
and after line 2282
$sys_col_count++;
-------------------------------------------
Configuration.
1.Set display option TOTAL to true.
ex.
$opts['display'] = array(
'query' => false,
'sort' => true,
'time' => true,
'tabs' => true,
'total' => true
)
2. Add language depended total line
name
$opts['total_label']='Total line'
3. For field definition add
option TOTAL with function name (sum, count, etc...)
ex.
$opts['fdd']['Number'] = array(
'name' => 'Number',
'maxlen' => 11,
'default' => '0',
'total' =>sum
);
$opts['fdd']['DIFF_REAL_V'] = array(
'name' => '',
'options' => 'LF',
'select' => 'N',
'maxlen' => 10,
'sort' => true,
'sql' =>'DIFF-BONUS_USE',
'total' =>avg
);
Source code add at:
http://opensource.platon.sk/projects/bug_view_advanced_page.php?f_bug_id=399
|
xleduff
Založený: 27.07.2005
Príspevky: 4
Zaslal: 2009-09-04 14:22
Návrat hore
Odpovedať s citátom
|
Hi,
do you have any ideas for a date to include this fonctionnality in cvs ?
I think it's a good ideas !
What is the date of the next release of phpmyedit ?
|
|
Odoslať novú tému
Odpovedať na tému
|