<?php
 session_start();

 $level= $_SESSION["level"];
 if(!isset($_SESSION["level"]) || $level>5) {
          /*   alert("관리자 승인이 필요합니다."); */
     sleep(2);
         header ("Location:/login/logout.php");
         exit;
   }
   
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
header("Expires: 0"); // rfc2616 - Section 14.21   
//header("Refresh:0");  // reload refresh   

 ?>
 
 <!DOCTYPE HTML>
 <html>
 <head>
 <meta charset="UTF-8">
 <link rel="stylesheet" type="text/css" href="../css/common.css">
 <link rel="stylesheet" type="text/css" href="../css/motor.css">
  <link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">   <!--날짜 선택 창 UI 필요 -->
 <title> 주일기업 통합정보시스템 </title> 
 </head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> 

 <script>
   $(document).ready(function() { 
  $("input:radio[name=separate_date]").click(function() { 
  process_list(); 
  }) 
   }); 
 </script>
 
 <?php
 
 if(!$_REQUEST["view_table"]=='')   // 윗단 검색창 클릭 여부 확인
      $view_table=$_REQUEST["view_table"];
        else
            $view_table='all';      
      
// print $view_table;
 
  if(isset($_REQUEST["search"]))   //목록표에 제목,이름 등 나오는 부분
   $search=$_REQUEST["search"];
  if(isset($_REQUEST["separate_date"]))   //출고일 접수일
   $separate_date=$_REQUEST["separate_date"];  
   
   if(isset($_REQUEST["list"]))   //목록표에 제목,이름 등 나오는 부분
   $list=$_REQUEST["list"];
    else
      $list=0;
    
  require_once("../lib/mydb.php");
  $pdo = db_connect();  
 // $find="firstord";     //검색할때 고정시킬 부분 저장 ex) 전체/공사담당/건설사 등
 if(isset($_REQUEST["page"])) // $_REQUEST["page"]값이 없을 때에는 1로 지정 
 {
    $page=$_REQUEST["page"];  // 페이지 번호
 }
  else
  {
    $page=1;   
  }
 
  $scale = 10;       // 한 페이지에 보여질 게시글 수
  $page_scale = 10;   // 한 페이지당 표시될 페이지 수  10페이지
  $first_num = ($page-1) * $scale;  // 리스트에 표시되는 게시글의 첫 순번.
   
  if(isset($_REQUEST["mode"]))
     $mode=$_REQUEST["mode"];
  else 
     $mode="";     
 
 $cursort=$_REQUEST["cursort"];    // 현재 정렬모드 지정
 if(isset($_REQUEST["sortof"]))
    {
     $sortof=$_REQUEST["sortof"];  // 클릭해서 넘겨준 값
  if($sortof==1) {
    
   if($cursort!=1)
      $cursort=1;
      else
       $cursort=2;
      } 
  if($sortof==2) {     //접수일 클릭되었을때
    
   if($cursort!=3)
      $cursort=3;
      else
     $cursort=4;      
     }     
  if($sortof==3) {     //구분 클릭되었을때
    
   if($cursort!=5)
      $cursort=5;
      else
     $cursort=6;      
     }         
  if($sortof==4) {     //절곡 클릭되었을때
    
   if($cursort!=7)
      $cursort=7;
      else
     $cursort=8;      
     }     
  if($sortof==5) {     //모터 클릭되었을때
    
   if($cursort!=9)
      $cursort=9;
      else
     $cursort=10;     
     }       
  }   
  else 
  {
     $sortof=0;     
   $cursort=0;
  }
  
  if($separate_date=="") $separate_date="1";
 
 // 기간을 정하는 구간
$fromdate=$_REQUEST["fromdate"];   
$todate=$_REQUEST["todate"];   
$up_fromdate=$_REQUEST["up_fromdate"];   
$up_todate=$_REQUEST["up_todate"];  

if($up_fromdate=="")
{
  $up_fromdate=substr(date("Y-m-d",time()),0,4) ;
  $up_fromdate=$up_fromdate . "-01-01";
}
if($up_todate=="")
{
  $up_todate=substr(date("Y-m-d",time()),0,4) . "-12-31" ;
  $up_Transup_todate=strtotime($up_todate.'+1 days');
  $up_Transup_todate=date("Y-m-d",$up_Transup_todate);
}
    else
  {
  $up_Transtodate=strtotime($up_todate);
  $up_Transtodate=date("Y-m-d",$up_Transtodate);
  }

if($fromdate=="")
{
  $fromdate=substr(date("Y-m-d",time()),0,4) ;
  $fromdate=$fromdate . "-01-01";
}
if($todate=="")
{
  $todate=substr(date("Y-m-d",time()),0,4) . "-12-31" ;
  $Transtodate=strtotime($todate.'+1 days');
  $Transtodate=date("Y-m-d",$Transtodate);
}
    else
  {
  $Transtodate=strtotime($todate);
  $Transtodate=date("Y-m-d",$Transtodate);
  }
      
   if(isset($_REQUEST["find"]))   //목록표에 제목,이름 등 나오는 부분
   $find=$_REQUEST["find"];
 
$process="전체";  // 기본 전체로 정한다.
/*  
$a=" order by outdate desc limit $first_num, $scale";  
$b=" order by outdate desc"; */

if($separate_date=="1") $SettingDate="outdate ";
    else
     $SettingDate="indate ";


$common="   where " . $SettingDate . " between date('$fromdate') and date('$Transtodate') order by " . $SettingDate;
$a= $common . " desc, num desc limit $first_num, $scale";    //내림차순
$b= $common . " desc, num desc ";    //내림차순 전체
$c= $common . " asc, num desc limit $first_num, $scale";    //오름차순
$d= $common . " asc, num desc ";    //오름차순 전체

