'', 'type' => '', 'status' => '', 'accountID' => '', 'start_date' => '', 'duration' => '', 'service_count' => '', 'contract_details' => '', 'created' => '', 'createdby' => '', 'billing_plan' => '', 'pricing' => '', 'reference' => '', 'servicetool' => '', 'assigned_users' => [] ]; $contract_ID = $_GET['rowID'] ?? ''; if ($contract_ID !=''){ $url = 'index.php?page=contract&rowID='.$contract_ID.''; } else { $url = 'index.php?page=contracts'; } if (isset($_GET['rowID'])) { //CALL TO API $api_url = '/v1/contracts/rowID='.$contract_ID; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;} $contract = json_decode(json_encode($responses[0]), true); if ($update_allowed === 1){ if (isset($_POST['submit'])) { //GET ALL POST DATA $data = json_encode($_POST, JSON_UNESCAPED_UNICODE); //Secure data $payload = generate_payload($data); //API call $responses = ioServer('/v1/contracts', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=contracts&success_msg=2'); exit; } } } if ($delete_allowed === 1){ if (isset($_POST['delete'])) { //GET ALL POST DATA $data = json_encode($_POST , JSON_UNESCAPED_UNICODE); //Secure data $payload = generate_payload($data); //API call $responses = ioServer('/v1/contracts', $payload); // Redirect and delete product if ($responses === 'NOK'){ } else { header('Location: index.php?page=contracts&success_msg=3'); exit; } } } } else { // Create a new product if (isset($_POST['submit']) && $create_allowed === 1) { //GET ALL POST DATA $data = json_encode($_POST, JSON_UNESCAPED_UNICODE); //Secure data $payload = generate_payload($data); //API call $responses = ioServer('/v1/contracts', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=contracts&success_msg=1'); exit; } } } template_header('Contract', 'contract', 'manage'); $view ='

'.$contract_h2.'

'.$button_cancel.' '; if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ $view .= ''; } $view .= '
'; $view .= '
'.$tab1 .' '.$tab2.' '.$tab3.'
'; $view .='
'; //Define end_date based on duration if ($contract['duration'] !='' && $contract['start_date'] !=''){ $date = date('Y-m-d', strtotime('+'.$contract['duration'].' months', strtotime($contract['start_date']))); $view .= '
'; } $view .= '
'; //GET PARTNER DROPDOWN $soldto_dropdown = listAccounts('accountID',$_SESSION['permission'],$contract['accountID']); $view .= '
'.$soldto_dropdown.'
'; //Check for assigned users $assigned_users = (is_string($contract['assigned_users']))? json_decode($contract['assigned_users']) : ''; if (is_array($assigned_users)) { foreach ($assigned_users as $user){ $view .= ''; } } else{ $view .= ''; } $view .='
'.$contract_assigned_users_add.'
'; $view .= '
'; $view .= '
'; //Output echo $view; template_footer()?>