Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
config
:
function.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php function encryptIt($q) { $cryptKey = 'NGoApP1bgIAdeQYZ'; $method = "AES-256-CBC"; // This is equivalent to MCRYPT_RIJNDAEL_256 in OpenSSL. $key = hash('sha256', $cryptKey, true); // Hash the key using SHA-256 for consistency. $iv = substr(hash('md5', $cryptKey), 0, 16); // Generate an IV from the key (MD5 hash). $qEncoded = base64_encode(openssl_encrypt($q, $method, $key, OPENSSL_RAW_DATA, $iv)); return $qEncoded; } function decryptIt($q) { $cryptKey = 'NGoApP1bgIAdeQYZ'; $method = "AES-256-CBC"; // The OpenSSL cipher method. $key = hash('sha256', $cryptKey, true); // Hash the key using SHA-256. $iv = substr(hash('md5', $cryptKey), 0, 16); // Generate a 16-byte IV from the MD5 hash of the key. // Decrypt the base64-decoded string using openssl_decrypt $qDecoded = openssl_decrypt(base64_decode($q), $method, $key, OPENSSL_RAW_DATA, $iv); return rtrim($qDecoded, "\0"); // Trim any padding. } function category($category_id) { global $cn; $sqlCategory = mysqli_query($cn,"select name from `tbl_category` where id='".$category_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function categorySlugUrl($category_id) { global $cn; $sqlCategory = mysqli_query($cn,"select slug_url from `tbl_category` where id='".$category_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['slug_url']; } function polishName($polish_id) { global $cn; $sqlCategory = mysqli_query($cn,"select name from `tbl_polish` where id='".$polish_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function sizeName($size_id) { global $cn; $sqlCategory = mysqli_query($cn,"select name from `tbl_size` where id='".$size_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function stoneName($stone_id) { global $cn; $sqlCategory = mysqli_query($cn,"select name from `tbl_stone` where id='".$stone_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function categorySlugToId($slug_url) { global $cn; $sqlCategory = mysqli_query($cn,"select `id` from `tbl_category` where `slug_url`='".$slug_url."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['id']; } function categorySlugToName($slug_url) { global $cn; $sqlCategory = mysqli_query($cn,"select `name` from `tbl_category` where `slug_url`='".$slug_url."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function subcategorySlugToId($slug_url) { global $cn; $sqlCategory = mysqli_query($cn,"select `id` from `tbl_subcategory` where `slug_url`='".$slug_url."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['id']; } function subcategorySlugToName($slug_url) { global $cn; $sqlCategory = mysqli_query($cn,"select `name` from `tbl_subcategory` where `slug_url`='".$slug_url."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function subcategorySlugToCategoryName($slug_url) { global $cn; $sqlCategory = mysqli_query($cn,"select `category_id` from `tbl_subcategory` where `slug_url`='".$slug_url."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return category($sqlCategoryData['category_id']); } function subcategorySlugToCategorySlug($slug_url) { global $cn; $sqlCategory = mysqli_query($cn,"select `category_id` from `tbl_subcategory` where `slug_url`='".$slug_url."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return categorySlugUrl($sqlCategoryData['category_id']); } function productDefaultPhoto($productId) { global $cn; $sqlProduct = mysqli_query($cn,"select `image` from `tbl_product` where `id`='".$productId."'"); $sqlProductData = mysqli_fetch_array($sqlProduct); $ProductImg = explode("$",$sqlProductData['image']); return $ProductImg[0]; } function state($state_id) { global $cn; $sqlCategory = mysqli_query($cn,"select name from `tbl_state` where id='".$state_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function currencyPrice($price) { global $cn; if(isset($_SESSION['currency'])) { $sqlCategory = mysqli_query($cn,"select currency_symbol,value from `tbl_currency` where `name`='".$_SESSION['currency']."'"); } else { $sqlCategory = mysqli_query($cn,"select currency_symbol,value from `tbl_currency` where 1"); } $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['currency_symbol']." ".number_format($price/$sqlCategoryData['value'],2); } function city($city_id) { global $cn; $sqlCategory = mysqli_query($cn,"select name from `tbl_city` where id='".$city_id."'"); $sqlCategoryData = mysqli_fetch_array($sqlCategory); return $sqlCategoryData['name']; } function orderTotal($order_id) { global $cn; $actualPrice = 0; $discount = 0; $afterDiscountPrice = 0; $gst = 0; $afterGstPrice = 0; $orderTotal = 0; $sqlInvoice2 = mysqli_query($cn,"select * from `tbl_order` where `order_id`='".$order_id."'"); while($sqlInvoiceData2 = mysqli_fetch_array($sqlInvoice2)) { $discount_type = $sqlInvoiceData2['discount_type']; $discount_amount = $sqlInvoiceData2['discount_amount']; if($sqlInvoiceData2['discount_type']=='P') { $actualPrice = $sqlInvoiceData2['price']*$sqlInvoiceData2['qty']; $discount = ($actualPrice/100)*$sqlInvoiceData2['discount_amount']; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } else { $actualPrice = $sqlInvoiceData2['price']*$sqlInvoiceData2['qty']; $discount = 0; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } $orderTotal = $orderTotal + $afterGstPrice; } $sqlItem = mysqli_query($cn,"select * from `tbl_order_item` where `order_id`='".$order_id."'"); while($sqlItemData = mysqli_fetch_array($sqlItem)) { if($discount_type=='P') { $actualPrice = $sqlItemData['item_price']*$sqlItemData['item_qty']; $discount = ($actualPrice/100)*$discount_amount; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } else { $actualPrice = $sqlItemData['item_price']*$sqlItemData['item_qty']; $discount = 0; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } $orderTotal = $orderTotal + $afterGstPrice; } if($discount_type=='F') { $orderTotal = $orderTotal - $discount_amount; } return round($orderTotal); } function orderBeforeGstTotal($order_id) { global $cn; $actualPrice = 0; $discount = 0; $afterDiscountPrice = 0; $gst = 0; $afterGstPrice = 0; $orderTotal = 0; $sqlInvoice2 = mysqli_query($cn,"select * from `tbl_order` where `order_id`='".$order_id."'"); while($sqlInvoiceData2 = mysqli_fetch_array($sqlInvoice2)) { $discount_type = $sqlInvoiceData2['discount_type']; $discount_amount = $sqlInvoiceData2['discount_amount']; if($sqlInvoiceData2['discount_type']=='P') { $actualPrice = $sqlInvoiceData2['price']*$sqlInvoiceData2['qty']; $discount = ($actualPrice/100)*$sqlInvoiceData2['discount_amount']; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } else { $actualPrice = $sqlInvoiceData2['price']*$sqlInvoiceData2['qty']; $discount = 0; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } $orderTotal = $orderTotal + $actualPrice; } $sqlItem = mysqli_query($cn,"select * from `tbl_order_item` where `order_id`='".$order_id."'"); while($sqlItemData = mysqli_fetch_array($sqlItem)) { if($discount_type=='P') { $actualPrice = $sqlItemData['item_price']*$sqlItemData['item_qty']; $discount = ($actualPrice/100)*$discount_amount; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } else { $actualPrice = $sqlItemData['item_price']*$sqlItemData['item_qty']; $discount = 0; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; } $orderTotal = $orderTotal + $actualPrice; } if($discount_type=='F') { $orderTotal = $orderTotal - $discount_amount; } return round($orderTotal); } function orderIgstTotal($order_id) { global $cn; $actualPrice = 0; $discount = 0; $afterDiscountPrice = 0; $gst = 0; $afterGstPrice = 0; $orderTotal = 0; $totalGst = 0; $sqlInvoice2 = mysqli_query($cn,"select * from `tbl_order` where `order_id`='".$order_id."'"); while($sqlInvoiceData2 = mysqli_fetch_array($sqlInvoice2)) { $discount_type = $sqlInvoiceData2['discount_type']; $discount_amount = $sqlInvoiceData2['discount_amount']; if($sqlInvoiceData2['discount_type']=='P') { $actualPrice = $sqlInvoiceData2['price']*$sqlInvoiceData2['qty']; $discount = ($actualPrice/100)*$sqlInvoiceData2['discount_amount']; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; $totalGst = $totalGst + $gst; } else { $actualPrice = $sqlInvoiceData2['price']*$sqlInvoiceData2['qty']; $discount = 0; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; $totalGst = $totalGst + $gst; } $orderTotal = $orderTotal + $afterGstPrice; } $sqlItem = mysqli_query($cn,"select * from `tbl_order_item` where `order_id`='".$order_id."'"); while($sqlItemData = mysqli_fetch_array($sqlItem)) { if($discount_type=='P') { $actualPrice = $sqlItemData['item_price']*$sqlItemData['item_qty']; $discount = ($actualPrice/100)*$discount_amount; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; $totalGst = $totalGst + $gst; } else { $actualPrice = $sqlItemData['item_price']*$sqlItemData['item_qty']; $discount = 0; $afterDiscountPrice = $actualPrice-$discount; $gst = ($afterDiscountPrice/100)*18; $afterGstPrice = $afterDiscountPrice +$gst; $totalGst = $totalGst + $gst; } $orderTotal = $orderTotal + $afterGstPrice; } if($discount_type=='F') { $orderTotal = $orderTotal - $discount_amount; } return round($totalGst); } function generatePIN($digits = 4){ $i = 0; //counter $pin = ""; //our default pin is blank. while($i < $digits){ //generate a random number between 0 and 9. $pin .= mt_rand(0, 9); $i++; } return $pin; } function pendingOrder() { global $cn; $sql = mysqli_query($cn,"SELECT `id` FROM `tbl_order` where `status`=0 group by `order_id`")or die(mysql_error()); $data = mysqli_num_rows($sql); return $data; } function approvedOrder() { global $cn; $sql = mysqli_query($cn,"SELECT `id` FROM `tbl_order` where `status`=1 group by `order_id`")or die(mysql_error()); $data = mysqli_num_rows($sql); return $data; } function packedOrder() { global $cn; $sql = mysqli_query($cn,"SELECT `id` FROM `tbl_order` where `status`=2 group by `order_id`")or die(mysql_error()); $data = mysqli_num_rows($sql); return $data; } function dispatchOrder() { global $cn; $sql = mysqli_query($cn,"SELECT `id` FROM `tbl_order` where `status`=3 group by `order_id`")or die(mysql_error()); $data = mysqli_num_rows($sql); return $data; } function pickedOrder() { global $cn; $sql = mysqli_query($cn,"SELECT `id` FROM `tbl_order` where `status`=4 group by `order_id`")or die(mysql_error()); $data = mysqli_num_rows($sql); return $data; } function deliveredOrder() { global $cn; $sql = mysqli_query($cn,"SELECT `id` FROM `tbl_order` where `status`=5 group by `order_id`")or die(mysql_error()); $data = mysqli_num_rows($sql); return $data; } function search($array, $search_list) { // Create the result array $result = array(); // Iterate over each array element foreach ($array as $key => $value) { // Iterate over each search condition foreach ($search_list as $k => $v) { // If the array element does not meet // the search condition then continue // to the next element if (!isset($value[$k]) || $value[$k] != $v) { // Skip two loops continue 2; } } // Append array element's key to the //result array $result[] = $value; } // Return result return $result; } ?>