Created
June 2, 2017 01:48
-
-
Save worstn8mare/bac4e0a877c2ed3932d4b54ec8c367ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ecompact ang input ug array $input_holder | |
*/ | |
function bogart($input_holder){ | |
$where = ''; | |
if($date_from && $date_to){ | |
$where += 'and sd_headers.dr_date >= '.$date_from.' and sd_headers.dr_date <= '.$date_to; | |
} | |
if($category_id){ | |
$where += 'and item_categories.id = '.$category_id; | |
} | |
if($sub_category_id){ | |
$where += 'and item_subcategories.id = '.$sub_category_id; | |
} | |
if($description){ | |
$where += 'and ---where closes sa description---'; | |
} | |
return $where; | |
} | |
$header= DB::select(" | |
SELECT sd_headers.dr_type as type, items.description as item_desc, item_categories.name as item_cat, item_subcategories.name as item_sub_cat, | |
sd_details.qty, case | |
when sd_details.type = 'base' then (SELECT bulk_units.name from bulk_units where bulk_units.id = sd_details.uom) | |
ELSE | |
(select short from uoms where uoms.id = sd_details.uom) | |
end as uom, sd_details.price as net_price, sd_details.qty * sd_details.price as sales_price, sd_details.price as cost, | |
(sd_details.qty * sd_details.price) - sd_details.price as margin | |
from sd_details | |
INNER JOIN sd_headers on sd_details.dr_id = sd_headers.id | |
INNER JOIN items on sd_details.item_id = items.id | |
LEFT JOIN item_categories on items.category_id = item_categories.id | |
LEFT JOIN item_subcategories on items.subcategory_id = item_subcategories.id | |
where sd_headers.status = 'Finalized' and sd_headers.a_status in ('1','2') | |
".bogart($input_holder)." ORDER BY items.description asc "); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment