150 lines
3.7 KiB
PHP
Executable File
150 lines
3.7 KiB
PHP
Executable File
<?php
|
|
|
|
if (!function_exists('pre')) {
|
|
function pre($data)
|
|
{
|
|
echo "<pre>";
|
|
print_r($data);
|
|
echo "</pre>";
|
|
}
|
|
}
|
|
|
|
if (!function_exists('getHashedPassword')) {
|
|
function getHashedPassword($plainPassword)
|
|
{
|
|
return password_hash($plainPassword, PASSWORD_DEFAULT);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('verifyHashedPassword')) {
|
|
function verifyHashedPassword($plainPassword, $hashedPassword)
|
|
{
|
|
return password_verify($plainPassword, $hashedPassword) ? true : false;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('get_fav')) {
|
|
function get_fav($user)
|
|
{
|
|
$db = db_connect();
|
|
$user = (int)$user;
|
|
$query = $db->table('t_fav_add')->where('Created_BY', $user)->where('Status', 1)->get();
|
|
return $query->getResult();
|
|
}
|
|
}
|
|
|
|
if (!function_exists('reOrderListing')) {
|
|
function reOrderListing()
|
|
{
|
|
$db = db_connect();
|
|
$subQuery = 'SELECT * FROM t_materialmaster WHERE Current_stock < reorder?';
|
|
$query = $db->query($subQuery);
|
|
return $query->getResult();
|
|
}
|
|
}
|
|
|
|
if (!function_exists('generateCopyrightNotice')) {
|
|
function generateCopyrightNotice()
|
|
{
|
|
$current_year = date('Y');
|
|
if ($current_year > 2024) {
|
|
return " © 2024 - $current_year ";
|
|
} else {
|
|
return " © $current_year ";
|
|
}
|
|
}
|
|
}
|
|
function number_alignment($amount)
|
|
{
|
|
|
|
if ($amount) {
|
|
// Ensure the number has two decimal places
|
|
$number = number_format($amount, 2, '.', '');
|
|
|
|
// Split the number into integer and decimal parts
|
|
$numberParts = explode('.', $number);
|
|
$integerPart = $numberParts[0];
|
|
$decimalPart = isset($numberParts[1]) ? $numberParts[1] : '00';
|
|
|
|
// Format the integer part with commas according to the Indian numbering system
|
|
$lastThree = substr($integerPart, -3);
|
|
$restUnits = substr($integerPart, 0, -3);
|
|
if (strlen($restUnits) > 0) {
|
|
$formattedInteger = preg_replace('/\B(?=(\d{2})+(?!\d))/', ',', $restUnits) . ',' . $lastThree;
|
|
} else {
|
|
$formattedInteger = $lastThree;
|
|
}
|
|
|
|
return $formattedInteger . '.' . $decimalPart;
|
|
}
|
|
return "0.00";
|
|
}
|
|
|
|
if (!function_exists('htmlsc')) {
|
|
function htmlsc($output)
|
|
{
|
|
return htmlspecialchars($output, ENT_QUOTES);
|
|
}}
|
|
|
|
if (!function_exists('_htmlsc')) {
|
|
function _htmlsc($output)
|
|
{
|
|
echo htmlspecialchars($output, ENT_QUOTES);
|
|
}}
|
|
|
|
if (!function_exists('_htmle')) {
|
|
function _htmle($output)
|
|
{
|
|
echo htmlentities($output);
|
|
}}
|
|
|
|
if (!function_exists('_trans')) {
|
|
function _trans($line, $id = '', $default = null)
|
|
{
|
|
echo trans($line, $id, $default);
|
|
}}
|
|
|
|
if (!function_exists('trans')) {
|
|
function trans($line, $id = '', $default = null)
|
|
{
|
|
// Load the Language service
|
|
$lang = service('language');
|
|
|
|
// Get the translation
|
|
$lang_string = $lang->getLine($line);
|
|
|
|
// Fall back to default language if translation is not found
|
|
if (empty($lang_string)) {
|
|
$lang->setLocale('english'); // Set the default locale
|
|
$lang_string = $lang->getLine($line);
|
|
}
|
|
|
|
// Fall back to the $line value if the default language has no translation either
|
|
if (empty($lang_string)) {
|
|
$lang_string = $default ?? $line;
|
|
}
|
|
|
|
if ($id != '') {
|
|
$lang_string = '<label for="' . $id . '">' . $lang_string . '</label>';
|
|
}
|
|
|
|
return $lang_string;
|
|
}
|
|
}
|
|
|
|
|
|
if (!function_exists('generateCostCenterCode')) {
|
|
function generateCostCenterCode($id)
|
|
{
|
|
if ($id < 10) {
|
|
$CostCenterCode = 'C00' . $id;
|
|
} elseif ($id < 100) {
|
|
$CostCenterCode = 'C0' . $id;
|
|
} else {
|
|
$CostCenterCode = 'C' . $id;
|
|
}
|
|
|
|
return $CostCenterCode;
|
|
}
|
|
}
|