コード例 #1
0
ファイル: upload_vinayaka.php プロジェクト: teju/Android
define('TRAVEL_ID', 6);
db_connect();
$filename = 'vinayaka.csv';
$handle = fopen($filename, "r");
if ($handle === false) {
    echo 'Error opening the file';
    exit;
}
db_transaction_start();
$upload_count = 0;
while (($item = fgetcsv($handle, 65535, ',', '"')) !== FALSE) {
    // Get the vehicle details
    $reg_no = clean_csv_string(get_arg($item, 0));
    $vehicle_model = clean_csv_string(get_arg($item, 1));
    $client_name = clean_csv_string(get_arg($item, 3));
    $sticker_no = clean_csv_string(get_arg($item, 2));
    echo "[{$sticker_no}]";
    //upload the details into csv if sticker no is not empty
    if ($sticker_no == "") {
        continue;
    }
    // Check if the client is already available
    $client_row = db_client_select("", $client_name);
    if ($client_row[0]['STATUS'] != 'OK') {
        echo "Error getting client details for {$client_name}";
        exit;
    }
    // Insert new Client
    if ($client_row[0]['NROWS'] == 0) {
        $resp = db_client_insert($client_name, 'no_image.jpg', '', '');
        if ($resp['STATUS'] != 'OK') {
コード例 #2
0
ファイル: upload_vehicle.php プロジェクト: teju/Android
db_connect();
$filename = 'vehicle.csv';
$handle = fopen($filename, "r");
if ($handle === false) {
    echo 'Error opening the file';
    exit;
}
define('TRAVEL_ID', 1);
db_transaction_start();
$upload_count = 0;
while (($item = fgetcsv($handle, 65535, ',', '"')) !== FALSE) {
    // Get the vehicle details
    $sticker_no = clean_csv_string(get_arg($item, 0));
    $reg_no = clean_csv_string(get_arg($item, 1));
    $vehicle_model = clean_csv_string(get_arg($item, 2));
    $client_name = clean_csv_string(get_arg($item, 3));
    // Check if the client is already available
    $client_row = db_client_select("", $client_name);
    if ($client_row[0]['STATUS'] != 'OK') {
        echo "Error getting client details for {$client_name}";
        exit;
    }
    // Insert new Client
    if ($client_row[0]['NROWS'] == 0) {
        $resp = db_client_insert($client_name, 'no_image.jpg', '', '');
        if ($resp['STATUS'] != 'OK') {
            echo "Error inserting client for {$client_name}";
            exit;
        }
        $client_id = $resp['INSERT_ID'];
    } else {