<?php

$table_name67="Aprocess2";
$table_name100="signin2";
$table_name101="sig_map";
$table_name102="sig_map_text";
include("../../../admin/GoTool/cat.inc");
$connection = @mysql_connect($host,$user,$password) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection) or die(mysql_error());
     
//$survey_idR=$_POST['survey_id'];
$stringSS=$_POST['stringSS'];


$dataxS=explode(',', $stringSS);
$dataxM=explode(',', $stringMS);

//$dataxS[0]=22;
//$dataxM[0]=327;

$stringMS=$_POST['stringMS'];
$pic1=$_POST['pic1'];
$sig1=$_POST['sig1'];

$myname=date("Ymshis");
$myFile = "$myname.txt";
$fh = fopen("$myFile", 'w') or die("can't open file");
//$stringData = "Raw Score for this Application: $Ascore out of $maxpoints - $PerT% <br /><br/>";
//fwrite($fh, $stringData);
fclose($fh);

$myname2="bobby";
$myFile2 = "$myname2.txt";
$fh1 = fopen("../../../power/pdf3/documents/$myFile2", 'w') or die("can't open file");
$stringData = "Raw Score for this Application: $Ascore out of $maxpoints - $PerT% <br /><br/> \n";
fwrite($fh1, $stringData);
fclose($fh1);

$firstname=$_POST['first'];
$lastname=$_POST['last'];
$dateD=$_POST['createD'];
//$map_id='';
//$map_id55='';

 for ($hhh=0;$hhh<=4; $hhh++){

$sq112ass="SELECT * FROM $table_name80 WHERE survey_id = '$dataxS[$hhh]' AND map_id ='$dataxM[$hhh]' ";

$map_id=$dataxM[$hhh];
$map_id55=$dataxM[0];
$survey_idR=$dataxS[$hhh];
$survey_num=$survey_idR;

$result222 = @mysql_query($sq112ass,$connection) or die(mysql_error());
while ($row1 = mysql_fetch_array($result222)) {
$survey_id=  $row1['survey_id'];
//$map_id=  $row1['map_id'];
//$map_id55=  $row1['test_type'];          //for the new survey
  //$firstname=   stripslashes($row1['firstname']);
  // $lastname=   stripslashes($row1['lastname']);
$lastnamez=$lastname;
   $firstnamez=$firstname;

  $company=  stripslashes($row1['company']);
  $email=  stripslashes($row1['email']);
   $van5=  stripslashes($row1['van5']);
   $country=$van5;
   $van6=  stripslashes($row1['van6']);
   $state=$van6;
  $van7=  stripslashes($row1['van7']);
  $answerT[7]=$van7;
  $van8=  stripslashes($row1['van8']);
  $answerT[8]=$van8;
  $Ccreate_dateR= $row1['create_date'];
  $Ccreate_dateR=strtotime("$Ccreate_dateR");
  $Ccreate_dateR=date("n-j-Y","$Ccreate_dateR");
  $Ascore= $row1['Ascore'];

      include("../../../admin/GoTool/survey/survey-row1-variables.php");
}


//$map_id55=$dataxM[$hhh];
$sq112bb="SELECT * FROM $table_name82 WHERE map_id = '$map_id55' ";

$result222aa = @mysql_query($sq112bb,$connection) or die(mysql_error());
      while ($row1dd = mysql_fetch_array($result222aa)) {
$val_fname=  stripslashes($row1dd['firstname']);
$val_lname=  stripslashes($row1dd['lastname']);
$val_email=  stripslashes($row1dd['email']);
$val_phoneW=  stripslashes($row1dd['telephone']);
$val_phoneF=  stripslashes($row1dd['fax']);
$val_phoneC=  stripslashes($row1dd['cell']);
$val_phoneH=  stripslashes($row1dd['homeP']);
$val_addressH=  stripslashes($row1dd['addressH']);
$stateH=  stripslashes($row1dd['stateH']);
$val_cityH=  stripslashes($row1dd['cityH']);
$countryH=  stripslashes($row1dd['countryH']);
$ipH=  $row1dd['ip'];
$val_zipH=  stripslashes($row1dd['zip']);
$webH=  stripslashes($row1dd['web']);
$company=  stripslashes($row1dd['company']);

$agent_idH=  stripslashes($row1dd['agent_id']);


      }

$sq112ab="SELECT * FROM $table_name81 WHERE survey_id = '$dataxS[$hhh]'";
 //$sq112ab="SELECT * FROM $table_name81 WHERE survey_id = '$survey_idR'";
//$survey_idR=$dataxS[$hhh];
//$map_id=$dataxM[$hhh];
//$map_id55=$map_id;

$result222a = @mysql_query($sq112ab,$connection) or die(mysql_error());
while ($row1ab = mysql_fetch_array($result222a)) {
$survey_id=  $row1ab['survey_id'];
  $stitle=   stripslashes($row1ab['name']);
          }

$survey_num=$survey_id;

//  $stitle=stripslashes($_POST['stitle77']);


$summary77="MIT Application for $firstname $lastname submitted: $dateD";
$author1="GalliumGroup";
$title1 ="Sample PDF Document";
$subj1="Public Document";
$key1="Keywords, PDF, User Docs";
$today = date("Y-m-d h:i:s");
$Rtoday=$today;
$map_title=date("Ymshis");

//$map_id=$_GET['map_id'];
//if ($map_id==$blink){
//$map_id=$_POST['map_id'];
//}

$laddy="<h1>$stitle</h1> <br/> ID:$map_id <br/>Assessment:$survey_num<br/>";
$utf8text .=$laddy;

$sq112a="SELECT * FROM $table_name76 WHERE survey_id ='$survey_idR' Order By surveyQ_id ";
$survey_idR=$dataxS[$hhh];
//$map_id55=$dataxM[$hhh];
include("../../../admin/GoTool/survey/surv_display2a.php");

$utf8text2 =$display_blockAdminB;

//$myname=date("Ymshis");
//$myFile = "$myname.txt";
$fh = fopen("$myFile", 'a') or die("can't open file");

$stringData=$utf8text2 ;
fwrite($fh, $stringData);
fclose($fh);

$display_blockAdminB='';
//$l='';
//$i='';
}

 $sack=stripslashes($_POST['sack']);
   //$good1=$_POST['good1'];
   // $pic88=$_POST['pic88'];
   // $pic88="../../../admin/GoTool/survey_MIT/$pic88";
 //    $stuff88="$good1.txt";
  //$sack=1;

 $a312="Assessment";
