Prescription class error on printing

Hi,

I need help for the prescription class codes error. I modified the codes myself. It works find in localhost but it is unable to display properly when running on webhost.

The codes are as follows:

                echo("<div class='paddingdiv'>\n");
                $this->providerid = $p->provider->id;
	        echo ("<table cellspacing='0' cellpadding='0' width='100%'>\n");
	        
			
			echo ("<td rowspan='2' class='bordered'>\n");
	        $res = sqlQuery("SELECT concat('<b>',f.name,'</b>\n',f.street,'\n',f.city,', ',f.state,' ',f.postal_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . add_escape_custom($p->provider->id) . "'");
                if (!empty($res)) {
	            $patterns = array ('/\n/','/Tel:/','/Fax:/');
	            $replace = array ('<br>', xl('Tel').':', xl('Fax').':');
	            $res = preg_replace($patterns, $replace, $res);
                }
                
	        
                echo ( $p->provider->get_name_display() . '<br>');
                
                if ($GLOBALS['rx_enable_DEA']) {
                    if ($GLOBALS['rx_show_DEA']) {
                        echo ( xl('Prescriber number ') . $p->provider->federal_drug_id . '<br>');
                    }
                    else {
                        echo ( xl('Prescriber number ') . '</b> ________________________<br>' );
                    }
                }
                if ($GLOBALS['rx_enable_NPI']) {
                    if ($GLOBALS['rx_show_NPI']) {
                        echo ( xl('NPI') . $p->provider->npi . '<br>');
                    }
                    else {
                        echo ( xl('NPI') . '</b> ________________________<br>');
                    }
               }
               if ($GLOBALS['rx_enable_SLN']) {
                   if ($GLOBALS['rx_show_SLN']) {
                       echo ( xl('State Lic. #') . $p->provider->state_license_number . '<br>');
                   }
                   else {
                       echo ( xl('State Lic. #') . '</b> ________________________<br>');
                   }
               }
	        echo ("</td>\n");
	    

            echo ("<td class='bordered'>\n");
			$res = sqlQuery("SELECT concat('<b>',f.name,'</b>\n',f.street,'\n',f.city,', ',f.state,' ',f.postal_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . add_escape_custom($p->provider->id) . "'");
                if (!empty($res)) {
	            $patterns = array ('/\n/','/Tel:/','/Fax:/');
	            $replace = array ('<br>', xl('Tel').':', xl('Fax').':');
	            $res = preg_replace($patterns, $replace, $res);
                }
                
	            echo ( $p->provider->get_name_display() . '<br>');
                
                if ($GLOBALS['rx_enable_DEA']) {
                    if ($GLOBALS['rx_show_DEA']) {
                        echo ( xl('Prescriber number ') . $p->provider->federal_drug_id . '<br>');
                    }
                    else {
                        echo ( xl('Prescriber number ') . '</b> ________________________<br>' );
                    }
                }
                if ($GLOBALS['rx_enable_NPI']) {
                    if ($GLOBALS['rx_show_NPI']) {
                        echo ( xl('NPI') . $p->provider->npi . '<br>');
                    }
                    else {
                        echo ( xl('NPI') . '</b> ________________________<br>');
                    }
               }
               if ($GLOBALS['rx_enable_SLN']) {
                   if ($GLOBALS['rx_show_SLN']) {
                       echo ( xl('State Lic. #') . $p->provider->state_license_number . '<br>');
                   }
                   else {
                       echo ( xl('State Lic. #') . '</b> ________________________<br>');
                   }
               }
			echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("<tr>\n");
			
			
			

		    echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("<tr>\n");
			
		echo ("<td rowspan='2' class='bordered'>\n");
	        $res = sqlQuery("SELECT concat('<b>',f.name,'</b>\n',f.street,'\n',f.city,', ',f.state,' ',f.postal_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . mysql_real_escape_string($p->provider->id) . "'");
	        $patterns = array ('/\n/','/Tel:/','/Fax:/');
	        $replace = array ('<br>', xl('Tel').':', xl('Fax').':');
	        $res = preg_replace($patterns, $replace, $res);
                echo ( $res['addr'] );
	        echo ("</td>\n");
			
			echo ("<td class='bordered'>\n");
			$res = sqlQuery("SELECT concat('<b>',f.name,'</b>\n',f.street,'\n',f.city,', ',f.state,' ',f.postal_code,'\nTel:',f.phone,if(f.fax != '',concat('\nFax: ',f.fax),'')) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id ='" . mysql_real_escape_string($p->provider->id) . "'");
	        $patterns = array ('/\n/','/Tel:/','/Fax:/');
	        $replace = array ('<br>', xl('Tel').':', xl('Fax').':');
	        $res = preg_replace($patterns, $replace, $res);
                echo ( $res['addr'] );
			echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("<tr>\n");
						
			
			echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("<tr>\n");
	        echo ("<td rowspan='2' >\n");
                echo ('<b><span class="small">' . xl('Patient Name & Address') . '</span></b>'. '<br>');
                echo ($p->patient->get_name_display() . '<br>');
				$res = sqlQuery("SELECT  concat(street,'\n',city,', ',state,' ',postal_code,'\n',if(phone_home!='',phone_home,if(phone_cell!='',phone_cell,if(phone_biz!='',phone_biz,'')))) addr from patient_data where pid =". mysql_real_escape_string ($p->patient->id));
                $patterns = array ('/\n/');
	        $replace = array ('<br>');
	        $res = preg_replace($patterns, $replace, $res);
                echo ($res['addr']);
				echo ('<br> <b><span class="small">' . xl('Date of Birth') . '</span></b>' . '<br>');
                echo ($p->patient->date_of_birth . '<br>' );
				echo ('<b><span class="small">' . xl('Medicare number') . '</span></b>' . '<br>');
                echo ($p->patient->get_ssn());
	        echo ("</td>\n");
	        
			echo ("<td >\n");
			    echo ('<b><span class="small">' . xl('Patient Name & Address') . '</span></b>'. '<br>');
                echo ($p->patient->get_name_display() . '<br>');
				$res = sqlQuery("SELECT  concat(street,'\n',city,', ',state,' ',postal_code,'\n',if(phone_home!='',phone_home,if(phone_cell!='',phone_cell,if(phone_biz!='',phone_biz,'')))) addr from patient_data where pid =". mysql_real_escape_string ($p->patient->id));
                $patterns = array ('/\n/');
			$replace = array ('<br>');
	        $res = preg_replace($patterns, $replace, $res);
                echo ($res['addr']);
				echo ('<br> <b><span class="small">' . xl('Date of Birth') . '</span></b>' . '</br>');
                echo ($p->patient->date_of_birth. '<br>' );
				echo ('<b><span class="small">' . xl('Medicare number') . '</span></b>' . '<br>');
                echo ($p->patient->get_ssn());
	        echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("<tr>\n");
	        
			
			echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("<tr>\n");
	        echo ("<td rowspan='2' class='bordered'>\n");
                echo ('<span class="small">' . xl('Prescriptions') . '</span></b>');
	        echo ("</td>\n");
			
			echo ("<td class='bordered'>\n");
                echo ('<span class="small">' . xl('Prescriptions') . '</span></b>');
				
            echo ("</td>\n");    
			echo ("</tr>\n");
	        echo ("</tr>\n");
	        echo ("</table>\n");
        }

        function multiprintcss_preheader() {
	        // this sets styling and other header information of the multiprint css sheet
                echo ("<html>\n");
                echo ("<head>\n");
                echo ("<style>\n");
	        echo ("div {\n");
	        echo (" padding: 0;\n");
	        echo (" margin: 0;\n");
	        echo ("}\n");
                echo ("body {\n");
                echo (" font-family: sans-serif;\n");
                echo (" font-weight: normal;\n");
                echo (" font-size: 10pt;\n");
                echo (" background: white;\n");
                echo (" color: black;\n");
                echo ("}\n");
	        echo ("span.large {\n");
	        echo (" font-size: 12pt;\n");
	        echo ("}\n");
	        echo ("span.small {\n");
	        echo (" font-size: 6pt;\n");
	        echo ("}\n");
	        echo ("td {\n");
	        echo (" vertical-align: top;\n");
	        echo (" width: 50%;\n");
	        echo (" font-size: 10pt;\n");
	        echo (" padding-bottom: 8pt;\n");
	        echo ("}\n");
	        echo ("td.bordered {\n");
	        echo (" border-top:1pt solid black;\n");
	        echo ("}\n");
                echo ("div.paddingdiv {\n");
                echo (" width: 524pt;\n");
	        echo (" height: 668pt;\n");
                echo ("}\n");
            
			echo ("div.scriptdiv {\n");
	        echo (" padding-top: 12pt;\n");
	        echo (" padding-left: 0pt;\n");
			echo (" padding-bottom: 22pt;\n");
	        echo (" float: left;\n");
		    echo ("}\n");
			
			echo ("div.scriptdiv1 {\n");
	        echo (" padding-top: 12pt;\n");
	        echo (" padding-bottom: 22pt;\n");
	        echo (" padding-left: 0pt;\n");
			echo (" float: right;\n");
			echo (" padding-right: 128px;\n");
			echo ("}\n");
	        
			
			echo ("div.signdiv {\n");
	        echo (" margin-top: 18px;\n");
                echo (" font-size: 12px;\n");
				echo (" float: left;\n");
			echo ("}\n");
			
			echo ("div.signdiv1 {\n");
	        echo (" margin-top: 21px;\n");
			echo (" padding-left: 24px;\n");
			echo (" float: right;\n");
			echo (" margin-right: 35px;\n");
			    echo (" font-size: 12px;\n");
	        echo ("}\n");
                echo ("</style>\n");

                echo ("<title>" . xl('Prescription') . "</title>\n");
                echo ("</head>\n");
                echo ("<body>\n");
        }

	function multiprintfax_footer( & $pdf ) {
		return $this->multiprint_footer( $pdf );
	}

	function multiprint_footer(& $pdf, $p) {
		$this->providerid = $p->provider->id;
		$pdf->ezText('<b>' . $p->provider->get_name_display() . '</b>',12);
		if($this->pconfig['use_signature'] && ( $this->is_faxing || $this->is_print_to_fax ) ) {
			$sigfile = str_replace('{userid}', $_SESSION{"authUser"}, $this->pconfig['signature']);
			if (file_exists($sigfile)) {
				$pdf->ezText( xl('Signature') . ": ",12);
				// $pdf->ezImage($sigfile, "", "", "none", "left");
				$pdf->ezImage($sigfile, "", "", "none", "center");
				$pdf->ezText( xl('Date') . ": " . date('Y-m-d'), 12);
				if ( $this->is_print_to_fax ) {
					$pdf->ezText(xl('Please do not accept this prescription unless it was received via facsimile.'));
				}

				$addenumFile = $this->pconfig['addendum_file'];
				if ( file_exists( $addenumFile ) ) {
					$pdf->ezText('');
					$f = fopen($addenumFile, "r");
					while ( $line = fgets($f, 1000) ) {
						$pdf->ezText(rtrim($line));
					}
				}

				return;
			}
		}
		$pdf->ezText("\n\n\n\n" . xl('Signature') . ":________________________________\n" . xl('Date') . ": " . date('Y-m-d'),12);
	}

        function multiprintcss_footer() {
			
	        echo ("<table>\n");
	            echo ("</tr>\n");
	            echo ("<td>\n");
				
				echo ("<div class='signdiv'>\n");
                echo (xl('Signature') . ":________________________________<br>");
                echo (xl('Date') . ": " . date('Y-m-d'). '<br>');
	            
                echo (xl(' test '). '<br>');
			echo ("</div>\n");
			echo ("</td>\n");
			    
				echo ("<td>\n");
				                
				echo ("<div class='signdiv1'>\n");
				
                echo (xl('Signature') . ":________________________________<br>");
                echo (xl('Date') . ": " . date('Y-m-d'). '<br>');
				
				echo (xl(' test '). '<br>');
	        echo ("</div>\n");
            echo ("</td>\n");
	        echo ("</tr>\n");
	        echo ("</table>\n");
		}

Please advise.

Thanks

Hi jhunyan,

Have you moved all local file changes to your hosting environment?
Kindly share the screen-shot of the problem you are facing.

Thanks,
ViSolve

Here is the snapshot running on localhost.

This is the snapshot for running on webhost

What version OpenEMR and have you looked at your php error log on host?

Hello jhunyan,
Do you have this error once after your customization? What is the state before customization?
Please check with your customization coding part.
Check the PHP congiguration (php.ini) in both local and hosting environment.
Make sure that both configuration are same.

Thanks,
ViSolve

Hi,

The Openemr version I am using is the latest version 5.

The error occured after customization. There was no error at all before the customization.

I checked the PHP.ini configuration and this should not be the problem.

Please advise.

Thanks

My humble suggestion is to back out of the modification and revert to the original code. Once the web host is running, then introduce a little code at a time until the web host hangs.

It is extremely difficult for us to say where the error is in the code you wrote. However, if you take a step by step approach to injecting the code into the web host. You should find the issue in no time at all.