CM89 - expired contract handling

This commit is contained in:
“VeLiTi”
2024-09-25 12:01:18 +02:00
parent ffb29b731a
commit ae821d3870
16 changed files with 923 additions and 159 deletions

View File

@@ -48,8 +48,11 @@ $responses = $responses[0];
//------------------------------
$contract_status_text = 'contract_status'.$responses->status ?? '';
$contract_type_text = 'contract_type'.$responses->type ?? '';
$contract_billingplan_text = 'contract_billing'.$responses->billing_plan ?? '';
$servicetools = json_decode($responses->servicetool,true) ?? '';
$assigned_users = json_decode($responses->assigned_users,true) ?? '';
$ignore_lists = json_decode($responses->ignore_list,true) ?? '';
//Partnerdata
$partner_data = json_decode($responses->accounthierarchy);
@@ -114,7 +117,11 @@ $view .= ' <div class="content-block order-details">
<h3>'.$contract_type.'</h3>
<p><span class="status id'.$responses->type.'">'.$$contract_type_text.'</span></p>
</div>
<div class="order-detail">
<div class="order-detail">
<h3>'.$contract_billinglabel.'</h3>
<p><span class="status id'.$responses->billing_plan.'">'.($$contract_billingplan_text ?? '').'</span></p>
</div>
<div class="order-detail">
<h3>'.$contract_start_date.'</h3>
<p>'.$responses->start_date.'</p>
</div>
@@ -130,7 +137,13 @@ $view .= ' <div class="content-block order-details">
<div class="order-detail">
<h3>'.$contract_end_date.'</h3>
<p>'.$date.'</p>
</div>';
</div>
<div class="order-detail">
<h3>'.$contract_service.'</h3>
<p>'.$responses->service_count.'</p>
</div>
';
}
$view .='
@@ -165,22 +178,30 @@ $view .='<div class="content-block order-details">
</div>';
$view .= '</div>';
//Usageview
//get all assigned serialnumbers
$url_input = '';
foreach($servicetools as $service_tool){
$url_input .= $service_tool.',';
}
//get ignore list
$ignored_serialnumbers = '';
if (!empty($ignore_lists) || $ignore_lists != ''){
foreach($ignore_lists as $list){
$ignored_serialnumbers .= $list.',';
}
$ignored_serialnumbers = '&ignore='.substr($ignored_serialnumbers,0,-1);
}
//Return report_usage_servicereports
$api_url = '/v1/application/type=ServiceReport&serialnumber='.substr($url_input,0,-1).'/contract_usage_servicereports';
$api_url = '/v1/application/type=ServiceReport&serialnumber='.substr($url_input,0,-1).$ignored_serialnumbers.'&between='.$responses->start_date.'||'.$date.'/contract_usage_servicereports';
$contract_usage_servicereports = ioServer($api_url,'');
//Decode Payload
if (!empty($contract_usage_servicereports)){$contract_usage_servicereports = decode_payload($contract_usage_servicereports);}else{$contract_usage_servicereports = null;}
$service_events = usageView(json_decode(json_encode($contract_usage_servicereports),true));
$contract_usage_servicereports = json_decode(json_encode($contract_usage_servicereports),true);
$service_events = usageView($contract_usage_servicereports);
$view .= '<div class="content-block">
<div class="block-header">
@@ -192,6 +213,68 @@ $view .= '<div class="content-block">
</div>
';
$usage_billing = usageBilling($contract_usage_servicereports);
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.$contract_billinglabel.'
</div>
<div class="table order-table">
<table>
<head>
<tr>
<th>'.$general_year.'</th>
<th>'.$general_total.'</th>
<th '.(($responses->billing_plan && $responses->billing_plan == 2) ? '' :'style="display:none;"').'>'.$general_quarter.'</th>
<th '.(($responses->billing_plan && $responses->billing_plan == 2) ? '' :'style="display:none;"').'>'.$general_total.'</th>
<th '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'>'.$general_month.'</th>
<th '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'>'.$general_total.'</th>
</tr>
</head>
<tbody>';
foreach($usage_billing as $key => $value){
$view .= '
<tr>
<td>'.$key.'</td>
<td>'.$value['total'].'</td>
<td></td>
<td></td>
<td></td>
</tr>
';
foreach ($value['quarters'] as $key => $value){
$view .= '
<tr '.(($responses->billing_plan && $responses->billing_plan == 2) ? '' :'style="display:none;"').'>
<td></td>
<td></td>
<td>'.$key.'</td>
<td>'.$value['total'].'</td>
<td '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'></td>
<td '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'></td>
</tr>
';
foreach($value['months'] as $key => $value){
$view .= '
<tr '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'>
<td></td>
<td></td>
<td '.(($responses->billing_plan && $responses->billing_plan == 2) ? '' :'style="display:none;"').'></td>
<td '.(($responses->billing_plan && $responses->billing_plan == 2) ? '' :'style="display:none;"').'></td>
<td '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'>'.$key.'</td>
<td '.(($responses->billing_plan && $responses->billing_plan == 1) ? '' :'style="display:none;"').'>'.$value.'</td>
</tr>
';
}
}
}
$view .= '</tbody>
</table>
</div>
</div>
';
$view .= '<div class="content-block">
<div class="block-header">
@@ -229,6 +312,25 @@ $view .= '
</div>
</div>
';
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'. $contract_ignore_serial.'
</div>
<div class="table order-table">
<table class="sortable">
<tbody>';
//Check for ignore list
foreach ($ignore_lists as $list){
$view .= '<tr><td>'.$list.'</td><tr>';
}
$view .= '
</tbody>
</table>
</div>
</div>
';
$view .= '<div class="content-block">
<div class="block-header">
<i class="fa-solid fa-bars fa-sm"></i>'.$tab3.'