//$a312=date("Ymshis");


    




//============================================================+
//
//
//
//string   	$name   	The name of the file when saved. Note that special characters are removed and blanks characters are replaced with the underscore character.
//string   	$dest   	Destination where to send the document. It can take one of the following values:

//    I: send the file inline to the browser (default). The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.
//    D: send to the browser and force a file download with the name given by name.
//    F: save to a local server file with the name given by name.
//    S: return the document as a string. name is ignored.
//    FI: equivalent to F + I option
//    FD: equivalent to F + D option
//============================================================+



//require_once('../config/lang/eng.php');
//require_once('../tcpdf.php');
require_once('tcpdf_include.php');    

// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor("$author1");
$pdf->SetTitle("$title1");
$pdf->SetSubject("$subj1");
$pdf->SetKeywords("$keys1");

// set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING);
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Document - $a312", PDF_HEADER_STRING);

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
//$pdf->setLanguageArray($l);

if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
    require_once(dirname(__FILE__).'/lang/eng.php');
    $pdf->setLanguageArray($l);
}


// ---------------------------------------------------------

// set default font subsetting mode
//$pdf->setFontSubsetting(true);
$pdf->setFontSubsetting(false);

// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
//$pdf->SetFont('dejavusans', '', 14, '', true);
$pdf->SetFont('dejavusans', '', 10, '', false);

// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
 //<h1>Welcome to <a href="http://www.tcpdf.org" style="text-decoration:none;color:black;"><span style="background-color:#CC0000;"> TC<span style="color:white;">PDF</span> </span></a>!</h1>

// set JPEG quality
//$pdf->setJPEGQuality(75);

// Image method signature:
// Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false)


// get esternal file content
//$utf8text = file_get_contents("$stuff88", false);
$utf8text = file_get_contents("$myFile");
//echo "$utf8text"; ’
$prob55="’";
$fix55="'";
//$utf8text=str_replace($prob55,$fix55,$utf8text);
//echo "$utf8text";

//$utf8text = iconv('UTF-8', 'ASCII//TRANSLIT', $utf8text); 
$utf8text = str_replace(chr(130), ',', $utf8text);  
$utf8text = str_replace(chr(146), "'", $utf8text);    // right single quote
$utf8text = str_replace(chr(147), '"', $utf8text);    // left double quote
$utf8text = str_replace(chr(132), '"', $utf8text);    // baseline double quote
$utf8text = str_replace(chr(133), '...', $utf8text);  // ellipsis
$utf8text = str_replace(chr(145), "'", $utf8text);    // left single quote
$utf8text = str_replace(chr(148), '"', $utf8text);    // right double quote

//$utf8text = mb_convert_encoding($utf8text, 'HTML-ENTITIES', 'UTF-8');


$pdf->Write(0, "$summary77", '', 0, 'L', true, 0, false, false, 0);

$pdf->SetFont('helvetica', '', 8);

//$pdf->Image("$good1", 15, 140, 75, 113, 'JPG', 'http://www.tcpdf.org', '', true, 150, '', false, false, 1, false, false, false);
// Set some content to print
$html = <<<EOF
 $utf8text
EOF;

// Print text using writeHTMLCell()
//writeHTML($html, $ln=true, $fill=false, $reseth=false, $cell=false, $align='')
//$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=1, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);

//$pdf->Write(15, $utf8text, '', 0, '', false, 0, false, false, 0);
//$pdf->writeHTML($html, true, 0, true, 0);
//$pdf->writeHTML($html, true, false, false,false, 0);
//$pdf->writeHTML($utf8text, true, false, true, false, '');
$pdf->writeHTML($html, true, 0, true, 0);

// set JPEG quality
$pdf->setJPEGQuality(75);

// Image method signature:
// $pdf->Image($file, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false)
//$pdf->Image($pic88, $x='', $y='', $w=0, $h=0, $type='', $link='', $align='', $resize=false, $dpi=300, $palign='', $ismask=false, $imgmask=false, $border=0, $fitbox=false, $hidden=false, $fitonpage=false);


// reset pointer to the last page
$pdf->lastPage();

// ---------------------------------------------------------

// Close and output PDF document
// This method has several options, check the source code documentation for more information.
$pdf->Output("$a312.pdf", 'FD');

//header('Location:https://411webhost.com/guest_forms/download.html');
//============================================================+
// END OF FILE
//============================================================+
?>