$where=" where " . $SettingDate . " between date('$fromdate') and date('$Transtodate') ";
$all=" limit $first_num, $scale";
  
  if($mode=="search"){
      if($search==""){
               $sql="select * from chandj.motor " . $a;           
                           $sqlcon = "select * from chandj.motor " . $b;   // 전체 레코드수를 파악하기 위함.         
             }
             elseif($search!="") { // 각 필드별로 검색어가 있는지 쿼리주는 부분           
                $sql ="select * from chandj.motor where (outdate like '%$search%')  or (outworkplace like '%$search%') ";
                $sql .="or (orderman like '%$search%') or (outputplace like '%$search%') or (receiver like '%$search%') or";
                $sql .=" (phone like '%$search%') or (comment like '%$search%') order by " . $SettingDate . " desc, num desc limit $first_num, $scale ";
                $sqlcon ="select * from chandj.motor where (outdate like '%$search%')  or (outworkplace like '%$search%') ";
                $sqlcon .="or (orderman like '%$search%') or (outputplace like '%$search%') or (receiver like '%$search%') or";
                $sqlcon .=" (phone like '%$search%') or (comment like '%$search%') order by " . $SettingDate . "  desc, num desc ";               
            }

               }
  if($mode=="") {
               $sql="select * from chandj.motor " . $a;           
                           $sqlcon = "select * from chandj.motor " . $b;   // 전체 레코드수를 파악하기 위함.         
                }   
        
if($cursort==1)
{ 
                     $sql="select * from chandj.motor  " . $c;          
                     $sqlcon="select * from chandj.motor  " . $d;          
}  
 
if($cursort==2)
{ 
                             $sql="select * from chandj.motor   " . $a;           
                     $sqlcon="select * from chandj.motor " . $b;         
}  
if($cursort==3) // 접수일 클릭시 정렬
{ 
                             $sql="select * from chandj.motor " . $where . " order by indate desc  " . $all;           
                     $sqlcon="select * from chandj.motor " . $where . " order by indate desc, num desc  " ;            
}  
if($cursort==4) // 접수일 클릭시 정렬
{ 
                             $sql="select * from chandj.motor " . $where . " order by indate asc  " . $all;           
                     $sqlcon="select * from chandj.motor " . $where . " order by indate asc, num desc  " ;             
}  
if($cursort==5) // 구분 클릭시 주일/경동 내림 정렬
{ 
                             $sql="select * from chandj.motor " . $where . " order by root desc, " . $SettingDate . "  desc, num desc  " . $all;           
                     $sqlcon="select * from chandj.motor " . $where . " order by root desc, " . $SettingDate . "  desc, num desc  " ;         
}     

if($cursort==6) // 구분 클릭시 주일/경동 오름차순 정렬
{ 
                             $sql="select * from chandj.motor" . $where . " order by root asc, " . $SettingDate . "  desc, num desc  " . $all;           
                     $sqlcon="select * from chandj.motor" . $where . " order by root asc, " . $SettingDate . "  desc , num desc " ;       
}        
if($cursort==7) // 절곡 클릭시 내림 정렬
{ 
                             $sql="select * from chandj.motor" . $where . " order by steel desc, " . $SettingDate . "  desc, num desc  " . $all;           
                     $sqlcon="select * from chandj.motor" . $where . " order by steel desc, " . $SettingDate . "  desc, num desc  ";         
}        
if($cursort==8) // 절곡 클릭시 오름차순 정렬
{ 
                             $sql="select * from chandj.motor" . $where . " order by steel asc, " . $SettingDate . "  desc, num desc  " . $all;           
                     $sqlcon="select * from chandj.motor" . $where . " order by steel asc, " . $SettingDate . "  desc, num desc  ";     
}           

if($cursort==9) // 모터 클릭시 내림 정렬
{ 
                             $sql="select * from chandj.motor" . $where . " order by motor desc, " . $SettingDate . "  desc, num desc  " . $all;           
                     $sqlcon="select * from chandj.motor" . $where . " order by motor desc, " . $SettingDate . "  desc, num desc  " ;          
}        

if($cursort==10) // 모터 클릭시 오름차순 정렬
{ 
                             $sql="select * from chandj.motor" . $where . " order by motor asc, " . $SettingDate . "  desc, num desc  " . $all;           
                     $sqlcon="select * from chandj.motor" . $where . " order by motor asc, " . $SettingDate . "  desc, num desc  " ;       
}              
   
$nowday=date("Y-m-d");   // 현재일자 변수지정   

