From a81bbf0ca5b59f29efdce5e56f2e4d7127832360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Fri, 25 Oct 2024 14:50:43 +0200 Subject: [PATCH] CMXX - Update billing report --- api/v1/get/contracts.php | 16 ++++++++-------- api/v2/get/contracts.php | 16 ++++++++-------- report_contracts_billing.php | 19 +++++++++++++------ settings/settingsprofiles.php | 2 +- settings/translations/translations_DE.php | 4 ++++ settings/translations/translations_ES.php | 4 ++++ settings/translations/translations_NL.php | 4 ++++ settings/translations/translations_PT.php | 4 ++++ settings/translations/translations_US.php | 4 ++++ 9 files changed, 50 insertions(+), 23 deletions(-) diff --git a/api/v1/get/contracts.php b/api/v1/get/contracts.php index c375187..67ddc90 100644 --- a/api/v1/get/contracts.php +++ b/api/v1/get/contracts.php @@ -22,15 +22,15 @@ switch ($permission) { $whereclause = ''; break; case '3': - $whereclause = ''; + $whereclause = 'WHERE u.view IN (4,5)'; break; case '2': $condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search; - $whereclause = 'WHERE accounthierarchy like :condition '; + $whereclause = 'WHERE c.accounthierarchy like :condition AND u.view IN (1,2,3)'; break; default: $condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search.'___shipto___'.substr($partner->shipto, 0, strpos($partner->shipto, "-")).'%___location___'.substr($partner->location, 0, strpos($partner->location, "-")).'%'; - $whereclause = 'WHERE accounthierarchy like :condition '; + $whereclause = 'WHERE c.accounthierarchy like :condition AND u.view IN (1,2,3)'; break; } @@ -53,11 +53,11 @@ if(isset($get_content) && $get_content!=''){ } elseif ($v[0] == 'search') { //build up search - $clause .= ' AND reference like :'.$v[0]; + $clause .= ' AND c.reference like :'.$v[0]; } elseif ($v[0] == 'servicetool') { //build up search - $clause .= ' AND servicetool like :'.$v[0]; + $clause .= ' AND c.servicetool like :'.$v[0]; } else {//create clause $clause .= ' AND '.$v[0].' = :'.$v[0]; @@ -72,15 +72,15 @@ if(isset($get_content) && $get_content!=''){ //Define Query if(isset($criterias['totals']) && $criterias['totals'] ==''){ //Request for total rows - $sql = 'SELECT count(*) as count FROM contracts '.$whereclause.''; + $sql = 'SELECT count(*) as count FROM contracts c JOIN users u ON c.createdby = u.username '.$whereclause.''; } elseif (isset($criterias['list']) && $criterias['list'] =='') { //SQL for Paging - $sql = 'SELECT * FROM contracts '.$whereclause.''; + $sql = 'SELECT * FROM contracts c JOIN users u ON c.createdby = u.username '.$whereclause.''; } else { //SQL for Paging - $sql = 'SELECT * FROM contracts '.$whereclause.' LIMIT :page,:num_products'; + $sql = 'SELECT * FROM contracts c JOIN users u ON c.createdby = u.username '.$whereclause.' LIMIT :page,:num_products'; } $stmt = $pdo->prepare($sql); diff --git a/api/v2/get/contracts.php b/api/v2/get/contracts.php index d03c5ce..55461a7 100644 --- a/api/v2/get/contracts.php +++ b/api/v2/get/contracts.php @@ -22,15 +22,15 @@ switch ($permission) { $whereclause = ''; break; case '3': - $whereclause = ''; + $whereclause = 'WHERE u.view IN (4,5)'; break; case '2': $condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search; - $whereclause = 'WHERE accounthierarchy like :condition '; + $whereclause = 'WHERE accounthierarchy like :condition AND u.view IN (1,2,3)'; break; default: $condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search.'___shipto___'.substr($partner->shipto, 0, strpos($partner->shipto, "-")).'%___location___'.substr($partner->location, 0, strpos($partner->location, "-")).'%'; - $whereclause = 'WHERE accounthierarchy like :condition '; + $whereclause = 'WHERE accounthierarchy like :condition AND u.view IN (1,2,3)'; break; } @@ -53,11 +53,11 @@ if(isset($get_content) && $get_content!=''){ } elseif ($v[0] == 'search') { //build up search - $clause .= ' AND reference like :'.$v[0]; + $clause .= ' AND c.reference like :'.$v[0]; } elseif ($v[0] == 'servicetool') { //build up search - $clause .= ' AND servicetool like :'.$v[0]; + $clause .= ' AND c.servicetool like :'.$v[0]; } else {//create clause $clause .= ' AND '.$v[0].' = :'.$v[0]; @@ -72,15 +72,15 @@ if(isset($get_content) && $get_content!=''){ //Define Query if(isset($criterias['totals']) && $criterias['totals'] ==''){ //Request for total rows - $sql = 'SELECT count(*) as count FROM contracts '.$whereclause.''; + $sql = 'SELECT count(*) as count FROM contracts c JOIN users u ON c.createdby = u.username '.$whereclause.''; } elseif (isset($criterias['list']) && $criterias['list'] =='') { //SQL for Paging - $sql = 'SELECT * FROM contracts '.$whereclause.''; + $sql = 'SELECT * FROM contracts c JOIN users u ON c.createdby = u.username '.$whereclause.''; } else { //SQL for Paging - $sql = 'SELECT * FROM contracts '.$whereclause.' LIMIT :page,:num_products'; + $sql = 'SELECT * FROM contracts c JOIN users u ON c.createdby = u.username '.$whereclause.' LIMIT :page,:num_products'; } $stmt = $pdo->prepare($sql); diff --git a/report_contracts_billing.php b/report_contracts_billing.php index ed48505..24e584c 100644 --- a/report_contracts_billing.php +++ b/report_contracts_billing.php @@ -40,8 +40,8 @@ $status = isset($_GET['status']) ? '&status='.$_GET['status'] : ''; $search = isset($_GET['search']) ? '&search='.$_GET['search'] : ''; //SET DEFAULT VALUES -$ye = (isset($_GET['year'])? $_GET['year'] : $curYear); -$mo = (isset($_GET['month'])? $_GET['month'] : ''); +$ye = ((isset($_GET['year']) && $_GET['year'] !='' )? $_GET['year'] : $curYear); +$mo = ((isset($_GET['month']) && $_GET['month'] !='')? $_GET['month'] : $curMonth_name); $qu = ((isset($_GET['month']) ? (int)ceil(date("n",strtotime($mo)) / 3): $curQuarter)); // Determine the URL @@ -157,10 +157,11 @@ $view .= ' $view .= '
| '.$contract_id.' | +# | '.$contract_status.' | '.$contract_account.' | '.$contract_type.' | @@ -168,8 +169,9 @@ $view .= ''.$contract_start_date.' | '.$contract_end_date.' | '.$contract_reference.' | -BillingCount | -'.$contract_service.' | +'.$contract_billing_count.' | +'.$contract_service_2.' | +'.$contract_overrun.' | '.$general_actions.' |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| '.$response['rowID'].' | @@ -258,7 +264,8 @@ $view .= ''.$date.' | '.$response['reference'].' | '.$billing_run.' | -'.$response['service_count'].' | +'.$response['service_count'].' | +'.$usage_percentage.' | '.$general_view .' |