<?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_sparepart/print/";
$paramsx=array();

switch ($_REQUEST['form']) {
    case "stockmasuksparepart":
        $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;
    break;
    case "stockkeluarsparepart":
        $ssql="select ftstock_out_no,ftcategory_code from txstock_out_hdr_sparepart 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");
      
         show_report($dir."spprint02_stok_keluar",$paramsx);
      
      
    break;
    case "mutasibarang":
         $ssql="select ftstock_mutation_no from txstock_mutation_hdr_sparepart 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 "mutasibarangjadi":
         $ssql="select ftstock_mutation_no from txstock_mutation_hdr_sptobj 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_sptobj",$paramsx);
        break;
    case "penyesuaianbarangsparepart":
         $ssql="select ftstock_adjustment_no from txstock_adjustment_hdr_sparepart 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",$paramsx);
   break;
   
}