"; print_r($object); echo ""; if ($die) die; } function label($text, $echo = true) { if ($echo) { echo $text; } else { return $text; } } function template($filepath) { $filepath = env("APP_URL") .'/' .env("CLIENT_PATH") . '/' . $filepath; // $filepath=str_replace('\\','/',env("APP_URL")."/layout/".$filepath); echo $filepath; // return } if (!function_exists('N2')) { function N2($N) { return number_format($N, 2, '.', ','); } } if (!function_exists('slugify')) { function slugify($text, $tableName = null) { // Generate the initial slug from the text $slug = preg_replace('/[^a-zA-Z0-9\-]/', '-', $text); $slug = preg_replace('/-+/', '-', $slug); $slug = trim($slug, '-'); $slug = strtolower($slug); // If the table name is provided, check for uniqueness and modify the slug if needed if ($tableName) { $originalSlug = $slug; $count = 1; while (isSlugExists($tableName, $slug)) { $slug = $originalSlug . '-' . $count; $count++; } } return $slug; } } if (!function_exists('isSlugExists')) { function isSlugExists($tableName, $slug) { $aliasField = 'alias'; $count = DB::table($tableName) ->where($aliasField, $slug) ->count(); return $count > 0; } } function createButton($class = "", $type = "submit", $display = "Submit", $url = "") { if (!$url) : ?>
placeholder="" name="" class="form-control " value="" required>

where('status', '<>', -1)->orderBy($pk, 'asc')->pluck($name, $pk); $customColumnName = !empty($customColumnName) ? $customColumnName : $pk; //if we pass column name other then primary key. customCreateSelect($pk, $pk, $class, $display ?? $name, $systems, ($data) ? $data->$customColumnName : null); } function customCreateSelect($name, $id, $class = "form-control", $display = '', $values = array(), $defaultValue = '') { $disabled = (in_array("DISABLED", explode(" ", strtoupper($class)))) ? "Disabled" : false; $required = (in_array("REQUIRED", explode(" ", strtoupper($class)))) ? "Required" : false; ?>

where('status', '<>', -1); if ($defaultCondition) { $query->whereRaw($defaultCondition); } $systems = $query->orderBy($fieldNameForValue, 'asc')->pluck($fieldNameToDisplay, $fieldNameForValue); ?>

