You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
291 lines
13 KiB
291 lines
13 KiB
function get_news(length){
|
|
<!-- Получение наименования типа техники -->
|
|
var response = '';
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/management/get_news',
|
|
async: false,
|
|
data: ({length: length}),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
response = data.data;
|
|
} else {
|
|
<!-- Ошибка отправки -->
|
|
console.log('Ошибка GET_NEWS(): ' + data.response);
|
|
}
|
|
}
|
|
});
|
|
return response;
|
|
}
|
|
function open_service_request_charge_modal(id){
|
|
$('[name=charge_request_object_id]').val(id);
|
|
$('[name=charge_request_seller_checked]').val('');
|
|
$('[name=charge_request_description]').val('');
|
|
$('[name=charge_request_new_seller]').html('');
|
|
var services = get_managers();
|
|
for (var i = 0; i < services.length; i++) {
|
|
if (i == 0) {
|
|
$('[name="charge_request_seller_checked"]').val(services[i]['id'])
|
|
}
|
|
$('[name="charge_request_new_seller"]').append('<option id="' + services[i]['id'] + '">' + services[i]['name'] + '</option>');
|
|
}
|
|
$('#charge_request_modal').modal('show')
|
|
}
|
|
function remove_service_request(id){
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/wallet/pay/remove_service_request/',
|
|
async: false,
|
|
data: {'ID': id},
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
$('[name=service_request_row_'+id+']').hide()
|
|
} else {
|
|
<!-- Ошибка отправки -->
|
|
console.log('ОШИБКА remove_service_request' + data['response'])
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function sent_robokassa(){
|
|
$('#error_append_money').html('');
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/wallet/pay/sent',
|
|
async: false,
|
|
data: $(document.forms['append_money']).serialize(),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
$('#error_append_money').html('');
|
|
document.location.href = data.data;
|
|
} else {
|
|
<!-- Ошибка отправки -->
|
|
$('#error_append_money').html(data.response)
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function search_users(data){
|
|
$('[name="load_user_list"]').css('display', 'block');
|
|
$('[name="empty_user_list"]').css('display', 'none');
|
|
$('[name="search_results"]').html('');
|
|
if (data){
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/management/search_users',
|
|
async: false,
|
|
data: ({'phone': data}),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
$('[name="load_user_list"]').css('display', 'none');
|
|
for(var i=0; i<data['data'].length; i++){
|
|
$("[name='search_results']").append(
|
|
'<tr style="border-bottom: 1px dotted #ccc;">' +
|
|
'<td style="padding: 10px; background: #ffc;"><i class="glyphicon glyphicon-user"></i> ' + data['data'][i]['user'] + ' <b>' + data['data'][i]['user_role'] + '</b></td>' +
|
|
'<td style="padding: 10px; background: #ffc;"><i class="glyphicon glyphicon-earphone"></i> ' + data['data'][i]['email'] + '</td>' +
|
|
'<td style="padding: 10px; background: #ffc;"><i class="glyphicon glyphicon-earphone"></i> ' + data['data'][i]['phone'] + '</td>' +
|
|
'<td style="padding: 10px; background: #ffc;">' +
|
|
'<button onclick="sent_bill('+data['data'][i]['id']+', \''+ data['data'][i]['user'] +'\')">Выставить счет</button></td>' +
|
|
'</tr>'
|
|
)
|
|
}
|
|
} else {
|
|
$('[name="load_user_list"]').css('display', 'none');
|
|
$('[name="empty_user_list"]').css('display', 'block');
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
show_system_message('Введите номер телефона пользователя');
|
|
$('[name="load_user_list"]').css('display', 'none');
|
|
}
|
|
}
|
|
|
|
function get_bill_info(id) {
|
|
$('[name=content_result]').html('');
|
|
$('[name=empty_user_list]').fadeOut(function () {
|
|
if (only_numbers(id)){
|
|
var response = false;
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/wallet/get_user_from_bill_id',
|
|
data: {'id': id},
|
|
async: false,
|
|
success: function(data){
|
|
if(data['code'] == '1'){
|
|
for (var i in data['data']){
|
|
if( i == 'status' ){
|
|
$('[name=content_result]').append('<b>' + i + ':</b> ' + data['data'][i]['title'] + '<br>')
|
|
} else if ( i == 'pay_url' ) {
|
|
$('[name=content_result]').append('<p><b>' + i + ':</b> <input id="foo" style="color: #0099CC;width: 239px;border: 0;display: none;" readonly value="' + data['data'][i] + '"> <button id="copy_unique_user_id" class="btn" type="button" data-clipboard-action="copy" data-clipboard-target="#foo" onclick="show_system_message(\'Ссылка скопирована\')"> <i class="glyphicon glyphicon-duplicate"></i> <span class="hidden-xs hidden-sm">Скопировать</span></button></p>')
|
|
new Clipboard('#copy_unique_user_id');
|
|
} else {
|
|
$('[name=content_result]').append('<b>' + i + ':</b> ' + data['data'][i] + '<br>')
|
|
}
|
|
|
|
}
|
|
} else {
|
|
$('[name=empty_user_list]').fadeIn();
|
|
}
|
|
}
|
|
});
|
|
return response
|
|
} else {
|
|
$('[name=empty_user_list]').fadeIn();
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
function super_search_users(data){
|
|
$('[name="load_user_list"]').css('display', 'block');
|
|
$('[name="empty_user_list"]').css('display', 'none');
|
|
$('[name="search_results"]').html('');
|
|
if (data){
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/management/search_users',
|
|
async: false,
|
|
data: ({'phone': data}),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
$('[name="load_user_list"]').css('display', 'none');
|
|
for(var i=0; i<data['data'].length; i++){
|
|
$("[name='search_results']").append(
|
|
'<tr style="border-bottom: 1px dotted #ccc;">' +
|
|
'<td style="padding: 10px; background: #ffc;"><i class="glyphicon glyphicon-user"></i> ' + data['data'][i]['user'] + ' <b>' + data['data'][i]['user_role'] + '</b></td>' +
|
|
'<td style="padding: 10px; background: #ffc;"><i class="glyphicon glyphicon-earphone"></i> ' + data['data'][i]['email'] + '</td>' +
|
|
'<td style="padding: 10px; background: #ffc;"><i class="glyphicon glyphicon-earphone"></i> ' + data['data'][i]['phone'] + '</td>' +
|
|
'<td style="padding: 10px; background: #ffc;">' +
|
|
'<button onclick="sent_bill('+data['data'][i]['id']+', \''+ data['data'][i]['user'] +'\')">Выставить счет</button>' +
|
|
'<button onclick="sent_role('+data['data'][i]['id']+', \''+ data['data'][i]['user'] +'\')" style="margin-left: 10px;">Назначить роль</button></td>' +
|
|
'</tr>'
|
|
)
|
|
}
|
|
} else {
|
|
$('[name="load_user_list"]').css('display', 'none');
|
|
$('[name="empty_user_list"]').css('display', 'block');
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
show_system_message('Введите номер телефона пользователя');
|
|
$('[name="load_user_list"]').css('display', 'none');
|
|
}
|
|
}
|
|
|
|
function simple_registration(token, email) {
|
|
if (check_email(email)){
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/access/create_user/',
|
|
data: {'email': email, 'token': token},
|
|
async: false,
|
|
success: function(data) {
|
|
show_system_message(data.response);
|
|
}
|
|
});
|
|
} else {
|
|
show_system_message('Email указан не верно');
|
|
}
|
|
}
|
|
function get_managers(){
|
|
var response = '';
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/management/get_managers',
|
|
async: false,
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
response = data.data;
|
|
} else {
|
|
<!-- Ошибка отправки -->
|
|
console.log('Ошибка get_services_for_user(): ' + data.response);
|
|
}
|
|
}
|
|
});
|
|
return response;
|
|
}
|
|
function get_services_for_user(user_id){
|
|
var response = '';
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/management/get_services_for_user',
|
|
async: false,
|
|
data: ({'id': user_id}),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
response = data.data;
|
|
} else {
|
|
<!-- Ошибка отправки -->
|
|
console.log('Ошибка get_services_for_user(): ' + data.response);
|
|
}
|
|
}
|
|
});
|
|
return response;
|
|
}
|
|
function sent_role(id, user){
|
|
$('[name="new_role_user"]').val(user);
|
|
$('[name="new_role_user_id"]').val(id);
|
|
$('[name="new_role_service"]').html('');
|
|
var user_role = get_user_role(id);
|
|
if (user_role != 'A' && user_role != 'S'){
|
|
$('option[name=new_role_name_option][value=' + user_role + ']').attr('selected', true);
|
|
$('#new_role').modal('show');
|
|
} else if ( user_role == 'S'){
|
|
show_system_message('Вы не можете редактировать профиль равный вашему')
|
|
} else if ( user_role == 'A' ){
|
|
show_system_message('Вы не можете редактировать профиль выше вашего')
|
|
}
|
|
|
|
|
|
// Открыть Форму для заполнения данных
|
|
// Отправить данные из формы
|
|
// Написать сообщение, что все отправленно
|
|
}
|
|
function create_new_role(){
|
|
$('#error_new_role').html('');
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '/access/new_role',
|
|
async: false,
|
|
data: $(document.forms['new_role']).serialize(),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
show_system_message('Роль назначена');
|
|
super_search_users($('[name=user_search]').val());
|
|
clear_form('new_role');
|
|
$('#new_role').modal('hide');
|
|
} else {
|
|
<!-- Ошибка отправки -->
|
|
$('#error_new_role').html(data['response'])
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function new_feedback(){
|
|
<!-- Получение наименования типа техники -->
|
|
var response = '';
|
|
$('#error_new_feedback').hide().html('');
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '/management/new_feedback/',
|
|
async: false,
|
|
data: $(document.forms['new_feedback_form']).serialize(),
|
|
success: function(data) {
|
|
if (data.code == '1'){
|
|
clear_form('new_feedback_form', 'error_new_feedback');
|
|
$('#FeedBack').modal('hide');
|
|
$('#FeedBackSuccess').modal('show');
|
|
$('#error_new_feedback').hide('').html('');
|
|
} else {
|
|
$('#error_new_feedback').html(data['response']).fadeIn('fast');
|
|
<!-- Ошибка отправки -->
|
|
console.log('Ошибка GET_NEWS(): ' + data.response);
|
|
}
|
|
}
|
|
});
|
|
return response;
|
|
} |