<?php
function __showHeader(&$rowx=0, &$styleArray, &$row1, &$row2, &$row3, &$jn_trans_name) {
	global $activeSheet;
	
	$headTable = array (
		$row1, $row2, $row3, $jn_trans_name
	);
	$styleArray = array (
	  'font' => array (
		'bold' => true
	  ) 
	);
	
	foreach ($headTable as $value) {
		if ($value) {
			$rowx++;
			$activeSheet->setCellValue("A".$rowx, $value);
			$activeSheet->mergeCells("A".$rowx.":D".$rowx);
			$activeSheet->getStyle("A".$rowx.":D".$rowx)->getAlignment()->setHorizontal('center');
			$activeSheet->getStyle("A".$rowx.":D".$rowx)->applyFromArray($styleArray);  
		}
	}
	return array ($styleArray, $rowx);
}

include_once (__DIR__ . "/func_" . str_replace("_full", "", $laporan));
//if (!isset($jenis_transaksi)) $jenis_transaksi = null;
$jn_trans = $jn_trans_name = $valuesID = null;
$_transaksi = (isset($_transaksi) ? $_transaksi : (isset($_POST["_transaksi"]) ? $_POST["_transaksi"] : null ));
$jenis_transaksi = (isset($jenis_transaksi) ? $jenis_transaksi : (isset($_POST["jenis_transaksi"]) ? $_POST["jenis_transaksi"] : null ));

//var_dump ($jenis_transaksi);
if ($jenis_transaksi!=null || $_transaksi!=null) {	// array
	$jn_trans = $valuesID = '';
	if ($jenis_transaksi!=null) {
		//var_dump ($jenis_transaksi);		
		foreach ($jenis_transaksi as $arr) {
			if (!$jn_trans) $jn_trans = " AND jn_trans in ("; else $jn_trans .= ",";
			$jn_trans .= $arr;
			if ($valuesID) $valuesID .= ',';
			$valuesID .= $arr;
		} if($jn_trans) $jn_trans .= ") ";
		//$_transaksi = $valuesID; 
	} else if ($_transaksi!=null) {
		//echo "transaksi: ".$_transaksi."<br>";
		//echo "<br>_transaksi: ".$_transaksi;
		$_transaksi = explode(',',$_transaksi);
		$jenis_transaksi = array();
		foreach ($_transaksi as $arr) {
			if (!$jn_trans) $jn_trans = " AND jn_trans in ("; else $jn_trans .= ",";
			$jn_trans .= $arr;
			//$jenis_transaksi[] = $arr;
			if ($valuesID) $valuesID .= ',';
			$valuesID .= $arr;
		} if($jn_trans) $jn_trans .= ") ";
	}
	//echo "<br>jn_trans: ".$jn_trans;
	
	if ($valuesID) {
		$sql7 = 
		" SeLECT * FROM form_element_value " .
		" WHERE elementSubParentID = 92 " .
		" AND valueID in (".$valuesID.")";
		//echo "<br>sql7: ".$sql7;
		if ($hasil7 = mysqli_query($conn, $sql7)) {
			while ($data7 = mysqli_fetch_array($hasil7)) {
				if ($jn_trans_name) $jn_trans_name .= ', ';
				$jn_trans_name .= $data7["valueName"];
			}
		}
	}
}
//echo '<p>'.$jn_trans.'</p>';
//$jn_trans2 = " AND jn_trans not in (1220, 1214, 1219) ";
//$jn_trans2 = " AND jn_trans = 1217 ";

$txt_remark = $txt_pic = null;
if ($remark && $pic) {
	$txt_remark = " ";
	$txt_pic 	= " ";
} else if (!$remark && $pic) {
	$txt_remark = " AND remark = '0' ";
	$txt_pic 	= " ";
} else if ($remark && !$pic) {
	$txt_remark = " ";
	$txt_pic 	= " AND pic = '0' ";
} else if (!$remark && !$pic) {
	$txt_remark = " AND remark = '0' ";
	$txt_pic 	= " AND pic = '0' ";
}

$head_report_trans_rekap = '
<div align="center" style="border-top:1px solid #333; margin:0; padding:25px 0px 10px 0px">
	<strong> '.$row1.'</strong><br><br>
	<div align="right">
		as of '.date("d M Y ", strtotime($date_end)).' pukul '.date("H:m").'
	</div>
</div>';

$head_report_negara_kel_produk = '
<div align="center" style="border-top:1px solid #333; margin:0; padding:25px 0px 10px 0px">
	<strong> '.$row1.'</strong><br>
	'.$row2;
	if (isset($jn_trans_name) != null) 
		$head_report_negara_kel_produk .= 
		'<br><strong>'.$row3.'</strong><br>'.$jn_trans_name;
	$head_report_negara_kel_produk .= '
</div>';
?>