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 = ""; 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 "$Name"; } else { echo ""; } } function linkLedger($Account) { $ci = &get_instance(); echo "$Account->account_name"; } function linkGroup($Group) { $ci = &get_instance(); echo "$Group->acgroup_name"; } function linkCategory($Category) { $ci = &get_instance(); if ($Category) : echo "$Category->accategory_name"; endif; } function myCurrency($number, $inline = false) { if ($number == 0) { if (!$inline) return " "; else return " "; } if ($number < 0) return "(" . number_format(abs($number), 2, ".", ",") . ")"; if (!$inline) return "" . number_format($number, 2, ".", ",") . ""; else return "" . number_format($number, 2, ".", ",") . ""; } function showNill() { return "Nill"; } 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; }