<?php
include "../../config/koneksi.php";



	$cek = mysql_query("
								select 'MutasiTax' AS `Mutasi`,'0','Tax' as tax,`mutasitaxm`.`billno` AS `pk`,`mutasitaxm`.`billdate` AS `billdate`,0 AS `0`,'' AS `Name_exp_50`,`mutasitaxm`.`dateadded` AS `dateadded`
								,`mutasitax`.`produk` AS `produk`,if((`mutasitaxm`.`gudang2` = 1),`mutasitax`.`qty`,(-(1) * `mutasitax`.`qty`)) AS `qty`,0 AS `0` 
								from (`mutasitaxm` join `mutasitax` on(((`mutasitax`.`mutasi` = `mutasitaxm`.`billno`) and (`mutasitaxm`.`status` = 'Y')))) ");
	$i = 0;
	while ($r=mysql_fetch_array($cek)){	
			$i = $i + 1;
			// if ($i == 8220){
				// echo"$r[jenis], $r[billno],$r[billdate],$r[cust],$r[custname],$r[produk], $r[qty], $r[harga]";
			// }
			$custname = str_replace("'","",$r['custname']);
			mysql_query("INSERT INTO qqtmpproduk(jenis,billno,billdate,cust,custname,dateadded,produk,qty,harga,status,ucode,tax) VALUES('$r[jenis]','$r[billno]','$r[billdate]','$r[cust]','$custname','$r[dateadded]','$r[produk]','$r[qty]','$r[harga]','$i','$r[ucode]','$r[tax]')");


	}
	

	mysql_query("Update setup set setup = 'N' where id = 1");
	//echo $i;
	header('location:data.php');

?>