<?php
/**
 !! This file should be run if the Office Address was ever to change!
 This program will configure the distance of the client, as well as the travel time from this location, for each client.
 This information is stored to ensure that the planner takes less time to process with less calls the the DistanceMatrix API.
**/
include(__DIR__.'/../includes/sysinit.php');

$clients	= $sableDB->getRows('select client_id, coalesce(client_cell, client_phone) as client_number from client');
$count		= 0;
$tot		= 0;
foreach($clients as $client)
{
	$num = $client['client_number'];
	SableSystem::validateFixNumber($num);
	$sql = 'update sms_message set client_id = '.$client['client_id'].' where sms_number = "'.$num.'"';
	$res = $sableDB->updateQuery($sql);
	if ($res) $tot += $res;
	$count++;
}
echo($count.' client records updated.<br>'.$tot.'sms records updated.');