<?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";
//foreach ($_REQUEST as $key1 => $value1) {
//  $_REQUEST[$key1]=str_replace('_|_','/',$_REQUEST[$key1]);
//}

$dir="report/inventory_sparepart/report/";
$paramsx=array();

$ssql="select * from tlreport where fnid='{$_REQUEST['id']}'";
$rs=mysql_query($ssql);
$r=mysql_fetch_assoc($rs);
$code=$r['ftreport_code'];
//$code=$_REQUEST['code'];


switch ($code) {
    case "spi00":
           if($_REQUEST['ftitem_code']=="SELURUH") {
               $ftitem_code="%%";
           }
           else {
               $ftitem_code=$_REQUEST['ftitem_code'];
           }
           
           $paramsx[]=array("name"=>"ftitem_code",
                          "value"=>$ftitem_code,
                          "type"=>"string");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
//        pr($paramsx);
      show_report($dir."reportbb00_data_barang",$paramsx);
    break;
    case "spi00_1":
         $paramsx[]=array("name"=>"stock_type",
                          "value"=>"invsp",
                          "type"=>"string");
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb12_stock_awal",$paramsx);
    break;
    case "spi01":
          if($_REQUEST['ftitem_code']=="SELURUH") {
               $ftitem_code="'%%'";
           }
           else {
               $ftitem_code=$_REQUEST['ftitem_code'];
           }

           $paramsx[]=array("name"=>"ftitem_code",
                          "value"=>$ftitem_code,
                          "type"=>"string");
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
//                      pr($paramsx);
        show_report($dir."reportbb01_per-stock_group",$paramsx);
    break;
   
    case "spi03":
         if($_REQUEST['stock']=="SELURUH") {
               $stock="%%";
           }
           else {
               $stock=$_REQUEST['stock'];
           }
           
         $paramsx[]=array("name"=>"stock",
                          "value"=>$stock,
                          "type"=>"string");
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb03_per_item_barang",$paramsx);
    break;
    case "spi05":
        if($_REQUEST['warehouse']=="SELURUH") {
            $warehouse="%%";
        }
        else {
            $warehouse=$_REQUEST['warehouse'];
        }
        
        if($_REQUEST['location']=="SELURUH") {
            $location="%%";
        }
        else {
            $location=$_REQUEST['location'];
        }
        
        if($_REQUEST['item']=="SELURUH") {
            $item="%%";
        }
        else {
            $item=$_REQUEST['item'];
        }

         $paramsx[]=array("name"=>"warehouse",
                          "value"=>$warehouse,
                          "type"=>"string");
         $paramsx[]=array("name"=>"location",
                          "value"=>$location,
                          "type"=>"string");
         $paramsx[]=array("name"=>"item",
                          "value"=>$item,
                          "type"=>"string");
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb07_kartu_stock",$paramsx);
     break;
    case "spi06":
        $paramsx[]=array("name"=>"ftlocation_from",
                          "value"=>$_REQUEST['ftlocation_from'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"ftlocation_to",
                          "value"=>$_REQUEST['ftlocation_to'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
        $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
        $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb08_mutasi",$paramsx);
     break;
    case "spi07":
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb09_penyesuaian",$paramsx);
     break;
    case "spi08":
        if($_REQUEST['warehouse']=="SELURUH") {
            $warehouse="%%";
        }
        else {
            $warehouse=$_REQUEST['warehouse'];
        }

         $paramsx[]=array("name"=>"warehouse",
                          "value"=>$warehouse,
                          "type"=>"string");
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb04_per_gudang",$paramsx);
     break;
     case "spi09":
       
        if($_REQUEST['location']=="SELURUH") {
            $location="%%";
        }
        else {
            $location=$_REQUEST['location'];
        }


        if($_REQUEST['ftitem_code']=="SELURUH") {
            $ftitem_code="%%";
        }
        else {
            $ftitem_code=$_REQUEST['ftitem_code'];
        }

         $paramsx[]=array("name"=>"location",
                          "value"=>$location,
                          "type"=>"string");
         $paramsx[]=array("name"=>"ftitem_code",
                          "value"=>$ftitem_code,
                          "type"=>"string");
         $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
         $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
       
        show_report($dir."reportbb05_per_lokasi",$paramsx);
    break;
    case "spi10":
           if($_REQUEST['stock']=="SELURUH") {
            $stock="%%";
        }
        else {
            $stock=$_REQUEST['stock'];
        }

         $paramsx[]=array("name"=>"stock",
                  "value"=>$stock,
                  "type"=>"string");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
        show_report($dir."reportbb06_minim_level",$paramsx);

    break;
    case "spi11":
        $paramsx[]=array("name"=>"pftcategory_code",
                          "value"=>$_REQUEST['ftcategory_code'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"pftitem_code",
                          "value"=>$_REQUEST['ftitem_code'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"pftlocation_code",
                          "value"=>$_REQUEST['ftlocation_code'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
        $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
        $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");

        show_report($dir."reportsp11_stock_keluar",$paramsx);

    break;

    case "spi12":
        $paramsx[]=array("name"=>"pftcategory_code",
                          "value"=>$_REQUEST['ftcategory_code'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"pftitem_code",
                          "value"=>$_REQUEST['ftitem_code'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"pftlocation_code",
                          "value"=>$_REQUEST['ftlocation_code'],
                          "type"=>"string");
        $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
        $paramsx[]=array("name"=>"date_end",
                          "value"=>Cdate($_REQUEST['date_end']). " 00:00:00",
                          "type"=>"date");
        $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");

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