|
|
@@ -12,22 +12,34 @@
|
|
|
|
|
|
require "../initialise.php";
|
|
|
|
|
|
-if($argc < 3) {
|
|
|
- die(sprintf("Usage: php %s [PATH] [CUSTOMER ID] [REGION CODE]\n", basename(__FILE__)));
|
|
|
+if($argc < 4) {
|
|
|
+ echo sprintf("Usage: php %s [PATH] [CUSTOMER ID] [REGION CODE]\n", basename(__FILE__));
|
|
|
+ exit(0);
|
|
|
}
|
|
|
|
|
|
+[$script, $path, $customer_id, $region_code] = $argv;
|
|
|
+
|
|
|
$script = array_shift($argv);
|
|
|
$path = array_shift($argv);
|
|
|
$customer_id = array_shift($argv);
|
|
|
$region_code = array_shift($argv);
|
|
|
|
|
|
-if(!file_exists($path)) die($path . " not found.");
|
|
|
+if(!file_exists($path)) {
|
|
|
+ echo $path . " not found.\n";
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
|
|
|
$customer = Customer::get($customer_id);
|
|
|
-if(!$customer) die("Customer not found.");
|
|
|
+if(!$customer) {
|
|
|
+ echo "Customer not found.\n";
|
|
|
+ exit(1);
|
|
|
+}
|
|
|
|
|
|
$confirm = trim(readline($customer->name . ": Confirm Y/N: "));
|
|
|
-if($confirm !== "Y") die("Aborted");
|
|
|
+if($confirm !== "Y") {
|
|
|
+ echo "Aborted.\n";
|
|
|
+ exit(0);
|
|
|
+}
|
|
|
|
|
|
$handle = fopen($path, "rb");
|
|
|
|
|
|
@@ -89,7 +101,7 @@ for($i = 0; $data = fgetcsv($handle); $i++) {
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- throw new Exception("Unknown field name: {$field_name}");
|
|
|
+ throw new RuntimeException("Unknown field name: {$field_name}");
|
|
|
}
|
|
|
}
|
|
|
continue;
|