if($view_table=='all') {  // 전체기간의 모터재고 현황을 확인할때 처리 구간
     $all_sql="select * from chandj.motor";
}
if($view_table=='search') {  // 기간별 재고현황 조회
     $all_sql="select * from chandj.motor where outdate between date('$up_fromdate') and date('$up_Transtodate') ";
}

   try{  
// 레코드 전체 sql 설정

    $stmh = $pdo->query($all_sql);            // 검색조건에 맞는글 stmh
   while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {

        $num=$row["num"];
        
        $con_num=$row["con_num"];
        $outdate=$row["outdate"];
        $indate=$row["indate"];
        $outworkplace=$row["outworkplace"];
        $orderman=$row["orderman"];       
        $outputplace=$row["outputplace"];
        $receiver=$row["receiver"];       
        $phone=$row["phone"];
        $comment=$row["comment"];
        $root=$row["root"];   
        $delivery=$row["delivery"];  
        $regist_state=$row["regist_state"];    
        $out_control=$row["out_control"];  
        $in_control=$row["in_control"];  
        $inbox=$row["inbox"];  
        $casecover=$row["casecover"];  
        $switchset=$row["switchset"];  
        $which=$row["which"];  
        
        $motor220v_150k=$row["motor220v_150k"]; 
        $motor220v_300k=$row["motor220v_300k"]; 
        $motor220v_400k=$row["motor220v_400k"]; 
        $motor220v_500k=$row["motor220v_500k"]; 
        $motor220v_600k=$row["motor220v_600k"]; 
        $motor220v_800k=$row["motor220v_800k"]; 
        $motor220v_1000k=$row["motor220v_1000k"]; 
        $motor220v_1500k=$row["motor220v_1500k"]; 
        $motor220v_2000k=$row["motor220v_2000k"]; 

        $motor380v_150k=$row["motor380v_150k"]; 
        $motor380v_300k=$row["motor380v_300k"]; 
        $motor380v_400k=$row["motor380v_400k"]; 
        $motor380v_500k=$row["motor380v_500k"]; 
        $motor380v_600k=$row["motor380v_600k"]; 
        $motor380v_800k=$row["motor380v_800k"]; 
        $motor380v_1000k=$row["motor380v_1000k"]; 
        $motor380v_1500k=$row["motor380v_1500k"]; 
        $motor380v_2000k=$row["motor380v_2000k"]; 
        
        $bracket_150k=$row["bracket_150k"]; 
        $bracket_screen300k=$row["bracket_screen300k"]; 
        $bracket_300k=$row["bracket_300k"]; 
        $bracket_500k=$row["bracket_500k"]; 
        $bracket_800k=$row["bracket_800k"]; 
        $bracket_1500k=$row["bracket_1500k"]; 
        $bracket_2000k=$row["bracket_2000k"];   
        
// 전체재고 합계 구하는 부분
if($which=='1') { 
        $motor220v_150k_sum = $motor220v_150k_sum + $motor220v_150k;
        $motor220v_300k_sum = $motor220v_300k_sum + $motor220v_300k;  
        $motor220v_400k_sum = $motor220v_400k_sum + $motor220v_400k;  
        $motor220v_500k_sum = $motor220v_500k_sum + $motor220v_500k;  
        $motor220v_600k_sum = $motor220v_600k_sum + $motor220v_600k;  
        $motor220v_800k_sum = $motor220v_800k_sum + $motor220v_800k;  
        $motor220v_1000k_sum = $motor220v_1000k_sum + $motor220v_1000k; 
        $motor220v_1500k_sum = $motor220v_1500k_sum + $motor220v_1500k; 
        $motor220v_2000k_sum = $motor220v_2000k_sum + $motor220v_2000k; 
        


        $motor380v_150k_sum = $motor380v_150k_sum + $motor380v_150k;
        $motor380v_300k_sum = $motor380v_300k_sum + $motor380v_300k;  
        $motor380v_400k_sum = $motor380v_400k_sum + $motor380v_400k;  
        $motor380v_500k_sum = $motor380v_500k_sum + $motor380v_500k;  
        $motor380v_600k_sum = $motor380v_600k_sum + $motor380v_600k;  
        $motor380v_800k_sum = $motor380v_800k_sum + $motor380v_800k;  
        $motor380v_1000k_sum = $motor380v_1000k_sum + $motor380v_1000k; 
        $motor380v_1500k_sum = $motor380v_1500k_sum + $motor380v_1500k; 
        $motor380v_2000k_sum = $motor380v_2000k_sum + $motor380v_2000k; 
      
        $bracket_150k_sum = $bracket_150k_sum + $bracket_150k;  
        $bracket_screen300k_sum = $bracket_screen300k_sum + $bracket_screen300k;  
        $bracket_300k_sum = $bracket_300k_sum + $bracket_300k;  
        $bracket_500k_sum = $bracket_500k_sum + $bracket_500k;  
        $bracket_800k_sum = $bracket_800k_sum + $bracket_800k;  
        $bracket_1500k_sum = $bracket_1500k_sum + $bracket_1500k; 
        $bracket_2000k_sum = $bracket_2000k_sum + $bracket_2000k;   

        $out_control_sum = $out_control_sum + $out_control;  
        $in_control_sum = $in_control_sum + $in_control;   
        $inbox_sum = $inbox_sum + $inbox;  
        $casecover_sum = $casecover_sum + $casecover;  
        $switchset_sum = $switchset_sum + $switchset;                 
            }   
      
if($which=='2') { 
        $motor220v_150k_sum = $motor220v_150k_sum - $motor220v_150k;
        $motor220v_300k_sum = $motor220v_300k_sum - $motor220v_300k;  
        $motor220v_400k_sum = $motor220v_400k_sum - $motor220v_400k;  
        $motor220v_500k_sum = $motor220v_500k_sum - $motor220v_500k;  
        $motor220v_600k_sum = $motor220v_600k_sum - $motor220v_600k;  
        $motor220v_800k_sum = $motor220v_800k_sum - $motor220v_800k;  
        $motor220v_1000k_sum = $motor220v_1000k_sum - $motor220v_1000k; 
        $motor220v_1500k_sum = $motor220v_1500k_sum - $motor220v_1500k; 
        $motor220v_2000k_sum = $motor220v_2000k_sum - $motor220v_2000k; 

        $motor380v_150k_sum = $motor380v_150k_sum - $motor380v_150k;
        $motor380v_300k_sum = $motor380v_300k_sum - $motor380v_300k;  
        $motor380v_400k_sum = $motor380v_400k_sum - $motor380v_400k;  
        $motor380v_500k_sum = $motor380v_500k_sum - $motor380v_500k;  
        $motor380v_600k_sum = $motor380v_600k_sum - $motor380v_600k;  
        $motor380v_800k_sum = $motor380v_800k_sum - $motor380v_800k;  
        $motor380v_1000k_sum = $motor380v_1000k_sum - $motor380v_1000k; 
        $motor380v_1500k_sum = $motor380v_1500k_sum - $motor380v_1500k; 
        $motor380v_2000k_sum = $motor380v_2000k_sum - $motor380v_2000k; 
        
        $bracket_150k_sum = $bracket_150k_sum - $bracket_150k;  
        $bracket_screen300k_sum = $bracket_screen300k_sum - $bracket_screen300k;  
        $bracket_300k_sum = $bracket_300k_sum - $bracket_300k;  
        $bracket_500k_sum = $bracket_500k_sum - $bracket_500k;  
        $bracket_800k_sum = $bracket_800k_sum - $bracket_800k;  
        $bracket_1500k_sum = $bracket_1500k_sum - $bracket_1500k; 
        $bracket_2000k_sum = $bracket_2000k_sum - $bracket_2000k;   

        $out_control_sum = $out_control_sum - $out_control;  
        $in_control_sum = $in_control_sum - $in_control;   
        $inbox_sum = $inbox_sum - $inbox;  
        $casecover_sum = $casecover_sum - $casecover;  
        $switchset_sum = $switchset_sum - $switchset;                             
      }
   } 
   
        $motor220v_sum=  $motor220v_150k_sum + $motor220v_300k_sum + $motor220v_400k_sum +$motor220v_500k_sum+$motor220v_600k_sum+$motor220v_800k_sum+$motor220v_1000k_sum+$motor220v_1500k_sum+$motor220v_2000k_sum ;   
        $motor380v_sum=  $motor380v_150k_sum + $motor380v_300k_sum + $motor380v_400k_sum +$motor380v_500k_sum+$motor380v_600k_sum+$motor380v_800k_sum+$motor380v_1000k_sum+$motor380v_1500k_sum+$motor380v_2000k_sum ;        
   
   } catch (PDOException $Exception) {
    print "오류: ".$Exception->getMessage();
}  


   
   try{  
    $allstmh = $pdo->query($sqlcon);         // 검색 조건에 맞는 쿼리 전체 개수
      $temp2=$allstmh->rowCount();  
    $stmh = $pdo->query($sql);            // 검색조건에 맞는글 stmh
      $temp1=$stmh->rowCount();
        
    $total_row = $temp2;     // 전체 글수       
                   
     $total_page = ceil($total_row / $scale); // 검색 전체 페이지 블록 수
   $current_page = ceil($page/$page_scale); //현재 페이지 블록 위치계산       
   //   print "$page&nbsp;$total_page&nbsp;$current_page&nbsp;$search&nbsp;$mode";
    
    if($regist_state==null)
       $regist_state="1";
     
        $date_font="black";  // 현재일자 Red 색상으로 표기
        if($nowday==$outdate) {
                            $date_font="red";
            }
                        
                $font="black";
              
              switch ($regist_state) {
                case   "1"     :  $font_state="black"; $regist_word="등록"; break;
                case   "2"     :  $font_state="red"  ; $regist_word="접수"; break;  
                case   "3"     :  $font_state="blue"  ; $regist_word="완료"; break; 
                default:  $regist_word="등록"; break;
              }               
                
 if($outdate!="") {
    $week = array("(일)" , "(월)"  , "(화)" , "(수)" , "(목)" , "(금)" ,"(토)") ;
    $outdate = $outdate . $week[ date('w',  strtotime($outdate)  ) ] ;
}  
    

    
       
      ?>
     
<body >
 <div id="wrap">
   <div id="header">
   <?php include "../lib/top_login2.php"; ?>
   </div>
   <div id="menu">
   <?php include "../lib/top_menu2.php"; ?>
   </div>
   <div id="content">      
<div id="col2">
  <form name="board_form" id="board_form"  method="post" action="list.php?mode=search&search=<?=$search?>&find=<?=$find?>&year=<?=$year?>&search=<?=$search?>&process=<?=$process?>&asprocess=<?=$asprocess?>&fromdate=<?=$fromdate?>&todate=<?=$todate?>&up_fromdate=<?=$up_fromdate?>&up_todate=<?=$up_todate?>&separate_date=<?=$separate_date?>&view_table=<?=$view_table?>">  
  <div id="col2">    
  
       <input id="view_table" name="view_table" type='hidden' value='<?=$view_table?>' >
     
<div id=display_board class=background name=display_board > 
<div id="list_search">
        <div id="list_search1"> </div>
        <div id="list_search1_1">        
       <input id="up_preyear" type='button' onclick='up_pre_year()' value='전년도'>   
     <input id ="up_premonth" type='button' onclick='up_pre_month()' value='전월'>   
       <input type="text" id="up_fromdate" name="up_fromdate" size="12" value="<?=$up_fromdate?>" placeholder="기간 시작일">부터    
       <input type="text" id="up_todate" name="up_todate" size="12"  value="<?=$up_todate?>" placeholder="기간 끝">까지
  
     <input id ="up_thistoday" type='button' onclick='up_this_today()' value='금일'>
     <input id ="up_thismonth" type='button' onclick='up_this_month()' value='당월'>
<!--      <input id ="thisyear" type='button' onclick='this_year()' value='당해년도'>               -->
       </div>   
       
        <div id="list_search5"><button id=test type="button" onclick="exe_view_table();"> <img src="../img/list_search_button.gif"></button> </div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

      </div> <!-- end of list_search -->
 
  <!--  <div id="sero1000"> <h3> 경동모터 전체 재고현황 </h3></div>  -->
  
     <div class="clear"></div>  
    <!-- 
 <div id="order1"> 전원(220V) : </div>
 <div id="order12">  경동150K </div>
 <div id="order12">  경동300K </div>
 <div id="order12">  경동400K </div>
 <div id="order12">  경동500K </div>
 <div id="order12">  경동600K </div>
 <div id="order12">  경동800K </div>
 <div id="order12">  경동1000K </div>
 <div id="order12">  경동1500K </div>
 <div id="order12">  경동2000K </div>
   -->
     <div class="clear"></div>     
    <!--   <div id="order11"> 수량 : </div>    -->
 <div id="order2">
   <input type="text" id=motor220v_150k name=motor220v_150k value="<?=$motor220v_150k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_300k name=motor220v_300k value="<?=$motor220v_300k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_400k name=motor220v_400k value="<?=$motor220v_400k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_500k name=motor220v_500k value="<?=$motor220v_500k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_600k name=motor220v_600k value="<?=$motor220v_600k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_800k name=motor220v_800k value="<?=$motor220v_800k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_1000k name=motor220v_1000k value="<?=$motor220v_1000k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_1500k name=motor220v_1500k value="<?=$motor220v_1500k_sum?>" size="6"  disabled>
   <input type="text" id=motor220v_2000k name=motor220v_2000k value="<?=$motor220v_2000k_sum?>" size="6"  disabled>  
   <input type="text" id=motor220v_sum name=motor220v_sum value="<?=$motor220v_sum?>" size="6"  disabled>  
   </div>      
   <div class="clear"></div>  
    <!-- 
 <div id="order1"> 전원(380V) :  </div>  
 <div id="order13">  경동150K </div>
 <div id="order13">  경동300K </div>
 <div id="order13">  경동400K </div>
 <div id="order13">  경동500K </div>
 <div id="order13">  경동600K </div>
 <div id="order13">  경동800K </div>
 <div id="order13">  경동1000K </div>
 <div id="order13">  경동1500K </div>
 <div id="order13">  경동2000K </div>  -->
     <div class="clear"></div>    
  <!--   <div id="order11"> 수량 : </div> -->
  <div id="order2">
   <input type="text" id=motor380v_150k name=motor380v_150k value="<?=$motor380v_150k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_300k name=motor380v_300k value="<?=$motor380v_300k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_400k name=motor380v_400k value="<?=$motor380v_400k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_500k name=motor380v_500k value="<?=$motor380v_500k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_600k name=motor380v_600k value="<?=$motor380v_600k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_800k name=motor380v_800k value="<?=$motor380v_800k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_1000k name=motor380v_1000k value="<?=$motor380v_1000k_sum?>" size="6"  disabled>
   <input type="text" id=motor380v_1500k name=motor380v_1500k value="<?=$motor380v_1500k_sum?>" size="6" disabled>
   <input type="text" id=motor380v_2000k name=motor380v_2000k value="<?=$motor380v_2000k_sum?>" size="6"  disabled>     
   <input type="text" id=motor380v_sum name=motor380v_sum value="<?=$motor380v_sum?>" size="6"  disabled>    
   </div> 

     <div class="clear"></div>
    <!--   
 <div id="order5"> 브라켓(Bracket) :  </div> 
 <div id="order14">  스크린150K </div>
 <div id="order14">  스크린300~400K </div>
 <div id="order14">  일반300~400K </div>
 <div id="order14">  일반500~600K </div>
 <div id="order14">  일반800~1000K </div>
 <div id="order14">  일반1500K </div>
 <div id="order14">  일반2000K </div> -->

    <div class="clear"></div>  
    <!--   <div id="order5"> 수량 :  </div>    -->   
   <div id="order2">
   <input type="text" id=bracket_150k name=bracket_150k value="<?=$bracket_150k_sum?>" size="6"  disabled>
   <input type="text" id=bracket_screen300k name=bracket_screen300k value="<?=$bracket_screen300k_sum?>" size="6"  disabled>
   <input type="text" id=bracket_300k name=bracket_300k value="<?=$bracket_300k_sum?>" size="6"  disabled>
   <input type="text" id=bracket_500k name=bracket_500k value="<?=$bracket_500k_sum?>" size="6"  disabled>
   <input type="text" id=bracket_800k name=bracket_800k value="<?=$bracket_800k_sum?>" size="6"  disabled>
   <input type="text" id=bracket_1500k name=bracket_1500k value="<?=$bracket_1500k_sum?>" size="6"  disabled>
   <input type="text" id=bracket_2000k name=bracket_2000k value="<?=$bracket_2000k_sum?>" size="6"  disabled>
   </div> 
    <!--     <div id="order15">  </div>    -->          
   <div class="clear"></div> 
    <!--   <div id="order5">  노출제어기 :  </div>   --> 
   <div id="order6_1">  <input type="text" id="out_control" name="out_control" class=textalign value="<?=$out_control_sum?>" size="7" disabled> </div>  
      <!--  <div id="order5">  매립제어기 :  </div>   -->  
   <div id="order6_1">  <input type="text" id="in_control" name="in_control" class=textalign value="<?=$in_control_sum?>" size="7"  disabled> </div>  
 
      <!-- <div id="order5">  방범스위치 :  </div>  -->  
   <div id="order6_1">  <input type="text" id="switchset" name="switchset"  class=textalign value="<?=$switchset_sum?>" size="7" disabled> </div>  
      <!-- <div id="order9">  방범스위치 케이스 :  </div>   --> 
   <div id="order10">  <input type="text" id="casecover" name="casecover"  class=textalign value="<?=$casecover_sum?>" size="7" disabled> </div>  
      <!-- <div id="order5">  뒷박스 :  </div>  -->  
   <div id="order6_1">  <input type="text" id="inbox" name="inbox"  class=textalign value="<?=$inbox_sum?>" size="7" disabled> </div>      
  <div class="clear"></div>    
   
   </div>  
<div id=list_board >    
   <div id="title"><h1> 모터 입출고 현황 </h1> </div>   
      <div class="clear"></div>  
 <!-- <div id="title2">
 <div id class="blink"  style="white-space:nowrap">  <font color=red> *****  AS 진행 현황 ***** </font> </div>
    </div>  -->

        <div id="list_search">
        <div id="list_search1"> <br> ▷ 총 <?= $total_row ?> 개의 자료 파일이 있습니다.</div>
        <div id="list_search111"> 
       <?php
      if($separate_date=="1") {
       ?>
      &nbsp; 입출고일 <input type="radio" checked name="separate_date" value="1">
      &nbsp; 접수일 <input type="radio" name="separate_date" value="2">
      <?php
                }    ?>  
       <?php
      if($separate_date=="2") {
       ?>
      &nbsp; 입출고일 <input type="radio"  name="separate_date" value="1">
      &nbsp; 접수일 <input type="radio" checked name="separate_date" value="2">
      <?php
                }    ?>     

       <input id="preyear" type='button' onclick='pre_year()' value='전년도'>   
     <input id ="premonth" type='button' onclick='pre_month()' value='전월'>   
       <input type="text" id="fromdate" name="fromdate" size="12" value="<?=$fromdate?>" placeholder="기간 시작일">부터     
       <input type="text" id="todate" name="todate" size="12"  value="<?=$todate?>" placeholder="기간 끝">까지
  
     <input id ="thistoday" type='button' onclick='this_today()' value='금일'>
     <input id ="Fromthistoday" type='button' onclick='Fromthis_today()' value='금일이후~'>    
     <input id ="tomorrow" type='button' onclick='this_tomorrow()' value='익일'>
     <input id ="Fromtomorrow" type='button' onclick='From_tomorrow()' value='익일이후~'>    
     <input id ="thismonth" type='button' onclick='this_month()' value='당월'>
<!--      <input id ="thisyear" type='button' onclick='this_year()' value='당해년도'>               -->
       </div>   
        <div id="list_search2"> <img src="../img/select_search.gif"></div>
        <div id="list_search3">
        <select name="find">
           <?php      
          if($find=="")
        {     ?>    
           <option value='all'>전체</option>
           <option value='outworkplace'>현장명</option>
           <option value='firstord'>발주처</option>

       <?php
        } ?>    
      <?php     
          if($find=="all")
        {     ?>    
           <option value='all' selected>전체</option>
           <option value='outworkplace'>현장명</option>

       <?php
        } ?>
      <?php
          if($find=="outworkplace")
        {     ?>    
           <option value='all' >전체</option>
           <option value='outworkplace' selected>현장명</option>
       <?php
        } ?>                      
        </select>
        
    </div> <!-- end of list_search3 -->

        <div id="list_search4"><input type="text" name="search" id="search" value="<?=$search?>"> </div>

        <div id="list_search5"><input type="image" src="../img/list_search_button.gif"></div> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

  <?php
   if(isset($_SESSION["userid"]))
   {
  ?>
   <a href="write_form.php?num=<?=$num?>&page=<?=$page?>&find=<?=$find?>&year=<?=$year?>&search=<?=$search?>&process=<?=$process?>&asprocess=<?=$asprocess?>&fromdate=<?=$fromdate?>&todate=<?=$todate?>&separate_date=<?=$separate_date?>&view_table=<?=$view_table?>"> <img src="../img/write.png"></a>
  <?php
   }
  ?>
      </div> <!-- end of list_search -->
      <div class="clear"></div>
      <div id="output_top_title">
      <div id="output_title1"> 번호 </div>
      <div id="output_title2"> <a href="list.php?&page=<?=$page?>&search=<?=$search?>&find=<?=$find?>&list=1&sortof=1&cursort=<?=$cursort?>&process=<?=$process?>&year=<?=$year?>"> 입출고일 </a> </div>     <!-- 출고일자 -->
      <div id="output_title3"> <a href="list.php?&page=<?=$page?>&search=<?=$search?>&find=<?=$find?>&list=1&sortof=2&cursort=<?=$cursort?>&process=<?=$process?>&year=<?=$year?>"> 접 수 일 </a> </div>     <!-- 접수일 -->
      <div id="output_title33"> 입출고 </div>         <!-- 접수상태 표시 -->
      <div id="output_title1"> 담당  </div> 
      <div id="output_title7"> 현 장 명 </div>     
      <div id="output_title8"> 수신처 </div>     
      <div id="output_title12"> 입출고 내역    </div>      
      </div>
      <div id="list_content">
   <?php
      if ($page<=1)  
      $start_num=$total_row;    // 페이지당 표시되는 첫번째 글순번
         else 
            $start_num=$total_row-($page-1) * $scale;
      
         while($row = $stmh->fetch(PDO::FETCH_ASSOC)) {

        $num=$row["num"];

        $con_num=$row["con_num"];
        $outdate=$row["outdate"];
        $indate=$row["indate"];
        $outworkplace=$row["outworkplace"];
        $orderman=$row["orderman"];       
        $outputplace=$row["outputplace"];
        $receiver=$row["receiver"];       
        $phone=$row["phone"];
        $comment=$row["comment"];
        $root=$row["root"];   
        $delivery=$row["delivery"];  
        $regist_state=$row["regist_state"];    
        $out_control=$row["out_control"];  
        $in_control=$row["in_control"];  
        $inbox=$row["inbox"];  
        $casecover=$row["casecover"];  
        $switchset=$row["switchset"];  
        $which=$row["which"];  
        
        $motor220v_150k=$row["motor220v_150k"]; 
        $motor220v_300k=$row["motor220v_300k"]; 
        $motor220v_400k=$row["motor220v_400k"]; 
        $motor220v_500k=$row["motor220v_500k"]; 
        $motor220v_600k=$row["motor220v_600k"]; 
        $motor220v_800k=$row["motor220v_800k"]; 
        $motor220v_1000k=$row["motor220v_1000k"]; 
        $motor220v_1500k=$row["motor220v_1500k"]; 
        $motor220v_2000k=$row["motor220v_2000k"]; 

        $motor380v_150k=$row["motor380v_150k"]; 
        $motor380v_300k=$row["motor380v_300k"]; 
        $motor380v_400k=$row["motor380v_400k"]; 
        $motor380v_500k=$row["motor380v_500k"]; 
        $motor380v_600k=$row["motor380v_600k"]; 
        $motor380v_800k=$row["motor380v_800k"]; 
        $motor380v_1000k=$row["motor380v_1000k"]; 
        $motor380v_1500k=$row["motor380v_1500k"]; 
        $motor380v_2000k=$row["motor380v_2000k"]; 
        
        $bracket_150k=$row["bracket_150k"]; 
        $bracket_screen300k=$row["bracket_screen300k"]; 
        $bracket_300k=$row["bracket_300k"]; 
        $bracket_500k=$row["bracket_500k"]; 
        $bracket_800k=$row["bracket_800k"]; 
        $bracket_1500k=$row["bracket_1500k"]; 
        $bracket_2000k=$row["bracket_2000k"];   

?>
        <div id="outlist_item" > 
          <div id="outlist_item1"><a href="view.php?num=<?=$num?>&page=<?=$page?>&find=<?=$find?>&search=<?=$search?>&process=<?=$process?>&asprocess=<?=$asprocess?>&yearcheckbox=<?=$yearcheckbox?>&year=<?=$year?>&fromdate=<?=$fromdate?>&todate=<?=$todate?>&separate_date=<?=$separate_date?>" >
        <?=$start_num ?></div>      
          <div id="outlist_item2" style="color:<?=$date_font?>;">
        <b> <?=iconv_substr($outdate,0,15, "utf-8")?></b></div>

         <?php                   //    접수일이 당일이면 깜빡이는 효과부여
        
        if($indate==date("Y-m-d",time()))  //    보라색 굵은 글씨체로 당일 해당 접수된 것 ......
              {
        //  print '<div id class="blink" style="white-space:nowrap; color:green;" >';
          print '<div id="outlist_item3" style=" color:red;">';
                }
                else
                {
                  print '<div id="outlist_item3">';
                }
                
       if($which=='1')
           {
               $tmp_word="입고";
         $font_state="black";
         }
               else
         {
                 $tmp_word="출고";
             $font_state="red";          
         }
                
        ?>
           <?=iconv_substr($indate,0,10, "utf-8")?>
        
           </div>
        <div id="outlist_item33"style="color:<?=$font_state?>;" > <?=$tmp_word?> </div>
        <div id="outlist_item11"><?=iconv_substr($orderman,0,4, "utf-8")?></div>        
        <div id="outlist_item7"> <?=iconv_substr($outworkplace,0,14, "utf-8")?> </div>
        <div id="outlist_item8"><?=iconv_substr($receiver,0,12, "utf-8")?></div>  
          <?php
                $temp="";
        if($which=='1')
          $temp .= "입고 ==> ";
           else
            $temp .= "출고 ==> ";  
        if((int)$motor220v_150k>0)
             $temp .= "단상(220v) 150K : " . $motor220v_150k . "EA, ";
        if((int)$motor220v_300k>0)
             $temp .= "단상(220v) 300K : " . $motor220v_300k . "EA, ";           
        if((int)$motor220v_400k>0)
             $temp .= "단상(220v) 400K : " . $motor220v_400k . "EA, ";                     
        if((int)$motor220v_500k>0)
             $temp .= "단상(220v) 500K : " . $motor220v_500k . "EA, ";                     
        if((int)$motor220v_600k>0)
             $temp .= "단상(220v) 600K : " . $motor220v_600k . "EA, ";                               
        if((int)$motor220v_800k>0)
             $temp .= "단상(220v) 800K : " . $motor220v_800k . "EA, ";                               
        if((int)$motor220v_1000k>0)
             $temp .= "단상(220v) 1000K : " . $motor220v_1000k . "EA, ";                               
        if((int)$motor220v_1500k>0)
             $temp .= "단상(220v) 1500K : " . $motor220v_1500k . "EA, ";                                         
        if((int)$motor220v_2000k>0)
             $temp .= "단상(220v) 2000K : " . $motor220v_2000k . "EA, ";                                         

        if((int)$motor380v_150k>0)
             $temp .= "단상(380v) 150K : " . $motor380v_150k . "EA, ";
        if((int)$motor380v_300k>0)
             $temp .= "단상(380v) 300K : " . $motor380v_300k . "EA, ";           
        if((int)$motor380v_400k>0)
             $temp .= "단상(380v) 400K : " . $motor380v_400k . "EA, ";                     
        if((int)$motor380v_500k>0)
             $temp .= "단상(380v) 500K : " . $motor380v_500k . "EA, ";                     
        if((int)$motor380v_600k>0)
             $temp .= "단상(380v) 600K : " . $motor380v_600k . "EA, ";                               
        if((int)$motor380v_800k>0)
             $temp .= "단상(380v) 800K : " . $motor380v_800k . "EA, ";                               
        if((int)$motor380v_1000k>0)
             $temp .= "단상(380v) 1000K : " . $motor380v_1000k . "EA, ";                               
        if((int)$motor380v_1500k>0)
             $temp .= "단상(380v) 1500K : " . $motor380v_1500k . "EA, ";                                         
        if((int)$motor380v_2000k>0)
             $temp .= "단상(380v) 2000K : " . $motor380v_2000k . "EA, ";        
           

        if((int)$bracket_150k>0)
             $temp .= "스크린브라켓 150K : " . $bracket_150k . "EA, ";
        if((int)$bracket_screen300k>0)
             $temp .= "스크린브라켓 300K : " . $bracket_screen300k . "EA, ";           
        if((int)$bracket_300k>0)
             $temp .= "일반 브라켓 300K  : " . $bracket_300k . "EA, ";                    
        if((int)$bracket_500k>0)
             $temp .= "일반 브라켓 500K : " . $bracket_500k . "EA, ";                     
        if((int)$bracket_800k>0)
             $temp .= "일반 브라켓 800K : " . $bracket_800k . "EA, ";                               
        if((int)$bracket_1500k>0)
             $temp .= "일반 브라켓 1500K : " . $bracket_1500k . "EA, ";                                         
        if((int)$bracket_2000k>0)
             $temp .= "일반 브라켓 2000K : " . $bracket_2000k . "EA, ";    

        if((int)$out_control>0)
             $temp .= "(노출)연동제어기: " . $out_control . "EA, ";  
        if((int)$in_control>0)
             $temp .= "(매립)연동제어기: " . $in_control . "EA, ";   
        if((int)$inbox>0)
             $temp .= "뒷박스: " . $inbox . "EA, ";    
        if((int)$switchset>0)
             $temp .= "방범스위치: " . $switchset . "EA, ";  
        if((int)$casecover>0)
             $temp .= "방범케이스: " . $casecover . "EA, ";             

           
?>
        
        <div id="outlist_item100"><?=$temp?></div> </a>
            <div class="clear"> </div>
        </div>
      <?php
      $start_num--;  
       } 
  } catch (PDOException $Exception) {
  print "오류: ".$Exception->getMessage();
  }  
   // 페이지 구분 블럭의 첫 페이지 수 계산 ($start_page)
      $start_page = ($current_page - 1) * $page_scale + 1;
   // 페이지 구분 블럭의 마지막 페이지 수 계산 ($end_page)
      $end_page = $start_page + $page_scale - 1;  
 ?>
 
       <div id="page_button">
  <div id="page_num">  
 <?php
      if($page!=1 && $page>$page_scale)
      {
        $prev_page = $page - $page_scale;    
        // 이전 페이지값은 해당 페이지 수에서 리스트에 표시될 페이지수 만큼 감소
        if($prev_page <= 0) 
            $prev_page = 1;  // 만약 감소한 값이 0보다 작거나 같으면 1로 고정
        print "<a href=list.php?page=$prev_page&mode=search&search=$search&find=$find&list=1&process=$process&asprocess=$asprocess&yearcheckbox=$yearcheckbox&year=$year&fromdate=$fromdate&todate=$todate&separate_date=$separate_date>◀ </a>";
      }
    for($i=$start_page; $i<=$end_page && $i<= $total_page; $i++) 
      {        // [1][2][3] 페이지 번호 목록 출력
        if($page==$i) // 현재 위치한 페이지는 링크 출력을 하지 않도록 설정.
           print "<font color=red><b>[$i]</b></font>"; 
        else 
           print "<a href=list.php?page=$i&mode=search&search=$search&find=$find&list=1&process=$process&asprocess=$asprocess&yearcheckbox=$yearcheckbox&year=$year&fromdate=$fromdate&todate=$todate&separate_date=$separate_date>[$i]</a>";
  }

      if($page<$total_page)
      {
        $next_page = $page + $page_scale;
        if($next_page > $total_page) 
            $next_page = $total_page;
        // netx_page 값이 전체 페이지수 보다 크면 맨 뒤 페이지로 이동시킴
        print "<a href=list.php?page=$next_page&mode=search&search=$search&find=$find&list=1&process=$process&asprocess=$asprocess&yearcheckbox=$yearcheckbox&year=$year&fromdate=$fromdate&todate=$todate&separate_date=$separate_date> ▶</a><p>";
      }
 ?>     
        </div>
     </div>

