goiintra/public_html/lib/update_cycle.php

68 lines
1.7 KiB
PHP

<?
include getenv("DOCUMENT_ROOT")."/include/session_include.php";
// Level 1 이하만 사용 가능
$func->checkLevelModal(1);
// ################# 차후 uptype 에 따른 if 구분이 필요함
// echo "[action=$action]";
// log file upload
if ($mode == "insert") {
$uploaddir = getenv("DOCUMENT_ROOT").'/upload/';
$upfilename = "Oil_2023.csv";
$existFlag = file_exists($uploaddir.$upfilename);
if (!file_exists($uploaddir.$upfilename)) {
echo "The file ".$uploaddir.$upfilename." does not exist";
}
//$rt = chmod ($uploaddir.$upfilename, 0755);
$lineCnt = 1;
$successRowCnt = 0;
if (($handle = fopen($uploaddir.$upfilename, "r")) !== FALSE) {
while (($getCSV = fgetcsv($handle, 2000, ",")) !== FALSE) {
// Get customer Info
$d_accountno = str_replace(" ", "", trim($getCSV[2])); // d_accountno
$qry_customer = "SELECT * FROM tbl_customer WHERE c_accountno = '".trim($getCSV[2])."' ";
$rt_customer = $jdb->fQuery($qry_customer, "query error");
//echo "[$qry_customer]<br>";
$saveCnt = 1;
echo " ##############################################################<br>";
if ($lineCnt >= 2) {
$d_cycle = str_replace(" ", "", trim($getCSV[4]));
$values[] = $d_cycle; // d_cycle
if ($d_cycle != "") {
//echo "[cnt=$lineCnt][".$rt_customer['c_name']."][".$rt_customer['c_uid']."][$d_cycle]<br>";
$jdb->nQuery("UPDATE tbl_customer SET c_paymentcycle='$d_cycle' WHERE c_uid = '".$rt_customer['c_uid']."'", "Update error");
}
}
//if ($lineCnt == 100) break;
$lineCnt++;
}
fclose($handle);
}
}
?>