add client route
This commit is contained in:
57
app/routes/client.php
Normal file
57
app/routes/client.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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";
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user