<?php
session_start();
header('Content-Type: text/html; charset=utf-8');

//set_time_limit(900);

$client_id = $_SESSION['client_id'];

$dbset = json_decode($_SESSION['settingsApp'],true);
//$db = new mysqli ($dbset['DB']['DB_HOST'],$dbset['DB']['DB_USER'],$dbset['DB']['DB_PASS'],$dbset['DB']['DB_NAME']);

$DB_HOST='194.0.150.90';
$DB_USER='ilog';
$DB_PASS='1111';
$DB_NAME='tms37';
$db = new mysqli ($DB_HOST,$DB_USER,$DB_PASS,$DB_NAME);

$db->query("SET CHARSET SET utf8");
$db->query("SET NAMES 'utf8'");
if (mysqli_connect_errno()) {
	echo "Error connecting to DB";
	exit;
}

include "logger.php";
include "LogistMobile_checkwebtask.php";


	$query = "SELECT id FROM `tms_web_tasks` WHERE user_id = ".$client_id." AND `in_progress` = 0 ORDER BY `creation_time` DESC";
	if($stmt = $db->prepare($query)){
    if($stmt->execute()){
		$stmt->bind_result($last_id);
		$stmt->store_result();
		if($stmt->num_rows()>0){
		while ($stmt->fetch()) {
			$res = check($last_id);
		}
		$stmt->close();
		}else{ die('ok'); }
	}else{ die('ok'); }
    }else{ die('ok'); }
	
	//echo 'last_id = '.$last_id;		

	$db->close();
	exit;

?>
