←':''; //Check if allowed if (isAllowed($page,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'R') === 0){ header('location: index.php'); exit; } //PAGE Security $page_manage = 'contract_manage'; $update_allowed = isAllowed($page_manage ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'U'); $delete_allowed = isAllowed($page_manage ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'D'); $create_allowed = isAllowed($page_manage ,$_SESSION['authorization']['profile'],$_SESSION['authorization']['permission'],'C'); //Close Contracts when end_date expired closeContract(); //GET PARAMETERS $pagination_page = isset($_GET['p']) ? $_GET['p'] : 1; $status = isset($_GET['status']) ? '&status='.$_GET['status'] : ''; $search = isset($_GET['search']) ? '&search='.$_GET['search'] : ''; // Determine the URL $url = 'index.php?page=contracts'.$status.$search; //GET Details from URL $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API $api_url = '/v1/contracts/'.$GET_VALUES; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;} //Return QueryTotal from API $api_url = '/v1/contracts/'.$GET_VALUES.'&totals='; $query_total = ioServer($api_url,''); //Decode Payload if (!empty($query_total)){$query_total = decode_payload($query_total);}else{$query_total = null;} // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = $message_contract_1; } if ($_GET['success_msg'] == 2) { $success_msg = $message_contract_2; } if ($_GET['success_msg'] == 3) { $success_msg = $message_contract_3; } } template_header('contracts', 'contracts','view'); $view = '

'.$contract_h2.' ('.$query_total.')

'.$contract_p .'

'.$back_btn_orgin; if ($create_allowed === 1){ $view .= '+'; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= ' '; $view .= '
'; if (empty($responses)){ $view .= ' '; } else { foreach ($responses as $response){ //Variable translation $status = 'contract_status' . $response->status; $type = 'contract_type'.$response->type; //calculate enddate from duration $date = date('Y-m-d', strtotime('+'.$response->duration.' months', strtotime($response->start_date))); //GetPartnerDetails $partner_data = json_decode($response->accounthierarchy); $view .= ' '; } } $view .= '
'.$contract_id.' '.$contract_status.' '.$contract_account.' '.$contract_type.' '.$contract_start_date.' '.$contract_end_date.' '.$contract_reference.'
'.$message_no_contract.'
'.$response->rowID.' '.(($response->status == 1)? ''.$$status: (($response->status == 3) ? ''.$$status : ''.$$status)).' '.$partner_data->soldto.' '.$$type.' '.$response->start_date.' '.$date.' '.$response->reference.'
'; $view.=''; //OUTPUT echo $view; template_footer(); ?>