
<?   
//일련번호(우리회사의 세금계산서)  //매출
     
	     $p_class= new number;
	     $ta_vno=$p_class->date_add($ta_vno,2);
	     $num_2=$p_class->date_3add($num_2);
	     $num_1=$ta_year.$ta_vno;
         
	      //공급받는자
	      if($accept_ex) {

                //체크한 값들을 더해서 입력시킨다.

                 if(!$accept_search) {  //sort
		     $accept_search="proof_id";
		  }

	         $p_class= new number;
	         $start_mm=$p_class->date_add($start_mm,2); 
	         $start_dd=$p_class->date_add($start_dd,2);
	         $end_mm=$p_class->date_add($end_mm,2); 
	         $end_dd=$p_class->date_add($end_dd,2);

	 	 $accept_date=$start_yy . $start_mm . $start_dd;
		 $accept_end_date=$start_yy . $end_mm . $end_dd;

                  //접수일자 -> $accept_search_menu : in_date
		  //교정일자 -> $accept_search_menu : pf_date
		  //출고일자 -> $accept_search_menu : out_date
		  if($accept_menu=='1') {
		     $accept_search_menu="in_date";
		  } else if($accept_menu=='2') {
		     $accept_search_menu="pf_date";
		  } else if($accept_menu=='3') {
		     $accept_search_menu="out_date";
		  }

                  switch($accept_type) {      //교정구분에 따른 query
		     case ('1') : {
			    $sub_type_query="";
			    break;
			 } 
			 case ('2') : {
			    $sub_type_query= " and out_date!='0' ";
			    break;
			 } 
			 case ('3') : {
			    $sub_type_query= " and put_date!='0' ";
			    break;
			 } 
			 case ('4') : {
			    $sub_type_query= " and in_date=='0' ";
			    break;
			 } 
			 case ('5') : {
			    $sub_type_query= " and out_date!='0' ";
			    break;
			 } 
		  }

                  if($accept_sang) {     //상호가있을경우
		     if($accept_class) {   //기기분류를 선택한경우
			if($accept_name) {   //상품명을 선택한경우
			   $sub_query=" and in_id = '" . $accept_ex . "' and product_name = '" . $accept_name . "'" . $sub_type_query;
			} else if(!$accept_name) {
			   $sub_query=" and in_id = '" . $accept_ex . "' and product_class = '" . $accept_class . "'" . $sub_type_query;
			}
		     } else if(!$accept_class) {    //기기분류를 선택하지 않은 경우
			$sub_query=" and in_id = '" . $accept_ex . "'" . $sub_type_query;
		     }
		  } else if(!$accept_sang) {
		     if($accept_class) {
			if($accept_name) {
			   $sub_query=" and product_name = '" . $accept_name . "'" . $sub_type_query;
			} else if(!$accept_name) {
			   $sub_query=" and product_class = '" . $accept_class . "'" . $sub_type_query;
			}
		     } else if(!$accept_class) {
		        $sub_query= $sub_type_query;
		     }
		  }
          
		  
		  $query_proof_obj="select amount,pf_amount from proof where $accept_search_menu >= '$accept_date' and $accept_search_menu <= '$accept_end_date' " . $sub_query . " order by $accept_search";
                  $result_proof_obj=mysql_query($query_proof_obj);
		  $count_proof_obj=@mysql_num_rows($result_proof_obj);

		  $check_return_value=explode("|",$check_value);
		  $str_strlen=sizeof($check_return_value);
		  $str_strlen--;

		  for($check_count=0 ; $check_count<$str_strlen ; $check_count++) {
		      //공급가액
		     $db_amount=mysql_result($result_proof_obj,$check_return_value[$check_count],0);
		     $db_pf_amount=mysql_result($result_proof_obj,$check_return_value[$check_count],1); 
		     $sum_ip_kum=$sum_ip_kum+$db_amount+$db_pf_amount;
		   
		  }
		  

		  $sum_ip_kum_gong=explode(".",$sum_ip_kum);  //콤마없이 출력하기위해
		  $str_sum_ip_kum=strlen($sum_ip_kum_gong[0]);//1글자씩출력

		  for($i=0 ; $i<$str_sum_ip_kum-1 ;$i++) {
		     $char_kum[$i]=substr($sum_ip_kum_gong[0],$i,1);
		     $ta_vat=$ta_vat.$char_kum[$i];
		  }
                  
		  
                  //세액
		  $ta_vat_gong=explode(".",$ta_vat);  //콤마없이 출력하기위해
                  $str_vat_ip_kum=strlen($ta_vat_gong[0]);//1글자씩출력

		  for($i=0 ; $i<$str_vat_ip_kum ;$i++) {
		    $char_vat[$i]=substr($ta_vat_gong[0],$i,1);
		  }
		//

	        //금액을 콤마출력(합계금액,외상미수금)
                $p_class= new number;
		$math_ip_kum=$ta_vat+$sum_ip_kum;
                $sum_ip_kum_print=$p_class->double_comma($sum_ip_kum);
		$math_ip_kum_print=$p_class->double_comma($math_ip_kum);

		//품목및 규격
		$query_product="select product_pf from proof where $accept_search_menu >= '$accept_date' and $accept_search_menu <= '$accept_end_date' " . $sub_query . " order by $accept_search";

		$result_product=mysql_query($query_product);
		$count_product=@mysql_num_rows($result_product);
		
		$check_return_value=explode("|",$check_value);

		for($check_count=0 ; $check_count<sizeof($check_return_value); ) {
		   $check_count++;
		   
		}
		$check_count--;
                $db_product_pf=@mysql_result($result_product,$check_return_value[0],0);
		//제품명
                $p_class=new product;
	        $name_str1=$p_class->product_name($db_product_pf);
                $name_str2=explode("?",$name_str1);
		$name_product=$name_str2[0];

                if($check_count=='1')
		   $ta_memo0=$name_product;
		else 
		    $ta_memo0=$name_product."외 ".$check_count."건";

		$p_class= new number;
		$sum_kum_print0=$p_class->double_comma($sum_ip_kum_gong[0]);
		$sum_vat_kum0_print=$p_class->double_comma($ta_vat_gong[0]);
         }
	   
?>