value="" multiple>
" style="height: 5rem" />
value="" multiple>
" style="height: 5rem" />
" style="height: 40px;" class="img-fluid" />
where($referenceFieldName, $referenceValue); $fieldData = ($query->value($returnField)) ? $query->value($returnField) : "N/A"; return $fieldData; } function createErrorParagraph($name, $class = null) { echo "

"; } function createActivityLog($controllerName, $methodName, $activity) { $user_id = (auth()->user()) ? auth()->user()->id : "0"; ActivityLog::create([ 'user_id' => $user_id, 'controllerName' => $controllerName, 'methodName' => $methodName, 'actionUrl' => request()->fullUrl(), 'activity' => $activity, ]); } function getOperationNumber() { $startNumber = date('YmdHis') . rand(1000, 9999); $isExists = OperationLog::where('operation_end_no', $startNumber)->first(); while ($isExists) { $startNumber = date('YmdHis') . rand(1000, 9999); $isExists = OperationLog::where('operation_end_no', $startNumber)->first(); } return $startNumber; } function createOperationLog($startOperationNumber, $endOperationNumber, $modelName, $modelId, $operationName, $previousValues, $newValues) { $operationId = getOperationNumber(); $user_id = (auth()->user()) ? auth()->user()->id : "0"; OperationLog::create([ 'user_id' => $user_id, 'operation_start_no' => $startOperationNumber, 'operation_end_no' => $endOperationNumber, 'model_name' => $modelName, 'model_id' => $modelId, 'operation_name' => $operationName, 'previous_values' => $previousValues ? json_encode($previousValues) : null, 'new_values' => $newValues ? json_encode($newValues) : null, ]); } function createErrorLog($controllerName, $methodName, $errors) { $user_id = (auth()->user()) ? auth()->user()->id : "0"; ErrorLog::create([ 'user_id' => $user_id, 'controller_name' => $controllerName, 'method_name' => $methodName, 'errors' => $errors, ]); } function createDate($name, $display = "", $class = "datepicker", $default = "") { ?>
display_order; $nextDisplayOrder = $maxDisplayOrder + 1; return $nextDisplayOrder; } function getAlias($textField, $tableName) { $maxDisplayOrder = DB::select("select max(display_order) as display_order from $tableName")[0]->display_order; $nextDisplayOrder = $maxDisplayOrder + 1; return $nextDisplayOrder; } if (!function_exists('myDate')) { function myDate($originalDate) { return date("F d Y", strtotime($originalDate)); } } if (!function_exists('dbDate')) { function dbDate($date) { return date("Y-m-d", strtotime($date)); } } if (!function_exists('myTime')) { function myTime($originalDate) { return date("g:i A", strtotime($originalDate)); } } if (!function_exists('myDateTime')) { function myDateTime($originalDate) { return date("F d Y g:i A", strtotime($originalDate)); } } if (!function_exists('myDaysDiff')) { function myDaysDiff($fromDate, $toDate) { $fromDate = strtotime($fromDate); $toDate = strtotime($toDate); $datediff = $toDate - $fromDate; return round($datediff / (60 * 60 * 24)); } } if (!function_exists('firstDayOfNepaliMonth')) { function firstDayOfNepaliMonth($engDate = "") { $engDate = ($engDate != "") ? $engDate : date("Y-m-d"); $NepaliDate = NepaliDate($engDate); $nD = explode("-", $NepaliDate); $Day = '1'; $Month = $nD[1]; $Year = $nD[0]; $t = "select bs_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'"; return DB::select($t)[0]->bs_date; } } if (!function_exists('firstDayOfNepaliMonth1')) { function firstDayOfNepaliMonth1($engDate = "") { $engDate = ($engDate != "") ? $engDate : date("Y-m-d"); $NepaliDate = NepaliDate($engDate); $nD = explode("-", $NepaliDate); $Day = '1'; $Month = ($nD[1] < 10) ? '0' . $nD[1] : $nD[1]; $Year = $nD[0]; $t = "select ad_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'"; return DB::select($t)[0]->ad_date; } } if (!function_exists('lastDayOfNepaliMonth')) { function lastDayOfNepaliMonth($engDate = "") { $engDate = ($engDate != "") ? $engDate : date("Y-m-d"); $NepaliDate = NepaliDate1($engDate); $nD = explode("-", $NepaliDate); $Day = '1'; $Month = $nD[1]; $Year = $nD[0]; $t = "select ad_date from tbl_nepengcalendar where bs_date like '" . $Year . "-" . $Month . "-%' order by ad_date"; $dates = DB::select($t); $date = end($dates); return $date->ad_date; } } if (!function_exists('EnglishDate')) { function EnglishDate($NepaliYear, $NepaliMonth, $NepaliDay) { if ($NepaliMonth < 10) { $NepaliMonth = "0" . $NepaliMonth; } $bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay; $t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'"; $q = DB::select($t); return $q[0]->ad_date; } } if (!function_exists('Today')) { function Today() { return date("Y-m-d"); } } if (!function_exists('NepaliToEnglishDate')) { function NepaliToEnglishDate($NepaliDate) { $NepaliDate = trim($NepaliDate); if (trim($NepaliDate) == "") { return date("Y-m-d"); } $NepaliDate = explode("-", $NepaliDate); $NepaliMonth = intval($NepaliDate[1]); $NepaliYear = intval($NepaliDate[0]); $NepaliDay = intval($NepaliDate[2]); if ($NepaliMonth < 10) { $NepaliMonth = "0" . $NepaliMonth; } $bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay; $t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'"; $q = DB::select($t); return $q[0]->ad_date; } } if (!function_exists('NepaliDate')) { function NepaliDate($engDate = "") { $engDate = ($engDate != "") ? $engDate : date("Y-m-d"); if ($engDate != "0000-00-00") { // return str_replace("-0", "-", DB::table('tbl_nepengcalendar')->where('ad_date', $engDate)->first()->bs_date); $result = DB::table('tbl_nepengcalendar')->where('ad_date', $engDate)->first(); if ($result) { $bsDate = $result->bs_date; $convertedDate = convertNumbersToUnicode(str_replace("-", "-", $bsDate)); return $convertedDate; } else { // Handle the case when the query result is null return null; } } else { return ""; } } } function convertNumbersToUnicode($number = "2080-10-13") { $unicodeDigits = [ '0' => '०', '1' => '१', '2' => '२', '3' => '३', '4' => '४', '5' => '५', '6' => '६', '7' => '७', '8' => '८', '9' => '९', ]; $converted = ''; $digits = str_split((string)$number); foreach ($digits as $digit) { if (isset($unicodeDigits[$digit])) { $converted .= $unicodeDigits[$digit]; } elseif ($digit === '-') { $converted .= '-'; } else { $converted .= $digit; } } //dd($converted); return $converted; } if (!function_exists('NepaliMonth')) { function NepaliMonth($engDate = "") { $NepaliDate = NepaliDate($engDate); $nD = explode("-", $NepaliDate); $Month = $nD[1]; return intval($Month); } } if (!function_exists('NepaliYear')) { function NepaliYear($engDate = "") { $NepaliDate = NepaliDate($engDate); $nD = explode("-", $NepaliDate); $Year = $nD[0]; return intval($Year); } } if (!function_exists('NepaliMonthNameByNumber')) { function NepaliMonthNameByNumber($number) { $MonthNames = array( "Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra" ); return $MonthNames[$number - 1]; } } if (!function_exists('NepaliMonthName')) { function NepaliMonthName($engDate = "") { $Month = NepaliMonth($engDate); $MonthNames = array( "Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra" ); return $MonthNames[$Month - 1]; } } if (!function_exists('N2')) { function N2($N) { return number_format($N, 2, '.', ','); } } function collectScripts(callable $callback) { ob_start(); $callback(); $script = ob_get_clean(); if (!empty($script)) { pushScriptToFooter($script); } } function pushScriptToFooter($script) { if (!isset($GLOBALS['scripts'])) { $GLOBALS['scripts'] = []; } $GLOBALS['scripts'][] = $script; } function sectionHeader($text, $sectiontitle = null) { $texts = explode(" ", $text); ?>