Skip to content

Commit

Permalink
Starting fixing fbs reports
Browse files Browse the repository at this point in the history
  • Loading branch information
dslater82 committed Oct 10, 2024
1 parent 597566b commit f715eba
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 12 deletions.
5 changes: 5 additions & 0 deletions conf/settings.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ define('CFOP_API_KEY','');
define('FBS_ACCESS_KEY','');
define('FBS_SECRET_KEY','');
define('FBS_FACILITY_ID','');
define('FBS_FACILITY_CODE','');
define('FBS_AREACODE','');
define('FBS_LABCODE','');
define('FBS_JOBS_SKUCODE','');
define('FBS_DATA_SKUCODE','');

?>
10 changes: 8 additions & 2 deletions html/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
$month = $_POST['month'];
$year = $_POST['year'];
$type = $_POST['report_type'];
$data = job_functions::get_jobs_fbs_bill($db,$month,$year);
$data = job_functions::get_jobs_fbs_bill($db,$month,$year,
settings::get_fbs_areacode(),settings::get_fbs_facility_code(),
settings::get_fbs_labcode(),settings::get_fbs_jobs_skucode()
);
$filename = $prefix . "-job-fbs-" . $month . "-" . $year . "." . $type;


Expand Down Expand Up @@ -78,7 +81,10 @@
$month = $_POST['month'];
$year = $_POST['year'];
$type = $_POST['report_type'];
$data = data_functions::get_data_fbs_bill($db,$month,$year,settings::get_data_minimal_bill());
$data = data_functions::get_data_fbs_bill($db,$month,$year,settings::get_data_minimal_bill(),
settings::get_fbs_areacode(),settings::get_fbs_facility_code(),settings::get_fbs_labcode(),
settings::get_fbs_data_skucode()
);
$filename = $prefix . "-data-fbs-" . $month . "-" . $year . "." . $type;


Expand Down
4 changes: 2 additions & 2 deletions html/stats_monthly.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
$graph_image = "<img src='graph.php?" . http_build_query($get_array) . "'>";


$graph_form = "<form class='form-inline' name='select_graph' id='select_graph' method='post' action='" . $_SERVER['PHP_SELF'];
$graph_form = "<form name='select_graph' id='select_graph' method='post' action='" . $_SERVER['PHP_SELF'];
$graph_form .= "?year=" . $selected_month->format("Y") . "&month=" . $selected_month->format("m") . "'>";
$graph_form .= "<select class='form-select' name='graph_type' onChange='document.select_graph.submit();'>";

Expand Down Expand Up @@ -148,7 +148,7 @@
<td>$<?php echo data_stats::get_billed_cost($db,$selected_month,$selected_month,true); ?></td>
</tr>
<tr>
<td colspan='2'><?php echo $graph_form; ?></td>
<td colspan='2'><div class='col-sm-2'><?php echo $graph_form; ?></div></td>
</tr>
<tr>
<td colspan='2'><?php echo $graph_image; ?></td>
Expand Down
13 changes: 9 additions & 4 deletions libs/data_functions.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ public static function get_data_custom_bill($db,$month,$year,$minimal_bill = 0.0
return $data_result;
}

