These minor changes were needed to get to the point where the Item form could be displayed. There are still some issues with the actual form

This commit is contained in:
Steve Ireland
2023-03-16 21:02:30 -04:00
parent c5180ab614
commit 0ce73cc249
6 changed files with 18 additions and 14 deletions

View File

@@ -492,7 +492,7 @@ class Items extends Secure_Controller
echo view('barcodes/barcode_sheet', $data);
}
public function attributes(int $item_id = NEW_ITEM): void
public function getAttributes(int $item_id = NEW_ITEM): void
{
$data['item_id'] = $item_id;
$definition_ids = json_decode($this->request->getPost('definition_ids', FILTER_SANITIZE_STRING), TRUE);

View File

@@ -322,17 +322,17 @@ function to_datetime(int $datetime = DEFAULT_DATETIME): string
return date($config['dateformat'] . ' ' . $config['timeformat'], $datetime);
}
function to_currency(float $number): string
function to_currency(?float $number): string
{
return to_decimals($number, 'currency_decimals', NumberFormatter::CURRENCY);
}
function to_currency_no_money(float $number): string
function to_currency_no_money(?float $number): string
{
return to_decimals($number, 'currency_decimals');
}
function to_currency_tax(float $number): string
function to_currency_tax(?float $number): string
{
$config = config('OSPOS')->settings;
@@ -346,8 +346,13 @@ function to_currency_tax(float $number): string
}
}
function to_tax_decimals(float $number): string
function to_tax_decimals($number): string
{
// TODO: When the tax array is empty the value passed in is an empty string, For now I "untyped" it to get past
// the issue because I don't understand why an empty string is being passed in when I know the array is empty.
// It looks like it must be creating a String value on the fly because the form is referring to the index 0 when
// there IS no index[0] row in the table
// taxes that are NULL, '' or 0 don't need to be displayed
// NOTE: do not remove this line otherwise the items edit form will show a tax with 0, and it will save it
if(empty($number))
@@ -358,18 +363,18 @@ function to_tax_decimals(float $number): string
return to_decimals($number, 'tax_decimals');
}
function to_quantity_decimals(float $number): string
function to_quantity_decimals(?float $number): string
{
return to_decimals($number, 'quantity_decimals');
}
function to_decimals(float $number, string $decimals = NULL, int $type = NumberFormatter::DECIMAL): string
function to_decimals(?float $number, string $decimals = NULL, int $type = NumberFormatter::DECIMAL): string
{
// ignore empty strings and return
// NOTE: do not change it to empty otherwise tables will show a 0 with no decimal nor currency symbol
if(!isset($number))
{
return $number;
return "";
}
$config = config('OSPOS')->settings;

View File

@@ -33,7 +33,7 @@ class Item_lib
return $this->session->get('item_location');
}
public function set_item_location(string $location): void
public function set_item_location(?string $location): void
{
$this->session->set('item_location',$location);
}
@@ -42,4 +42,4 @@ class Item_lib
{
$this->session->remove('item_location');
}
}
}

View File

@@ -193,7 +193,7 @@ class Attribute extends Model
return $this->to_array($results, 'definition_id');
}
public function get_values_by_definitions(array $definition_ids): array
public function get_values_by_definitions(?array $definition_ids): array
{
if(count($definition_ids ? : []))
{

View File

@@ -401,7 +401,6 @@ class Customer extends Person
public function get_found_rows(string $search): int
{
$result = $this->search($search, 0, 0, 'last_name', 'asc', TRUE);
log_message('info', '>>>Customer.get_found_rows-' . $result);
return $result;
}

View File

@@ -120,7 +120,7 @@ class Item extends Model
/**
* Perform a search on items
*/
public function search(string $search, array $filters, ?int $rows = 0, ?int $limit_from = 0, ?string $sort = 'items.name', ?string $order = 'asc', ?bool $count_only = FALSE): ResultInterface
public function search(string $search, array $filters, ?int $rows = 0, ?int $limit_from = 0, ?string $sort = 'items.name', ?string $order = 'asc', ?bool $count_only = FALSE)
{
// Set default values
if($rows == null) $rows = 0;
@@ -331,7 +331,7 @@ class Item extends Model
//Get all the fields from items table
foreach($this->db->getFieldNames('items') as $field)
{
$item_obj->$field = '';
$item_obj->$field = null;
}
return $item_obj;