<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.7

Copyright (C) 2006-2007  Sylvain FATOME
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/


// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/fic_age.inc.php");
include_once("../inc/fic_do.inc.php");
include_once("../inc/fic_st.inc.php");
include_once("../inc/fic_hum.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_int.inc.php");
include_once("../inc/fic_ot.inc.php");
include_once("../inc/fic_tec.inc.php");
include_once("../inc/fic_txt.inc.php");
include_once("../inc/func_time.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/func_txtcm.inc.php");
include_once("../inc/func_geo.inc.php");
Archivelog(@$_SESSION["code_log"]);

$co = strip_tags(trim($_GET['co']));	// Récupération code Intervention
$cg = strip_tags(trim($_GET['cgv']));	// Récupération si avec ou sans CGV
$niv_util = @$_SESSION["niv_log"];
	
if ($cg == "ok")
	$cgv = TRUE;
else
	$cgv = FALSE;
	
$pbm_otpdf = FALSE;

if ($co <> "")
{
	$row = lit_enr_ot($co);
	if (is_array($row))
	{
		extract ($row);
		
		// Contrôle de hack pour un sous-traitant
		if ((($niv_util == 11) OR ($niv_util == 10)) AND ($ot_codest <> @$_SESSION["code_st"]))
			$pbm_otpdf=TRUE;
		
		if ($pbm_otpdf==FALSE)
		{
			$ot_dateddef = formatedate($ot_datedde);
			$ot_datemodf = formatedate($ot_datemod);
			$ot_dateddef = formatedate($ot_datedde);
			$ot_daterdvf = formatedate($ot_daterdv);
			$ot_dateprevf = formatedate($ot_dateprev);
			$ot_datefinf = formatedate($ot_datefin);
	
			$row = lit_enr_int($ot_codeint);
			if (is_array($row))
			{
				extract ($row);
		
				// Coordonnées agence concernée
				$row = lit_enr_age($int_codeage);
				extract ($row);
		
				$cp_age = Retournecp_openId($age_ville,TRUE);
				$ville_age = Retourneville_openId($age_ville,TRUE);

				// Coordonnées compte client
				// & site intervention client
				if ($int_idsite>0)
				{
					$row = lit_enr_scli($int_idsite,TRUE);
					extract ($row);
				}
				else
				{
					$row = lit_enr_cli($int_codecli);
					extract ($row);
				}
			}

			// Coordonnées compte sous-traitant
			if ($ot_codest<>"")
			{
				$row = lit_enr_st($ot_codest);
				extract ($row);
		
				$cp_st = Retournecp_openId($st_ville,TRUE);
				$ville_st = Retourneville_openId($st_ville,TRUE);
			}
	
	
			// Coordonnées technicien
			$row = lit_enr_tec($ot_codetec);
			if (is_array($row))
				extract ($row);
	
			// Récupération du total travaillé & Techniciens traitants
			$nbtotalsec = 0;
			$str_tec_traitants = "";
			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
	
			// Récupération total travaillé
			$rech = "SELECT * FROM `" .TBOTH. "` WHERE `oth_codeot`= '".$co."'";
			$rs = mysql_query($rech);
			if (mysql_num_rows($rs) <> 0)
			{
				while ($row = mysql_fetch_assoc($rs)) 
				{         
					if ($row["oth_offert"] == 0)
						$nbtotalsec = $nbtotalsec + diff_time_sec($row["oth_heurea"],$row["oth_heured"]);
				}
			}
	
			// Chaîne des techniciens traitants
			$rech = "SELECT DISTINCT oth_codetec FROM `" .TBOTH. "` WHERE `oth_codeot`= '".$co."'";
			$rs = mysql_query($rech);
			if (mysql_num_rows($rs) <> 0)
			{
				while ($row = mysql_fetch_assoc($rs)) 
				{
					$rech2 = "SELECT tec_nom, tec_prenom FROM `" .TBTEC. "` WHERE `tec_code`= '".$row["oth_codetec"]."' ORDER BY tec_nom";
					$rs2 = mysql_query($rech2);
					if (mysql_num_rows($rs2) <> 0)
					{
						if ($row2 = mysql_fetch_assoc($rs2))
							$str_tec_traitants .= $row2["tec_nom"]." ".$row2["tec_prenom"].", ";
					}
					mysql_free_result($rs2);
				}
			}
			$str_tec_traitants = substr($str_tec_traitants,0,strlen($str_tec_traitants)-2).".";
			mysql_free_result($rs);
			mysql_close($conn);
	
			include_once('../classes/fpdf/fpdf.php');
			include_once('../inc/fpdf_ext.inc.php');
			
			$pdf=new PDF();
			$pdf->FPDF('P','mm','A4');
			$pdf->SetDisplayMode('real');
			$pdf->AliasNbPages();
			$pdf->SetTitle('Ordre N°'.$ot_code);
			$pdf->SetSubject('Ordre N°'.$ot_code);
			$pdf->settheader("ot");
			$pdf->AddPage();
	
			$pv_det_cli = $pv_ent_age; // Récupération de la position sous l'entête agence pour le pointeur détail client
			$pv_det_ot = $pv_ent_age; // Récupération de la position sous l'entête agence pour le pointeur détail ordre
	
			$pdf->SetLineWidth(0.4);
	
			// Impression du détail client
	
			$pdf->SetY($pv_det_cli); // Renvoie le pointeur SOUS l'entête agence
	
			$pdf->SetFont('Arial','BU',12); // Titre
			if ($int_idsite==0) // S'il s'agit du site principal
			{
				$pdf->Cell(95,5,'CLIENT','LTR',1,'C');
			
				$ent_cli = ""; // Détail
				if ($cli_ste <>"") 
				{
					$ent_cli.=$cli_ste."\n";
					$ent_cli.= $cli_civilite." ".$cli_prenom." ".$cli_nom."\n";
				}
				else
				{
					$ent_cli.= $cli_civilite." ".$cli_prenom." ".$cli_nom."\n\n"; // Double saut pour compenser le manque de la société
				}
				$pdf->SetFont('Arial','B',10);
				$pdf->MultiCell(95,4,$ent_cli,'LR','L');
		
				$ent_cli = $cli_adr1."\n"; // Suite...
				$ent_cli.= $cli_adr2."\n";
				$ent_cli.= Retournecp_openId($cli_ville,TRUE)." ".Retourneville_openId($cli_ville,TRUE)."\n";
				$ent_cli.= "Tel : ".$cli_telf."\n";
				$ent_cli.= "Fax : ".$cli_fax;

				$pdf->SetFont('Arial','',10);
				$pdf->MultiCell(95,4,$ent_cli,'LRB','L');
			}
			else // S'il s'agit d'un site secondaire
			{
				$pdf->Cell(95,5,'SITE INTERVENTION','LTR',1,'C');
			
				$ent_scli = ""; // Détail
				$ent_scli.=$scli_ste."\n";
				$ent_scli.= $scli_rcivil." ".$scli_rprenom." ".$scli_rnom."\n";
				$pdf->SetFont('Arial','B',10);
				$pdf->MultiCell(95,4,$ent_scli,'LR','L');
		
				$ent_scli = $scli_adr1."\n"; // Suite...
				$ent_scli.= $scli_adr2."\n";
				$ent_scli.= Retournecp_openId($scli_ville,TRUE)." ".Retourneville_openId($scli_ville,TRUE)."\n";
				$ent_scli.= "Tel : ".$scli_telf."\n";
				$ent_scli.= "Fax : ".$scli_fax;

				$pdf->SetFont('Arial','',10);
				$pdf->MultiCell(95,4,$ent_scli,'LRB','L');
			}
	
			// Impression du détail ordre
	
			$pdf->SetY($pv_det_ot); // Renvoie le pointeur SOUS l'entête agence
	
	
			$pdf->Cell(95);
			
			$pdf->SetFont('Arial','',8);  // Niveau d'urgence
			$pdf->Cell(95,5,$ot_urg,'LTR',1,'R');
	
			$pdf->Cell(95);
	
			$ent_ot = "Agence :\n";
			$ent_ot.= "Exécutant :\n";
			$ent_ot.= "\n";
			$ent_ot.= "Statut :\n";
			$ent_ot.= "Lieu :\n";
			$ent_ot.= "Rendez-vous :\n\n";
	
			$pdf->MultiCell(22,4,$ent_ot,'B','R');
	
			$pdf->SetY($pv_det_ot+5); // Renvoie le pointeur SOUS l'entête agence + 5mm (cellule niveau urgence)
			$pdf->Cell(117);
	
			$ent_ot = $int_codeage."\n";
			$ent_ot.= $ot_codest."\n";
			$ent_ot .= "\n";
	
				// Récupération libellé statut
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rs = mysql_query("SELECT * FROM ".TBSTA." WHERE statut_code='".$ot_codestatut."'");
				if ($row = mysql_fetch_array($rs))
				{
					extract($row);
				}
				mysql_free_result($rs);
				mysql_close($conn);
	
			$ent_ot.= $statut_desc."\n";
	
				// Récupération libellé lieu
				$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
				mysql_select_db(DBNAME);
				$rs = mysql_query("SELECT * FROM ".TBLIEU." WHERE lieu_code='".$ot_codelieu."'");
				if ($row = mysql_fetch_array($rs))
				{
					extract ($row);
				}
				mysql_free_result($rs);
				mysql_close($conn);
	
			$ent_ot.= $lieu_desc."\n";
			if ($ot_daterdvf <> "")
				$ent_ot.= $ot_daterdvf." (à partir de ".substr($ot_hrdv,0,5).")\n\n";
			else
				$ent_ot.= "-\n\n";
	
			$pdf->MultiCell(73,4,$ent_ot,'BR','L');
			
			$pdf->ln(2);
			
			$pdf->SetLineWidth(0.2);
			$pdf->SetDrawColor(220);
	
			// Détail de la prise en charge
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Matériel : ',0,0,'R');
			$pdf->SetFont('Arial','',8);
			$pdf->MultiCell(150,4,$ot_mat,1,'L');
	
			$pdf->ln(1);
	
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Descriptif Problème : ',0,0,'R');
			$pdf->SetFont('Arial','',8);
			$pdf->MultiCell(150,4,$ot_pbm,1,'L');
			
			$pdf->ln(1);
	
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Garantie : ',0,0,'R');
			$pdf->SetFont('Arial','',8);
			if ($ot_gar == 0)
				$pdf->Cell(8,5,'Non',0,0,'L');
			else
				$pdf->Cell(8,5,'Oui',0,0,'L');
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Référence Facture : ',0,0,'R');
			$pdf->SetFont('Arial','',8);
			$pdf->Cell(102,5,$ot_fgar,0,1,'L');
	
			$pdf->ln(2);
	
			// Détail du traitement du dossier
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Technicien Responsable : ',0,0,'R');
			$pdf->SetFont('Arial','',8);
			$pdf->MultiCell(150,4,$tec_civilite." ".$tec_prenom." ".$tec_nom,1,'L');
	
			$pdf->ln(1);
	
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Technicien(s) traitant(s) : ',0,0,'R');
			$pdf->SetFont('Arial','',8);
			$pdf->MultiCell(150,4,$str_tec_traitants,1,'L');
	
			$pdf->ln(1);
	

			$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
			mysql_select_db(DBNAME);
	
			$rech = "SELECT * FROM `" .TBOTH. "` WHERE `oth_codeot`= '".$co."' ORDER BY oth_date";
			$rs = mysql_query($rech);
			if (mysql_num_rows($rs) <> 0)
			{
				$pdf->SetFont('Arial','B',8);
				$pdf->Cell(40,5,'Détail horaires & techniciens : ',0,1,'R');
				$pdf->SetFont('Arial','',8);
				$pdf->SetFont('Arial','IU',7); // Titres
				$pdf->Cell(7);
				$pdf->Cell(14,4,'Date',1,0,'C');
				$pdf->Cell(50,4,'Technicien',1,0,'C');
				$pdf->Cell(50,4,'Lieu',1,0,'C');
				$pdf->Cell(16,4,'Heure début',1,0,'C');
				$pdf->Cell(16,4,'Heure fin',1,0,'C');
				$pdf->Cell(16,4,'Temps passé',1,0,'C');
				$pdf->Cell(10,4,'Offert',1,1,'C');
				$pdf->SetFont('Arial','I',8);

				while ($row = mysql_fetch_assoc($rs)) 
				{         
					extract($row);

					// Ligne 1
					$pdf->Cell(7);
					$pdf->SetFont('Arial','I',7);
					$pdf->Cell(14,4,formatedate($oth_date),'LR',0,'C');
					$pdf->Cell(50,4,$oth_codetec,'LR',0,'L');
					$rech2 = "SELECT * FROM ".TBLIEU." WHERE `lieu_code` = '".$oth_codelieu."'";
					$rs2 = mysql_query($rech2) or die(mysql_error());
					if (mysql_num_rows($rs2) <> 0)
					{
						if ($row2 = mysql_fetch_array($rs2))
							extract($row2);
					}
					$pdf->Cell(50,4,$lieu_desc,'LR',0,'L');
					$pdf->Cell(16,4,$oth_heurea,'LR',0,'C');
					$pdf->Cell(16,4,$oth_heured,'LR',0,'C');
					$pdf->Cell(16,4,sec_heure(diff_time_sec($oth_heurea,$oth_heured)),'LR',0,'C');
					if ($oth_offert == 1)
						$pdf->Cell(10,4,'oui','LR',1,'C');
					else
						$pdf->Cell(10,4,'-','LR',1,'C');

					// Ligne 2
					$pdf->Cell(7);
					$pdf->SetFont('Arial','I',7);
					$pdf->Cell(14,4,'','LR',0,'C');
					$rech2 = "SELECT * FROM ".TBTEC." WHERE `tec_code` = '".$oth_codetec."'";
					$rs2 = mysql_query($rech2) or die(mysql_error());
					if (mysql_num_rows($rs2) <> 0)
					{
						if ($row2 = mysql_fetch_array($rs2))
							extract($row2);
					}
					$pdf->Cell(50,4,$tec_nom." ".$tec_prenom,'LR',0,'L');
					$pdf->Cell(50,4,'','LR',0,'L');
					$pdf->Cell(16,4,'','LR',0,'C');
					$pdf->Cell(16,4,'','LR',0,'C');
					$pdf->Cell(16,4,'','LR',0,'C');
					$pdf->Cell(10,4,'','LR',1,'C');
				}
				$PosY = $pdf->GetY();
				$pdf->Line(17,$PosY,189,$PosY); // On "ferme" le tableau

				// Totaux
				$pdf->SetFont('Arial','IB',7);
				$pdf->Cell(137);
				$pdf->Cell(16,4,'Temps retenu :',0,0,'R');
				$pdf->Cell(16,4,sec_heure($nbtotalsec),0,1,'C');
			}
			else
			{
				$pdf->SetFont('Arial','B',8);
				$pdf->Cell(40,5,'Détail horaires & techniciens : ',0,1,'R');
				$pdf->SetFont('Arial','IU',7); // Titres
				$pdf->Cell(7);
				$pdf->Cell(14,4,'Date',1,0,'C');
				$pdf->Cell(50,4,'Technicien',1,0,'C');
				$pdf->Cell(50,4,'Lieu',1,0,'C');
				$pdf->Cell(16,4,'Heure début',1,0,'C');
				$pdf->Cell(16,4,'Heure fin',1,0,'C');
				$pdf->Cell(16,4,'Temps passé',1,0,'C');
				$pdf->Cell(10,4,'Offert',1,1,'C');
				$pdf->SetFont('Arial','I',8);

				for($i=0;$i<5;$i++)
				{         
					$pdf->Cell(7);
					$pdf->SetFont('Arial','I',7);
					$pdf->Cell(14,4,'','LR',0,'C');
					$pdf->Cell(50,4,'','LR',0,'L');
					$pdf->Cell(50,4,'','LR',0,'L');
					$pdf->Cell(16,4,'','LR',0,'C');
					$pdf->Cell(16,4,'','LR',0,'C');
					$pdf->Cell(16,4,'','LR',0,'C');
					$pdf->Cell(10,4,'','LR',1,'C');
				}
				$PosY = $pdf->GetY();
				$pdf->Line(17,$PosY,189,$PosY); // On "ferme" le tableau

				// Totaux
				$pdf->SetFont('Arial','IB',7);
				$pdf->Cell(137);
				$pdf->Cell(16,4,'Temps retenu :',0,0,'R');
				$pdf->Cell(16,4,'',0,1,'C');
			}
	
			$pdf->ln(1);
	
			$pdf->SetFont('Arial','B',10);
			$pdf->Cell(40,5,'Travail Effectué : ',0,0,'R');
			if ($ot_fait == "")
			{
				for ($i=0; $i<10; $i++)
				{
					$ot_fait.="\n";
				}
			}
			$pdf->SetFont('Arial','',8);
			$pdf->MultiCell(150,4,$ot_fait,1,'L');
	
			// On affiche la date où l'agence a été prévenue uniquement si elle a été complétée
			if ($ot_dateprevf <> "")
			{
				$pdf->ln(2);
		
				$pdf->SetFont('Arial','B',10);
				$pdf->Cell(40,5,'Agence prévenue le : ',0,0,'R');
				$pdf->SetFont('Arial','',8);
				$pdf->MultiCell(150,4,$ot_dateprevf,1,'L');
			}
	
			// Affichage de la date de fin uniquement si terminé
			if ($ot_datefinf <> "")
			{
				$pdf->ln(2);
	
				$pdf->SetFont('Arial','B',10);
				$pdf->Cell(40,5,'Ordre clôt le : ',0,0,'R');
				$pdf->SetFont('Arial','',8);
				$pdf->MultiCell(150,4,$ot_datefinf,1,'L');
			}
	
			$pdf->ln(2);
	
	
			$pdf->SetLineWidth(0.2);
			$pdf->SetDrawColor(0);
	
			if ($ot_codestatut <> "CLOT") // On affiche un pied de fiche intervention uniquement si c'est non clot
			{
				if ($str_tec_traitants == "") // Si pas déjà traité, texte préalable que le client doit accepter en le signant
				{
					$row = lit_enr_txt("CGV_SAV");
					extract ($row);

					$row = lit_enr_age($ot_codeage);
					extract ($row);

					$txt_sav = parse_txtcorps("age",$age_code,$txt_texte)."<BR>"; // BR important pour retour à la ligne final

					$pdf->SetFont('Arial','',6);
					$pdf->WriteHTML($txt_sav);
				}
				
				 // Si sur site (donc à effectuer), préparation d'une grille de saisie de paramètres
				if ($ot_codelieu == "SITE")
				{
					if ($str_tec_traitants == "") // Si pas déjà traité (Sinon, pas de pied)
					{
						// Si on est trop bas pour afficher la zone de signature, on effectue un saut de page
						$y_courant = $pdf->GetY();
						if ($y_courant > 245)
							$pdf->AddPage();

						$pdf->SetFont('Arial','BU',10);
						$pdf->SetFillColor(200);
						$pdf->Cell(95,5,"Horaires arrivée/ départ",'LTR',0,'C');
						$pdf->Cell(95,5,"Date & Signature Client :",'LTR',1,'C');
						$pdf->Cell(95,5,"",'LR',0,'L',1);
						$pdf->SetFont('Arial','I',8);
						$pdf->Cell(95,5,"Lu et approuvé",'LR',1,'C');
						$pdf->SetFont('Arial','BU',10);
						$pdf->Cell(95,5,"Intervention terminée / non terminée",'LTR',0,'C');
						$pdf->Cell(95,5,"",'LR',1,'L');
						$pdf->Cell(95,5,"",'LR',0,'L',1);
						$pdf->Cell(95,5,"",'LR',1,'L');
						$pdf->Cell(95,5,"Règlement",'LTR',0,'C');
						$pdf->Cell(95,5,"",'LR',1,'L');
						$pdf->Cell(95,5,"",'LRB',0,'L',1);
						$pdf->Cell(95,5,"",'LRB',1,'L');
					}
				}
				else
				{
					// Si on a pas encore traité l'intervention, on demande signature de demande de travaux
					if ($str_tec_traitants == "")
					{
						// Si on est trop bas pour afficher la zone de signature, on effectue un saut de page
						$y_courant = $pdf->GetY();
						if ($y_courant > 230)
							$pdf->AddPage();

						$pdf->Ln(5);

						$pdf->SetFont('Arial','BU',10);
						$pdf->Cell(47);
						$pdf->Cell(95,5,"Date & Signature client (Demande de travaux)",'LTR',1,'C');
						$pdf->SetFont('Arial','I',8);
						$pdf->Cell(47);
						$pdf->Cell(95,5,"Lu et approuvé",'LR',1,'C');
						for ($i=0; $i<5; $i++)
						{
							$pdf->Cell(47);
							$pdf->Cell(95,5,"",'LR',1,'L');
						}
						$pdf->Cell(47);
						$pdf->Cell(95,5,"",'LRB',1,'L');
					}
	
					// Si on a traité le dossier et que le client est prévenu, on affiche une zone de signature de travaux effectués
					if (($ot_durees <> 0) AND ($ot_dateprevf <> ""))
					{
						// Si on est trop bas pour afficher la zone de signature, on effectue un saut de page
						$y_courant = $pdf->GetY();
						if ($y_courant > 230)
							$pdf->AddPage();

						$pdf->Ln(5);

						$pdf->SetFont('Arial','BU',10);
						$pdf->Cell(47);
						$pdf->Cell(95,5,"Date & Signature client (Travaux effectués)",'LTR',1,'C');
						$pdf->Cell(47);
						$pdf->SetFont('Arial','I',8);
						$pdf->Cell(95,5,"Lu et approuvé",'LR',1,'C');
						for ($i=0; $i<5; $i++)
						{
							$pdf->Cell(47);
							$pdf->Cell(95,5,"",'LR',1,'L');
						}
						$pdf->Cell(47);
						$pdf->Cell(95,5,"",'LRB',1,'L');
					}
				}
			}
	
			if ($cgv == TRUE)
			{
				$pdf->AddPage();
				
				$row = lit_enr_txt("CGV_MASTER");
				extract ($row);
	
				$pdf->SetFont('Arial','BU',10);
				$txt_ent = parse_txtcorps("cdg","",$txt_entete);
				$pdf->MultiCell(190,5,$txt_ent."\n\n",0,'C');
	
				$txt_texte = formatetxt($txt_texte);
				$txt_cgv = parse_txtcorps("cdg","",$txt_texte)."<BR>"; // BR important pour retour à la ligne final
	
				$pdf->SetFont('Arial','',6);
				$pdf->WriteHTML($txt_cgv);
			}
	/*
			//Détermination d'un nom de fichier temporaire dans le répertoire courant
			$file=basename(tempnam(getcwd(),'tmp'));
			rename($file,$file.'.pdf');
			$file.='.pdf';
	*/
			// $pdf->Output($file,'D');
			$pdf->Output('int_'.$ot_code,'I');
		}
	}
	else
	{
		$pbm_otpdf = TRUE;
	}			
}
else
{
	$pbm_otpdf = TRUE;
}

if ($pbm_otpdf == TRUE)
{
?>
	<script type="text/javascript">
	self.close('');
	</script>
<?PHP
}
?>
