<?php
 session_cache_expire(1440);
session_start();
session_name("insys");
include "include/config.php";
include "include/functions.php";
//include "class/template_class.php";
include "include/report_generator.php";

$dir="report/inventory/print/";
$paramsx=array();

switch ($_REQUEST['form']) {
    case "stockmasuk":
        $ssql="select ftstock_in_no, ftcategory_code from txstock_in_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftstock_in_no"],
                          "type"=>"string");

        if ($r["ftcategory_code"]==9) {
            show_report($dir."spprint01_stok_masuk_tukar",$paramsx);
        } else {
            show_report($dir."spprint01_stok_masuk",$paramsx);
        }
        break;
    case "stockkeluar":
        $ssql="select ftstock_out_no,ftcategory_code from txstock_out_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftstock_out_no"],
                          "type"=>"string");
        $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        if($r["ftcategory_code"]!='1') {
            show_report($dir."spprint02_stok_keluar",$paramsx);
        }
        else {
              show_report($dir."spprint02_stock_keluar_sj_return",$paramsx);
        }
    break;
    case "mutasibarang":
         $ssql="select ftstock_mutation_no from txstock_mutation_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftstock_mutation_no"],
                          "type"=>"string");

        show_report($dir."spprint03_mutasi",$paramsx);
    break;
    case "mutasikonsinyasi":
         $ssql="select ftstock_mutation_no from txstock_mutation_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);
        
        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftstock_mutation_no"],
                          "type"=>"string");

        show_report($dir."spprint03_mutasi_konsinyasi",$paramsx);
    break;
    case "penyesuaianbarang":
         $ssql="select ftstock_adjustment_no from txstock_adjustment_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftstock_adjustment_no"],
                          "type"=>"string");

        show_report($dir."spprint04_penyesuaian_legal",$paramsx);
    break;
    case "assembly":
        $ssql="select ftassembly_no from txassembly_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftassembly_no"],
                          "type"=>"string");

        show_report($dir."spprint05_assembly",$paramsx);
    break;
    case "disassembly":
        $ssql="select ftdisassembly_no from txdisassembly_hdr where fnid='{$_REQUEST['id']}'";
        $rs=mysql_query($ssql);
        $r=mysql_fetch_assoc($rs);

        $paramsx[]=array("name"=>"trans_no",
                          "value"=>$r["ftdisassembly_no"],
                          "type"=>"string");

        show_report($dir."spprint06_disassembly",$paramsx);
    break;
}
