Display form with all summary followed by all details

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
dsm2000
User
Posts: 11

Display form with all summary followed by all details

Post by dsm2000 »

Customer wants form results displayed as follows
What's the best way to accomplish this?

I tried putting the generated display table on the form twice, deleting all displayed fields on the top except for the title field.
This gives me the desired form layout with the summary title fields but the bottom details section just repeats the last record over and over.
Where and how do I reset the current record ID so the bottom section iterates back through the results recordset again?

summary of returned records at top
rec 1 title field
rec 2 title field
rec 3 title field

rec 4 title field

Complete records in same order after all rec summaries
rec 1 title field
rec 1 color field
rec 1 vin field
rec 1 proddate field
rec 2 title field
rec 2 color field
rec 2 vin field
rec 2 proddate field
rec 3 title field
rec 3 date field
rec 3 date field
rec 3 date field
rec 4 title field
rec 4 date field
rec 4 date field
rec 4 date field


kirondedshem
User
Posts: 642

Post by kirondedshem »

If you still want the result to be exportable, adjustable according to serach etc, then as long as you can determine te sql its using you can even render it yourself, so for this example am going to reproduce a similar output from demo project so maybe it will give you a new insight.

NOTE: am using demo project supplier table for this.
comparing the two outputs the the bottom one if more complicated so i will let it be whats fendered by default ie use list template for it
########draw the detail complete(one below##########

  1. we use php list template to render the bottom summary where each record presented as
    filed1
    filed2
    filed3

Go to custom template->table specific->list page->custom template body and put code
<table class="table table-bordered">
<tr><td>{{{CompanyName}}}<td></tr>
<tr><td>{{{ContactName}}}<td></tr>
<tr><td>{{{ContactTitle}}}<td></tr>
<table>

########draw the detail complete(one below##########

########draw te summary table(one below##########
Assumming you want to draw it at te top.

-we get the sql that the list page is going to use to select from te database
-we gte the current pagination setting to know how many it is going to render
-we add the limit and offset to select the same result it is displaying
-we adjust te select to only pick desired fields.
-we render result in a table and add it to the eader of te page(beofre the list)

Go to list page->page_data_rendering and put
// Page Data Rendering event
function Page_DataRendering(&$header) {
// Example:
//$header = "your header";

//get the sql it uses to render the current list 
	$list_sql = $this->ListSQL();
	var_dump($list_sql);
	
	//get the pagination
	$DisplayRecs = $this->DisplayRecs;
	$StartRec = $this->StartRec;
	$RecRange = $this->RecRange;
	//formulate sql offset
	$sql_offset = $StartRec - 1;
	
	//add limiters on sql 
	$list_sql .= " LIMIT $DisplayRecs OFFSET $sql_offset ";
	
	
	//edit sql to only pick one field
	//replace * with filed name
	$list_sql = str_ireplace("*","CompanyName",$list_sql);
	var_dump($list_sql);
	
	$header = '<div class="panel panel-default">
	<div class="panel-heading">summary of returned records at top</div>'
	.ew_ExecuteHtml($list_sql,array("fieldcaption" => TRUE))
	.'</div>';

}

########draw te summary table(one below##########

HINT: you can even do it in page_data rendered it you want to draw it in footer. youcan even hide the default table and just use those two events to draw your own custom output that is still responds to pagination and serac filters.


dsm2000
User
Posts: 11

Post by dsm2000 »

Thanks for steering me in the right direction!

Got it working in both the demo and in my project. I notice in both that the results page displays the sql queries before the results.
How and where do you suppress the display of the queries in phpmaker 2018?

C:\wamp\www\phpdemo2018\supplierslist.php:1814:string 'SELECT * FROM suppliers' (length=25)

C:\wamp\www\phpdemo2018\supplierslist.php:1831:string 'SELECT CompanyName FROM suppliers LIMIT 20 OFFSET 0 ' (length=54)

summary of returned records at top
CompanyName
Exotic Liquids
New Orleans Cajun Delights
Grandma Kelly's Homestead


sangnandar
User
Posts: 980

Post by sangnandar »

Those look like php error messages.
It would be highly recommended to check the line that cause the error messages.
But if you absolutely sure things go as expected, you can put an @ in front of function call to suppress the error messages.


kirondedshem
User
Posts: 642

Post by kirondedshem »

I notice in both that the results page displays the sql queries before the results.
How and where do you suppress the display of the queries in phpmaker 2018?

NOTE:THese are not php errors, Infact if you had opened the supplierslist.php file in a text editor you should see that lines 1814 and 1831 have the var_dump on them, so removing it should solve your problem
I used var_dump(it helps to print out php objects at givens points during execution) so i can show you what am working with and what the queries look like, so just remove every line having var_dump on it.
ie remove the two lines that read
var_dump($list_sql);


Post Reply