File "admin-users-edit.inc.php"
Full Path: /srv/www/www.cadoro.it/src/controllers/admin-users-edit.inc.php
File size: 2.78 KB
MIME-type: text/x-php
Charset: utf-8
<?php
$user = models\User::get_by_id($user_id);
if (!$user || $principal['role'] != 1 && $principal['store'] != $user['store']) {
not_found();
}
$status = null;
$errors = array();
if (_request('pdf')) {
if ($user['card']) {
$pdf = $user->pdf();
if (_request('debug')) {
$pdf->Output();
} else {
$pdf->Output('D', $user['card'] . ".pdf");
}
} else {
$status = 2;
}
}
if (_request('card') == 'new' && $user['store']) {
$result = classes\Fidelity::GetNuovaTessera(sprintf("%03d", $user['store']));
if ($result && isset($result['codice'])) {
$user->update_active(1);
$user->update_card(array(
"card" => $result['codice'],
));
$user['card'] = $result['codice'];
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$params = array(
"card" => _post('card'),
"lastname" => _post('lastname'),
"firstname" => _post('firstname'),
"email" => _post('email'),
"password" => _post('password'),
"birthday" => _post('birthday'),
"gender" => _post('gender'),
"mobile" => _post('mobile'),
"phone" => _post('phone'),
'address' => _post('address'),
'address_no' => _post('address_no'),
'city' => _post('city'),
'province' => _post('province'),
'zipcode' => _post('zipcode'),
'country' => _post('country'),
'active' => $principal['role'] == 1 ? _post('active') : $user['active'],
'privacy' => $principal['role'] == 1 ? _post('privacy') : $user['privacy'],
'privacy1' => $principal['role'] == 1 ? _post('privacy1') : $user['privacy1'],
'privacy2' => $principal['role'] == 1 ? _post('privacy2') : $user['privacy2'],
'privacy3' => $principal['role'] == 1 ? _post('privacy3') : $user['privacy3'],
'store' => _post('store'),
'app_token' => _post('app_token'),
'app_notifications' => _post('app_notifications'),
'app_details' => _post('app_details'),
);
if ($params['card'] && !$user['card']) {
$res = classes\Fidelity::CheckNuovaTessera($params['card'], sprintf("%03d", $params['store']));
if (!$res || _a($res, 'Errore')) {
$errors['card'] = 3;
}
}
if (!$errors) {
$user->update_admin($params);
if ($params['card'] && !$user['card']) {
$user = models\User::get_by_id($user['id']);
$user->email_cardoro_conferma();
}
$status = 1;
}
}
$smarty->assign("user", $user);
$smarty->assign("status", $status);
$smarty->assign("errors", $errors);
$smarty->assign("menu", "users");
$smarty->assign("submenu", "users");
$smarty->assign("stores", models\Store::get_vocabulary(array(
"id" => $principal['role'] == 2 ? $principal['store'] : null,
)));
$smarty->display("admin-users-edit.tmpl");
?>