mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-18 13:28:32 -04:00
Attributes fixes and warning removal
- when the payments array was folded into sale_data there was an earlier payments[] reference in the foreach loop that didn't get folded in. - Update PHPdoc - Added ::class to remove polymorphic call warning - Removed unreachable 'break;' statement after return statement. - Added missing return type - fixed missing assignment of mailchimp_api_key
This commit is contained in:
@@ -3,6 +3,7 @@ namespace App\Config\Validation;
|
||||
|
||||
use App\Models\Employee;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
@@ -24,7 +25,7 @@ class OSPOSRules
|
||||
{
|
||||
$this->employee = model('Employee');
|
||||
$this->request = Services::request();
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
//Installation Check
|
||||
if(!$this->installation_check())
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\Cashup;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Reports\Summary_payments;
|
||||
use CodeIgniter\Model;
|
||||
use Config\OSPOS;
|
||||
|
||||
/**
|
||||
* @property cashup cashup
|
||||
@@ -18,11 +19,11 @@ class Cashups extends Secure_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('cashups');
|
||||
|
||||
|
||||
$this->cashup = model('Cashup');
|
||||
$this->expense = model('Expense');
|
||||
$this->summary_payments = model('Reports/Summary_payments');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
public function getIndex(): void
|
||||
|
||||
@@ -21,6 +21,7 @@ use CodeIgniter\Encryption\EncrypterInterface;
|
||||
use CodeIgniter\Files\File;
|
||||
use Config\Database;
|
||||
use Config\Encryption;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
use DirectoryIterator;
|
||||
use NumberFormatter;
|
||||
@@ -66,7 +67,7 @@ class Config extends Secure_Controller
|
||||
$this->rounding_mode = model('Rounding_mode');
|
||||
$this->stock_location = model('Stock_location');
|
||||
$this->tax = model('Tax');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
$this->db = Database::connect();
|
||||
|
||||
helper('security');
|
||||
@@ -258,7 +259,6 @@ class Config extends Secure_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
@@ -276,9 +276,7 @@ class Config extends Secure_Controller
|
||||
$data['tax_category_options'] = $this->tax_lib->get_tax_category_options();
|
||||
$data['tax_jurisdiction_options'] = $this->tax_lib->get_tax_jurisdiction_options();
|
||||
$data['show_office_group'] = $this->module->get_show_office_group();
|
||||
$data['currency_code'] = isset($this->config['currency_code'])
|
||||
? $this->config['currency_code']
|
||||
: '' ;
|
||||
$data['currency_code'] = $this->config['currency_code'] ?? '';
|
||||
$data['db_version'] = mysqli_get_server_info(db_connect()->mysqli);
|
||||
|
||||
// load all the license statements, they are already XSS cleaned in the private function
|
||||
@@ -304,11 +302,11 @@ class Config extends Secure_Controller
|
||||
$this->encrypter = Services::encrypter();
|
||||
}
|
||||
|
||||
$mailchimp_api_key = (isset($this->config['mailchimp_api_key']) && !empty($this->config['mailchimp_api_key']))
|
||||
$data['mailchimp']['api_key'] = (isset($this->config['mailchimp_api_key']) && !empty($this->config['mailchimp_api_key']))
|
||||
? $this->encrypter->decrypt($this->config['mailchimp_api_key'])
|
||||
: '';
|
||||
|
||||
$mailchimp_list_id = (isset($this->config['mailchimp_list_id']) && !empty($this->config['mailchimp_list_id']))
|
||||
$data['mailchimp']['list_id'] = (isset($this->config['mailchimp_list_id']) && !empty($this->config['mailchimp_list_id']))
|
||||
? $this->encrypter->decrypt($this->config['mailchimp_list_id'])
|
||||
: '';
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\Models\Tax_code;
|
||||
|
||||
use CodeIgniter\Encryption\Encryption;
|
||||
use CodeIgniter\Encryption\EncrypterInterface;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
use stdClass;
|
||||
|
||||
@@ -38,7 +39,7 @@ class Customers extends Persons
|
||||
$this->customer_rewards = model('Customer_rewards');
|
||||
$this->customer = model('Customer');
|
||||
$this->tax_code = model('Tax_code');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
$encrypter = Services::encrypter();
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class Expenses extends Secure_Controller
|
||||
|
||||
public function postSave(int $expense_id = NEW_ENTRY): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$newdate = $this->request->getPost('date', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$date_formatter = date_create_from_format($config['dateformat'] . ' ' . $config['timeformat'], $newdate);
|
||||
|
||||
@@ -73,7 +73,7 @@ class Giftcards extends Secure_Controller
|
||||
|
||||
public function getView(int $giftcard_id = NEW_ENTRY): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$giftcard_info = $this->giftcard->get_info($giftcard_id);
|
||||
|
||||
$data['selected_person_name'] = ($giftcard_id > 0 && isset($giftcard_info->person_id)) ? $giftcard_info->first_name . ' ' . $giftcard_info->last_name : '';
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Models\Supplier;
|
||||
use App\Models\Tax_category;
|
||||
|
||||
use Config\ForeignCharacters;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
use CodeIgniter\Files\File;
|
||||
use CodeIgniter\Images\Image;
|
||||
@@ -60,7 +61,7 @@ class Items extends Secure_Controller
|
||||
$this->stock_location = model('Stock_location');
|
||||
$this->supplier = model('Supplier');
|
||||
$this->tax_category = model('Tax_category');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
public function getIndex(): void
|
||||
@@ -811,7 +812,7 @@ class Items extends Secure_Controller
|
||||
/**
|
||||
* Ajax call to check to see if the item number, a.k.a. barcode, is already used by another item
|
||||
* If it exists then that is an error condition so return TRUE for "error found"
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
public function postCheckItemNumber(): void
|
||||
{
|
||||
@@ -1207,9 +1208,9 @@ class Items extends Secure_Controller
|
||||
/**
|
||||
* Saves attribute data found in the CSV import.
|
||||
*
|
||||
* @param array row
|
||||
* @param array item_data
|
||||
* @param array definitions
|
||||
* @param array $row
|
||||
* @param array $item_data
|
||||
* @param array $definitions
|
||||
*/
|
||||
private function save_attribute_data(array $row, array $item_data, array $definitions): bool
|
||||
{
|
||||
@@ -1270,8 +1271,10 @@ class Items extends Secure_Controller
|
||||
/**
|
||||
* Saves inventory quantities for the row in the appropriate stock locations.
|
||||
*
|
||||
* @param array row
|
||||
* @param array item_data
|
||||
* @param array $row
|
||||
* @param array $item_data
|
||||
* @param array $allowed_locations
|
||||
* @param int $employee_id
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
private function save_inventory_quantities(array $row, array $item_data, array $allowed_locations, int $employee_id): void
|
||||
@@ -1317,7 +1320,7 @@ class Items extends Secure_Controller
|
||||
/**
|
||||
* Saves the tax data found in the line of the CSV items import file
|
||||
*
|
||||
* @param array row
|
||||
* @param array $row
|
||||
*/
|
||||
private function save_tax_data(array $row, array $item_data): void
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Controllers;
|
||||
use App\Libraries\MY_Migration;
|
||||
use App\Models\Employee;
|
||||
use CodeIgniter\Model;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
@@ -19,7 +20,7 @@ class Login extends BaseController
|
||||
if(!$this->employee->is_logged_in())
|
||||
{
|
||||
$migration = new MY_Migration(config('Migrations'));
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$gcaptcha_enabled = array_key_exists('gcaptcha_enable', $config)
|
||||
? $config['gcaptcha_enable']
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\Item_kit;
|
||||
use App\Models\Receiving;
|
||||
use App\Models\Stock_location;
|
||||
use App\Models\Supplier;
|
||||
use Config\OSPOS;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
@@ -41,7 +42,7 @@ class Receivings extends Secure_Controller
|
||||
$this->receiving = model('Receiving');
|
||||
$this->stock_location = model('Stock_location');
|
||||
$this->supplier = model('Supplier');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
public function getIndex(): void
|
||||
@@ -108,7 +109,7 @@ class Receivings extends Secure_Controller
|
||||
|
||||
$this->_reload(); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
|
||||
public function set_comment(): void
|
||||
{
|
||||
$this->receiving_lib->set_comment($this->request->getPost('comment', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
@@ -122,12 +123,12 @@ class Receivings extends Secure_Controller
|
||||
{
|
||||
$this->receiving_lib->set_print_after_sale($this->request->getPost('recv_print_after_sale', FILTER_SANITIZE_NUMBER_INT));
|
||||
}
|
||||
|
||||
|
||||
public function set_reference(): void
|
||||
{
|
||||
$this->receiving_lib->set_reference($this->request->getPost('recv_reference', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
}
|
||||
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
$data = [];
|
||||
@@ -192,7 +193,7 @@ class Receivings extends Secure_Controller
|
||||
|
||||
$this->_reload($data); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
|
||||
public function edit($receiving_id): void
|
||||
{
|
||||
$data = [];
|
||||
@@ -202,18 +203,18 @@ class Receivings extends Secure_Controller
|
||||
{
|
||||
$data['suppliers'][$supplier->person_id] = $supplier->first_name . ' ' . $supplier->last_name;
|
||||
}
|
||||
|
||||
|
||||
$data['employees'] = [];
|
||||
foreach($this->employee->get_all()->getResult() as $employee)
|
||||
{
|
||||
$data['employees'][$employee->person_id] = $employee->first_name . ' '. $employee->last_name;
|
||||
}
|
||||
|
||||
|
||||
$receiving_info = $this->receiving->get_info($receiving_id)->getRowArray();
|
||||
$data['selected_supplier_name'] = !empty($receiving_info['supplier_id']) ? $receiving_info['company_name'] : '';
|
||||
$data['selected_supplier_id'] = $receiving_info['supplier_id'];
|
||||
$data['receiving_info'] = $receiving_info;
|
||||
|
||||
|
||||
echo view('receivings/form', $data);
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ class Receivings extends Secure_Controller
|
||||
{
|
||||
$employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
$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 ([
|
||||
@@ -269,7 +270,7 @@ class Receivings extends Secure_Controller
|
||||
public function complete(): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
$data['total'] = $this->receiving_lib->get_total();
|
||||
$data['transaction_time'] = to_datetime(time());
|
||||
@@ -284,7 +285,7 @@ class Receivings extends Secure_Controller
|
||||
$data['amount_tendered'] = $this->request->getPost('amount_tendered', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$data['amount_change'] = to_currency($data['amount_tendered'] - $data['total']);
|
||||
}
|
||||
|
||||
|
||||
$employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
$employee_info = $this->employee->get_info($employee_id);
|
||||
$data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name;
|
||||
@@ -334,7 +335,7 @@ class Receivings extends Secure_Controller
|
||||
*/
|
||||
public function requisition_complete(): void
|
||||
{
|
||||
if($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination())
|
||||
if($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination())
|
||||
{
|
||||
foreach($this->receiving_lib->get_cart() as $item)
|
||||
{
|
||||
@@ -342,17 +343,17 @@ class Receivings extends Secure_Controller
|
||||
$this->receiving_lib->add_item($item['item_id'], $item['quantity'], $this->receiving_lib->get_stock_destination(), $item['discount_type']);
|
||||
$this->receiving_lib->add_item($item['item_id'], -$item['quantity'], $this->receiving_lib->get_stock_source(), $item['discount_type']);
|
||||
}
|
||||
|
||||
|
||||
$this->complete();
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$data['error'] = lang('Receivings.error_requisition');
|
||||
|
||||
$this->_reload($data); //TODO: Hungarian notation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function receipt($receiving_id): void
|
||||
{
|
||||
$receiving_info = $this->receiving->get_info($receiving_id)->getRowArray();
|
||||
@@ -402,7 +403,7 @@ class Receivings extends Secure_Controller
|
||||
$data['mode'] = $this->receiving_lib->get_mode();
|
||||
$data['stock_locations'] = $this->stock_location->get_allowed_locations('receivings');
|
||||
$data['show_stock_locations'] = count($data['stock_locations']) > 1;
|
||||
if($data['show_stock_locations'])
|
||||
if($data['show_stock_locations'])
|
||||
{
|
||||
$data['modes']['requisition'] = lang('Receivings.requisition');
|
||||
$data['stock_source'] = $this->receiving_lib->get_stock_source();
|
||||
@@ -434,7 +435,7 @@ class Receivings extends Secure_Controller
|
||||
$data['supplier_location'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$data['print_after_sale'] = $this->receiving_lib->is_print_after_sale();
|
||||
|
||||
echo view("receivings/receiving", $data);
|
||||
@@ -446,7 +447,7 @@ class Receivings extends Secure_Controller
|
||||
public function save(int $receiving_id = -1): void //TODO: Replace -1 with a constant
|
||||
{
|
||||
$newdate = $this->request->getPost('date', FILTER_SANITIZE_FULL_SPECIAL_CHARS); //TODO: newdate does not follow naming conventions
|
||||
|
||||
|
||||
$date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $newdate);
|
||||
$receiving_time = $date_formatter->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ use App\Models\Reports\Summary_sales;
|
||||
use App\Models\Reports\Summary_sales_taxes;
|
||||
use App\Models\Reports\Summary_suppliers;
|
||||
use App\Models\Reports\Summary_taxes;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
@@ -61,7 +62,7 @@ class Reports extends Secure_Controller
|
||||
$request = Services::request();
|
||||
$method_name = $request->getUri()->getSegment(2);
|
||||
$exploder = explode('_', $method_name);
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
$this->stock_location = model('Stock_location');
|
||||
|
||||
if(sizeof($exploder) > 1)
|
||||
@@ -810,7 +811,7 @@ class Reports extends Secure_Controller
|
||||
|
||||
$labels = [];
|
||||
$series = [];
|
||||
|
||||
|
||||
foreach($report_data as $row)
|
||||
{
|
||||
$labels[] = $row['name'];
|
||||
@@ -1751,7 +1752,7 @@ class Reports extends Secure_Controller
|
||||
|
||||
$attribute_values = expand_attribute_values($definition_names, $drow);
|
||||
|
||||
$details_data[$row['sale_id']][] =
|
||||
$details_data[$row['sale_id']][] =
|
||||
array_merge ([
|
||||
$drow['name'],
|
||||
$drow['category'],
|
||||
|
||||
@@ -21,6 +21,7 @@ use App\Models\Tokens\Token_invoice_count;
|
||||
use App\Models\Tokens\Token_customer;
|
||||
use App\Models\Tokens\Token_invoice_sequence;
|
||||
use CodeIgniter\Config\Services;
|
||||
use Config\OSPOS;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
@@ -57,7 +58,7 @@ class Sales extends Secure_Controller
|
||||
$this->sale_lib = new Sale_lib();
|
||||
$this->tax_lib = new Tax_lib();
|
||||
$this->token_lib = new Token_lib();
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
$this->customer = model('Customer');
|
||||
$this->sale = model('Sale');
|
||||
@@ -1454,8 +1455,7 @@ class Sales extends Secure_Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$payments[] = [
|
||||
$sale_data['payments'] = [
|
||||
'payment_id' => $payment_id,
|
||||
'payment_type' => $payment_type,
|
||||
'payment_amount' => $payment_amount,
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Models\Module;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use CodeIgniter\Session\Session;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,7 @@ class Secure_Controller extends BaseController
|
||||
{
|
||||
$this->employee = model(Employee::class);
|
||||
$this->module = model(Module::class);
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$validation = Services::validation();
|
||||
|
||||
if(!$this->employee->is_logged_in())
|
||||
@@ -78,7 +79,7 @@ class Secure_Controller extends BaseController
|
||||
* AJAX function used to confirm whether values sent in the request are numeric
|
||||
* @return void
|
||||
*/
|
||||
public function getCheckNumeric()
|
||||
public function getCheckNumeric(): void
|
||||
{
|
||||
$result = true;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Models\Tax;
|
||||
use App\Models\Tax_category;
|
||||
use App\Models\Tax_code;
|
||||
use App\Models\Tax_jurisdiction;
|
||||
use Config\OSPOS;
|
||||
|
||||
/**
|
||||
* @property tax_lib tax_lib
|
||||
@@ -19,6 +20,8 @@ use App\Models\Tax_jurisdiction;
|
||||
*/
|
||||
class Taxes extends Secure_Controller
|
||||
{
|
||||
public array $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('taxes');
|
||||
@@ -28,9 +31,9 @@ class Taxes extends Secure_Controller
|
||||
$this->tax_category = model('Tax_category');
|
||||
$this->tax_code = model('Tax_code');
|
||||
$this->tax_jurisdiction = model('Tax_jurisdiction');
|
||||
|
||||
|
||||
$this->tax_lib = new Tax_lib();
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
helper('tax_helper');
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use App\Models\Appconfig;
|
||||
use CodeIgniter\Database\ResultInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @property appconfig appconfig
|
||||
* @property tax_lib tax_lib
|
||||
@@ -64,7 +64,7 @@ class Migration_TaxAmount extends Migration
|
||||
|
||||
private function upgrade_tax_history_for_sale(int $sale_id, string $tax_decimals, bool $tax_included): void //TODO: $tax_included is passed as a parameter but never used in the function body.
|
||||
{
|
||||
$customer_sales_tax_support = FALSE;
|
||||
$customer_sales_tax_support = false;
|
||||
$tax_type = Migration_TaxAmount::VAT_TAX;
|
||||
$sales_taxes = [];
|
||||
$tax_group_sequence = 0;
|
||||
@@ -74,7 +74,7 @@ class Migration_TaxAmount extends Migration
|
||||
{
|
||||
// This computes tax for each line item and adds it to the tax type total
|
||||
$tax_group = (float)$item['percent'] . '% ' . $item['name'];
|
||||
$tax_basis = $this->get_item_total($item['quantity_purchased'], $item['item_unit_price'], $item['discount'], TRUE);
|
||||
$tax_basis = $this->get_item_total($item['quantity_purchased'], $item['item_unit_price'], $item['discount'], true);
|
||||
$item_tax_amount = $this->get_item_tax($tax_basis, $item['percent'], PHP_ROUND_HALF_UP, $tax_decimals);
|
||||
$this->update_sales_items_taxes_amount($sale_id, $item['line'], $item['name'], $item['percent'], $tax_type, $item_tax_amount);
|
||||
$this->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $item['percent'], $tax_basis, $item_tax_amount, $tax_group_sequence, PHP_ROUND_HALF_UP, $sale_id, $item['name']);
|
||||
@@ -155,7 +155,7 @@ class Migration_TaxAmount extends Migration
|
||||
public function get_item_total(string $quantity, string $price, string $discount, bool $include_discount = FALSE): string
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
|
||||
|
||||
if($include_discount)
|
||||
{
|
||||
$total = bcsub($total, bcmul(bcmul($quantity, $price), bcdiv($discount, 100)));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use App\Models\Appconfig;
|
||||
use CodeIgniter\Database\Forge;
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Router\Exceptions\RedirectException;
|
||||
@@ -44,7 +45,7 @@ class Convert_to_ci4 extends Migration
|
||||
|
||||
private function convert_ci3_encrypted_data()
|
||||
{
|
||||
$appconfig = model('Appconfig');
|
||||
$appconfig = model(Appconfig::class);
|
||||
|
||||
$ci3_encrypted_data = [
|
||||
'clcdesq_api_key' => '',
|
||||
@@ -83,7 +84,8 @@ class Convert_to_ci4 extends Migration
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @param array $encrypted_data
|
||||
* @return array
|
||||
*/
|
||||
private function decrypt_ci3_data(array $encrypted_data): array
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ define('DEFAULT_DATETIME', mktime(0, 0, 0, 1, 1, 2010));
|
||||
function current_language_code(bool $load_system_language = false): string
|
||||
{
|
||||
$employee = model(Employee::class);
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// Returns the language code of the employee if set or system language code if not
|
||||
if($employee->is_logged_in() && $load_system_language === false)
|
||||
@@ -37,7 +37,7 @@ function current_language_code(bool $load_system_language = false): string
|
||||
function current_language(bool $load_system_language = FALSE): string
|
||||
{
|
||||
$employee = model(Employee::class);
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// Returns the language of the employee if set or system language if not
|
||||
if($employee->is_logged_in() && !$load_system_language)
|
||||
@@ -231,7 +231,7 @@ function get_timeformats(): array
|
||||
function get_payment_options(): array
|
||||
{
|
||||
$payments = [];
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
//TODO: This needs to be switched to a switch statement
|
||||
if($config['payment_options_order'] == 'debitcreditcash') //TODO: ===
|
||||
@@ -279,7 +279,7 @@ function get_payment_options(): array
|
||||
|
||||
function currency_side(): bool
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$fmt = new NumberFormatter($config['number_locale'], NumberFormatter::CURRENCY);
|
||||
$fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, $config['currency_symbol']);
|
||||
|
||||
@@ -288,37 +288,37 @@ function currency_side(): bool
|
||||
|
||||
function quantity_decimals(): int
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return $config['quantity_decimals'] ? $config['quantity_decimals'] : 0;
|
||||
}
|
||||
|
||||
function totals_decimals(): int
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return $config['currency_decimals'] ? (int)$config['currency_decimals'] : 0;
|
||||
}
|
||||
|
||||
function cash_decimals(): int
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return $config['cash_decimals'] ? $config['cash_decimals'] : 0;
|
||||
}
|
||||
|
||||
function tax_decimals(): int
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return $config['tax_decimals'] ? $config['tax_decimals'] : 0;
|
||||
}
|
||||
|
||||
function to_date(int $date = DEFAULT_DATE): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return date($config['dateformat'], $date);
|
||||
}
|
||||
|
||||
function to_datetime(int $datetime = DEFAULT_DATETIME): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return date($config['dateformat'] . ' ' . $config['timeformat'], $datetime);
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ function to_currency_no_money(?float $number): string
|
||||
|
||||
function to_currency_tax(?float $number): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['tax_included']) //TODO: ternary notation
|
||||
{
|
||||
@@ -377,7 +377,7 @@ function to_decimals(?float $number, string $decimals = NULL, int $type = Number
|
||||
return "";
|
||||
}
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$fmt = new NumberFormatter($config['number_locale'], $type);
|
||||
$fmt->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : $config[$decimals]);
|
||||
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, empty($decimals) ? DEFAULT_PRECISION : $config[$decimals]);
|
||||
@@ -432,7 +432,7 @@ function parse_decimals(string $number, int $decimals = null)
|
||||
return false;
|
||||
}
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($decimals === false)
|
||||
{
|
||||
@@ -506,7 +506,7 @@ function dateformat_momentjs(string $php_format): string
|
||||
|
||||
function dateformat_mysql(): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$php_format = $config['dateformat'];
|
||||
|
||||
$SYMBOLS_MATCHING = [
|
||||
@@ -591,7 +591,7 @@ function dateformat_bootstrap(string $php_format): string
|
||||
|
||||
function valid_date(string $date): bool //TODO: need a better name for $date. Perhaps $candidate. Also the function name would be better as is_valid_date()
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
return (DateTime::createFromFormat($config['dateformat'], $date));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ function get_sales_manage_table_headers(): string
|
||||
['change_due' => lang('Sales.change_due')],
|
||||
['payment_type' => lang('Sales.payment_type')]
|
||||
];
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['invoice_enable'])
|
||||
{
|
||||
@@ -106,7 +106,7 @@ function get_sale_data_row(object $sale): array
|
||||
'payment_type' => $sale->payment_type
|
||||
];
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['invoice_enable'])
|
||||
{
|
||||
@@ -390,7 +390,7 @@ function get_supplier_data_row(object $supplier): array
|
||||
function get_items_manage_table_headers(): string
|
||||
{
|
||||
$attribute = model(Attribute::class);
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$definition_names = $attribute->get_definitions_by_flags($attribute::SHOW_IN_ITEMS); //TODO: this should be made into a constant in constants.php
|
||||
|
||||
$headers = [
|
||||
@@ -439,7 +439,7 @@ function get_item_data_row(object $item): array
|
||||
$attribute = model(Attribute::class);
|
||||
$item_taxes = model(Item_taxes::class);
|
||||
$tax_category = model(Tax_category::class);
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['use_destination_based_tax'])
|
||||
{
|
||||
|
||||
@@ -287,7 +287,7 @@ return [
|
||||
"server_notice" => "Пожалуйста, используйте приведенную ниже информацию для сообщения о проблеме.",
|
||||
"service_charge" => "",
|
||||
"show_due_enable" => "",
|
||||
"show_office_group" => "Показать значок "Офис"",
|
||||
"show_office_group" => "Показать значок \"Офис\"",
|
||||
"statistics" => "Отправить статистику",
|
||||
"statistics_tooltip" => "Отправляйте статистику для разработки и улучшения функций.",
|
||||
"stock_location" => "Расположение склада",
|
||||
|
||||
@@ -31,7 +31,7 @@ class Barcode_lib
|
||||
|
||||
public function get_barcode_config(): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$data['company'] = $config['company'];
|
||||
$data['barcode_content'] = $config['barcode_content'];
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class BarcodeBase
|
||||
* @var data - to be set
|
||||
*/
|
||||
protected $data = '';
|
||||
|
||||
|
||||
/*
|
||||
* @var int x (width)
|
||||
*/
|
||||
@@ -89,7 +89,7 @@ abstract class BarcodeBase
|
||||
* Generate a barcode for this implementation using the given seed.
|
||||
* Default implementation returns just the seed
|
||||
* @param $number The seed to generate a barcode for
|
||||
* @return mixed The generated barcode
|
||||
* @return string|null The generated barcode
|
||||
*/
|
||||
public function generate($number)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ abstract class BarcodeBase
|
||||
|
||||
/*
|
||||
* Set Quality
|
||||
* @param int q - jpeg quality
|
||||
* @param int q - jpeg quality
|
||||
* @return instance of \emberlabs\Barcode\BarcodeBase
|
||||
*/
|
||||
public function setQuality($q)
|
||||
@@ -170,11 +170,11 @@ abstract class BarcodeBase
|
||||
/*
|
||||
* Save Image
|
||||
*
|
||||
* @param string filename - File to write to (needs to have .png, .gif, or
|
||||
* @param string filename - File to write to (needs to have .png, .gif, or
|
||||
* .jpg extension)
|
||||
* @return void
|
||||
* @throws \RuntimeException - If the file could not be written or some
|
||||
* other I/O error.
|
||||
* @throws \RuntimeException - If the file could not be written or some
|
||||
* other I/O error.
|
||||
*/
|
||||
public function save($filename)
|
||||
{
|
||||
@@ -197,12 +197,11 @@ abstract class BarcodeBase
|
||||
|
||||
default:
|
||||
throw new \RuntimeException("Could not determine file type.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Base64 Encoded
|
||||
* Base64 Encoded
|
||||
* For ouput in-page
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -28,9 +28,9 @@ class Code128 extends BarcodeBase
|
||||
private $type = self::TYPE_AUTO;
|
||||
|
||||
/*
|
||||
* This map maps the bar code to the common index. We use the built-in
|
||||
* index that PHP gives us to produce the common index.
|
||||
* @var static array
|
||||
* This map maps the bar code to the common index. We use the built-in
|
||||
* index that PHP gives us to produce the common index.
|
||||
* @var static array
|
||||
*/
|
||||
private static $barMap = array(
|
||||
11011001100, 11001101100, 11001100110, 10010011000, 10010001100, // 4 (end)
|
||||
@@ -60,7 +60,7 @@ class Code128 extends BarcodeBase
|
||||
/*
|
||||
* This map takes the charset from subtype A and PHP will index the array
|
||||
* natively to the matching code from the barMap.
|
||||
* @var static array
|
||||
* @var static array
|
||||
*/
|
||||
private static $mapA = array(
|
||||
' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', // 9 (end)
|
||||
@@ -70,7 +70,7 @@ class Code128 extends BarcodeBase
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', // 49
|
||||
'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', // 59
|
||||
'\\', ']', '^', '_', // 63 (We're going into the weird bytes next)
|
||||
|
||||
|
||||
// Hex is a little more concise in this context
|
||||
"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", // 69
|
||||
"\x06", "\x07", "\x08", "\x09", "\x0A", "\x0B", // 75
|
||||
@@ -78,7 +78,7 @@ class Code128 extends BarcodeBase
|
||||
"\x12", "\x13", "\x14", "\x15", "\x16", "\x17", // 87
|
||||
"\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", // 93
|
||||
"\x1E", "\x1F", // 95
|
||||
|
||||
|
||||
// Now for system codes
|
||||
'FNC_3', 'FNC_2', 'SHIFT_B', 'CODE_C', 'CODE_B', // 100
|
||||
'FNC_4', 'FNC_1', 'START_A', 'START_B', 'START_C', // 105
|
||||
@@ -100,7 +100,7 @@ class Code128 extends BarcodeBase
|
||||
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 79
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', // 89
|
||||
'z', '{', '|', '}', '~', "\x7F", // 95
|
||||
|
||||
|
||||
// Now for system codes
|
||||
'FNC_3', 'FNC_2', 'SHIFT_A', 'CODE_C', 'FNC_4', // 100
|
||||
'CODE_A', 'FNC_1', 'START_A', 'START_B', 'START_C', // 105
|
||||
@@ -109,12 +109,12 @@ class Code128 extends BarcodeBase
|
||||
|
||||
/*
|
||||
* Map C works a little different. The index is the value when the mapping
|
||||
* occors.
|
||||
* occors.
|
||||
* @var static array
|
||||
*/
|
||||
private static $mapC = array(
|
||||
100 =>
|
||||
'CODE_B', 'CODE_A', 'FNC_1', 'START_A', 'START_B',
|
||||
100 =>
|
||||
'CODE_B', 'CODE_A', 'FNC_1', 'START_A', 'START_B',
|
||||
'START_C', 'STOP', // 106
|
||||
);
|
||||
|
||||
@@ -158,11 +158,9 @@ class Code128 extends BarcodeBase
|
||||
{
|
||||
case self::TYPE_A:
|
||||
return array_search($char, self::$mapA);
|
||||
break;
|
||||
|
||||
case self::TYPE_B:
|
||||
return array_search($char, self::$mapB);
|
||||
break;
|
||||
return array_search($char, self::$mapB);
|
||||
|
||||
case self::TYPE_C:
|
||||
$charInt = (int) $char;
|
||||
@@ -172,12 +170,10 @@ class Code128 extends BarcodeBase
|
||||
}
|
||||
|
||||
return array_search($char, self::$mapC);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$this->resolveSubtype();
|
||||
return $this->getKey($char); // recursion!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +189,7 @@ class Code128 extends BarcodeBase
|
||||
}
|
||||
|
||||
/*
|
||||
* Resolve subtype
|
||||
* Resolve subtype
|
||||
* @todo - Do some better charset checking and enforcement
|
||||
* @return void
|
||||
*/
|
||||
@@ -218,28 +214,29 @@ class Code128 extends BarcodeBase
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the name of a start char fr te current subtype
|
||||
/**
|
||||
* Get the name of a start char from the current subtype
|
||||
* @return string
|
||||
*/
|
||||
private function getStartChar()
|
||||
private function getStartChar(): string
|
||||
{
|
||||
$this->resolveSubtype();
|
||||
|
||||
switch($this->type)
|
||||
{
|
||||
case self::TYPE_A: return 'START_A'; break;
|
||||
case self::TYPE_B: return 'START_B'; break;
|
||||
case self::TYPE_C: return 'START_C'; break;
|
||||
default:
|
||||
case self::TYPE_A: return 'START_A';
|
||||
case self::TYPE_B: return 'START_B';
|
||||
case self::TYPE_C: return 'START_C';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Draw the image
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function draw()
|
||||
public function draw(): void
|
||||
{
|
||||
$this->resolveSubtype();
|
||||
$charAry = str_split($this->data);
|
||||
@@ -287,12 +284,12 @@ class Code128 extends BarcodeBase
|
||||
$checkSumCollector = $this->getKey($this->getStartChar());
|
||||
|
||||
$this->img = @imagecreate($this->x, $this->y);
|
||||
|
||||
|
||||
if (!$this->img)
|
||||
{
|
||||
throw new \RuntimeException("Code128: Image failed to initialize");
|
||||
}
|
||||
|
||||
|
||||
$white = imagecolorallocate($this->img, 255, 255, 255);
|
||||
$black = imagecolorallocate($this->img, 0, 0, 0);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace app\Libraries;
|
||||
use CodeIgniter\Email\Email;
|
||||
use CodeIgniter\Encryption\Encryption;
|
||||
use CodeIgniter\Encryption\EncrypterInterface;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
|
||||
@@ -24,16 +25,16 @@ class Email_lib
|
||||
public function __construct()
|
||||
{
|
||||
$this->email = new Email();
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
$encrypter = Services::encrypter();
|
||||
|
||||
|
||||
$smtp_pass = $this->config['smtp_pass'];
|
||||
if(!empty($smtp_pass))
|
||||
{
|
||||
$smtp_pass = $encrypter->decrypt($smtp_pass);
|
||||
}
|
||||
|
||||
|
||||
$email_config = [
|
||||
'mailtype' => 'html',
|
||||
'useragent' => 'OSPOS',
|
||||
|
||||
@@ -25,7 +25,7 @@ class MY_Migration extends MigrationRunner
|
||||
/**
|
||||
* Gets the database version number
|
||||
*
|
||||
* @return string The version number of the last successfully run database migration.
|
||||
* @return int The version number of the last successfully run database migration.
|
||||
*/
|
||||
public static function get_current_version(): int
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace app\Libraries;
|
||||
|
||||
use CodeIgniter\Encryption\EncrypterInterface;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,7 @@ class MailchimpConnector
|
||||
*/
|
||||
public function __construct(string $api_key = '')
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$encrypter = Services::encrypter();
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class Receiving_lib
|
||||
//TODO: This array signature needs to be reworked. It's way too long. Perhaps an object needs to be passed rather than these?
|
||||
public function add_item(int $item_id, int $quantity = 1, int $item_location = NULL, float $discount = 0, int $discount_type = 0, float $price = NULL, string $description = NULL, string $serialnumber = NULL, float $receiving_quantity = NULL, int $receiving_id = NULL, bool $include_deleted = FALSE): bool
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
//make sure item exists in database.
|
||||
if(!$this->item->exists($item_id, $include_deleted))
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Models\Enums\Rounding_mode;
|
||||
use App\Models\Sale;
|
||||
use CodeIgniter\Session\Session;
|
||||
use App\Models\Stock_location;
|
||||
use Config\OSPOS;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
@@ -50,7 +51,7 @@ class Sale_lib
|
||||
$this->rounding_mode = model('enums/Rounding_mode');
|
||||
// $this->sale = model('Sale'); //TODO: This is causing an infinite loop because the constructor calls the sale library
|
||||
$this->stock_location = model('Stock_location');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
public function get_line_sequence_options(): array
|
||||
@@ -414,7 +415,7 @@ class Sale_lib
|
||||
/**
|
||||
* Adds a new payment to the payments array or updates an existing one.
|
||||
* It will also disable cash_mode if a non-qualifying payment type is added.
|
||||
* @param int $payment_id
|
||||
* @param string $payment_id
|
||||
* @param string $payment_amount
|
||||
* @param int $cash_adjustment
|
||||
*/
|
||||
@@ -1042,14 +1043,13 @@ class Sale_lib
|
||||
return -1; //TODO: Replace -1 with constant
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
/* @param string $line
|
||||
* @param string $description
|
||||
* @param string $serialnumber
|
||||
* @param string $quantity
|
||||
* @param string $discount
|
||||
* @param string $discount_type
|
||||
* @param string $price
|
||||
* @param string|null $discount_type
|
||||
* @param string|null $price
|
||||
* @param string|NULL $discounted_total
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ class Sms_lib
|
||||
*/
|
||||
public function sendSMS(int $phone, string $message): bool
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$encrypter = Services::encrypter();
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Models\Tax_category;
|
||||
use App\Models\Tax_code;
|
||||
use App\Models\Tax_jurisdiction;
|
||||
use App\Libraries\Sale_lib;
|
||||
use Config\OSPOS;
|
||||
|
||||
/**
|
||||
* Tax library
|
||||
@@ -47,7 +48,7 @@ class Tax_lib
|
||||
$this->tax_category = model('Tax_category');
|
||||
$this->tax_code = model('Tax_code');
|
||||
$this->tax_jurisdiction = model('Tax_jurisdiction');
|
||||
$this->config = config('OSPOS')->settings;
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
public function get_tax_types(): array
|
||||
|
||||
@@ -19,7 +19,7 @@ class Token_lib
|
||||
// Apply the transformation for the "%" tokens if any are used
|
||||
if(strpos($tokened_text, '%') !== FALSE)
|
||||
{
|
||||
$tokened_text = strftime($tokened_text);
|
||||
$tokened_text = strftime($tokened_text); //TODO: these need to be converted to IntlDateFormatter::format()
|
||||
}
|
||||
|
||||
// Call scan to build an array of all of the tokens used in the text to be transformed
|
||||
@@ -74,7 +74,7 @@ class Token_lib
|
||||
|
||||
public function parse_barcode(?string &$quantity, ?string &$price, ?string &$item_id_or_number_or_item_kit_or_receipt): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$barcode_formats = json_decode($config['barcode_formats']);
|
||||
$barcode_tokens = Token::get_barcode_tokens();
|
||||
|
||||
@@ -89,7 +89,7 @@ class Token_lib
|
||||
$price = (isset($parsed_results['P'])) ? (double) $parsed_results['P'] : NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$quantity = 1; //TODO: Quantity is handled using bcmath functions so that it is precision safe. This should be '1'
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use CodeIgniter\Database\ResultInterface;
|
||||
use CodeIgniter\Model;
|
||||
use Config\OSPOS;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
@@ -68,7 +69,7 @@ class Appconfig extends Model
|
||||
|
||||
if($success)
|
||||
{
|
||||
config('OSPOS')->update_settings();
|
||||
config(OSPOS::class)->update_settings();
|
||||
}
|
||||
|
||||
return $success;
|
||||
@@ -112,7 +113,7 @@ class Appconfig extends Model
|
||||
*/
|
||||
public function acquire_next_invoice_sequence(bool $save = true): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$last_used = (int)$config['last_used_invoice_number'] + 1;
|
||||
|
||||
if($save)
|
||||
@@ -128,7 +129,7 @@ class Appconfig extends Model
|
||||
*/
|
||||
public function acquire_next_quote_sequence(bool $save = true): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$last_used = (int)$config['last_used_quote_number'] + 1;
|
||||
|
||||
if($save)
|
||||
@@ -144,7 +145,7 @@ class Appconfig extends Model
|
||||
*/
|
||||
public function acquire_next_work_order_sequence(bool $save = true): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$last_used = (int)$config['last_used_work_order_number'] + 1;
|
||||
|
||||
if($save)
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Models;
|
||||
use CodeIgniter\Database\ResultInterface;
|
||||
use CodeIgniter\Model;
|
||||
use CodeIgniter\Database\RawSql;
|
||||
use Config\OSPOS;
|
||||
use DateTime;
|
||||
use stdClass;
|
||||
use ReflectionClass;
|
||||
@@ -88,7 +89,7 @@ class Attribute extends Model
|
||||
*/
|
||||
public function value_exists($attribute_value, string $definition_type = TEXT)
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
switch($definition_type)
|
||||
{
|
||||
@@ -728,7 +729,7 @@ class Attribute extends Model
|
||||
|
||||
public function save_value(string $attribute_value, int $definition_id, $item_id = FALSE, $attribute_id = FALSE, string $definition_type = DROPDOWN): int
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$locale_date_format = $config['dateformat'];
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
@@ -88,7 +88,7 @@ class Cashup extends Model
|
||||
if($order == null) $order = 'asc';
|
||||
if($count_only == null) $count_only = FALSE;
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$builder = $this->db->table('cash_up AS cash_up');
|
||||
|
||||
// get_found_rows case
|
||||
|
||||
@@ -266,7 +266,7 @@ class Customer extends Person
|
||||
public function delete($customer_id = null, bool $purge = false): bool
|
||||
{
|
||||
$result = TRUE;
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// if privacy enforcement is selected scramble customer data
|
||||
if($config['enforce_privacy'])
|
||||
|
||||
@@ -96,7 +96,7 @@ class Expense extends Model
|
||||
if($order == null) $order = 'asc';
|
||||
if($count_only == null) $count_only = FALSE;
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$builder = $this->db->table('expenses AS expenses');
|
||||
|
||||
// get_found_rows case
|
||||
@@ -315,7 +315,7 @@ class Expense extends Model
|
||||
*/
|
||||
public function get_payments_summary(string $search, array $filters): array //TODO: $search is passed but never used in the function
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// get payment summary
|
||||
$builder = $this->db->table('expenses');
|
||||
|
||||
@@ -64,7 +64,7 @@ class Item extends Model
|
||||
*/
|
||||
public function item_number_exists(string $item_number, string $item_id = ''): bool
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['allow_duplicate_barcodes'])
|
||||
{
|
||||
@@ -124,7 +124,7 @@ class Item extends Model
|
||||
if($order == NULL) $order = 'asc';
|
||||
if($count_only == NULL) $count_only = FALSE;
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$builder = $this->db->table('items AS items'); //TODO: I'm not sure if it's needed to write items AS items... I think you can just get away with items
|
||||
|
||||
// get_found_rows case
|
||||
@@ -557,7 +557,7 @@ class Item extends Model
|
||||
|
||||
function get_search_suggestion_format(string $seed = NULL): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$seed .= ',' . $config['suggestions_first_column'];
|
||||
|
||||
if($config['suggestions_second_column'] !== '')
|
||||
@@ -575,7 +575,7 @@ class Item extends Model
|
||||
|
||||
function get_search_suggestion_label($result_row): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$label = '';
|
||||
$label1 = $config['suggestions_first_column'];
|
||||
$label2 = $config['suggestions_second_column'];
|
||||
@@ -1082,7 +1082,7 @@ class Item extends Model
|
||||
*/
|
||||
function get_item_name(string $as_name = NULL): string
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($as_name == NULL) //TODO: Replace with ternary notation
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ class Item_kit extends Model
|
||||
*/
|
||||
public function item_number_exists(string $item_kit_number, string $item_kit_id = ''): bool
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['allow_duplicate_barcodes'])
|
||||
{
|
||||
|
||||
@@ -145,7 +145,7 @@ class Person extends Model
|
||||
* Inserts or updates a person
|
||||
*
|
||||
* @param array $person_data array containing person information
|
||||
* @param bool $person_id identifier of the person to update the information
|
||||
* @param int $person_id identifier of the person to update the information
|
||||
* @return boolean TRUE if the save was successful, FALSE if not
|
||||
*/
|
||||
public function save_value(array &$person_data, int $person_id = NEW_ENTRY): bool
|
||||
|
||||
@@ -121,7 +121,7 @@ class Receiving extends Model
|
||||
|
||||
foreach($items as $line => $item_data)
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$cur_item_info = $item->get_info($item['item_id']);
|
||||
|
||||
$receivings_items_data = [
|
||||
@@ -290,7 +290,7 @@ class Receiving extends Model
|
||||
*/
|
||||
public function create_temp_table(array $inputs): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if(empty($inputs['receiving_id']))
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class Summary_discounts extends Summary_report
|
||||
|
||||
public function getData(array $inputs): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$builder = $this->db->table('sales_items AS sales_items');
|
||||
|
||||
if($inputs['discount_type'] == FIXED) //TODO: if there are only two options for this if/else statement then it needs to be refactored to use ternary operators. Also ===?
|
||||
|
||||
@@ -16,7 +16,7 @@ class Summary_expenses_categories extends Summary_report
|
||||
|
||||
public function getData(array $inputs): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$builder = $this->db->table('expenses AS expenses');
|
||||
$builder->select('expense_categories.category_name AS category_name, COUNT(expenses.expense_id) AS count, SUM(expenses.amount) AS total_amount, SUM(expenses.tax_amount) AS total_tax_amount');
|
||||
@@ -42,7 +42,7 @@ class Summary_expenses_categories extends Summary_report
|
||||
|
||||
public function getSummaryData(array $inputs): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$builder = $this->db->table('expenses AS expenses');
|
||||
$builder->select('SUM(expenses.amount) AS expenses_total_amount, SUM(expenses.tax_amount) AS expenses_total_tax_amount');
|
||||
|
||||
@@ -20,7 +20,7 @@ class Summary_payments extends Summary_report
|
||||
public function getData(array $inputs): array
|
||||
{
|
||||
$cash_payment = lang('Sales.cash'); //TODO: This is never used. Should it be?
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$separator[] = [
|
||||
'trans_group' => '<HR>',
|
||||
|
||||
@@ -9,7 +9,7 @@ abstract class Summary_report extends Report
|
||||
*/
|
||||
private function __common_select(array $inputs, &$builder): void //TODO: Hungarian notation
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$where = ''; //TODO: Duplicated code
|
||||
|
||||
if(empty($config['date_or_time_format']))
|
||||
@@ -101,7 +101,7 @@ abstract class Summary_report extends Report
|
||||
|
||||
private function __common_where(array $inputs, &$builder): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
//TODO: Probably going to need to rework these since you can't reference $builder without it's instantiation.
|
||||
if(empty($config['date_or_time_format'])) //TODO: Duplicated code
|
||||
|
||||
@@ -17,7 +17,7 @@ class Summary_sales_taxes extends Summary_report
|
||||
|
||||
protected function _where(array $inputs, object &$builder): void //TODO: hungarian notation
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$builder->where('sales.sale_status', COMPLETED);
|
||||
|
||||
@@ -33,7 +33,7 @@ class Summary_sales_taxes extends Summary_report
|
||||
|
||||
public function getData(array $inputs): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$where = 'WHERE sale_status = ' . COMPLETED . ' ';
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class Summary_taxes extends Summary_report
|
||||
|
||||
protected function _where(array $inputs, &$builder): void //TODO: hungarian notation
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$builder->where('sales.sale_status', COMPLETED);
|
||||
|
||||
@@ -34,7 +34,7 @@ class Summary_taxes extends Summary_report
|
||||
|
||||
public function getData(array $inputs): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$where = 'WHERE sale_status = ' . COMPLETED . ' '; //TODO: Duplicated code
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class Sale extends Model
|
||||
*/
|
||||
public function get_info(int $sale_id): ResultInterface
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$this->create_temp_table (['sale_id' => $sale_id]);
|
||||
|
||||
$decimals = totals_decimals();
|
||||
@@ -135,7 +135,7 @@ class Sale extends Model
|
||||
if($order == null) $order = 'desc';
|
||||
if($count_only == null) $count_only = FALSE;
|
||||
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// Pick up only non-suspended records
|
||||
$where = 'sales.sale_status = 0 AND ';
|
||||
@@ -324,7 +324,7 @@ class Sale extends Model
|
||||
*/
|
||||
public function get_payments_summary(string $search, array $filters): array
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// get payment summary
|
||||
$builder = $this->db->table('sales AS sales');
|
||||
@@ -527,7 +527,7 @@ class Sale extends Model
|
||||
*/
|
||||
public function is_valid_receipt(string &$receipt_sale_id): bool //TODO: like the others, maybe this should be an array rather than a delimited string... either that or the parameter name needs to be changed. $receipt_sale_id implies that it's an int.
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if(!empty($receipt_sale_id))
|
||||
{
|
||||
@@ -643,7 +643,7 @@ class Sale extends Model
|
||||
public function save_value(int $sale_id, string &$sale_status, array &$items, int $customer_id, int $employee_id, string $comment, ?string $invoice_number,
|
||||
?string $work_order_number, ?string $quote_number, int $sale_type, ?array $payments, ?int $dinner_table_id, ?array &$sales_taxes): int //TODO: this method returns the sale_id but the override is expecting it to return a bool. The signature needs to be reworked. Generally when there are more than 3 maybe 4 parameters, there's a good chance that an object needs to be passed rather than so many params.
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$attribute = model(Attribute::class);
|
||||
$customer = model(Customer::class);
|
||||
$giftcard = model(Giftcard::class);
|
||||
@@ -995,7 +995,7 @@ class Sale extends Model
|
||||
*/
|
||||
public function get_sale_items_ordered(int $sale_id): ResultInterface
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$item = model(Item::class);
|
||||
|
||||
$builder = $this->db->table('sales_items AS sales_items');
|
||||
@@ -1183,7 +1183,7 @@ class Sale extends Model
|
||||
*/
|
||||
public function create_temp_table(array $inputs): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if(empty($inputs['sale_id']))
|
||||
{
|
||||
@@ -1472,7 +1472,7 @@ class Sale extends Model
|
||||
{
|
||||
//Run these queries as a transaction, we want to make sure we do all or nothing
|
||||
$this->db->transStart();
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['dinner_table_enable'])
|
||||
{
|
||||
@@ -1495,7 +1495,7 @@ class Sale extends Model
|
||||
public function clear_suspended_sale_detail(int $sale_id): bool
|
||||
{
|
||||
$this->db->transStart();
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if($config['dinner_table_enable'])
|
||||
{
|
||||
@@ -1542,7 +1542,7 @@ class Sale extends Model
|
||||
*/
|
||||
private function save_customer_rewards(int $customer_id, int $sale_id, float $total_amount, float $total_amount_used): void
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
if(!empty($customer_id) && $config['customer_reward_enable'])
|
||||
{
|
||||
|
||||
@@ -246,7 +246,7 @@ class Tax_code extends Model
|
||||
*/
|
||||
public function get_sales_tax_code(string $city = '', string $state = '')
|
||||
{
|
||||
$config = config('OSPOS')->settings;
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
// if tax code using both city and state cannot be found then try again using just the state
|
||||
// if the state tax code cannot be found then try again using blanks for both
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
<div class="col-sm-8" id="issuetemplate" style="text-align: left;"><br>
|
||||
<?php echo lang('Config.ospos_info') . ':' ?>
|
||||
<?php echo esc(config('App')->application_version) ?> - <?php echo esc(substr(config('OSPOS')->commit_sha1, 0, 6)) ?><br>
|
||||
<?php echo esc(config('App')->application_version) ?> - <?php echo esc(substr(config(OSPOS::class)->commit_sha1, 0, 6)) ?><br>
|
||||
Language Code: <?php echo current_language_code() ?><br><br>
|
||||
<div id="TimeError"></div>
|
||||
Extensions & Modules:<br>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php $config = config('OSPOS')->settings; ?>
|
||||
<?php $config = config(OSPOS::class)->settings; ?>
|
||||
|
||||
var pickerconfig = function(config) {
|
||||
return $.extend({
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="jumbotron push-spaces">
|
||||
<strong><?= lang('Common.copyrights', [date('Y')]) ?> ·
|
||||
<a href="https://opensourcepos.org" target="_blank"><?= lang('Common.website') ?></a> ·
|
||||
<?= esc(config('App')->application_version) ?> - <a target="_blank" href="https://github.com/opensourcepos/opensourcepos/commit/<?= esc(config('OSPOS')->commit_sha1) ?>"><?= esc(substr(config('OSPOS')->commit_sha1, 0, 6)); ?></a></strong>.
|
||||
<?= esc(config('App')->application_version) ?> - <a target="_blank" href="https://github.com/opensourcepos/opensourcepos/commit/<?= esc(config(OSPOS::class)->commit_sha1) ?>"><?= esc(substr(config(OSPOS::class)->commit_sha1, 0, 6)); ?></a></strong>.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user