<?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/preproduksi/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 "p01": //laporan outstanding mingguan
          $paramsx[]=array("name"=>"pfntrans_type",
                      "value"=>$_REQUEST['pfntrans_type'],
                      "type"=>"string");
          if(($_REQUEST['pfntrans_type']=="seluruh")||(strtolower($_REQUEST['pfntrans_type'])=="seluruh")) {
              $pfntrans_type="SELURUH";
              $pfntrans_type_1="SELURUH";
          }
          else {
              $pfntrans_type=$_REQUEST['pfntrans_type'];
               $ssql="SELECT  fttrans_status_name
                        FROM tstransaction_status WHERE fntrans_group_code = 16";              
               $pfntrans_type_1=RetRstField($ssql);
          }

           $paramsx[]=array("name"=>"pfntrans_type",
                      "value"=>$pfntrans_type,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pfntrans_type_1",
                      "value"=>$pfntrans_type_1,
                      "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."report01_om",$paramsx);
         break;
    case "p02": //mpor
      
       $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."report02_mpor",$paramsx);
         break;      
    break;

    case "p03": //laporan mrp produksi

    break;
    case "p04": //laporan production request
        $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");

            //ftstock_group_code
            if(($_REQUEST['ftstock_group_code']=='')||(strtolower($_REQUEST['ftstock_group_code'])=='seluruh')) {
                $pftstock_group_code="%%";
                $pftstock_group_code_1="SELURUH";
            }
            else {
                $pftstock_group_code=$_REQUEST['ftstock_group_code'];
                $pftstock_group_code_1=base64_decode($_REQUEST['hidden_ftstock_group_code']);

            }
            $paramsx[]=array("name"=>"pftstock_group_code",
                      "value"=>$pftstock_group_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftstock_group_code_1",
                      "value"=>$pftstock_group_code_1,
                      "type"=>"string");

             //pftcolor_code
            if(($_REQUEST['ftcolor_code']=='')||(strtolower($_REQUEST['ftcolor_code'])=='seluruh')) {
                $pftcolor_code="%%";
                $pftcolor_code_1="SELURUH";
            }
            else {
                $pftcolor_code=$_REQUEST['ftcolor_code']."%";
                $pftcolor_code_1=base64_decode($_REQUEST['hidden_ftcolor_code']);
            }
          
            $paramsx[]=array("name"=>"pftcolor_code",
                      "value"=>$pftcolor_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftcolor_code_1",
                      "value"=>$pftcolor_code_1,
                      "type"=>"string");

           //pftsize_code
            if(($_REQUEST['ftsize_code']=='')||(strtolower($_REQUEST['ftsize_code'])=='seluruh')) {
                $pftsize_code="%%";
                $pftsize_code_1="SELURUH";
            }
            else {
                $pftsize_code=$_REQUEST['ftsize_code'];
                $pftsize_code_1=base64_decode($_REQUEST['hidden_ftsize_code']);
            }
            $paramsx[]=array("name"=>"pftsize_code",
                      "value"=>$pftsize_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftsize_code_1",
                      "value"=>$pftsize_code_1,
                      "type"=>"string");

           //pftkaca_helm_code
            if(($_REQUEST['ftkaca_helm_code"']=='')||(strtolower($_REQUEST['ftkaca_helm_code"'])=='seluruh')) {
                $pftkaca_helm_code="%%";
                $pftkaca_helm_code_1="SELURUH";
            }
            else {
                $pftkaca_helm_code=$_REQUEST['ftkaca_helm_code"'];
                $pftkaca_helm_code_1=base64_decode($_REQUEST['hidden_ftkaca_helm_code"']);
            }
            $paramsx[]=array("name"=>"pftkaca_helm_code",
                      "value"=>$pftkaca_helm_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftkaca_helm_code_1",
                      "value"=>$pftkaca_helm_code_1,
                      "type"=>"string");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");


         show_report($dir."report04_por",$paramsx);
         break;
    break;
    case "p05": //laporan production sheet
            $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");
            
            //ftstock_group_code
            if(($_REQUEST['ftstock_group_code']=='')||(strtolower($_REQUEST['ftstock_group_code'])=='seluruh')) {
                $pftstock_group_code="%%";
                $pftstock_group_code_1="SELURUH";
            }
            else {
                $pftstock_group_code=$_REQUEST['ftstock_group_code'];
                $pftstock_group_code_1=base64_decode($_REQUEST['hidden_ftstock_group_code']);

            }
            $paramsx[]=array("name"=>"pftstock_group_code",
                      "value"=>$pftstock_group_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftstock_group_code_1",
                      "value"=>$pftstock_group_code_1,
                      "type"=>"string");

             //pftcolor_code
            if(($_REQUEST['ftcolor_code']=='')||(strtolower($_REQUEST['ftcolor_code'])=='seluruh')) {
                $pftcolor_code="%%";
                $pftcolor_code_1="SELURUH";
            }
            else {
                $pftcolor_code=$_REQUEST['ftcolor_code']."%";;
                $pftcolor_code_1=base64_decode($_REQUEST['hidden_ftcolor_code']);
            }
            $paramsx[]=array("name"=>"pftcolor_code",
                      "value"=>$pftcolor_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftcolor_code_1",
                      "value"=>$pftcolor_code_1,
                      "type"=>"string");

           //pftsize_code
            if(($_REQUEST['ftsize_code']=='')||(strtolower($_REQUEST['ftsize_code'])=='seluruh')) {
                $pftsize_code="%%";
                $pftsize_code_1="SELURUH";
            }
            else {
                $pftsize_code=$_REQUEST['ftsize_code'];
                $pftsize_code_1=base64_decode($_REQUEST['hidden_ftsize_code']);
            }
            $paramsx[]=array("name"=>"pftsize_code",
                      "value"=>$pftsize_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftsize_code_1",
                      "value"=>$pftsize_code_1,
                      "type"=>"string");
         
           //pftkaca_helm_code
            if(($_REQUEST['ftkaca_helm_code"']=='')||(strtolower($_REQUEST['ftkaca_helm_code"'])=='seluruh')) {
                $pftkaca_helm_code="%%";
                $pftkaca_helm_code_1="SELURUH";
            }
            else {
                $pftkaca_helm_code=$_REQUEST['ftkaca_helm_code"'];
                $pftkaca_helm_code_1=base64_decode($_REQUEST['hidden_ftkaca_helm_code"']);
            }
            $paramsx[]=array("name"=>"pftkaca_helm_code",
                      "value"=>$pftkaca_helm_code,
                      "type"=>"string");
            $paramsx[]=array("name"=>"pftkaca_helm_code_1",
                      "value"=>$pftkaca_helm_code_1,
                      "type"=>"string");
            $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
         

         show_report($dir."report03_pos",$paramsx);
         break;
      case "p06": //laporan production sheet
            $paramsx[]=array("name"=>"date_from",
                          "value"=>Cdate($_REQUEST['date_from'])." 00:00:00",
                          "type"=>"date");
            if($_REQUEST['pftcustomer_code']=='SELURUH') {
                $pftcustomer_code='%%';
            }
            else {
                $pftcustomer_code=$_REQUEST['pftcustomer_code']; 
            }
              $paramsx[]=array("name"=>"pftcustomer_code",
                      "value"=>$pftcustomer_code,
                      "type"=>"string");
                    $paramsx[]=array("name"=>"username",
                          "value"=>$_SESSION['username'],
                          "type"=>"string");
//         pr($paramsx);
         show_report($dir."report06_Laporan Outstanding Mingguan Yg sudah dibuatin DO (Perminggu , Percustomer)",$paramsx);
          break;
    break;
}