This topic is locked
[SOLVED]

 Change List page Key Id link based on lookup

3/19/2014 5:04:17 PM
PHPRunner General questions
A
Anapolis author

The methods I have been trying out from the PHPRunner 7.1 docs are not giving me what I want so I will lay the case out here.
I have a List page that shows appointments booked with the column values in a horizontal row.
The KEY id, named "id" for each row of records shows up first like this:


There is a Custom Expression for that id field that wraps the ID with a link to an ADD Page form to create a Reports record that also stores the "id" value of the Calendar appointment record.
The custom expression passes other values like this:



$value="<a href='reports_add.php?&apoort=".$data["ort"]."&aponame=" .$data["kunde"]."&apostrasse=" .$data["strasse"]."&apoplz=" .$data["plz"]."&ansprech=" .$data["ansprech"]. "&promotiondate=" . $data["DateField"] . "&sap=".$data["kdnr"]."&trainername=".$data["trainername"]."&aussendname=".$data["aussendname"]."&lieracphyto=".$data["lieracphyto"]."&promotiondate=".$data["DateField"]."&calcalendarid=".$data["id"]. " '> Report erstellen >> ".$data["id"]. "</a>"


the Link that this makes on the Calendar List page looks like this;


What I am trying to do is to PREVENT more than 1 Report to be posted on the Reports_add form by querying the Reports table to see if it finds one row named "calcalendarid" with the same number value, such as "1", and REMOVING the LINK built around the Calendar Id, and simply reverting it to an ID number . The link Report erstellen >> 1 is overwritten by simply "1" or "2", etc.
I have tried code like this in the Calendar list page in function BeforeProcessList($conn, $pageObject)
[code]global $conn;

$strSQLExists = "select calcalendarid from reports where calcalendarid='".$data["id"]. "'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)
{

$record["id_fieldcolumn"]=false;

}

else

{

$record["id_fieldcolumn"]=true;

}
and variations of this code using
Example only!
$new_variable = "Nothing here, move along";
$xt->assign("id_fieldcolumn",$new_variable);
At any rate, I am puzzling over this!

A
Anapolis author 3/19/2014

As USUAL, when after hours of trial and all errors I give up and come lay my ignorant self humbly before the Forum, I find an answer within the hour afterwards!
In my example I wanted to prevent Users from filing more than one Followup Report on a Booked Appointment.

I used a link from the Appointments calendar list page that would pre-fill as many Followup fields as possible from already known values in the Calendar Appointment record for a certain place at a certain day.
Instead of trying to use the Events pages I simply took my code into the Custom Expression of the Calendar Id field. Here is the code I put in there:

global $dal;
$myid=$data["id"];

global $conn;
$strSQLExists = "SELECT calcalendarid from reports where calcalendarid=".$myid."";

$rsExists = db_query($strSQLExists,$conn);

$mydata=db_fetch_array($rsExists);

if($mydata)
{

$value=$myid;

}

else

$value="<a href='reports_add.php?&apoort=".$data["ort"]."&aponame=" .$data["kunde"]."&apostrasse=" .$data["strasse"]."&apoplz=" .$data["plz"]."&ansprech=" .$data["ansprech"]. "&promotiondate=" . $data["DateField"] . "&sap=".$data["kdnr"]."&trainername=".$data["trainername"]."&aussendname=".$data["aussendname"]."&lieracphyto=".$data["lieracphyto"]."&promotiondate=".$data["DateField"]."&calcalendarid=".$myid. " '> Report erstellen >> ".$myid. "</a>"


So now IF the logged in User has yet to Submit a Followup Report form for the Appointment on the Calendar list page there will be a link on that record that helps them Submit the Followup Report.
The link using the ID number when clicked takes the User to the Report form.
When the Report ADD page loads the Report Form as many fields as possible are already filled out for User convenience and Report accuracy.
However, if they already Submitted a Report Form, the code above Removes the Helpful Link to the Report Form Add page.

If there is no link, simply an Id number, such as 1, 2, 3, etc, then the User also knows they have submitted the required Followup Report form for this appointment.
And so my problem solved!