public static function get_data_fbs_bill($db,$month,$year,$minimal_bill = 0.01) {
$sql = "SELECT 'IGB' as 'AreaCode','CNRG' as 'FacilityCode', ";
$sql .= "'' as 'LabCode', IF(users.user_supervisor <> 0,CONCAT(supervisors.user_lastname,', ',supervisors.user_firstname),CONCAT(users.user_lastname,', ',users.user_firstname)) as 'LabName', ";
public static function get_data_fbs_bill($db,$month,$year,$minimal_bill = 0.01,$fbs_areacode,$fbs_facilitycode,$fbs_labcode,$fbs_data_skucode) {
$sql = "SELECT :fbs_areacode as 'AreaCode',:fbs_facilitycode as 'FacilityCode', ";
$sql .= ":fbs_labcode as 'LabCode', IF(users.user_supervisor <> 0,CONCAT(supervisors.user_lastname,', ',supervisors.user_firstname), ";
$sql .= "CONCAT(users.user_lastname,', ',users.user_firstname)) as 'LabName', ";
$sql .= "CONCAT(users.user_firstname,users.user_lastname) as 'RequestedBy', ";
$sql .= "users.user_name as 'NAME', CONCAT(cfops.cfop_value,IF(cfops.cfop_activity <> '','-',''),cfops.cfop_activity) as 'CFOP', ";
$sql .= "'BIOCLUSTER' as 'SKU_Code', CONCAT(:month,'-',:year) as 'UsageDate', ";
$sql .= ":fbs_data_skucode as 'SKU_Code', CONCAT(:month,'-',:year) as 'UsageDate', ";
$sql .= "'1.000' as 'Quantity', ROUND(data_bill.data_bill_billed_cost,2) as 'UnitPriceOverride', ";
$sql .= "CONCAT('Biocluster Data - ',SUBSTRING_INDEX(data_dir.data_dir_path,'/',-1)) as 'PrintableComments', ";
$sql .= "'' as 'UsageRef', '' as 'OrderRef', '' as 'PO_Ref','' as 'PayAlias', ";
Expand All @@ -162,6 +163,10 @@ public static function get_data_fbs_bill($db,$month,$year,$minimal_bill = 0.01)
$sql .= "ORDER BY LabName ASC";

$parameters = array(
':fbs_areacode'=>$fbs_areacode,
':fbs_facilitycode'=>$fbs_facilitycode,
':fbs_data_skucode'=>$fbs_data_skucode,
':fbs_labcode'=>$fbs_labcode,
':month'=>$month,
':year'=>$year,
':terabytes'=>data_functions::CONVERT_TERABYTES,
Expand Down
14 changes: 10 additions & 4 deletions libs/job_functions.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ public static function get_all_jobs_by_month($db,$month,$year) {

}

public static function get_jobs_fbs_bill($db,$month,$year) {
$sql = "SELECT 'IGB' as 'AreaCode','CNRG' as 'FacilityCode', ";
$sql .= "'' as 'LabCode', IF(users.user_supervisor <> 0,CONCAT(supervisors.user_lastname,', ',supervisors.user_firstname),CONCAT(users.user_lastname,', ',users.user_firstname)) as 'LabName', ";
public static function get_jobs_fbs_bill($db,$month,$year,$fbs_areacode,$fbs_facilitycode,$fbs_labcode,$fbs_job_skucode) {
$sql = "SELECT :fbs_areacode as 'AreaCode',:fbs_facilitycode as 'FacilityCode', ";
$sql .= "CONCAT(:month,'-',:year) as 'UsageDate', ";
$sql .= ":fbs_labcode as 'LabCode', IF(users.user_supervisor <> 0,CONCAT(supervisors.user_lastname,' ',supervisors.user_firstname),";
$sql .= "CONCAT(users.user_lastname,', ',users.user_firstname)) as 'LabName', ";
$sql .= "CONCAT(users.user_firstname,users.user_lastname) as 'RequestedBy', ";
$sql .= ":fbs_job_skucode as 'SKU_Code', ";
$sql .= "users.user_name as 'NAME', CONCAT(cfops.cfop_value,IF(cfops.cfop_activity <> '','-',''),cfops.cfop_activity) as 'CFOP', ";
$sql .= "'BIOCLUSTER' as 'SKU_Code', CONCAT(:month,'-',:year) as 'UsageDate', ";
$sql .= "'1.000' as 'Quantity', ROUND(SUM(job_bill.job_bill_billed_cost),2) as 'UnitPriceOverride', ";
$sql .= "CONCAT('Biocluster Jobs - ',users.user_name) as 'PrintableComments', ";
$sql .= "'' as 'UsageRef', '' as 'OrderRef', '' as 'PO_Ref','' as 'PayAlias', ";
Expand All @@ -90,6 +92,10 @@ public static function get_jobs_fbs_bill($db,$month,$year) {
$sql .= "GROUP BY job_bill.job_bill_user_id ";
$sql .= "ORDER BY LabName ASC";
$parameters = array(
':fbs_areacode'=>$fbs_areacode,
':fbs_facilitycode'=>$fbs_facilitycode,
':fbs_labcode'=>$fbs_labcode,
':fbs_job_skucode'=>$fbs_job_skucode,
':month'=>$month,
':year'=>$year,
':billtype'=>project::BILLTYPE_CFOP
Expand Down
36 changes: 36 additions & 0 deletions libs/settings.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,42 @@ public static function get_fbs_facility_id() {
return false;

}

public static function get_fbs_facility_code() {
if (defined("FBS_FACILITY_CODE")) {
return FBS_FACILITY_CODE;
}
return "";

}
public static function get_fbs_areacode() {
if (defined("FBS_AREACODE")) {
return FBS_AREACODE;
}
return "";

}
public static function get_fbs_labcode() {
if (defined("FBS_LABCODE")) {
return FBS_LABCODE;
}
return "";
}

public static function get_fbs_jobs_skucode() {
if (defined("FBS_JOBS_SKUCODE")) {
return FBS_JOBS_SKUCODE;
}
return "";
}

public static function get_fbs_data_skucode() {
if (defined("FBS_DATA_SKUCODE")) {
return FBS_DATA_SKUCODE;
}
return "";

}
}

?>

0 comments on commit f715eba

Please sign in to comment.