Expand|Select|Wrap|Line Numbers
- <?php
- include 'includes/configenquirer.php';
- include 'includes/variables.php';
- include 'lib/functions.php';
- require('fpdf.php');
- $e_dtl_id = $_REQUEST['e_dtl_id'];
- class PDF extends FPDF
- {
- //Load data
- function SetWidths($w)
- {
- //Set the array of column widths
- $this->widths=$w;
- }
- function SetAligns($a)
- {
- //Set the array of column alignments
- $this->aligns=$a;
- }
- function Row($data)
- {
- //Calculate the height of the row
- $nb=0;
- for($i=0;$i<count($data);$i++)
- $nb=max($nb,$this->NbLines($this->widths[$i],$data[$i]));
- $h=5*$nb;
- //Issue a page break first if needed
- $this->CheckPageBreak($h);
- //Draw the cells of the row
- for($i=0;$i<count($data);$i++)
- {
- $w=$this->widths[$i];
- $a=isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
- //Save the current position
- $x=$this->GetX();
- $y=$this->GetY();
- //Draw the border
- $this->Rect($x,$y,$w,$h);
- //Print the text
- $this->MultiCell($w,5,$data[$i],0,$a);
- //Put the position to the right of the cell
- $this->SetXY($x+$w,$y);
- }
- //Go to the next line
- $this->Ln($h);
- }
- function CheckPageBreak($h)
- {
- //If the height h would cause an overflow, add a new page immediately
- if($this->GetY()+$h>$this->PageBreakTrigger)
- $this->AddPage($this->CurOrientation);
- }
- function NbLines($w,$txt)
- {
- //Computes the number of lines a MultiCell of width w will take
- $cw=&$this->CurrentFont['cw'];
- if($w==0)
- $w=$this->w-$this->rMargin-$this->x;
- $wmax=($w-2*$this->cMargin)*1000/$this->FontSize;
- $s=str_replace("\r",'',$txt);
- $nb=strlen($s);
- if($nb>0 and $s[$nb-1]=="\n")
- $nb--;
- $sep=-1;
- $i=0;
- $j=0;
- $l=0;
- $nl=1;
- while($i<$nb)
- {
- $c=$s[$i];
- if($c=="\n")
- {
- $i++;
- $sep=-1;
- $j=$i;
- $l=0;
- $nl++;
- continue;
- }
- if($c==' ')
- $sep=$i;
- $l+=$cw[$c];
- if($l>$wmax)
- {
- if($sep==-1)
- {
- if($i==$j)
- $i++;
- }
- else
- $i=$sep+1;
- $sep=-1;
- $j=$i;
- $l=0;
- $nl++;
- }
- else
- $i++;
- }
- return $nl;
- }
- }
- $pdf=new PDF();
- $pdf->AliasNbPages();
- $pdf->AddPage('P','A4');
- $pdf->SetFont('Times','',12);
- $query = "select enq.*,exp.*,detail.* from " .$Enquiry_details." as detail inner join (".$Enquirer_registration." as enq,".$Expert_registration." as exp) on enq.e_id = detail.e_id and exp.x_id= detail.x_id where e_dtl_id = '$e_dtl_id'";
- //echo $query;
- $dbr = mysql_query($query);
- $count = mysql_num_rows($dbr);
- $myFile = "casepaper.txt";
- $fh = fopen($myFile, 'w') or die("can't open file");
- while($row=mysql_fetch_array($dbr))
- {
- $stringData =" ".$row['e_dtl_id'];
- // $stringData .= "\n";
- $stringData .= "Summary";
- $stringData .=
- $stringData .= "Age/Gender".$row['e_age']."/".$row['e_gender'];
- $stringData .= "History".$row['e_clinic_case'];
- $stringData .= "Problems".$row['e_desc'];
- $stringData .= "Tratement Received".$row['e_title'];
- $pdf->SetFont('Arial','B',17);
- // $pdf->Cell(120,10,"Global Diagnosis Consultation Report-.".$uniqueId.$row['e_dtl_id']."",0,1,'C');
- $pdf->SetTopMargin(40);
- $pdf->SetLeftMargin(30);
- $pdf->SetRightMargin(30);
- $pdf->Cell(110,3,"Global Diagnosis Consultation Report-",0,0,'C');
- $pdf->SetFont('Arial','B',10);
- $pdf->Cell(1,3,$uniqueId.$row['e_dtl_id'],0,1,'');
- $pdf->SetFont('Arial','B',10);
- $pdf->Cell(50,4,"",0,1,'C');
- $pdf->Cell(50,10,''. "Summary:",0,0,'L');
- $pdf->Cell(50,5,"",0,1,'C');
- $pdf->Cell(25,20,"Enquiry ID:",0,0,'');
- //$pdf->Cell(50,20,"",0,1,'C');
- $pdf->Cell(20,20,''.$uniqueId.$row['e_dtl_id'].'',0,0,'');
- $pdf->Cell(50,20,''. "Age/Gender:".$row['e_age'].""."/".$row['e_gender']."",0,0,'R');
- $pdf->Cell(40,20,''. "Date:".$row['e_date']."",0,0,'R');
- $pdf->Cell(50,10,"",0,1,'C');
- $pdf->Cell(32,20,"Experts:"."Dr.".$row['x_firstname'].",",0,0,'R');
- $pdf->Cell(76,20,$row['x_organisation_name'],0,0,'R');
- $selectcity = "select * from ".$cities ." where city_id =".$row['x_city'];
- //echo $selectcity;
- $resultcity = mysql_query($selectcity);
- while($rowcity =mysql_fetch_array($resultcity))
- $pdf->Cell(18,20,",".$rowcity['city_name'].",",0,0,'R');
- $invite_exp_query = "select inv_exp.*,exp.*,detail.* from " .$invited_experts." as inv_exp inner join (".$Enquiry_details." as detail,".$Expert_registration." as exp) on detail.e_dtl_id = inv_exp.e_dtl_id and inv_exp.x_fwd_id = exp.x_id where detail.e_dtl_id = '$e_dtl_id'";
- //echo $invite_exp_query;
- $invite_exp_result = mysql_query($invite_exp_query);
- while($row_invite =mysql_fetch_array($invite_exp_result))
- {
- $pdf->Cell(17,20,"Dr.".$row_invite['x_firstname'].",",0,1,'R');
- $pdf->Cell(78,2,$row_invite['x_organisation_name'],0,0,'R');
- $selectinvcity = "select * from ".$cities ." where city_id =".$row_invite['x_city'];
- //echo $selectcity;
- $resultinvcity = mysql_query($selectinvcity);
- while($rowinvcity =mysql_fetch_array($resultinvcity))
- $pdf->Cell(12,2,",".$rowinvcity['city_name'],0,0,'R');
- }
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(50,5,"",0,1,'C');
- $pdf->Cell(18,10,"History:",0,1,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,4,$row['e_clinic_case'],'0','L','');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(30,5,"",0,1,'C');
- $pdf->Cell(22,10,"Problems:",0,1,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,4,$row['e_desc'],'0','L','');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(30,5,"",0,1,'C');
- $pdf->Cell(43,10,"Tratement Received:",0,1,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,4,$row['e_title'],'0','L','');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->Cell(52,10,"Reason for Consultation:",0,1,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,4,$row['e_consultation'],'0','L','');
- $pdf->SetFont('Arial','B',10);
- $pdf->Cell(10,5,"",0,1,'C');
- $selectupload = "select * from ".$upload." where e_dtl_id= '$e_dtl_id'";
- //echo $selectupload;
- $resultupload = mysql_query($selectupload);
- $countupload = mysql_num_rows($resultupload);
- $pdf->SetDrawColor(222) ;
- $pdf->SetWidths(array(30, 50, 30, 40));
- $pdf->Row(array('Documen_Name','Date', 'Quality'));
- $pdf->SetFont('Arial','',10);
- while($uploadrow =mysql_fetch_array($resultupload))
- {
- $upload_name =$uploadrow['upload_file_name'];
- $upload_date =$uploadrow['createdate'];
- $upload_qual ='Good';
- srand(microtime()*1000000);
- $pdf->Row(array($upload_name,$upload_date, $upload_qual));
- }
- $pdf->SetFont('Arial','B',10);
- $pdf->Cell(42,20,"Summary of Collboration:",0,1,'L');
- $pdf->SetDrawColor(0);
- $name='';
- $comments_text='';
- $selectresponse = "select * from " .$response." where e_dtl_id ='$e_dtl_id' order by comments_id asc ";
- // echo $selectresponse;
- $resultresponse = mysql_query($selectresponse);
- if(mysql_num_rows($resultresponse)>0)
- {
- $caseresponse = array();
- //Selctin al records from the comments table for maxpage for pagination
- //End of selction max record
- $selectmaxresponse = "select * from " .$response." where e_dtl_id ='$e_dtl_id'";
- //echo $selectmaxresponse;
- $expertmaxresponse = mysql_query($selectmaxresponse);
- while($casevalenq = mysql_fetch_array($resultresponse,MYSQL_ASSOC))
- {
- $x_id=$casevalenq['x_id'];
- $e_id1=$casevalenq['e_id'];
- $comments_id=$casevalenq['comments_id'];
- $date = $casevalenq['createdate'];
- $time = $casevalenq['createtime'];
- //echo $x_id."-----------".$e_id;
- $pdf->SetFont('Arial','B',10);
- if($x_id!=0)
- {
- //fetch expert name
- $expert_detail = "select * from " .$Expert_registration." where x_id ='$x_id'";
- $result_expert = mysql_query($expert_detail);
- $caseresponse = mysql_fetch_array($result_expert,MYSQL_ASSOC);
- $name=$caseresponse['x_firstname'];
- //fetch expert advice
- $expertresponse_query = "select * from " .$response." where e_dtl_id ='$e_dtl_id' and x_id=$x_id and comments_id=$comments_id";
- //echo $expertresponse_query;
- $expertresponse = mysql_query($expertresponse_query);
- $row = mysql_fetch_array($expertresponse,MYSQL_ASSOC);
- $comments_text=strip_tags($row['x_response_text']);
- $newtext = wordwrap($comments_text, 50, "\n", true);
- $pdf->SetFont('Arial','B',10);
- }
- if($e_id1!=0)
- {
- //fetch enquirer name
- $enquirer_detail = "select * from ".$Enquirer_registration." where e_id ='$e_id1'";
- $result_enq = mysql_query($enquirer_detail);
- $response_enq = mysql_fetch_array($result_enq,MYSQL_ASSOC);
- $name=$response_enq['e_firstname'];
- //Fetch enquirer comments
- $enquirer_response_query = "select * from " .$response." where e_dtl_id ='$e_dtl_id' and e_id=$e_id1 and comments_id=$comments_id";
- //echo $enquirer_response_query;
- $enquirer_response = mysql_query($enquirer_response_query);
- $row1 = mysql_fetch_array($enquirer_response,MYSQL_ASSOC);
- $comments_text=strip_tags($row1['e_response_text']);
- $newtext = wordwrap($comments_text, 40, "\n", true);
- }
- $pdf->Cell(30,2,$name,'0',0,'0');
- $pdf->Cell(15,2,$date,0,0,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->Cell(40,10, $comments_text,'0',0,'L');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(42,5,"",0,1,'c');
- $pdf->SetFont('Arial','',10);
- //$pdf->Rect(30,150,120, 40 ,'D');
- //$pdf->MultiCell(150,5,'Dopcument Name','T','L','');
- //$pdf->MultiCell(50,1,'Date','T','R','');
- //$pdf->MultiCell(30,4,'123','B','L','');
- //$pdf->MultiCell(30,4,'11','B','L','');
- //$pdf->MultiCell(30,4,'456','B','L','');
- }
- }
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(42,20,"Expert Recommendation and Suggetions:",0,1,'c');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,5,'Mrs JVM who is 42 years old has had severe recurrent Sciatica for over 2
- years. Her symptoms have been aggravated recently and she has los of sleep
- and mild functional loss. Her Von Willebrand disease status is under control
- and hematologists has confirmed no risk of bleeding tendency. Her current
- MRI shows significant disc herniation and mild osteorarthritis of facet joints.','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'Based on above she is a candidate suitable for repeat discectomy. It is
- preferable to do an open discectomy. The Sciatica is likely to respond to
- repeat surgery but back ache related to facet joint arthritis may persist and will
- need pain management. Surgery may also help prevent further loss of
- sensation and muscle power','0','L','');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(42,20,"References and Evidence base analysis:",0,1,'c');
- //$pdf->Write(5,'Visit ');
- //Then put a blue underlined link
- $pdf->SetTextColor(0,0,255);
- $pdf->SetFont('','U');
- $query = "select * from " .$enquirer_ref_links ." where e_dtl_id = '$e_dtl_id' ";
- //echo $query ;
- $result = mysql_query($query);
- while($row = mysql_fetch_array($result,MYSQL_ASSOC))
- {
- $links=$row['links'];
- $count=count(explode(',',$links));
- $link=explode(',',$links);
- if($count>0)
- {
- for($i=0;$i<$count;$i++)
- {
- $link_string=$link[$i];
- $pdf->Write(5,$link_string,$link_string);
- }
- }
- else
- {
- $link_string=links;
- $pdf->Write(5,$link_string,$link_string);
- }
- }
- $pdf->SetTextColor(0);
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->Cell(81,13,"SOME IMPORTANT CONSIDERATIONS:",0,1,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,5,'Spinal surgery for sciatica and spinal stenosis is better for the leg pain than it is for
- back pain. Both the leg pain and back pain may improve.','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'Symptoms of numbness or weakness may well persist after surgery','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'In patients attending general practice for the first time with sciatica 75% are better
- within 28 days. The sciatica pain may continue to improve without the need for
- surgery. The pain often gets better anyway and pain relief in the early stage may be
- achieved with tablets or injections.','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'Surgery seems to get people better quicker but has some risks associated with it..','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'Certain types of disc prolapse are more likely to recur than others. Surgery for disc
- prolapse has a recurrence rate of between 7% and 15% within ten years. This is the
- same whether or not you have an operation..','0','L','');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->Cell(60,13,"SPECIFIC USUAL BENEFITS:",0,1,'R');
- $pdf->SetFont('Arial','',10);
- $pdf->MultiCell(150,5,'70-75% of patients experience a significant improvement in leg pain. 20-25% may
- be better but still have persistent leg pain 5% may have no benefit at all 1% may be
- worse in terms of pain.','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->SetFont('Arial','B',12);
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->Cell(45,13,"Global Dx Disclaimer:",0,1,'R');
- $pdf->SetFont('Arial','B',10);
- $pdf->MultiCell(150,5,'By using this Second Opinion service, you agree to abide by the Terms
- and Conditions posted at our Web Site, including particularly the Terms
- and Conditions described below:','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->Cell(34,13,"Diagnostic Service",0,1,'R');
- $pdf->MultiCell(150,5,'The service provided through our Web site is different from the
- diagnostic services typically provided by a physician. The experts
- providing this service will not have the benefit of information that would
- be obtained by examining you in person and observing your physical
- condition. Therefore, the physician may not be aware of facts or
- information that would affect his or her opinion of your diagnosis. TO
- REDUCE THE RISK TO YOU OF THIS LIMITATION, Global Diagnosis
- STRONGLY ENCOURAGES YOU TO SHARE THE RECCOMENDATIONS
- WITH YOUR PHYSICIAN WHO WILL HAVE FINAL OPINION ON
- TREATING YOU. BY DECIDING TO ENGAGE THIS SERVICE, YOU
- ACKNOWLEDGE AND AGREE THAT YOU ARE AWARE OF THIS
- LIMITATION AND AGREE TO ASSUME THE RISK OF THIS LIMITATION.','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'BY REQUESTING A ADVICE/ INFORMATION/ OPINION PURSUANT TO
- THIS WEB SITE, YOU ACKNOWLEDGE AND AGREE THAT:','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'* THE RECCOMENDATION THAT YOU WILL RECEIVE IS LIMITED AND
- PROVISIONAL; * THE OPINION IS NOT INTENDED TO REPLACE A FULL
- MEDICAL EVALUATION OR A FACE-TO-FACE VISIT WITH A
- PHYSICIAN; * THE PHYSICIAN DOES NOT HAVE IMPORTANT
- INFORMATION THAT IS USUALLY OBTAINED THROUGH A PHYSICAL
- EXAMINATION; * THE ABSENCE OF A PHYSICAL EXAMINATION MAY
- AFFECT THE PHYSICIAN'.'S ABILITY TO DIAGNOSIS YOUR CONDITION,
- DISEASE OR INJURY;','0','L','');
- $pdf->Cell(10,5,"",0,1,'C');
- $pdf->MultiCell(150,5,'BY ENGAGING OUR SERVICES, YOU ACKNOWLEDGE AND AGREE TO
- ASSUME THE RISK OF THESE LIMITATIONS. YOU FURTHER
- UNDERSTAND THAT NO WARRANTY OR GUARANTEE HAS BEEN
- MADE TO ME CONCERNING ANY PARTICULAR RESULT OR CURE OF
- MY CONDITION.','0','L','');
- }
- header('Content-type: application/pdf');
- // Es wird downloaded.pdf benannt
- header('Content-Disposition: attachment; filename="downloaded.pdf"');
- // Die originale PDF Datei heißt original.pdf
- readfile('downloaded.pdf');
- $pdf->Output();
- //unlink( $pdf );
- ?>
Acrobat reader giving error as it was sent as email attachment and was not correctly decoded