예제 #1
0
function sync_stock_report()
{
    global $user_id;
    $tag = 'STOCK SYNC';
    $ch = curl_init(BASE_URL . 'get_form_data.php?user_id=' . $user_id);
    $post_params = array('form_id' => 9);
    curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);
    curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_params));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    $content = curl_exec($ch);
    curl_close($ch);
    $json = json_decode($content, TRUE);
    echo "<hr/>STOCK SYNC<br/>";
    print_r($json);
    echo "<hr/>";
    Log::i($tag, "Stock sync Responce : " . multi_implode(" ", $json));
    $status = $json['status'];
    if ($status == 'success') {
        write_plu_file($json['data']['stock']);
    } else {
        if ($json['error'] == 'Session expired') {
            $user_id = 0;
        } else {
            send_error_message(mysql_error());
        }
    }
}
예제 #2
0
$user_id = 0;
if (is_loggedin()) {
    send_sales_to_server();
    if ($user_id == 0) {
        //session expired
        if (login()) {
            send_sales_to_server();
        } else {
            send_error_message("");
        }
    }
} else {
    if (login()) {
        send_sales_to_server();
    } else {
        send_error_message("");
    }
}
function is_loggedin()
{
    $ch = curl_init(BASE_URL . 'is_logged_in.php');
    curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);
    curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
    //curl_setopt($ch, CURLOPT_POST, 1);
    //curl_setopt($ch, CURLOPT_POSTFIELDS,"user_name=owner&password=1234");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    $content = curl_exec($ch);
    curl_close($ch);
    $json = json_decode($content, TRUE);
    echo "<hr/>IS LOGED IN<br/>";