Skip to content

Instantly share code, notes, and snippets.

View ranafaraz's full-sized avatar

Rana Faraz ranafaraz

View GitHub Profile
@ranafaraz
ranafaraz / select2 typing issue.php
Created July 14, 2021 05:43
If we place a select2 in a pop up form, it do not allow to type. Use this piece of code to resolve this issue.
// globally override Bootstrap's behavior:
// Do this before you initialize any of your modals
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
@ranafaraz
ranafaraz / 01 - Electrical.sql
Created March 18, 2021 09:29
Queries relevant to Balance sheet of IUB
-- Electrical Equipment / Office Equipment
SELECT
SUM(lad.netamttoinvoice) AS "2016-17",
-- 2017 - 2018 - Started
(SELECT
SUM(lad.netamttoinvoice) AS "2017-18"
@ranafaraz
ranafaraz / developmental_utilization.sql
Created March 11, 2021 21:20
Query to calculate the Utilization of Developmental Budget Heads
SELECT
SUM(i.grandtotal) AS total_utilization
FROM
adempiere.c_invoice i
INNER JOIN adempiere.gl_budget b ON (( b.gl_budget_id = i.gl_budget_id ))
INNER JOIN adempiere.c_invoiceline il ON (( il.c_invoice_id = i.c_invoice_id ))
INNER JOIN adempiere.vwcharge vc ON (( vc.c_charge_id = il.c_charge_id ))
INNER JOIN adempiere.vwchart vwc ON (( vwc.c_elementvalue_id = vc.account_id ))
WHERE
i.isactive = 'Y'
@ranafaraz
ranafaraz / non_developmental_budget.sql
Created March 11, 2021 20:04
This query will get the allocated budget for
SELECT
SUM(f.amt) AS allocated_budget
FROM
adempiere.gl_fund f
INNER JOIN adempiere.gl_budget b ON (( b.gl_budget_id = f.gl_budget_id ))
INNER JOIN adempiere.vwchart vwc ON (( vwc.c_elementvalue_id = f.c_elementvalue_id ))
WHERE
f.isactive = 'Y'
AND
f.ad_client_id = 1000000
@ranafaraz
ranafaraz / developmental_budget.sql
Created March 11, 2021 19:58
This query will get the allocated budget against A09 - Expenditure on Acquiring of Physical Assets; A12 - Civil Works; A13 - Repair and Maintenance
SELECT
SUM(f.amt) AS allocated_budget
FROM
adempiere.gl_fund f
INNER JOIN adempiere.gl_budget b ON (( b.gl_budget_id = f.gl_budget_id ))
INNER JOIN adempiere.vwchart vwc ON (( vwc.c_elementvalue_id = f.c_elementvalue_id ))
WHERE
f.isactive = 'Y'
AND
f.ad_client_id = 1000000
@ranafaraz
ranafaraz / Withholding.sql
Created March 11, 2021 19:12
Query to get withholdings in iDempiere
SELECT
wh.documentno AS wh_docno,
i.documentno AS invioce_docno,
(SELECT t.name FROM adempiere.c_tax t WHERE t.c_tax_id = wh.c_tax_id) AS tax,
(SELECT wt.name FROM adempiere.lco_withholdingtype wt WHERE wt.lco_withholdingtype_id = wh.lco_withholdingtype_id) AS wh_type,
wh.wh_other_baseamt as base_amt,
wh.wh_other_percent as wh_percent,
wh.other_charge as deducted_amt,
wh.description
FROM
@ranafaraz
ranafaraz / Import Legacy Data.php
Created March 7, 2021 13:35
This snippet contains the script to import legacy data of budget utilization into iDempiere.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "idempiere";
// Creating connection with MySQL - Local DB
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
SELECT
bi.value, -- Unique Identifier for Buildings & Infrastructures.
bi.name, -- Name of the Building or Infrastructure.
bi.description,
bi.location,
(SELECT cm.name FROM f_campus cm WHERE cm.f_campus_id = bi.f_campus_id) AS Campus,
(SELECT c.name FROM city c WHERE c.city_id = bi.city_id) AS city,
bi.longitude,
bi.latitude,
bi.dimentions,
SELECT
l.value, -- Unique Identifier of Land
l.name, -- Name of the Land
l.description,
l.location,
(SELECT c.name FROM city c WHERE c.city_id = l.city_id) AS city,
l.longitude,
l.latitude,
l.dimentions,
(SELECT u.name FROM c_uom u WHERE u.c_uom_id = l.c_uom_id) AS uom,
@ranafaraz
ranafaraz / Budget Allocation and Utilization.sql
Last active February 24, 2021 13:39
Query to fetch Major Head, Minor Head, Sub Head, Budget Head wise ==> Allocation and Utilization against a specified Budget ID.
SELECT
concat(o.value, ' - ', o.name) AS Org,
concat(vwc.majorheadvalue, ' - ', vwc.majorhead) AS MajorHead,
concat(vwc.minorheadvalue, ' - ', vwc.minerhead) AS MinorHead,
concat(vwc.subheadvalue, ' - ', vwc.subhead) AS SubHead,
concat(vwc.value, ' - ', vwc.name) AS BudgetHead,
SUM(f.amt) AS Allocation,
SUM(i.grandtotal) AS Utilization
FROM