<div id="write_button">    

  <br><br><br>
      </div>
     </div>   
 
  </form>
   </div>   
    </div> <!-- end of col2 -->
   </div> <!-- end of content -->
   </div>      
  </div> <!-- end of wrap -->
<script>



function blinker() {
  $('.blinking').fadeOut(500);
  $('.blinking').fadeIn(500);
}
setInterval(blinker, 1000);


/* $(document).ready(function() { 
  $("input:radio[name=separate_date]").click(function() { 
  process_list(); 
  }) 
); */

  $(function() {
     $( "#id_of_the_component" ).datepicker({ dateFormat: 'yy-mm-dd'}); 
});  
$(function () {
            $("#fromdate").datepicker({ dateFormat: 'yy-mm-dd'});
            $("#todate").datepicker({ dateFormat: 'yy-mm-dd'});
            $("#up_fromdate").datepicker({ dateFormat: 'yy-mm-dd'});
            $("#up_todate").datepicker({ dateFormat: 'yy-mm-dd'});      
      
});
 
 function up_pre_year(){   // 윗쪽 전년도 추출
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

today = mm+'/'+dd+'/'+yyyy;
yyyy=yyyy-1;
frompreyear = yyyy+'-01-01';
topreyear = yyyy+'-12-31';  

    document.getElementById("up_fromdate").value = frompreyear;
    document.getElementById("up_todate").value = topreyear;
document.getElementById('view_table').value="search";   
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과  
}  
 
