This topic is locked

detail add

12/31/2007 4:21:16 AM
PHPRunner General questions
G
garethp authorDevClub member

hello
I am hoping someone can help with this question...
I have two tables
spares - orderno, date and this is the master

sparesdetail - id, orderno, part and this is the detail linked on orderno
This all works perferctly
If I click the sparesdetail tab all the entries are shown for all orderno. If I then click "add new" is there a way to display an error message saying "no master selected" and then to redirect back to the spares list page so the user is forced to select an orderno and then add the sparesdtail for that master selected.
Many thanks - hope this makes sense

G
garethp authorDevClub member 1/5/2008

I have found this link that does this even better - it will hide the add button if a master is not selected
http://www.asprunner.com/forums/index.php?showtopic=6858
I made it work if no masterkey is selected replacing the following code in the html editor.
For the complete beginner (like me) left click the "add new" button in the visual editor and then left click the html editor button (3rd from left on the top menu) - this will show you the code. To get back to visual editor click 2nd from left.

<INPUT class=button onclick="window.location.href='spares_add.php'" type=button value="Add new" disptype="control1">

with

{if $addnew}<INPUT class=button onclick="window.location.href='spares_add.php'" type=button value="Add new" disptype="control1">{/if}


and adding the following List page: Before Display event

if ($_SESSION["spares_masterkey1"]<1)

{

$smarty->assign("addnew",0);

}

else

{

$smarty->assign("addnew",1);

}


you can change the ($_SESSION["spares_masterkey1"]<1) depending on you rmasterkey.
I am not a programmer but this works - if anyone knows a better or more correct way please tell me.

N
nix386 9/10/2008

This worked better in my instance. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=32919&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />
//display add button if coming from the masterkey, don't display the button if coming from the menu link

if (@$_REQUEST["masterkey1"])

{

$smarty->assign("addnew",1);

}

else

{

$smarty->assign("addnew",0);

}