This topic is locked

Show Auto Created Record After Editing Existing Record

4/11/2008 4:05:09 PM
PHPRunner General questions
W
westmar author

I have a master detail record relationship where I only need to edit the detail record on an inline edit page. Once the user completes editing the record and clicks on save I create a child record, ie, roll-over record that contains existing data from the original record the user edited as well as new data which is inserted into the auto created record automatically. I'm using the event functions to do this and all of that is working fine. All I need to do is just show a portion of the auto created record in the list which is the same portion of the edited record so nothing really changes on the titles at all. Basically it is a combination of the edit and add functions in the template. From looking at the code for the add and edit modules it appears that the data is outputed very simply using the echo command in the print_inline_array function. All that needs to happen is have about four fileds on the screen be shown from the auto created record. Sorry if this has already been answered but I checked the forums and I didn't see any mention of somebody who has already done this.
Thanks in advance,
Art

J
Jane 4/14/2008

Hi,
you can do it to modify generated ..._inline_edit.php/..._inline_add.php files manually (add refreshing after adding new record).

However we don't have a ready to go solution for this.

W
westmar author 4/14/2008

Hi,

you can do it to modify generated ..._inline_edit.php/..._inline_add.php files manually (add refreshing after adding new record).

However we don't have a ready to go solution for this.


Jane:
Thanks for the response. As I suspected this would need to be done in the php file. My question is, can I use the inline_add template file to do this(adds the necessary code in the list template file) ? Where I'm struggling is where is the output going. I've got everthing fine up to the point I try to show the output. I added this code to the following if statement:
if ( $_REQUEST["a"]=="edited" && $inlineedit )
{
echo "<textarea id=\"data\">";
if($IsSaved)
{
if($HaveData)
echo "saved";
else
echo "savnd";
print_inline_array($showKeys);
echo "\n";
print_inline_array($showValues);
echo "\n";
print_inline_array($showFields);
echo "\n";
print_inline_array($showRawValues);
echo "\n";
print_inline_array($showDetailKeys,true);
echo "\n";
print_inline_array($showDetailKeys);
$fh = fopen("/tmp/PrintLine.txt", "w+");
fwrite($fh, "\nShow Keys\n");
foreach ( $showKeys as $key=>$val )
// echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n";
fwrite($fh, str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n");
fwrite($fh, "\nShow Values\n");
foreach ( $showValues as $key=>$val )
// echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n";
fwrite($fh, str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n");
fwrite($fh, "\nShow Fields\n");
foreach ( $showFields as $key=>$val )
// echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n";
fwrite($fh, str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n");
fwrite($fh, "\nShow Raw Values\n");
foreach ( $showRawValues as $key=>$val )
// echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n";
fwrite($fh, str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n");
fwrite($fh, "\nShow Detail Keys\n");
foreach ( $showDetailKeys as $key=>$val )
// echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n";
fwrite($fh, str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),str_replace(array("\\","\r","\n"),array("\\\\","\\r","\\n"),$val))."\\n");
fwrite($fh, "\n\n");
fclose($fh);
}
else
{
echo "error";
echo str_replace(array("&","<","\\","\r","\n"),array("&amp;","&lt;","\\\\","\\r","\\n"),$message);
}
echo "</textarea>";

}
else
{
if(function_exists("BeforeShowEdit"))
BeforeShowEdit($smarty,$templatefile);

$smarty->display($templatefile);
}
So when I call this code the text file has the edited record values as well as the auto generated record values, escaped properly to be inserted/displayed on the template file. I'm comfortable with the smarty calls as I've convinced myself by testing that I understand how they are working. Where my ignorance is killing me is that I assume the output is directed to the list template.

So it appears that I need to do something there, correct or incorrect ? If I send the output twice to the list template I'm going to see one record or the other, i.e.,, the values are being over written as they are passed a second time ? So can I use the list template with the add record and edit record capabilities to show both records after the user saves the edited record ? And if so how do I properly direct the output to the template. Or, am I totaly not seeing somehting ?????
Thanks,
Art
PS I have no problem hard coding the php files as I've written sets of perl scripts that post processes the output from phprunner making the changes transparent while generating a change log.