51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
|
||
|
|
//var_dump($_POST);
|
||
|
|
if ($_SESSION['id'] && ($_POST['client_id'] || $_POST['clients_id'])) {
|
||
|
|
$all = 0;
|
||
|
|
if(isset($_POST['all']) && $_POST['all'] > 0){
|
||
|
|
$all = 1;
|
||
|
|
}
|
||
|
|
$post = clearInputData($_POST);
|
||
|
|
$client = new Clients;
|
||
|
|
$client_id = $post['client_id'];
|
||
|
|
$clients_id = $post['clients_id'];
|
||
|
|
$success = true;
|
||
|
|
//var_dump($clients_id);
|
||
|
|
if($all == 1){
|
||
|
|
if(isset($_SESSION['where_campaigns'])){
|
||
|
|
$where = $_SESSION['where_campaigns'];
|
||
|
|
$sql = "SELECT id FROM clients WHERE 1 ".$where;
|
||
|
|
|
||
|
|
$q = mysql_query($sql);
|
||
|
|
while($r = mysql_fetch_assoc($q)) {
|
||
|
|
if (!$client->restore($r['id']))
|
||
|
|
$success = false;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
exit();
|
||
|
|
}
|
||
|
|
} else
|
||
|
|
if (isset($clients_id) && is_array($clients_id)) {
|
||
|
|
foreach ($clients_id as $id) {
|
||
|
|
if (mb_strtolower($id) !== "all") {
|
||
|
|
if (!$client->restore($id))
|
||
|
|
$success = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else if (isset($client_id)) {
|
||
|
|
if (!$client->restore($client_id))
|
||
|
|
$success = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($success)
|
||
|
|
echo json_encode([
|
||
|
|
'success' => true
|
||
|
|
]);
|
||
|
|
else
|
||
|
|
echo json_encode([
|
||
|
|
'error' => mysql_error()
|
||
|
|
]);
|
||
|
|
}
|