<?php
ini_set("display_errors","1");
include_once "../inc/config.php";
//ini_set('error_reporting', 'E_ALL');  //wrong way to open error_reporting
//ini_set("error_reporting","32759");   //Right way to set error_reporting
$mysqli = get_mysqli_connection();
include_once __DIR__ . "/../inc/excelOperate.inc.php";
include_once __DIR__ . "/../inc/tradeRec.inc.php";

$file = $_REQUEST['fpath'];
$company = $_REQUEST['up_vendor'];
$msg = array();
/*
echo json_encode(array(
    "status" => "2",
    "fpath"=> $file,
    'company'=> $_REQUEST['up_vendor'],
    "msg" => "upload sucessful!",
));
*/
$data = readMyExcel($file);
$msg[] = addslashes("Finished excel read! <br />");
$msg_op = dbOp($data, $company);
if($msg_op == false) exit(); //if return false, function dbOp() will echo massage to ajax
$msg = array_merge($msg,$msg_op);
echo json_encode(array(
    "status" => "1",
    "fpath"=> $file,
    'company'=> $_REQUEST['up_vendor'],
    "msg" => $msg,
));
?>