function pre_year(){   // 전년도 추출
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

today = mm+'/'+dd+'/'+yyyy;
yyyy=yyyy-1;
frompreyear = yyyy+'-01-01';
topreyear = yyyy+'-12-31';  

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과  
}  

function up_pre_month(){    // 윗쪽 전월
  document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
    dd='0'+dd;
} 

mm=mm-1;
if(mm<1) {
    mm='12';
} 
if(mm<10) {
    mm='0'+mm;
} 
if(mm>=12) {
    yyyy=yyyy-1;
} 

frompreyear = yyyy+'-'+mm+'-01';
topreyear = yyyy+'-'+mm+'-31';

    document.getElementById("up_fromdate").value = frompreyear;
    document.getElementById("up_todate").value = topreyear;
document.getElementById('view_table').value="search";   
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 
 
function pre_month(){    // 전월
  document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
    dd='0'+dd;
} 

mm=mm-1;
if(mm<1) {
    mm='12';
} 
if(mm<10) {
    mm='0'+mm;
} 
if(mm>=12) {
    yyyy=yyyy-1;
} 

frompreyear = yyyy+'-'+mm+'-01';
topreyear = yyyy+'-'+mm+'-31';

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 

function up_this_year(){   // 윗쪽 당해년도
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

today = mm+'/'+dd+'/'+yyyy;
frompreyear = yyyy+'-01-01';
topreyear = yyyy+'-12-31';  

    document.getElementById("up_fromdate").value = frompreyear;
    document.getElementById("up_todate").value = topreyear;
fromdate1=frompreyear;
todate1=topreyear;
document.getElementById('view_table').value="search"; 
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 


function this_year(){   // 아래쪽 당해년도
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

today = mm+'/'+dd+'/'+yyyy;
frompreyear = yyyy+'-01-01';
topreyear = yyyy+'-12-31';  

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
fromdate1=frompreyear;
todate1=topreyear;
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 

function up_this_month(){   // 윗쪽 당해월
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

frompreyear = yyyy+'-'+mm+'-01';
topreyear = yyyy+'-'+mm+'-31';

    document.getElementById("up_fromdate").value = frompreyear;
    document.getElementById("up_todate").value = topreyear;
document.getElementById('view_table').value="search";   
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 


function this_month(){   // 당해월
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

frompreyear = yyyy+'-'+mm+'-01';
topreyear = yyyy+'-'+mm+'-31';

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 

function From_tomorrow(){   // 익일 이후
var today = new Date();
var dd = today.getDate()+1;  // 하루를 더해준다. 익일
var mm = today.getMonth()+1; //January is 0! 항상 1을 더해야 해당월을 구한다
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 
frompreyear = yyyy+'-'+mm+'-'+dd;
topreyear = yyyy+'-12-31';  
    document.getElementById("fromdate").value = frompreyear;   
    document.getElementById("todate").value = topreyear;       
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 



function Fromthis_today(){   // 금일이후
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0! 항상 1을 더해야 해당월을 구한다
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

frompreyear = yyyy+'-'+mm+'-'+dd;
topreyear = yyyy+'-12-31';  

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
  
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 

function up_this_today(){   // 윗쪽 날짜 입력란 금일
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0! 항상 1을 더해야 해당월을 구한다
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

frompreyear = yyyy+'-'+mm+'-'+dd;
topreyear = yyyy+'-'+mm+'-'+dd;

    document.getElementById("up_fromdate").value = frompreyear;
    document.getElementById("up_todate").value = topreyear;
document.getElementById('view_table').value="search";   
  
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 

function this_today(){   // 금일
document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0! 항상 1을 더해야 해당월을 구한다
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

frompreyear = yyyy+'-'+mm+'-'+dd;
topreyear = yyyy+'-'+mm+'-'+dd;

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
  
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과 
} 

function this_tomorrow(){   // 익일

document.getElementById('search').value=null; 
var today = new Date();
var dd = today.getDate()+1;
var mm = today.getMonth()+1; //January is 0! 항상 1을 더해야 해당월을 구한다
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd;
} 

if(mm<10) {
    mm='0'+mm;
} 

frompreyear = yyyy+'-'+mm+'-'+dd;
topreyear = yyyy+'-'+mm+'-'+dd;

    document.getElementById("fromdate").value = frompreyear;
    document.getElementById("todate").value = topreyear;
  
document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과  

} 

function process_list(){   // 접수일 출고일 라디오버튼 클릭시

document.getElementById('search').value=null; 

document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과  

} 

function exe_view_table(){   // 출고현황 검색을 클릭시 실행

document.getElementById('view_table').value="search"; 

document.getElementById('board_form').submit();  // form의 검색버튼 누른 효과  

} 

  </script>
  
  

<?php
if($mode==""&&$fromdate==null)  
{
  echo ("<script language=javascript> this_year();</script>");  // 당해년도 화면에 초기세팅하기
}

?>
  </body>
<script> 
  // 스크린합 구한값 화면에 출력하기
var total_sum = '<?php echo $total_sum ;?>';
var total_m2 = '<?php echo $total_m2 ;?>';
$("#top_board2").text(total_sum);
$("#top_board4").text(total_m2);
</script>
  </html>