<?	
include_once'../lib/pdflib/class.ezpdf.php';//inherit...
include_once'../lib/library.php';
require_once('../configDB.inc.php');
require_once('../configTable.inc.php');
//************************ SQL QUERY 4 CompanyProfile record *****************************************
$table = "$tbl_employee e ,$tbl_companyprofile c";
$column = "where e.companyPkey = c.companyPkey";
$gdcompanycode=get_data($table,"*",$column);	
//-------------------------SQL QUERY 4 audittrail report----------------------------------
$auditpky=$_GET['auditTrailPkey'];
//----------------------SQL QUERY 4 ISI REPORT------------------------------------------------
//condition

            $data = array();
			$Query="SELECT * FROM $tbl_audittrail
					INNER JOIN $tbl_employee
					ON audittrail.employeePkey=employee.employeePkey
					WHERE auditTrailPkey='".$auditpky."'";
			
					//echo $Query;
					//exit();
			$ResultAll=mysql_query($Query);
			
			$i=0;
			while($myrow=mysql_fetch_array($ResultAll, MYSQL_ASSOC)){
			 $data[$i]['BIL']=$i+1;
			 $data[$i]['EMPLOYEE NAME']=$myrow['employeeFullname'];
			 $data[$i]['IP ADDRESS']=$myrow['auditTrailIP'];
			 $data[$i]['DATE & TIME']=unconverttounix($myrow['auditTrailDateTime']); 
			 $data[$i]['MODULE INVOLVED']=$myrow['auditTrailModule']; 
			 $data[$i]['TRANSACTION']=$myrow['auditTrailTransaction'];
			 $i=$i+1;
}


//-------------------------------------------------------------------------------------------------------
class Creport extends Cezpdf {
function Creport($p,$o){
  $this->Cezpdf($p,$o);
	}
}

$pdf = new Creport('a4','portrait');
$pdf -> ezSetMargins(35,50,30,50);

//$mainFont = './fonts/Helvetica.afm';
$mainFont = '../lib/pdflib/fonts/Arial-Narrow.afm';
$codeFont = '../lib/pdflib/fonts/Courier.afm';
$pdf->selectFont($mainFont);
// put a line top and bottom on all the pages
$all = $pdf->openObject();
$pdf->saveState();
$pdf->setStrokeColor(0,0,0,1);
$pdf->line(20,40,578,40);
$pdf->line(20,810,578,810);
// header
$pdf->addText(30,815,11,'SmartHR v3');
$pdf->addText(400,815,11,$gdcompanycode['companyname']);//utk dapatkan nama company ikut 
//footer
$pdf->addText(30,30,11,'Date:'.date('d-m-Y').'  Time:'.date('G:i:s'));
$pdf->restoreState();
$pdf->closeObject();
// note that object can be told to appear on just odd or even pages by changing 'all' to 'odd'
// or 'even'.
$pdf->addObject($all,'all');

$pdf->ezStartPageNumbers(500,28,10,'','',1);

//-------------------------------mula design display utk PDF------------------------------------------------------------------
//-----------------------------------get company name----------------------------------------
$pdf->ezSetDy(-15);
$pdf->addText(30,$pdf->y,11,"<b>".$gdcompanycode['companyname']."</b>");
$pdf->ezSetDy(-13);
$pdf->addText(30,$pdf->y,11,$gdcompanycode['companystreet1'].", ".$gdcompanycode['companystreet2']);
$pdf->ezSetDy(-13);
$pdf->addText(30,$pdf->y,11,$gdcompanycode['companyzipcode']." ".$gdcompanycode['companycity'].", ".$gdcompanycode['companystate']);
//------------------------------------------------------------
$pdf->ezSetDy(-13);
$pdf->addText(30,$pdf->y,11,'Tel: '.$gdcompanycode['companyphone']."  Fax: ".$gdcompanycode['companyfax']."  Email:".$gdcompanycode['companyemail']);
$pdf->ezSetDy(-5);
$pdf->line(25,$pdf->y,570,$pdf->y);
$pdf->ezSetDy(-2);
$pdf->line(25,$pdf->y,570,$pdf->y);
	
//---------------------------------------------------------------------------------	
$pdf->ezSetDy(-20);
$pdf->ezText("<b><U>AUDIT TRAIL REPORT</U></b>",14,array('justification'=>'centre'));
$pdf->ezSetDy(-10);

//-----------------------if no rekod-------------------------------------------------------
$CountAll=mysql_num_rows($ResultAll);
if($CountAll<1)
{
$pdf->ezSetDy(-15);
$pdf->ezText("<b>-Sorry,  No Audit Trail Report-</b>",12,array('justification'=>'center'));
$pdf->ezSetDy(-5);
}
//-----------------------------------------------------------------------------

$mycol=array('maxWidth'=>500,'xPos'=>'left','xOrientation'=>'right','font'=>11,'cols'=>array('BIL'=>array('width'=>30),'EMPLOYEE NAME'=>array('width'=>150),'IP ADDRESS'=>array('width'=>100),'DATE & TIME'=>array('width'=>60),'MODULE INVOLVED'=>array('width'=>100),'TRANSACTION'=>array('width'=>120)));
		$pdf->ezTable($data,'',$myTag,$mycol);//(msk data dr db,'array cols','title',design column2)

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

if (isset($d) && $d){
  $pdfcode = $pdf->ezOutput(1);
  $pdfcode = str_replace("\n","\n<br>",htmlspecialchars($pdfcode));
  echo '<html>';
  echo '<head><title>';
  echo '</title></head><body>';
  echo trim($pdfcode);
  echo '</body></html>';
} else {
  $pdf->ezStream();
}


?>