mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2025-12-31 13:37:54 -05:00
* Remove HtmlPurifier calls - All calls to Services::htmlPurifier()->purify() removed from data received from view. - Bootstrap and bootswatch bump in package-lock.json Signed-off-by: objecttothis <objecttothis@gmail.com> * Pre-view filtering Items Controller - Refactored code for clarity - Created and called sanitization functions. - Sanitize TEXT type Attributes before being sent to the view. Signed-off-by: objecttothis <objecttothis@gmail.com> * Pre-view filtering Customers Controller - Refactored code for clarity - Replaced == with === operator to prevent type juggling - Added Sanitization of Customer data before being sent to the view Signed-off-by: objecttothis <objecttothis@gmail.com> * Bump bootstrap-table to 1.23.1 - Bump bootstrap-table to 1.23.1 in attempt to resolve issue with sticky headers - Sanitize attribute data in tables - Sanitize item data with controller function. Signed-off-by: objecttothis <objecttothis@gmail.com> * Pre-view filtering Items Controller - Refactored code for clarity - Created and called sanitization functions. - Sanitize TEXT type Attributes before being sent to the view. Signed-off-by: objecttothis <objecttothis@gmail.com> * Sanitize Item data - Sanitize category and item_number before display in forms. - refactor check in pic_filename for empty to be best practices compliant. - Added TODO Signed-off-by: objecttothis <objecttothis@gmail.com> * Minor changes - Refactored for code clarity. - Removed extra blank lines. - Minor reformatting. - Added PHPdocs - bumped bootstrap-table to 1.23.2 Signed-off-by: objecttothis <objecttothis@gmail.com> * Pre-view filtering Items Controller - Refactored code for clarity - Created and called sanitization functions. - Sanitize TEXT type Attributes before being sent to the view. Signed-off-by: objecttothis <objecttothis@gmail.com> * Sanitize Item data - Sanitize category and item_number before display in forms. - refactor check in pic_filename for empty to be best practices compliant. - Added TODO Signed-off-by: objecttothis <objecttothis@gmail.com> --------- Signed-off-by: objecttothis <objecttothis@gmail.com> Co-authored-by: objecttothis <objecttothis@gmail.com>
72 lines
1.6 KiB
PHP
72 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Models\Person;
|
|
use Config\Services;
|
|
use function Tamtamchik\NameCase\str_name_case;
|
|
|
|
abstract class Persons extends Secure_Controller
|
|
{
|
|
protected Person $person;
|
|
|
|
/**
|
|
* @param string|null $module_id
|
|
*/
|
|
public function __construct(string $module_id = null)
|
|
{
|
|
parent::__construct($module_id);
|
|
|
|
$this->person = model(Person::class);
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function getIndex(): void
|
|
{
|
|
$data['table_headers'] = get_people_manage_table_headers();
|
|
|
|
echo view('people/manage', $data);
|
|
}
|
|
|
|
/**
|
|
* Gives search suggestions based on what is being searched for
|
|
*/
|
|
public function getSuggest(): void
|
|
{
|
|
$search = $this->request->getPost('term');
|
|
$suggestions = $this->person->get_search_suggestions($search);
|
|
|
|
echo json_encode($suggestions);
|
|
}
|
|
|
|
/**
|
|
* Gets one row for a person manage table. This is called using AJAX to update one row.
|
|
*/
|
|
public function getRow(int $row_id): void
|
|
{
|
|
$data_row = get_person_data_row($this->person->get_info($row_id));
|
|
|
|
echo json_encode($data_row);
|
|
}
|
|
|
|
/**
|
|
* Capitalize segments of a name, and put the rest into lower case.
|
|
* You can pass the characters you want to use as delimiters as exceptions.
|
|
* The function supports UTF-8 strings
|
|
*
|
|
* Example:
|
|
* i.e. <?php echo nameize("john o'grady-smith"); ?>
|
|
*
|
|
* returns John O'Grady-Smith
|
|
*/
|
|
protected function nameize(string $input): string
|
|
{
|
|
$adjusted_name = str_name_case($input);
|
|
|
|
// Use preg_replace to match HTML entities and convert them to lowercase.
|
|
return preg_replace_callback('/&[a-zA-Z0-9#]+;/', function($matches) { return strtolower($matches[0]); }, $adjusted_name);
|
|
}
|
|
}
|