Files
anpdf/app/routes/client.php
Andrey Kuvshinov 90ea0aa6a3 add client route
2020-04-26 19:54:50 +03:00

57 lines
1.6 KiB
PHP

<?php
function addclient_kuri(){
$buys = db_get("SELECT `buy_id`, `buy_email`, `date_start` FROM `anbuy`");
foreach($buys as $buy){
if ($buy['date_start'] == '0000-00-00 00:00:00')
$clientdate = date('Y-m-d G:i:s');
else
$clientdate = $buy['date_start'];
$clientmail = strtolower(trim($buy['buy_email']));
$clienthash = md5($clientmail);
$client = db_get("SELECT `client_id`, `clientcard`, `clientdate` FROM `clients` WHERE `clientmail` = '$clientmail' LIMIT 1");
if (isset($client['client_id'])){
if ($client['clientdate'] == '0000-00-00 00:00:00'){
$updsql = "UPDATE `clients` SET `clientdate` = '$clientdate' WHERE `client_id` = '{$client['client_id']}'";
db_get($updsql, 'writer');
echo "$updsql \n";
}
if ($client['clienthash'] == '' ){
$updsql = "UPDATE `clients` SET `clienthash` = '$clienthash' WHERE `client_id` = '{$client['client_id']}'";
db_get($updsql, 'writer');
echo "$updsql \n";
}
}
else {
$inssql = "INSERT INTO `clients` (clientmail, clientdate, clienthash) VALUES ('$clientmail', '$clientdate', '$clienthash')";
db_get($inssql, 'writer');
echo "$inssql \n";
}
}
}
// номер клубной карты
function addcard($id, $date) {
$year = substr($date, 0, 4);
$number = str_pad($id, 9, '0', STR_PAD_LEFT);
return "$year$number";
}