This topic is locked

Extra fields in list

7/4/2006 12:53:46 PM
PHPRunner General questions
kujox author

Does anyone know how to add an extra field in the list page without adding to the table.
I want it to be:-
Qty in stock - Qty on order = New figure
I dont really want to change the generated PHP as I keep generrating the pages, I would rather have the PHP in one of the events, for example under list page.
thanks
Chris

J
Jane 7/5/2006

Chris,
you can do it using calculated fields.

Modify SQL query on the Edit SQL query tab in the following way:

select `Qty in stock`,

`Qty on order`,

`Qty in stock`-`Qty on order` as `New figure`

...

from TableName



where TableName is your actual table name.

Read more about it here:

SQL query

kujox author 7/5/2006

jane,
Thanks for your reply, What I want is to produce the following
Qty In Stock Qty on order Free Stock(new figure)

10 5 5

19 7 12
Free stock(new figure) is then calculated, $free_stock = $qty_stock - $qty_order;
I want to then display the free stock figure in the list as an extra column. I don't want to add anything to the mysql table, and i want to display in stock and on order fields as well.
I know this could be done by changing the generated page but as i'm still generanting all the time I would prefer to store it in the events bit.

Alexey admin 7/5/2006

Chris,
the workaround with calculated field fits your needs perfectly.

Just follow the instructions we gave you.

kujox author 7/5/2006

Alexa,
I did try that and it did work, How would I get to access that figure in the list_page on_load event?
What I would like to do is change the formatting of the free stock figure and make it red/bold if it is a negative?
Also on another question, but releated to the same thing, can I pull the column headings from a table and place them on the list page in place of the ones already there using the on_load event.
Or would these need to be done after I have finished and generatedall the pages?
BTW, This is a great piece of software, the more I play with it the more I can see what can be done with it.

J
Jane 7/6/2006

Chris,
you can do it to modify generated files.

Open ..._list.php file, find following code snippet:

if(""!=FORMAT_HTML && ""!=FORMAT_FILE_IMAGE)

echo ProcessLargeText(GetData($rsData,$data,"free_stock", ""),$iquery);

else

echo GetData($rsData,$data,"free_stock", "");



and replace it with this one:

if(""!=FORMAT_HTML && ""!=FORMAT_FILE_IMAGE)

{

if ($data["free_stock"]<0)

{

?><FONT color=#cc0000><?php

echo ProcessLargeText(GetData($rsData,$data,"free_stock", ""),$iquery);

?></FONT><?php

}

else


echo ProcessLargeText(GetData($rsData,$data,"free_stock", ""),$iquery);

}

else

echo GetData($rsData,$data,"free_stock", "");



where free_stock is your actual field name.
I'm not really sure that I understand your another question correctly.

Please give me more detailed description of what you need to achieve.

kujox author 7/6/2006

Jane,
Ok the other question. but i'm not the best at explaining myself.
I have ten fields in a table which are used as analisys for the client, they want these to be used defined, I could rename the headings in phprunner but they would then be fixed , I would like the headings stored in a table so the client could change them.
Could I pull those headings from a table and put them in place of the column headings using on_load event?

Alexey admin 7/7/2006

Hi,
the OnLoad event won't help you.
You'll need to modify generated List page manually to replace fixed column headings with database table values.

Put your code to select values from the database there and replace column names with PHP code.

WriteTableHeader function is the best place to put your code into.

kujox author 7/7/2006

No problem, I'll just wait until it's all finished and modify the page