This topic is locked
[SOLVED]

 Button previuos and next by day variable

1/11/2012 4:43:27 AM
PHPRunner General questions
T
technoserv author

Hi everybody.

I use phprunner 5.3.

I have list of appointments with 20 records every day and everything multiplied for 3 months.(the number is not every day the same).

I would like to see in list records page, one day every page with a button day - and day + to go on and back.

with the kind help of Cristian I put the code necessary for filtering the list page in the "List page: Before SQL query" event:
Now I must create 2 button (day - and day +) in list page with associated $_SESSION['day'] variable but I don't sincerely know from where to begin.
the first day visible in the list page is tomorrow, the day after today, because i already filter the principal sql query:
[color="#0000FF"]SELECT id_app,

giorno_app,

ora_app,

fine_app,

cliente_app,

grp_tratt_app,

trattamento_app,

lavorante_app,

web_app,

note_app

FROM appuntamenti

WHERE (giorno_app >= CURDATE()+1)

ORDER BY giorno_app, ora_app
Somebody can help me?
thanks in advance.

C
cgphp 1/11/2012

Remove the old where clause from the "Before SQL query" event:

$strWhereClause = whereAdd("day(giorno_app) ='".$_SESSION['day']."'",$strWhereClause);


and enter the following code:

if( ! isset($_SESSION['step_date']))

{

$_SESSION['step_date'] = date('Y-m-d',strtotime("+1 day",time()));

}
$strWhereClause = whereAdd("giorno_app='".$_SESSION['step_date']."'",$strWhereClause); //start to filter from tomorrow


In the "Before display" event enter:

$xt->assign("step_date",'You are filtering by: '.$_SESSION['step_date']);


In the visual editor insert two buttons (+ and -)
In the Server section of the + button enter:

$_SESSION['step_date'] = date('Y-m-d',strtotime('+1 day', strtotime($_SESSION['step_date'])));


In the Client after section:

location.href = 'appuntamenti_list.php';


In the Server section of the - button:

$_SESSION['step_date'] = date('Y-m-d',strtotime('-1 day', strtotime($_SESSION['step_date'])));


In the Client after section of the - button:

location.href = 'appuntamenti_list.php';


In the visual editor, near the two buttons insert the following template variable:

{$step_date}
T
technoserv author 1/12/2012

Hi Cristian.
You are great.
It works good.
There is only a thing does not convince me.

When i make search with panel search for example, it makes it only in the page that i'm looking and not in all records.
For example.
If i want to see record of 20th march i put in search panel the date and it should make me see record of that date. It shoes nothing No record found.

If i want to see record of another field, for example "cliente_app" , it should make me see record where that field is present (it sometimes foresses in three or four months). Thath search shows nothing, too. No record found.
Could be found solution to this problem?
Anyway Thank you very much for your interesting.

C
cgphp 1/12/2012

In the "Before process" event of the search page enter the following code:

unset($_SESSION['step_date']);
T
technoserv author 1/12/2012

It does not work.
when i put some field to search panel and it shows no records, no button end the message
2012-01-13 is the date before search action with any field key and remain olso if i want to make a search really for date.
I think [color="#0000FF"]unset $_SESSION['step_date'] don't work.

C
cgphp 1/12/2012

Remove the unset code from the "Before process" event of the Search page and enter the following code in the "Before SQL query" of list page:

if( ! isset($_SESSION['step_date']))

$_SESSION['step_date'] = date('Y-m-d',strtotime("+1 day",time()));

if( ! isset($_GET['ctlSearchFor']))

$strWhereClause = whereAdd("giorno_app ='".$_SESSION['step_date']."'",$strWhereClause);
T
technoserv author 1/12/2012

Cristian I infinitely thank you.
It works perfectly. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=63602&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

T
technoserv author 1/13/2012

Cristian
I have been to much optimist....
in my preceding tests I had few records of test...
now with the real massive structure of records the query response is
Sending request to server...
and make anything else.
those rarely that it succeeds in giving a result, when i put in search panel any fields it works fine,

if i put field date in search panel it gives records of that date results but the variable $_SESSION['step_date'] is still that preceding and therefore the buttons previous and next don't works correctly.
I am exhausted to break me the head on this list...

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=63633&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

C
cgphp 1/13/2012

Remove any code from the "Client before" section of the buttons.

T
technoserv author 1/13/2012

Good Morning Cristian,
happy to see you.
now the answer of the server seems more rapids.
There is still the problem of the request in searching of date parameter that is not equal at $_SESSION['step_date'] and

it make to see records with search date paramenters, none buttons and You are filtering by: (variable $_SESSION['step_date'])