<?php
	require_once 'globalad.php';
	require_once '../class/Bank.php';
	require_once '../class/BSM_Online.php';
	require_once '../class/AccountBank.php';	
	require_once '../class/class.Mandiri.php';	
	
	$accbank = new AccountBank();
	$bank = new Bank();
	$bsmonline = new BSM_Online();
	$mandiri = new Mandiri();
		
	if (empty($userid)){
		redirecting("index.php");
	}	
	
	if (empty($useraccess['manage_bsm_online_bank'])){
		redirecting('index.php');
	}
	
	$_GET['id'] = ((empty($_GET['id']))?array():$_GET['id']);
	if (!is_array($_GET['id'])){
		$_GET['id'] = array($_GET['id']);
	}
	$trid = $_GET['id'];
	
	if (sizeof($trid) > 0){
		$invoicetemplate = '';
		$tmpl = gettemplate('invoice_online');
		
		sort($trid);
		
		foreach ($trid as $id){
			
			$ab = $ab = $db->fetch_one("SELECT t.*, DATE_FORMAT(t.created_date, '%M %d, %Y, %h:%i %p') AS f_transaction_date FROM bsm_online t WHERE id = '".$db->clean($id)."'");
			
			if (empty($ab['id'])){
				continue;
			}
			
			$date = $ab['f_transaction_date'];
			$kode_transaksi = empty($ab['transactionnumber'])?'':htmlspecialchars($ab['transactionnumber']);
			$bank = empty($ab['to_bank'])?'':htmlspecialchars($ab['to_bank']);
			$no_rekening = empty($ab['to_account'])?'':htmlspecialchars($ab['to_account']);
			$no_ref = empty($ab['cust_ref_number'])?'':htmlspecialchars($ab['cust_ref_number']);
			$name = empty($ab['to_accname'])?'':htmlspecialchars($ab['to_accname']);
			$amount = empty($ab['amount'])?'':number_format($ab['amount'], 2);
			$notes = empty($ab['note'])?'':nl2br(htmlspecialchars($ab['note']));
			$email = empty($ab['to_email'])?'':htmlspecialchars($ab['to_email']);
			
			
			//$db->query("UPDATE transaction SET print_status = 'T' WHERE transaction_id = '".$db->clean($id)."'");
			
			eval("\$invoicetemplate .= \"$tmpl\";");

			
		}
		//echo $invoicetemplate;exit;
		require_once("../incl/pdf/html2pdf.class.php");
		$pdf= new HTML2PDF('P','A4', 'en', false, 'ISO-8859-15');
		//echo $invoicetemplate;exit;
		$pdf->WriteHTML($invoicetemplate);
		$pdf->Output("INVOICE_ONLINE.pdf");
		
		/* require_once "incl/global_template.php";
		$tmpl = gettemplate('invoice');
		eval("\$template = \"$tmpl\";");
		echo $template; */
	}
?>