<?php
die;
include_once(dirname(dirname(__FILE__)) . '/classes/check.class.php');
include_once(dirname(dirname(__FILE__)) . '/admin/classes/functions.php');
protect("Admin");

$file = 'import/ClientsCA.csv';

$fp = new SplFileObject($file, 'r');

$header = $fp->fgetcsv();

$fp->next();

$db = DB::getInstance();

while ( !$fp->eof() )
{
	$provience = 'Québec';
	$row = $fp->fgetcsv();


	if ( !empty($row[0]) )
	{
		$row[3] = $provience;

		$data = [
			'cie'       => $row[0],
			'email'     => strtolower($row[1]),
			'address'   => $row[2],
			'state'     => $row[3],
			'tel1'      => $row[4],
		];

		$db->insert('clients', json_decode(json_encode($data), true));
	}
}
