Use Content-Type application/json for AJAX responses

This commit is contained in:
jekkos
2025-12-23 09:22:00 +01:00
parent 849439c71e
commit 2aa32a52cd
22 changed files with 100 additions and 100 deletions

View File

@@ -53,7 +53,7 @@ class Attributes extends Secure_Controller
$data_rows[] = get_attribute_definition_data_row($attribute_row);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -70,7 +70,7 @@ class Attributes extends Secure_Controller
$this->request->getPost('attribute_id', FILTER_SANITIZE_NUMBER_INT) ?? false
);
echo json_encode(['success' => $success != 0]);
$this->response->setJSON(['success' => $success != 0]);
}
/**
@@ -85,7 +85,7 @@ class Attributes extends Secure_Controller
$this->request->getPost('definition_id', FILTER_SANITIZE_NUMBER_INT)
);
echo json_encode(['success' => $success]);
$this->response->setJSON(['success' => $success]);
}
/**
@@ -128,20 +128,20 @@ class Attributes extends Secure_Controller
$this->attribute->saveAttributeValue($definition_value, $definition_data['definition_id']);
}
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Attributes.definition_successful_adding') . ' ' . $definition_name,
'id' => $definition_data['definition_id']
]);
} else { // Existing definition
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Attributes.definition_successful_updating') . ' ' . $definition_name,
'id' => $definition_id
]);
}
} else { // Failure
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Attributes.definition_error_adding_updating', [$definition_name]),
'id' => NEW_ENTRY

View File

@@ -64,7 +64,7 @@ class Cashups extends Secure_Controller
$data_rows[] = get_cash_up_data_row($cash_up);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -192,7 +192,7 @@ class Cashups extends Secure_Controller
$cash_ups_info = $this->cashup->get_info($row_id);
$data_row = get_cash_up_data_row($cash_ups_info);
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -227,12 +227,12 @@ class Cashups extends Secure_Controller
if ($this->cashup->save_value($cash_up_data, $cashup_id)) {
// New cashup_id
if ($cashup_id == NEW_ENTRY) {
echo json_encode(['success' => true, 'message' => lang('Cashups.successful_adding'), 'id' => $cash_up_data['cashup_id']]);
$this->response->setJSON(['success' => true, 'message' => lang('Cashups.successful_adding'), 'id' => $cash_up_data['cashup_id']]);
} else { // Existing Cashup
echo json_encode(['success' => true, 'message' => lang('Cashups.successful_updating'), 'id' => $cashup_id]);
$this->response->setJSON(['success' => true, 'message' => lang('Cashups.successful_updating'), 'id' => $cashup_id]);
}
} else { // Failure
echo json_encode(['success' => false, 'message' => lang('Cashups.error_adding_updating'), 'id' => NEW_ENTRY]);
$this->response->setJSON(['success' => false, 'message' => lang('Cashups.error_adding_updating'), 'id' => NEW_ENTRY]);
}
}

View File

@@ -306,7 +306,7 @@ class Config extends Secure_Controller
$message = lang('Config.saved_' . ($success ? '' : 'un') . 'successfully');
$message = $upload_success ? $message : strip_tags($upload_data['error']);
echo json_encode(['success' => $success, 'message' => $message]);
$this->response->setJSON(['success' => $success, 'message' => $message]);
}

View File

@@ -72,7 +72,7 @@ class Customers extends Persons
$data_row = get_customer_data_row($person, $stats);
echo json_encode($data_row);
$this->response->setJSON($data_row);
}

View File

@@ -41,7 +41,7 @@ class Employees extends Persons
$data_rows[] = get_person_data_row($person);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -54,7 +54,7 @@ class Employees extends Persons
$search = $this->request->getGet('term');
$suggestions = $this->employee->get_search_suggestions($search, 25, true);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -65,7 +65,7 @@ class Employees extends Persons
$search = $this->request->getPost('term');
$suggestions = $this->employee->get_search_suggestions($search);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -163,20 +163,20 @@ class Employees extends Persons
if ($this->employee->save_employee($person_data, $employee_data, $grants_array, $employee_id)) {
// New employee
if ($employee_id == NEW_ENTRY) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Employees.successful_adding') . ' ' . $first_name . ' ' . $last_name,
'id' => $employee_data['person_id']
]);
} else { // Existing employee
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Employees.successful_updating') . ' ' . $first_name . ' ' . $last_name,
'id' => $employee_id
]);
}
} else { // Failure
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Employees.error_adding_updating') . ' ' . $first_name . ' ' . $last_name,
'id' => NEW_ENTRY
@@ -192,12 +192,12 @@ class Employees extends Persons
$employees_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ($this->employee->delete_list($employees_to_delete)) { // TODO: this is passing a string, but delete_list expects an array
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Employees.successful_deleted') . ' ' . count($employees_to_delete) . ' ' . lang('Employees.one_or_multiple')
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Employees.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Employees.cannot_be_deleted')]);
}
}

View File

@@ -78,7 +78,7 @@ class Expenses extends Secure_Controller
$data_rows[] = get_expenses_data_last_row($expenses);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows, 'payment_summary' => $payment_summary]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows, 'payment_summary' => $payment_summary]);
}
/**
@@ -137,7 +137,7 @@ class Expenses extends Secure_Controller
$expense_info = $this->expense->get_info($row_id);
$data_row = get_expenses_data_row($expense_info);
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -167,12 +167,12 @@ class Expenses extends Secure_Controller
if ($this->expense->save_value($expense_data, $expense_id)) {
// New Expense
if ($expense_id == NEW_ENTRY) {
echo json_encode(['success' => true, 'message' => lang('Expenses.successful_adding'), 'id' => $expense_data['expense_id']]);
$this->response->setJSON(['success' => true, 'message' => lang('Expenses.successful_adding'), 'id' => $expense_data['expense_id']]);
} else { // Existing Expense
echo json_encode(['success' => true, 'message' => lang('Expenses.successful_updating'), 'id' => $expense_id]);
$this->response->setJSON(['success' => true, 'message' => lang('Expenses.successful_updating'), 'id' => $expense_id]);
}
} else { // Failure
echo json_encode(['success' => false, 'message' => lang('Expenses.error_adding_updating'), 'id' => NEW_ENTRY]);
$this->response->setJSON(['success' => false, 'message' => lang('Expenses.error_adding_updating'), 'id' => NEW_ENTRY]);
}
}
@@ -184,7 +184,7 @@ class Expenses extends Secure_Controller
$expenses_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ($this->expense->delete_list($expenses_to_delete)) {
echo json_encode(['success' => true, 'message' => lang('Expenses.successful_deleted') . ' ' . count($expenses_to_delete) . ' ' . lang('Expenses.one_or_multiple'), 'ids' => $expenses_to_delete]);
$this->response->setJSON(['success' => true, 'message' => lang('Expenses.successful_deleted') . ' ' . count($expenses_to_delete) . ' ' . lang('Expenses.one_or_multiple'), 'ids' => $expenses_to_delete]);
} else {
echo json_encode(['success' => false, 'message' => lang('Expenses.cannot_be_deleted'), 'ids' => $expenses_to_delete]);
}

View File

@@ -45,7 +45,7 @@ class Expenses_categories extends Secure_Controller // TODO: Is this class ev
$data_rows[] = get_expense_category_data_row($expense_category);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -56,7 +56,7 @@ class Expenses_categories extends Secure_Controller // TODO: Is this class ev
{
$data_row = get_expense_category_data_row($this->expense_category->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -84,20 +84,20 @@ class Expenses_categories extends Secure_Controller // TODO: Is this class ev
if ($this->expense_category->save_value($expense_category_data, $expense_category_id)) {
// New expense_category
if ($expense_category_id == NEW_ENTRY) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Expenses_categories.successful_adding'),
'id' => $expense_category_data['expense_category_id']
]);
} else { // Existing Expense Category
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Expenses_categories.successful_updating'),
'id' => $expense_category_id
]);
}
} else { // Failure
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Expenses_categories.error_adding_updating') . ' ' . $expense_category_data['category_name'],
'id' => NEW_ENTRY
@@ -113,12 +113,12 @@ class Expenses_categories extends Secure_Controller // TODO: Is this class ev
$expense_category_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ($this->expense_category->delete_list($expense_category_to_delete)) { // TODO: Convert to ternary notation.
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Expenses_categories.successful_deleted') . ' ' . count($expense_category_to_delete) . ' ' . lang('Expenses_categories.one_or_multiple')
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Expenses_categories.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Expenses_categories.cannot_be_deleted')]);
}
}
}

View File

@@ -46,7 +46,7 @@ class Giftcards extends Secure_Controller
$data_rows[] = get_giftcard_data_row($giftcard);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -60,7 +60,7 @@ class Giftcards extends Secure_Controller
$search = $this->request->getGet('term');
$suggestions = $this->giftcard->get_search_suggestions($search, true);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -71,7 +71,7 @@ class Giftcards extends Secure_Controller
$search = $this->request->getPost('term');
$suggestions = $this->giftcard->get_search_suggestions($search);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -82,7 +82,7 @@ class Giftcards extends Secure_Controller
{
$data_row = get_giftcard_data_row($this->giftcard->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -131,20 +131,20 @@ class Giftcards extends Secure_Controller
if ($this->giftcard->save_value($giftcard_data, $giftcard_id)) {
// New giftcard
if ($giftcard_id == NEW_ENTRY) { // TODO: Constant needed
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Giftcards.successful_adding') . ' ' . $giftcard_data['giftcard_number'],
'id' => $giftcard_data['giftcard_id']
]);
} else { // Existing giftcard
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Giftcards.successful_updating') . ' ' . $giftcard_data['giftcard_number'],
'id' => $giftcard_id
]);
}
} else { // Failure
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Giftcards.error_adding_updating') . ' ' . $giftcard_data['giftcard_number'],
'id' => NEW_ENTRY
@@ -176,12 +176,12 @@ class Giftcards extends Secure_Controller
$giftcards_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ($this->giftcard->delete_list($giftcards_to_delete)) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Giftcards.successful_deleted') . ' ' . count($giftcards_to_delete) . ' ' . lang('Giftcards.one_or_multiple')
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Giftcards.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Giftcards.cannot_be_deleted')]);
}
}
}

View File

@@ -62,27 +62,27 @@ class Home extends Secure_Controller
];
if ($this->employee->change_password($employee_data, $employee_id) && strlen($employee_data['password']) >= 8) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Employees.successful_change_password'),
'id' => $employee_id
]);
} else { // Failure // TODO: Replace -1 with constant
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Employees.unsuccessful_change_password'),
'id' => -1
]);
}
} else { // TODO: Replace -1 with constant
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Employees.current_password_invalid'),
'id' => -1
]);
}
} else { // TODO: Replace -1 with constant
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Employees.current_password_invalid'),
'id' => -1

View File

@@ -89,7 +89,7 @@ class Item_kits extends Secure_Controller
$data_rows[] = get_item_kit_data_row($item_kit);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -100,7 +100,7 @@ class Item_kits extends Secure_Controller
$search = $this->request->getPost('term');
$suggestions = $this->item_kit->get_search_suggestions($search);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -112,7 +112,7 @@ class Item_kits extends Secure_Controller
// Calculate the total cost and retail price of the Kit, so it can be added to the table refresh
$item_kit = $this->_add_totals_to_item_kit($this->item_kit->get_info($row_id));
echo json_encode(get_item_kit_data_row($item_kit));
$this->response->setJSON(get_item_kit_data_row($item_kit));
}
/**
@@ -201,20 +201,20 @@ class Item_kits extends Secure_Controller
}
if ($new_item) {
echo json_encode([
$this->response->setJSON([
'success' => $success,
'message' => lang('Item_kits.successful_adding') . ' ' . $item_kit_data['name'],
'id' => $item_kit_id
]);
} else {
echo json_encode([
$this->response->setJSON([
'success' => $success,
'message' => lang('Item_kits.successful_updating') . ' ' . $item_kit_data['name'],
'id' => $item_kit_id
]);
}
} else { // Failure
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Item_kits.error_adding_updating') . ' ' . $item_kit_data['name'],
'id' => NEW_ENTRY
@@ -230,12 +230,12 @@ class Item_kits extends Secure_Controller
$item_kits_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ($this->item_kit->delete_list($item_kits_to_delete)) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Item_kits.successful_deleted') . ' ' . count($item_kits_to_delete) . ' ' . lang('Item_kits.one_or_multiple')
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Item_kits.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Item_kits.cannot_be_deleted')]);
}
}

View File

@@ -134,7 +134,7 @@ class Items extends Secure_Controller
}
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**

View File

@@ -53,9 +53,9 @@ class Messages extends Secure_Controller
$response = $this->sms_lib->sendSMS($phone, $message);
if ($response) {
echo json_encode(['success' => true, 'message' => lang('Messages.successfully_sent') . ' ' . esc($phone)]);
$this->response->setJSON(['success' => true, 'message' => lang('Messages.successfully_sent') . ' ' . esc($phone)]);
} else {
echo json_encode(['success' => false, 'message' => lang('Messages.unsuccessfully_sent') . ' ' . esc($phone)]);
$this->response->setJSON(['success' => false, 'message' => lang('Messages.unsuccessfully_sent') . ' ' . esc($phone)]);
}
}
@@ -74,13 +74,13 @@ class Messages extends Secure_Controller
$response = $this->sms_lib->sendSMS($phone, $message);
if ($response) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Messages.successfully_sent') . ' ' . esc($phone),
'person_id' => $person_id
]);
} else {
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Messages.unsuccessfully_sent') . ' ' . esc($phone),
'person_id' => NEW_ENTRY

View File

@@ -38,7 +38,7 @@ abstract class Persons extends Secure_Controller
$search = $this->request->getGet('term');
$suggestions = $this->person->get_search_suggestions($search);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -48,7 +48,7 @@ abstract class Persons extends Secure_Controller
{
$data_row = get_person_data_row($this->person->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**

View File

@@ -65,7 +65,7 @@ class Receivings extends Secure_Controller
$suggestions = $this->item->get_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($search));
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -80,7 +80,7 @@ class Receivings extends Secure_Controller
$suggestions = $this->item->get_stock_search_suggestions($search, ['search_custom' => false, 'is_deleted' => false], true);
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($search));
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -277,13 +277,13 @@ class Receivings extends Secure_Controller
$receiving_ids = $receiving_id == -1 ? $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT) : [$receiving_id]; // TODO: Replace -1 with constant
if ($this->receiving->delete_list($receiving_ids, $employee_id, $update_inventory)) { // TODO: Likely need to surround this block of code in a try-catch to catch the ReflectionException
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Receivings.successfully_deleted') . ' ' . count($receiving_ids) . ' ' . lang('Receivings.one_or_multiple'),
'ids' => $receiving_ids
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Receivings.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Receivings.cannot_be_deleted')]);
}
}
@@ -493,13 +493,13 @@ class Receivings extends Secure_Controller
$this->inventory->update('RECV ' . $receiving_id, ['trans_date' => $receiving_time]);
if ($this->receiving->update($receiving_id, $receiving_data)) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Receivings.successfully_updated'),
'id' => $receiving_id
]);
} else {
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Receivings.unsuccessfully_updated'),
'id' => $receiving_id

View File

@@ -1658,7 +1658,7 @@ class Reports extends Secure_Controller
)
];
echo json_encode([$sale_id => $summary_data]);
$this->response->setJSON([$sale_id => $summary_data]);
}
/**

View File

@@ -120,7 +120,7 @@ class Sales extends Secure_Controller
$sale_info = $this->sale->get_info($row_id)->getRow();
$data_row = get_sale_data_row($sale_info);
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**

View File

@@ -36,7 +36,7 @@ class Suppliers extends Persons
$data_row = get_supplier_data_row($this->supplier->get_info($row_id));
$data_row['category'] = $this->supplier->get_category_name($data_row['category']);
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**

View File

@@ -50,7 +50,7 @@ class Tax_categories extends Secure_Controller
$data_rows[] = get_tax_categories_data_row($tax_category);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -61,7 +61,7 @@ class Tax_categories extends Secure_Controller
{
$data_row = get_tax_categories_data_row($this->tax_category->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**

View File

@@ -61,7 +61,7 @@ class Tax_codes extends Secure_Controller
$data_rows[] = get_tax_code_data_row($tax_code);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -72,7 +72,7 @@ class Tax_codes extends Secure_Controller
{
$data_row = get_tax_code_data_row($this->tax_code->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -102,20 +102,20 @@ class Tax_codes extends Secure_Controller
if ($this->tax_code->save($tax_code_data)) {
if ($tax_code_id == NEW_ENTRY) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Tax_codes.successful_adding'),
'id' => $tax_code_data['tax_code_id']
]);
} else {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Tax_codes.successful_updating'),
'id' => $tax_code_id
]);
}
} else {
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Tax_codes.error_adding_updating') . ' ' . $tax_code_data['tax_code_id'],
'id' => NEW_ENTRY
@@ -131,12 +131,12 @@ class Tax_codes extends Secure_Controller
$tax_codes_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
if ($this->tax_code->delete_list($tax_codes_to_delete)) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Tax_codes.successful_deleted') . ' ' . count($tax_codes_to_delete) . ' ' . lang('Tax_codes.one_or_multiple')
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Tax_codes.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Tax_codes.cannot_be_deleted')]);
}
}
}

View File

@@ -53,7 +53,7 @@ class Tax_jurisdictions extends Secure_Controller
$data_rows[] = get_tax_jurisdictions_data_row($tax_jurisdiction);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -64,7 +64,7 @@ class Tax_jurisdictions extends Secure_Controller
{
$data_row = get_tax_jurisdictions_data_row($this->tax_jurisdiction->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -92,20 +92,20 @@ class Tax_jurisdictions extends Secure_Controller
if ($this->tax_jurisdiction->save_value($tax_jurisdiction_data)) {
if ($jurisdiction_id == NEW_ENTRY) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Tax_jurisdictions.successful_adding'),
'id' => $tax_jurisdiction_data['jurisdiction_id']
]);
} else {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Tax_jurisdictions.successful_updating'),
'id' => $jurisdiction_id
]);
}
} else {
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Tax_jurisdictions.error_adding_updating') . ' ' . $tax_jurisdiction_data['jurisdiction_name'],
'id' => NEW_ENTRY
@@ -121,12 +121,12 @@ class Tax_jurisdictions extends Secure_Controller
$tax_jurisdictions_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
if ($this->tax_jurisdiction->delete_list($tax_jurisdictions_to_delete)) {
echo json_encode([
$this->response->setJSON([
'success' => true,
'message' => lang('Tax_jurisdictions.successful_deleted') . ' ' . count($tax_jurisdictions_to_delete) . ' ' . lang('Tax_jurisdictions.one_or_multiple')
]);
} else {
echo json_encode(['success' => false, 'message' => lang('Tax_jurisdictions.cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Tax_jurisdictions.cannot_be_deleted')]);
}
}
}

View File

@@ -92,7 +92,7 @@ class Taxes extends Secure_Controller
$data_rows[] = get_tax_rates_data_row($tax_rate_row);
}
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
$this->response->setJSON(['total' => $total_rows, 'rows' => $data_rows]);
}
/**
@@ -103,7 +103,7 @@ class Taxes extends Secure_Controller
$search = $this->request->getPost('term');
$suggestions = $this->tax->get_search_suggestions($search); // TODO: There is no get_search_suggestions function in the tax model
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -116,7 +116,7 @@ class Taxes extends Secure_Controller
$search = $this->request->getPost('term');
$suggestions = $this->tax_category->get_tax_category_suggestions($search);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
@@ -128,7 +128,7 @@ class Taxes extends Secure_Controller
{
$data_row = get_tax_rates_data_row($this->tax->get_info($row_id));
echo json_encode($data_row);
$this->response->setJSON($data_row);
}
/**
@@ -388,12 +388,12 @@ class Taxes extends Secure_Controller
if ($this->tax->save_value($tax_rate_data, $tax_rate_id)) {
if ($tax_rate_id == NEW_ENTRY) { // TODO: this needs to be replaced with ternary notation
echo json_encode(['success' => true, 'message' => lang('Taxes.tax_rate_successfully_added')]);
$this->response->setJSON(['success' => true, 'message' => lang('Taxes.tax_rate_successfully_added')]);
} else { // Existing tax_code
echo json_encode(['success' => true, 'message' => lang('Taxes.tax_rate_successful_updated')]);
$this->response->setJSON(['success' => true, 'message' => lang('Taxes.tax_rate_successful_updated')]);
}
} else {
echo json_encode(['success' => false, 'message' => lang('Taxes.tax_rate_error_adding_updating')]);
$this->response->setJSON(['success' => false, 'message' => lang('Taxes.tax_rate_error_adding_updating')]);
}
}
@@ -405,9 +405,9 @@ class Taxes extends Secure_Controller
$tax_codes_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
if ($this->tax->delete_list($tax_codes_to_delete)) { // TODO: this needs to be replaced with ternary notation
echo json_encode(['success' => true, 'message' => lang('Taxes.tax_code_successful_deleted')]);
$this->response->setJSON(['success' => true, 'message' => lang('Taxes.tax_code_successful_deleted')]);
} else {
echo json_encode(['success' => false, 'message' => lang('Taxes.tax_code_cannot_be_deleted')]);
$this->response->setJSON(['success' => false, 'message' => lang('Taxes.tax_code_cannot_be_deleted')]);
}
}
@@ -422,7 +422,7 @@ class Taxes extends Secure_Controller
$search = $this->request->getPostGet('term');
$suggestions = $this->tax_code->get_tax_codes_search_suggestions($search);
echo json_encode($suggestions);
$this->response->setJSON($suggestions);
}
/**
@@ -452,7 +452,7 @@ class Taxes extends Secure_Controller
$success = $this->tax_code->save_tax_codes($array_save);
echo json_encode([
$this->response->setJSON([
'success' => $success,
'message' => lang('Taxes.tax_codes_saved_' . ($success ? '' : 'un') . 'successfully')
]);
@@ -489,7 +489,7 @@ class Taxes extends Secure_Controller
];
if (in_array($tax_group[$key], $unique_tax_groups)) { // TODO: This can be replaced with `in_array($tax_group[$key], $unique_tax_groups)`
echo json_encode([
$this->response->setJSON([
'success' => false,
'message' => lang('Taxes.tax_group_not_unique', [$tax_group[$key]])
]);

View File

@@ -172,7 +172,7 @@ class Barcode_lib
if ($layout_type == 'name') {
$result = $item['name'];
} elseif ($layout_type == 'category' && isset($item['category'])) {
$result = lang('Items.category') . " " . $item['category'];
$result = lang('Items.category') . " " . esc($item['category']);
} elseif ($layout_type == 'cost_price' && isset($item['cost_price'])) {
$result = lang('Items.cost_price') . " " . to_currency($item['cost_price']);
} elseif ($layout_type == 'unit_price' && isset($item['unit_price'])) {