Example #1
0
}
$userid = 0;
$fullname = '';
if ($rows == 1) {
    while ($rsl = mysql_fetch_array($result)) {
        $userid = $rsl['ID'];
        $fullname = $rsl['full_name'];
        $rs = array("link" => 'index.php?page=' . $crpage . '#' . $crmenu, "id" => $rsl['ID'], "fullname" => $rsl['full_name'], "phone" => $rsl['phone_number'], "email" => $rsl['email'], "editable" => $rsl['editable'], "writable" => $rsl['writable'], "usertype" => $rsl['usertype'], "token" => $token);
        $_SESSION['id'] = $rsl['ID'];
        $_SESSION['fullname'] = $rsl['full_name'];
        $_SESSION['phone'] = $rsl['phone_number'];
        $_SESSION['email'] = $rsl['email'];
        $_SESSION['editable'] = $rsl['editable'];
        $_SESSION['writable'] = $rsl['writable'];
        $_SESSION['usertype'] = $rsl['usertype'];
        $_SESSION['token'] = $token;
        $_SESSION['login'] = 1;
        //$_SESSION['username']=$username;
    }
    echo json_encode($rs);
    $sql = 'UPDATE `user` SET `token`="' . $token . '" WHERE ID = ' . $rs['id'];
    $result = mysql_query($sql) or die('0');
    $action = 'đăng nhập';
    userlogs($userid, $fullname, $action);
} else {
    echo "0";
}
CLOSE_DB();
unset($sql, $result, $rs, $rows);
?>
 
    $sql = 'SELECT `sub_confirm` FROM `h1_confirm` 
				WHERE `meter_serial` = "' . $serial . '" AND `month_confirm` = "' . $month . '" AND `type` = 2';
    //check skd <> type = 2
    $result = mysql_query($sql) or die('500');
    $returnvalue = mysql_affected_rows();
    return $returnvalue;
}
if (record_exist($serial, $month, $kdstatus)) {
    die('409');
}
/*
 *	Chus ý cả phần PC confirm cũng thay đổi
 */
$val = 409;
//	Đã tồn tại
$sql = 'UPDATE 	`h1_confirm` 
			SET `dauky`="' . $dauky . '",`cuoiky`="' . $cuoiky . '", `sub_confirm`= 1 ,
			`id_user_confirm`=' . $userid . ',`fullname_sub_confirm`="' . $fullname . '",`date_confirm`="' . $timenow . '"
			WHERE `meter_serial` ="' . $serial . '" AND `month_confirm` = "' . $month . '" AND `type` = 2';
$result = mysql_query($sql) or die('500');
$countaffectedrows = mysql_affected_rows();
if ($countaffectedrows == 1) {
    $val = 200;
}
echo $val;
userlogs($userid, $fullname, 'xác nhận số liệu sau kiểm định công tơ');
CLOSE_DB();
unset($sql, $result, $rs);
?>
 
Example #3
0
			WHERE `meter_serial`="' . $serial . '" AND `month_confirm` ="' . $month . '" ORDER BY `edit_count` DESC LIMIT 0,1';
$result = mysql_query($sql) or die('0');
$confirmdata = array();
if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_array($result)) {
        $confirmdata = array('dauky' => $row['dauky'], 'cuoiky' => $row['cuoiky']);
    }
}
//echo $confirmdata['dauky'];
if (isset($confirmdata['dauky'])) {
    if ($confirmdata['dauky'] != null && $confirmdata['dauky'] != '') {
        $pc_confirm_update = 1;
    }
}
//echo $pc_confirm_update;
if ($pc_confirm_update) {
    $sql = 'UPDATE `h1_confirm` SET `pc_confirm`=1, `userid_pc_confirm`=' . $userid . ', 
			`fullname_pc_confirm`="' . $fullname_pc . '",`date_pc_confirm`="' . $timenow . '" 
			WHERE `meter_serial` = "' . $serial . '" AND `month_confirm`="' . $month . '"';
    $result = mysql_query($sql) or die('0');
    echo '200';
} else {
    //Nhà máy chưa xác nhận số liệu
    echo '406';
}
userlogs($userid, $fullname_pc, 'xác nhận số liệu');
CLOSE_DB();
unset($sql, $result, $rs);
?>
 
    $sql = 'SELECT * FROM `h1_confirm` 
				WHERE `meter_serial` = "' . $serial . '" AND `month_confirm` = "' . $month . '" AND `type` = 1';
    $result = mysql_query($sql) or die('500');
    $row = 0;
    while ($rows = mysql_fetch_array($result)) {
        $row = $rows['ID'];
    }
    if ($row == null || $row == '' || $row == 0) {
        $returnvalue = 0;
    } else {
        $returnvalue = 1;
    }
    return $returnvalue;
}
if (tkd_record_exist($serial, $month)) {
    die('409');
}
// $sql = 'INSERT INTO `h1_confirm`(`meter_serial`, `month_confirm`, `dauky`, `cuoiky`, `type`, `id_user_confirm`,
// 			`fullname_sub_confirm`,`date_confirm`)
// 			VALUES ("'.$serial.'","'.$month.'","'.$dauky.'","'.$cuoiky.'",'.$kdstatus.','.$userid.',"'.$fullname.'","'.$timenow.'")';
$sql = 'INSERT INTO `h1_confirm`(`meter_serial`, `month_confirm`, `dauky`, `type`, `id_user_confirm`, 
			`fullname_sub_confirm`,`date_confirm`) 
			VALUES ("' . $serial . '","' . $month . '","' . $dauky . '",2 ,' . $userid . ',"' . $fullname . '","' . $timenow . '")';
$result = mysql_query($sql) or die('500');
echo '200';
userlogs($userid, $fullname, 'xác nhận số liệu SKĐ tháng: ' . $month);
CLOSE_DB();
unset($sql, $result, $rs);
?>