<?PHP
/*
  $Id: result.php,v 1.0.1 2004/05/12
  catalog/result.php
  http://www.endless.ne.jp/

  Copyright (c) 2003 Endless Net

*/

// include server parameters
require('../includes/configure.php');
require('../includes/classes/db/' . DB_TYPE . '/query_factory.php');
require('../includes/database_tables.php');
// include the list of extra database tables and filenames
//  include(DIR_WS_MODULES . 'extra_datafiles.php');
if ($za_dir = @dir("../" . DIR_WS_INCLUDES . 'extra_datafiles')) {
  while ($zv_file = $za_dir->read()) {
    if (strstr($zv_file, '.php')) {
      require("../" . DIR_WS_INCLUDES . 'extra_datafiles/' . $zv_file);
    }
  }
}

// make a connection to the database... now
$db = new queryFactory();
$db->connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE, USE_PCONNECT, false) or die('Unable to connect to database server!');

if($_SERVER['REQUEST_METHOD'] == 'POST'){
	
	$sales_id=$_POST['X-S_TORIHIKI_NO'];
	$tranid=$_POST['X-TRANID'];
	$refapproved=$_POST['X-REFAPPROVED'];
	$refforwarded=$_POST['X-REFFORWARDED'];
	$errcode=$_POST['X-ERRCODE'];
	$errinfo=$_POST['X-ERRINFO'];
	$errlevel=$_POST['X-ERRLEVEL'];
	$r_code=$_POST['X-R_CODE'];
	$rec_type=$_POST['REC_TYPE'];
	$x_amount=$_POST['X-AMOUNT'];
	$x_tax=$_POST['X-TAX'];
	$x_total=$_POST['X-TOTAL'];
	$today = date('Y-m-d H:i:s');
	
	$db->Execute("INSERT INTO " . TABLE_REMISE_RESULT . " VALUES('','$sales_id','$tranid','$refapproved','$refforwarded','$errcode','$errinfo','$errlevel','$r_code','$rec_type','$x_amount','$x_tax','$x_total','','','','$today')");
	$insert_id = $db->Insert_ID();
	
	$db->close();
	
	if($insert_id){
		print "<SDBKDATA>STATUS=800</SDBKDATA>";
	}
}


?>
