'', 'equipmentid' => $_GET['equipmentID'] ?? '', 'type' => '', 'description' => '', 'created' => $date, 'createdby' => $_SESSION['username'] ]; //defaults $rowID = $_GET['rowID'] ?? ''; if ($rowID !=''){ $url = 'index.php?page=history&equipmentID='.$_GET['equipmentID']; } else { $url = 'index.php?page=equipment&equipmentID='.$_GET['equipmentID']; } if (isset($_GET['rowID'])) { // ID param exists, edit an existing product //CALL TO API $api_url = '/v1/history/historyid='.$rowID; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;} $history = 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/history', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=history&equipmentID='.$_GET['equipmentID'].'&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/history', $payload); // Redirect and delete product if ($responses === 'NOK'){ } else { header('Location: index.php?page=history&equipmentID='.$_GET['equipmentID'].'&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/history', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=history$equipmentID='.$_GET['equipmentID'].'&success_msg=1'); exit; } } } template_header('history', 'history', 'manage'); $view ='

'.$history_h2.'

'; if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ $view .= ''; } $view .= '
'; $view .= '
'.$tab1.'
'; $view .= '
'; $view .= '
'.$tab3.'
'; $view .= '
'; $view .= '
'; //Output echo $view; template_footer();