Lynn Thames
asked on
Help with php5 issue - loading a pdf file
I have a question (or plea for help) that I'm not sure even fits the scope of this site . . . . but here goes:
I have a web app that was written in php5 by someone no longer here. It communicates with a computer in our office (written by me) to give web access to plant data. One of the functions is not working in an acceptable format and I need help with a work around.
Basically, the web user requests a copy of a document. The php5 code sends the request to the computer in our office, which generates the pdf and then uplaods it to a specific file name/location on the web server. The computer in our office then sends the url to the web app and it is supposed to open it in a new tab or window.
The way it works now . . is that when the user requests the document copy, it pops up a small window and says 'Waiting' with an OK button. The user actually has to click 'OK' before it continues. This is unacceptable to our customers.
Previously, a blank window opened with no activity in it until the web app recieved the pdf url . . and then briefly flashed up a 'please wait' before loading the pdf. We had complained about that because the user thinks there is a problem and closes the window when nothing happens quickly. We wanted the 'please wait' to show up as soon as the new window opens. What the programmer did really didn't work . . .but was meant to hide the problem by making the user do something before the window popped up. But it only made it worse.
I'm now trying to make some changes to the app and I need to 1> get rid of the first pop up box that makes the user press 'OK'. And 2> try to make the 'please wait' show up as soon as the window opens. . . not when it starts loading the pdf file.
You can see what it is doing by going to the following website . . . www.excelss.net/libermans/index.php5 and log in as clthames account number 10001 Then mouse over one of the 'job numbers' listed and select 'View Acknowledgment'.
I have a web app that was written in php5 by someone no longer here. It communicates with a computer in our office (written by me) to give web access to plant data. One of the functions is not working in an acceptable format and I need help with a work around.
Basically, the web user requests a copy of a document. The php5 code sends the request to the computer in our office, which generates the pdf and then uplaods it to a specific file name/location on the web server. The computer in our office then sends the url to the web app and it is supposed to open it in a new tab or window.
The way it works now . . is that when the user requests the document copy, it pops up a small window and says 'Waiting' with an OK button. The user actually has to click 'OK' before it continues. This is unacceptable to our customers.
Previously, a blank window opened with no activity in it until the web app recieved the pdf url . . and then briefly flashed up a 'please wait' before loading the pdf. We had complained about that because the user thinks there is a problem and closes the window when nothing happens quickly. We wanted the 'please wait' to show up as soon as the new window opens. What the programmer did really didn't work . . .but was meant to hide the problem by making the user do something before the window popped up. But it only made it worse.
I'm now trying to make some changes to the app and I need to 1> get rid of the first pop up box that makes the user press 'OK'. And 2> try to make the 'please wait' show up as soon as the window opens. . . not when it starts loading the pdf file.
You can see what it is doing by going to the following website . . . www.excelss.net/libermans/index.php5 and log in as clthames account number 10001 Then mouse over one of the 'job numbers' listed and select 'View Acknowledgment'.
relevant code form the 'calling' php5 file:
mywindow = window.open ("genpdf.php5?keyjob="+keysent+"&ctype="+ctype,"mywindow","resizable=no,location=0,status=0,scrollbars=0,width=800,height=600");
code from the genpdf.php5 file - look down the code for '*******' for where I think this is happening. The beginning lines are building the request to send via the socket
<?php
session_start();
set_time_limit(0);
$host="xx.xx.xx.xx";
$port = xxx;
$socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')) or die("Could not create socket\n");
$result = socket_connect($socket, $host, $port) or die("Could not connect to server\n");
$ctype = $_GET['ctype'];
$keyjob = trim($_GET['keyjob']);
if($ctype=="Bill")
{
$out = "[getdoc]type=bol,field=order_num,key=$keyjob,acctno=".$_SESSION['acctno'].",user=".$_SESSION['username'];
}
if($ctype=="Ack")
{
$out = "[getdoc]type=acknowledgement,field=order_num,key=$keyjob,acctno=".$_SESSION['acctno'].",user=".$_SESSION['username'];
}
if($ctype=="Inv")
{
$out = "[getdoc]type=invoice,field=order_num,key=$keyjob,acctno=".$_SESSION['acctno'].",user=".$_SESSION['username'];
}
if($ctype=="erp")
{
$out = "[launch_report]reportid=ols00001.rpt, begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",acctno=".$_SESSION['acctno'].",user=".$_SESSION['username'];
}
if($ctype=="jsh")
{
$out = "[launch_report]reportid=ols00002.rpt, begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",acctno=".$_SESSION['acctno'].",user=".$_SESSION['username'];
}
if($ctype=="oo")
{
$out = "[launch_report]reportid=ols00003.rpt,acctno=".$_SESSION['acctno'].", begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",user=".$_SESSION['username'];
}
if($ctype=="ocum")
{
$out = "[launch_report]reportid=ols00004.rpt,acctno=".$_SESSION['acctno'].", begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",user=".$_SESSION['username'];
}
if($ctype=="osd")
{
$out = "[launch_report]reportid=ols00005.rpt,acctno=".$_SESSION['acctno'].", begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",user=".$_SESSION['username'];
}
if($ctype=="idv")
{
$out = "[launch_report]reportid=ols00006.rpt,acctno=".$_SESSION['acctno'].", begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",user=".$_SESSION['username'];
}
if($ctype=="ode")
{
$out = "[launch_report]reportid=ols00007.rpt,acctno=".$_SESSION['acctno'].", begin_date=".$_GET['bdate'].",end_date=".$_GET['edate'].",user=".$_SESSION['username'];
}
//*******************************
//echo "<img src='wait.gif' height=100 border=0 /> <br/>".$out;
$out .= "Connection: Close\r\n\r\n";
socket_write($socket, $out, strlen($out)) or die("Could not send data to server\n");
$result = socket_read ($socket, 100000,PHP_NORMAL_READ) or die("Could not read server response\n");
//echo "<br/>".$result."<br/>";
$tokeme = strtok($result,"~");
$theVariables = array();
$theVariables[0] = $tokeme;
while ($tokeme) {
//print ("$tokeme");
$tokeme = strtok("~");
$theVariables[] = $tokeme;
}
if(trim(str_ireplace('[end]','',$theVariables[1]))=="conntimeout")
{
echo '<br>Sorry. The Request Timed Out.';
}
else{
if(trim(str_ireplace('[end]','',$theVariables[1]))=="norecs")
{
echo '<br>Sorry. No Matching Records were found';
}
else
{
//echo trim(str_ireplace('[end]','',$theVariables[1]));
?>
<center><img src='wait.gif' height=100 border=0 /> <br/></center>
<body onload='mywindow = window.open ("<?php echo trim(str_ireplace('[end]','',$theVariables[1]));?>","mywindow","location=0,status=0,scrollbars=0,resizable=0,width=800,height=600");'>
</body>
<?php
}
}
socket_close($socket);
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It may not be elegant . . .but it worked like a charm!!! Thank you for everything!
Are we allowed to ask about hiring experts on this site?
Are we allowed to ask about hiring experts on this site?
ASKER
Excellent! The suggested code changes worked the first time!
You're welcome, glad to be of help.
A quick search of the site suggests 'no', one is probably not allowed to ask about hiring experts.
https://www.experts-exchange.com/questions/22742185/Hire-A-Qualified-Expert.html
Atan
A quick search of the site suggests 'no', one is probably not allowed to ask about hiring experts.
https://www.experts-exchange.com/questions/22742185/Hire-A-Qualified-Expert.html
Atan
ASKER
I've taken care of that issue.
On your second suggestion, is this something I can do with the existing window.open command in the calling program? The 2 pieces of code (I think) are below.
Thanks for your help!!!!!
Open in new window