commitall
This commit is contained in:
180
account/application/helpers/accounts_helper.php
Normal file
180
account/application/helpers/accounts_helper.php
Normal file
@ -0,0 +1,180 @@
|
||||
<?php
|
||||
function generateACCategoryCode($group_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$acgroup_code = $ci->db->where("acgroup_id=$group_id")->get("tbl_acgroups")->row()->acgroup_code;
|
||||
$lastACCategoryCode = $ci->db->select_max("accategory_code")->where("acgroup_id=$group_id")->get("tbl_accategories")->row()->accategory_code;
|
||||
$category_part = substr($lastACCategoryCode, 1);
|
||||
|
||||
$category_part = (float)$category_part + 1;
|
||||
//if($category_part<10)$category_part="00".$category_part;
|
||||
if ($category_part < 10) $category_part = "00" . $category_part;
|
||||
elseif ($category_part < 100) $category_part = "0" . $category_part;
|
||||
return $acgroup_code . $category_part;
|
||||
}
|
||||
function generateAccountCode($category_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$accategory_code = $ci->db->where("accategory_id=$category_id")->get("tbl_accategories")->row()->accategory_code;
|
||||
$lastAccountCode = $ci->db->select_max("account_code")->where("accategory_id=$category_id")->get("tbl_accounts")->row()->account_code;
|
||||
$account_part = substr($lastAccountCode, 4);
|
||||
|
||||
$account_part = (float)$account_part + 1;
|
||||
//if($category_part<10)$category_part="00".$category_part;
|
||||
if ($account_part < 10) $account_part = "00" . $account_part;
|
||||
elseif ($account_part < 100) $account_part = "0" . $account_part;
|
||||
return $accategory_code . $account_part;
|
||||
}
|
||||
function showFiscalYear()
|
||||
{
|
||||
$ci = &get_instance();
|
||||
echo getFieldfromValue("tbl_fiscalyear", "fiscalyear_year", "fiscalyear_id", $ci->session->userdata("FiscalYearID"));
|
||||
}
|
||||
function FYStart()
|
||||
{
|
||||
$ci = &get_instance();
|
||||
// echo $ci->session->userdata("FiscalYearID");die;asd;
|
||||
$FY = getFieldfromValue("tbl_fiscalyear", "fiscalyear_from", "fiscalyear_id", $ci->session->userdata("FiscalYearID"));
|
||||
// echo NepaliDate($FY);die;
|
||||
return NepaliDate($FY);
|
||||
}
|
||||
function FYEnd()
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$FY = getFieldfromValue("tbl_fiscalyear", "fiscalyear_to", "fiscalyear_id", $ci->session->userdata("FiscalYearID"));
|
||||
return NepaliDate($FY);
|
||||
}
|
||||
function showAccountCategoriesSelector($fieldName, $fieldID, $condition = "1=1", $selectedID = '', $additionalClass = "")
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$AccountCategories = $ci->db->where("status", 1)->where($condition)->get("tbl_accategories")->result();
|
||||
$isRequired = (stripos($additionalClass, "required") !== false); // Check if "required" exists in $additionalClass
|
||||
$html = "<select name='$fieldName' id='$fieldID' class='select2 $additionalClass'";
|
||||
if ($isRequired) {
|
||||
$html .= " required";
|
||||
}
|
||||
$html .= ">";
|
||||
|
||||
$html .= "<option value='' " . (($selectedID == '') ? "SELECTED" : "") . ">Select Account Category</option>";
|
||||
|
||||
foreach ($AccountCategories as $AccountCategory) {
|
||||
$html .= "<option value='$AccountCategory->accategory_id'" . (($selectedID == $AccountCategory->accategory_id) ? "selected" : "") . ">" . getFieldfromValue("tbl_acgroups", "acgroup_name", "acgroup_id", $AccountCategory->acgroup_id) . " >> $AccountCategory->accategory_name</option>";
|
||||
}
|
||||
|
||||
$html .= "</select>";
|
||||
echo $html;
|
||||
}
|
||||
function showAccountCategoriesByIds($AccountCategories = array())
|
||||
{
|
||||
// pre($AccountCategories); //die;
|
||||
$ci = &get_instance();
|
||||
|
||||
if ($AccountCategories) {
|
||||
$AccountCategories_a = $ci->db->where("status", 1);
|
||||
$AccountCategories_a = $AccountCategories_a->where_in("accategory_id", $AccountCategories);
|
||||
$AccountCategories_a = $AccountCategories_a->get("tbl_accategories")->result();
|
||||
$html = array();
|
||||
foreach ($AccountCategories_a as $AccountCategory) {
|
||||
$html[] = $AccountCategory->accategory_name;
|
||||
}
|
||||
echo implode(", ", $html);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function linkVoucher($voucher_id)
|
||||
{
|
||||
if($voucher_id!=0) {
|
||||
$ci = &get_instance();
|
||||
$Voucher = $ci->db->where("voucher_id", $voucher_id)->get("tbl_vouchers")->row();
|
||||
$Name = $ci->db->where("vouchertype_id", $Voucher->voucher_type)->get("tbl_vouchertypes")->row()->voucher_type . " Voucher # " . $Voucher->voucher_no;
|
||||
echo "<a class='link' target='_blank' href='" . site_url("accounts/vouchers/show_voucher/" . $voucher_id) . "'>$Name</a>";
|
||||
} else {
|
||||
echo "";
|
||||
}
|
||||
}
|
||||
function linkLedger($Account)
|
||||
{
|
||||
|
||||
$ci = &get_instance();
|
||||
echo "<a class='link' target='_blank' href='" . site_url("accounts/ledger/partyledger?from_date=" . FYStart() . "&to_date=" . FYEnd() . "&account_id=" . $Account->account_id . "&show_ledger=true") . "'>$Account->account_name</a>";
|
||||
}
|
||||
function linkGroup($Group)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
echo "<a class='link' target='_blank' href='" . site_url("accounts/reports/balance_by_category/") . "?group=" . $Group->acgroup_id . "'>$Group->acgroup_name</a>";
|
||||
}
|
||||
function linkCategory($Category)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
if ($Category) :
|
||||
echo "<a class='link' target='_blank' href='" . site_url("accounts/reports/balance_by_group/") . "?category=" . $Category->accategory_id . "'>$Category->accategory_name</a>";
|
||||
endif;
|
||||
}
|
||||
function myCurrency($number, $inline = false)
|
||||
{
|
||||
if ($number == 0) {
|
||||
if (!$inline)
|
||||
return "<span class='currency text-right'> </span>";
|
||||
else
|
||||
return "<span class='text-right'> </span>";
|
||||
}
|
||||
if ($number < 0) return "<span class='currency text-right'>(" . number_format(abs($number), 2, ".", ",") . ")</span>";
|
||||
if (!$inline)
|
||||
return "<span class='currency text-right'>" . number_format($number, 2, ".", ",") . "</span>";
|
||||
else
|
||||
return "<span class='text-right'>" . number_format($number, 2, ".", ",") . "</span>";
|
||||
}
|
||||
function showNill()
|
||||
{
|
||||
return "<span class='currency text-right'>Nill</span>";
|
||||
}
|
||||
function isVoucherExists($voucher_no)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
return ($ci->db->where("voucher_no", $voucher_no)->get("tbl_vouchers")->num_rows() > 0) ? true : false;
|
||||
}
|
||||
function isVoucherReverseable($voucher_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
return ($ci->db->select("voucher_state")->where("voucher_id", $voucher_id)->get("tbl_vouchers")->row()->voucher_state == "Entered") ? true : false;
|
||||
}
|
||||
function generateVoucherNo($vouchertype_id = "")
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$voucherTypeCondition = ($vouchertype_id != "") ? " WHERE voucher_type = '$vouchertype_id'" : "";
|
||||
|
||||
$query = $ci->db->query("SELECT MAX(voucher_no) AS voucher_no FROM tbl_vouchers" . $voucherTypeCondition);
|
||||
$row = $query->row();
|
||||
|
||||
$newVoucherNo = ($row->voucher_no !== null) ? $row->voucher_no + 1 : 1;
|
||||
|
||||
return $newVoucherNo;
|
||||
}
|
||||
|
||||
function countChildCategories($acgroup_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
return $ci->db->where("status", 1)->where("acgroup_id", $acgroup_id)->get("tbl_accategories")->num_rows();
|
||||
}
|
||||
function countChildAccounts($accategory_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
return $ci->db->where("status", 1)->where("accategory_id", $accategory_id)->get("tbl_accounts")->num_rows();
|
||||
}
|
||||
function getBalance($account_id)
|
||||
{
|
||||
$drTotal = getDrTotal($account_id);
|
||||
$crTotal = getCrTotal($account_id);
|
||||
return $drTotal - $crTotal;
|
||||
}
|
||||
function getDrTotal($account_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
return $ci->db->where("status", 1)->where("account_id", $account_id)->select_sum('dr')->get("tbl_voucherdetails")->row()->dr;
|
||||
}
|
||||
function getCrTotal($account_id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
return $ci->db->where("status", 1)->where("account_id", $account_id)->select_sum('cr')->get("tbl_voucherdetails")->row()->cr;
|
||||
}
|
160
account/application/helpers/bibhelper_helper.php
Normal file
160
account/application/helpers/bibhelper_helper.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
function cow($text = "")
|
||||
{
|
||||
echo ($text != "") ? $text : "COW";
|
||||
die;
|
||||
}
|
||||
function createButton($name, $display, $id, $type = "Submit", $class = "")
|
||||
{
|
||||
?>
|
||||
<div class="form-group">
|
||||
<?php if ($type == "Submit") : ?>
|
||||
<button type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="form-control <?php echo $class; ?>">
|
||||
<?php echo function_exists("myLang") ? myLang($display) : $display; ?>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="form-control <?php echo $class; ?>">
|
||||
<?php echo function_exists("myLang") ? myLang($display) : $display; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createInput($name, $display, $id, $default = "", $class = "")
|
||||
{
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
||||
<input type="text" name="<?php echo $name; ?>" id="<?php echo $id; ?>" class="form-control <?php echo $class; ?>" placeholder="Enter <?php echo function_exists("myLang") ? myLang($display) : $display; ?>" value="<?php echo $default; ?>" autocomplete="off">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createDateInput($name, $display, $id, $default = "", $class = "")
|
||||
{
|
||||
?>
|
||||
<label for="datepicker<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
||||
<div class="input-group date datepickers" id="ass_date" data-target-input="nearest">
|
||||
<input id="<?php echo $id; ?>" name="<?php echo $name; ?>" type="text" data-target="#<?php echo $id; ?>" data-toggle="datetimepicker" class="form-control datetimepicker <?php echo $class; ?>" autocomplete="off" required>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createNepaliDateInput($name, $display, $id, $default = "", $class = "")
|
||||
{
|
||||
?>
|
||||
<?php if ($display != "") : ?>
|
||||
<label for="datepicker<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
||||
<?php endif; ?>
|
||||
<div class="input-group" id="ass_date" data-target-input="nearest">
|
||||
<input id="<?php echo $id; ?>" name="<?php echo $name; ?>" type="text" class="form-control nepaliDatePicker <?php echo $class; ?>" autocomplete="off" value="<?php echo ($default == "") ? NepaliDate() : $default; ?>">
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createSelect($name, $display, $values = array(), $id = "", $default = "", $class = "")
|
||||
{
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
||||
<select name="<?php echo $name; ?>" class="form-control <?php echo $class; ?>" id="">
|
||||
<option value="">Select <?php echo function_exists("myLang") ? myLang($display) : $display; ?></option>
|
||||
<?php foreach ($values as $value) : ?>
|
||||
<option value="<?php echo $value[0]; ?>"><?php echo $value[1]; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function createTextarea($name, $display, $id, $default = "", $class = "")
|
||||
{
|
||||
?>
|
||||
<div class="form-group">
|
||||
<label for="<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
|
||||
<textarea class="form-control <?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $id; ?>" rows="3" placeholder="Enter <?php echo function_exists("myLang") ? myLang($display) : $display; ?>"><?php echo $default; ?></textarea>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
function getNamesfromCSV($tableName, $fieldName, $lookupField, $referenceValue)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$referenceValue = explode(",", $referenceValue);
|
||||
$result = array();
|
||||
foreach ($referenceValue as $V) :
|
||||
$v = $ci->db->query("select $fieldName from $tableName where $lookupField='$V'")->row();
|
||||
$result[] = $v->$fieldName;
|
||||
endforeach;
|
||||
return implode(",", $result);
|
||||
}
|
||||
function getFieldfromValue($tableName, $fieldName, $lookupField, $referenceValue)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$t = "select $fieldName from $tableName where $lookupField='$referenceValue'"; //echo $t; //die;
|
||||
$v = $ci->db->query($t);
|
||||
if ($v->num_rows() > 0) {
|
||||
$v = $v->row();
|
||||
return $v->$fieldName;
|
||||
} else {
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
function fillComboWithValue($fieldName, $displayName, $fieldID, $tableName, $displayField, $valueField, $default = "", $CSSclass = "", $multiple = false, $condition = "")
|
||||
{
|
||||
$ci = &get_instance();
|
||||
?>
|
||||
<?php if ($displayName != "") : ?>
|
||||
<label for="<?php echo $fieldID; ?>"><?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></label>
|
||||
<?php endif; ?>
|
||||
<select name="<?php echo $fieldName; ?><?php echo ($multiple) ? "[]" : ""; ?>" <?php if ($CSSclass != "none") : ?>class="form-control select2 <?php echo $CSSclass; ?>" <?php else : ?> class="form-control" <?php endif; ?> id="<?php echo $fieldID; ?>" <?php echo ($multiple) ? "multiple" : ""; ?>>
|
||||
<option value="">Select <?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></option>
|
||||
<?php
|
||||
$q = "select * from $tableName";
|
||||
$q .= ($condition != "") ? " where $condition" : " where status=1";
|
||||
$Values = $ci->db->query($q)->result(); ?>
|
||||
<?php foreach ($Values as $value) : ?>
|
||||
<option value="<?php echo $value->$valueField; ?>" <?php echo ($value->$valueField == $default) ? 'SELECTED' : ''; ?>><?php echo $value->$displayField; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
function getTableSchema($tableName)
|
||||
{
|
||||
echo "<pre>";
|
||||
//$R=DB::select("list columns from $tableName");
|
||||
// print_r(Schema::getColumnListing($tableName));
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
function showEditButton($url, $text = "Edit")
|
||||
{
|
||||
?>
|
||||
<a href="<?php echo site_url($url); ?>" class="btn btn-info btn-xs" title="<?php echo myLang($text); ?>"><i class="fas fa-edit"></i> <?php //echo myLang($text);
|
||||
?></a>
|
||||
<?php
|
||||
}
|
||||
function showDeleteButton($id, $text = "Delete")
|
||||
{
|
||||
?>
|
||||
<a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs" title="<?php echo myLang($text); ?>"><i class="fas fa-trash"></i> <?php //echo myLang($text);
|
||||
?></a>
|
||||
<?php
|
||||
}
|
||||
function showListButton($url, $text = "List")
|
||||
{
|
||||
?>
|
||||
<a href="<?php echo site_url($url); ?>" class="btn btn-success btn-xs float-right" title="<?php echo myLang($text); ?>"><i class="fas fa-list"></i> <?php //echo myLang($text);
|
||||
?></a>
|
||||
<?php
|
||||
}
|
||||
function showCreateButton($url, $text = "Create")
|
||||
{
|
||||
?>
|
||||
<a href="<?php echo site_url($url); ?>" class="btn btn-primary btn-xs float-right" title="<?php echo myLang($text); ?>"><i class="fas fa-pen"></i> <?php //echo myLang($text);
|
||||
?></a>
|
||||
<?php
|
||||
}
|
||||
function showDetailsButton($url, $text = "Details")
|
||||
{
|
||||
?>
|
||||
<a href="<?php echo site_url($url); ?>" class="btn btn-primary btn-xs" title="<?php echo myLang($text); ?>"><i class="fas fa-glasses"></i> <?php //echo myLang($text);
|
||||
?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
307
account/application/helpers/general_helper.php
Normal file
307
account/application/helpers/general_helper.php
Normal file
@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
function getalias($title, $alias_name, $table)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$new_string = trim(preg_replace('/[^A-Za-z0-9_]/', ' ', strip_tags($title)));
|
||||
$new_string = preg_replace('/\s+/', ' ', $new_string);
|
||||
$alias = strtolower(str_replace(" ", "-", trim($new_string)));
|
||||
$ci->load->model('MHelper');
|
||||
$a = $ci->MHelper->checkIfAliasExist($alias, $alias_name, $table);
|
||||
$c = 1;
|
||||
$newalias = $alias;
|
||||
while ($ci->MHelper->checkIfAliasExist($newalias, $alias_name, $table)) {
|
||||
$newalias = $alias . $c;
|
||||
$c++;
|
||||
}
|
||||
return $newalias;
|
||||
}
|
||||
function createalias($text)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$new_string = trim(preg_replace('/[^A-Za-z0-9_]/', ' ', strip_tags($text)));
|
||||
$new_string = preg_replace('/\s+/', ' ', $new_string);
|
||||
$alias = strtolower(str_replace(" ", "-", trim($new_string)));
|
||||
$alias = str_replace("-", "", $alias);
|
||||
return $alias;
|
||||
}
|
||||
|
||||
function getLocationsForMenu()
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MSubmission');
|
||||
$Locations = $ci->MSubmission->getLocation();
|
||||
return $Locations;
|
||||
}
|
||||
|
||||
function getDisplayOrder($table)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$max = $ci->MHelper->getMaxDisplayOrder($table);
|
||||
return $max + 1;
|
||||
}
|
||||
function countHolidayByDaterangeInFactory($from_date, $to_date)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getHolidayByDaterangeInFactory($from_date, $to_date);
|
||||
return $Holidays;
|
||||
}
|
||||
|
||||
function countTotaldaysByDaterange($from_date, $to_date)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getTotalDaysByDaterange($from_date, $to_date);
|
||||
//pre($Holidays);
|
||||
return $Holidays;
|
||||
}
|
||||
function countTotalPresentsdaysByDaterange($from_date, $to_date, $id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getTotalPresentsDaysByDaterange($from_date, $to_date, $id);
|
||||
return $Holidays;
|
||||
}
|
||||
|
||||
function countTotalPaidLeavesByDaterange($from_date, $to_date, $id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getTotalPaidLeavesByDaterange($from_date, $to_date, $id);
|
||||
return $Holidays;
|
||||
}
|
||||
function countTotalUnPaidLeavesByDaterange($from_date, $to_date, $id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getTotalUnPaidLeavesByDaterange($from_date, $to_date, $id);
|
||||
return $Holidays;
|
||||
}
|
||||
function countTotalAnnualLeavesByDaterange($from_date, $to_date, $id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getTotalAnnualLeavesByDaterange($from_date, $to_date, $id);
|
||||
return $Holidays;
|
||||
}
|
||||
function countTotalSickLeavesByDaterange($from_date, $to_date, $id)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->model('MHelper');
|
||||
$Holidays = $ci->MHelper->getTotalSickLeavesByDaterange($from_date, $to_date, $id);
|
||||
return $Holidays;
|
||||
}
|
||||
function getImagePath($path)
|
||||
{
|
||||
return str_replace(base_url(), '', $path);
|
||||
}
|
||||
function pre($array, $death = false)
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($array);
|
||||
echo '</pre>';
|
||||
if ($death) die();
|
||||
}
|
||||
|
||||
function image_url($path = '')
|
||||
{
|
||||
$path = explode("/", $path);
|
||||
$image = end($path);
|
||||
return config_item('kcfinder_path') . $image;
|
||||
}
|
||||
|
||||
|
||||
function myDate($originalDate)
|
||||
{
|
||||
return date("F d Y", strtotime($originalDate));
|
||||
}
|
||||
|
||||
function dbDate($date)
|
||||
{
|
||||
return date("Y-m-d", strtotime($date));
|
||||
}
|
||||
|
||||
function myTime($originalDate)
|
||||
{
|
||||
return date("g:i A", strtotime($originalDate));
|
||||
}
|
||||
|
||||
function myDateTime($originalDate)
|
||||
{
|
||||
return date("F d Y g:i A", strtotime($originalDate));
|
||||
}
|
||||
function myDaysDiff($fromDate, $toDate)
|
||||
{
|
||||
$fromDate = strtotime($fromDate);
|
||||
$toDate = strtotime($toDate);
|
||||
$datediff = $toDate - $fromDate;
|
||||
return round($datediff / (60 * 60 * 24));
|
||||
}
|
||||
function firstDayOfNepaliMonth($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Day = '1';
|
||||
$Month = $nD[1];
|
||||
if (strlen($Month) == 1) {
|
||||
$Month = '0' . $Month;
|
||||
}
|
||||
$Year = $nD[0];
|
||||
$ci = &get_instance();
|
||||
$t = "select bs_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'";
|
||||
return $ci->db->query($t)->row()->bs_date;
|
||||
}
|
||||
function firstDayOfNepaliMonth1($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Day = '1';
|
||||
$Month = $nD[1];
|
||||
if ($Month == 11 || $Month == 12 || $Month == 10) {
|
||||
$Month = $nD[1];
|
||||
} else {
|
||||
$Month = '0' . $nD[1];
|
||||
}
|
||||
|
||||
$Year = $nD[0];
|
||||
$ci = &get_instance();
|
||||
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date='" . $Year . "-" . $Month . "-" . $Day . "'";
|
||||
//echo $t;die;
|
||||
return $ci->db->query($t)->result()[0]->ad_date;
|
||||
}
|
||||
function lastDayOfNepaliMonth($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
//echo $engDate;
|
||||
$NepaliDate = NepaliDate1($engDate);
|
||||
// echo $NepaliDate;
|
||||
$nD = explode("-", $NepaliDate);
|
||||
//print_r($nD);
|
||||
$Day = '1';
|
||||
$Month = $nD[1];
|
||||
$Year = $nD[0];
|
||||
$ci = &get_instance();
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date like '" . $Year . "-" . $Month . "-%' order by ad_date";
|
||||
// echo $t;
|
||||
$dates = $ci->db->query($t)->result();
|
||||
//print_r($dates);
|
||||
$date = $dates[sizeof($dates) - 1];
|
||||
// print_r($date);die;
|
||||
return $date->ad_date;
|
||||
}
|
||||
function EnglishDate($NepaliYear, $NepaliMonth, $NepaliDay)
|
||||
{
|
||||
$ci = &get_instance();
|
||||
if ($NepaliMonth < 10) $NepaliMonth = "0" . $NepaliMonth;
|
||||
$bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay;
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'"; //echo $t;
|
||||
$q = $ci->db->query($t)->row();
|
||||
return $q->ad_date;
|
||||
}
|
||||
function Today()
|
||||
{
|
||||
return date("Y-m-d");
|
||||
}
|
||||
function NepaliToEnglishDate($NepaliDate)
|
||||
{
|
||||
$NepaliDate = trim($NepaliDate);
|
||||
if (trim($NepaliDate) == "") return date("Y-m-d");
|
||||
$ci = &get_instance();
|
||||
$NepaliDate = explode("-", $NepaliDate);
|
||||
$NepaliMonth = intval($NepaliDate[1]);
|
||||
$NepaliYear = intval($NepaliDate[0]);
|
||||
$NepaliDay = intval($NepaliDate[2]);
|
||||
if ($NepaliMonth < 10) $NepaliMonth = "0" . $NepaliMonth;
|
||||
//if($NepaliDay<10)$NepaliDay="0".$NepaliDay;
|
||||
$bs_date = $NepaliYear . "-" . $NepaliMonth . "-" . $NepaliDay;
|
||||
$t = "select ad_date from tbl_nepengcalendar where bs_date='$bs_date'"; //echo $t;
|
||||
$q = $ci->db->query($t)->row();
|
||||
return $q->ad_date;
|
||||
}
|
||||
function NepaliDate($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
if ($engDate != "0000-00-00") {
|
||||
$ci = &get_instance();
|
||||
return str_replace("-0", "-", $ci->db->query("select bs_date from tbl_nepengcalendar where ad_date='" . $engDate . "'")->result()[0]->bs_date);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
function NepaliDate1($engDate = "")
|
||||
{
|
||||
$engDate = ($engDate != "") ? $engDate : date("Y-m-d");
|
||||
$ci = &get_instance();
|
||||
return $ci->db->query("select bs_date from tbl_nepengcalendar where ad_date='" . $engDate . "'")->result()[0]->bs_date;
|
||||
}
|
||||
function NepaliMonth($engDate = "")
|
||||
{
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Month = $nD[1];
|
||||
return intval($Month);
|
||||
}
|
||||
function NepaliYear($engDate = "")
|
||||
{
|
||||
$NepaliDate = NepaliDate($engDate);
|
||||
$nD = explode("-", $NepaliDate);
|
||||
$Year = $nD[0];
|
||||
return intval($Year);
|
||||
}
|
||||
function NepaliMonthNameByNumber($number)
|
||||
{
|
||||
$MonthNames = array("Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra");
|
||||
return $MonthNames[$number - 1];
|
||||
}
|
||||
function NepaliMonthName($engDate = "")
|
||||
{
|
||||
$Month = NepaliMonth($engDate);
|
||||
$MonthNames = array("Baisakh", "Jestha", "Ashad", "Shrawan", "Bhadra", "Asoj", "Kartik", "Mangsir", "Poush", "Magh", "Falgun", "Chaitra");
|
||||
return $MonthNames[$Month - 1];
|
||||
}
|
||||
function N2($N)
|
||||
{
|
||||
return number_format($N, 2, '.', ',');
|
||||
}
|
||||
function loadView($viewName, $data = '')
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->load->view('includes/header', $data);
|
||||
$ci->load->view('includes/nav', $data);
|
||||
$ci->load->view('includes/sidebar', $data);
|
||||
$ci->load->view($viewName, $data);
|
||||
$ci->load->view('includes/footer', $data);
|
||||
}
|
||||
|
||||
function getUrlArray()
|
||||
{
|
||||
$host = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '')
|
||||
. '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$host = str_replace(base_url(), "", $host);
|
||||
$host = str_replace('-', '_', $host);
|
||||
$host = explode("/", $host);
|
||||
return $host;
|
||||
}
|
||||
|
||||
function showMenu($Display = "Balance By Account Groups", $Link = "accounts/reports/balance_by_group", $Icon = "fa-circle")
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$command = $ci->uri->segment(1);
|
||||
$param = $ci->uri->segment(2);
|
||||
$subparam = $ci->uri->segment(3);
|
||||
$subparam2 = $ci->uri->segment(4);
|
||||
$Link = explode("/", $Link);
|
||||
$Link1 = isset($Link[1]) ? $Link[1] : '';
|
||||
$Link2 = isset($Link[2]) ? $Link[2] : '';
|
||||
echo '<li class="nav-item">';
|
||||
echo '<a href="' . site_url($Link) . '" class="nav-link ' . ($param == $Link1 && $subparam == $Link2 ? "active" : "") . '">';
|
||||
// echo '<i class="far ' . $Icon . ' nav-icon"></i>';
|
||||
echo '<p>' . $Display . '</p>';
|
||||
echo '</a>';
|
||||
echo '</li>';
|
||||
}
|
11
account/application/helpers/index.html
Normal file
11
account/application/helpers/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
90
account/application/helpers/login_helper.php
Normal file
90
account/application/helpers/login_helper.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
function checkLogin()
|
||||
{
|
||||
$ci = &get_instance();
|
||||
initDatabase();
|
||||
if ($ci->session->userdata("loggedIn") == 1) {
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
|
||||
$re = $_SERVER['REDIRECT_QUERY_STRING'];
|
||||
} else {
|
||||
redirect("login");
|
||||
}
|
||||
redirect("login/?url=" . $re);
|
||||
}
|
||||
}
|
||||
|
||||
function authenticateUser($email, $password, $re)
|
||||
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->db->where('username', $email);
|
||||
$ci->db->where('password', $password);
|
||||
$users = $ci->db->get('tbl_users')->row();
|
||||
$FiscalYearID = $ci->db->where("status=1")->get("tbl_fiscalyear")->row()->fiscalyear_id;
|
||||
$FiscalYear = $ci->db->where("status=1")->get("tbl_fiscalyear")->row();
|
||||
$Branch = $ci->db->where("status=1")->get("tbl_branches")->row();
|
||||
if ($users != '') {
|
||||
$array = array(
|
||||
'loggedIn' => "1",
|
||||
'loggedInUser' => $email,
|
||||
'loggedUser' => $users->username,
|
||||
'FiscalYearID' => $FiscalYearID,
|
||||
'FiscalYear' => $FiscalYear,
|
||||
'BranchID' => $Branch->branch_id,
|
||||
'Branch'=>$Branch,
|
||||
'CompanyName' => $Branch->branch_name
|
||||
);
|
||||
if ($users->status == 1) {
|
||||
$array['superAdmin'] = 1;
|
||||
}
|
||||
if ($users->status == 2) {
|
||||
$array['superAdmin'] = 2;
|
||||
}
|
||||
if ($users->status == 3) {
|
||||
$array['superAdmin'] = 3;
|
||||
}
|
||||
$ci->session->set_userdata($array);
|
||||
redirect($re);
|
||||
}
|
||||
}
|
||||
function initDatabase()
|
||||
{
|
||||
$ci = &get_instance();
|
||||
$ci->db->trans_start();
|
||||
if (!$ci->db->field_exists('voucher_color', 'tbl_vouchertypes')) {
|
||||
// Create the column
|
||||
$ci->db->query("ALTER TABLE tbl_vouchertypes ADD COLUMN voucher_color VARCHAR(255) AFTER voucher_alias");
|
||||
$t = array();
|
||||
$t[] = "truncate tbl_vouchertypes";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Contra', 'Contra', 'contra', '1','#cfbdec');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Payment', 'Payment', 'payment', '1','#b3a3d0');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Receipt', 'Receipt', 'receipt', '1','#e5b8cd');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Journal', 'Journal', 'journal', '1','#df979e');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Sales', 'Sales', 'sales', '1','#e2bb9b');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Creditnote', 'Creditnote', 'creditnote', '1','#bfb69b');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Purchase', 'Purchase', 'purchase', '1','#80ad8a');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Debitnote', 'Debitnote', 'debitnote', '1','#87bfae');";
|
||||
$t[] = "INSERT INTO `tbl_vouchertypes` (`voucher_type`, `voucher_name`, `voucher_alias`, `status`,`voucher_color`) VALUES ('Reversing', 'Reversing', 'reversing', '1','#96ced7');";
|
||||
// $ci->db->query($t);
|
||||
|
||||
|
||||
foreach ($t as $query) {
|
||||
$ci->db->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ci->db->trans_complete();
|
||||
|
||||
if ($ci->db->trans_status() === FALSE) {
|
||||
// Handle transaction failure
|
||||
} else {
|
||||
// Transaction succeeded
|
||||
}
|
||||
}
|
45
account/application/helpers/mylang_helper.php
Normal file
45
account/application/helpers/mylang_helper.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
function myLang($text)
|
||||
{
|
||||
$text = str_replace('_', ' ', $text);
|
||||
$text = ucwords($text);
|
||||
$CI = &get_instance();
|
||||
$txtSQl = "CREATE TABLE IF NOT EXISTS tbl_translations (
|
||||
translation_id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
english VARCHAR(255),
|
||||
nepali VARCHAR(255),
|
||||
created_by VARCHAR(255),
|
||||
created_on DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
remarks TEXT,
|
||||
status INT DEFAULT 1
|
||||
);
|
||||
";
|
||||
$CI->db->query($txtSQl);
|
||||
|
||||
if ($CI->session->userdata("language") == "np") {
|
||||
|
||||
$query = $CI->db->get_where('tbl_translations', array('english' => $text, 'nepali !=' => ''));
|
||||
$result = $query->row();
|
||||
|
||||
// Check if a translation exists in the database
|
||||
if ($result) {
|
||||
$nepaliWord = $result->nepali;
|
||||
echo $nepaliWord;
|
||||
} else {
|
||||
$existingQuery = $CI->db->get_where('tbl_translations', array('english' => $text));
|
||||
$existingResult = $existingQuery->row();
|
||||
|
||||
if (!$existingResult) {
|
||||
$data = array(
|
||||
'english' => $text,
|
||||
'nepali' => ''
|
||||
);
|
||||
$CI->db->insert('tbl_translations', $data);
|
||||
}
|
||||
|
||||
echo $text;
|
||||
}
|
||||
} else {
|
||||
echo $text;
|
||||
}
|
||||
}
|
99
account/application/helpers/permission_helper.php
Normal file
99
account/application/helpers/permission_helper.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
function isSuperAdmin()
|
||||
{
|
||||
$ci =& get_instance();
|
||||
if ($ci->session->has_userdata('superAdmin')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isPermitted($value, $level = 0)
|
||||
{
|
||||
$ci =& get_instance();
|
||||
if (isSuperAdmin()) {
|
||||
return true;
|
||||
} else {
|
||||
//echo $level;die;
|
||||
$privilege = $ci->session->userdata('privilege');
|
||||
if (!empty($privilege[$value]) && ($privilege[$value] > $level || $privilege[$value] == $level)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getPrivilege($value)
|
||||
{
|
||||
$ci =& get_instance();
|
||||
$privilege = $ci->session->userdata('privilege');
|
||||
if (!empty($privilege[$value])) {
|
||||
return $privilege[$value];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isViewable($level = 0)
|
||||
{
|
||||
$urlArray = getUrlArray();
|
||||
if (!empty($urlArray[1]) && $level == 0) {
|
||||
$level = getLevel($urlArray[1]);
|
||||
}
|
||||
else if (!is_numeric($level)){
|
||||
$level = getLevel($level);
|
||||
}
|
||||
|
||||
if (isSuperAdmin()) {
|
||||
return true;
|
||||
} elseif (isPermitted($urlArray[0], $level)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isViewPermitted($level = '')
|
||||
{
|
||||
$urlArray = getUrlArray();
|
||||
|
||||
//pre($urlArray,1);
|
||||
if (!empty($urlArray[1]) && $level == '') {
|
||||
$level = $urlArray[1];
|
||||
}
|
||||
$level = getLevel($level);
|
||||
if (isViewable($level)) {
|
||||
return true;
|
||||
} else {
|
||||
show_404();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getLevel($val)
|
||||
{
|
||||
switch ($val) {
|
||||
case 'view':
|
||||
return 1;
|
||||
break;
|
||||
case '':
|
||||
return 1;
|
||||
break;
|
||||
case 'add':
|
||||
return 2;
|
||||
break;
|
||||
case 'edit':
|
||||
return 2;
|
||||
break;
|
||||
case 'update':
|
||||
return 2;
|
||||
break;
|
||||
case 'delete':
|
||||
return 3;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user