'', 'status' => '', 'name' => '', 'created' => '', 'createdby' => '', 'updated' => '', 'updatedby' => '', 'accounthierarchy' => '' ]; if (isset($_GET['rowID'])) { //CALL TO API $api_url = '/v2/pricelists/rowID='.$_GET['rowID']; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;} $pricelists = json_decode(json_encode($responses[0]), true); //CALL TO API FOR RELATED pricelists $api_url = '/v2/pricelists_items/pricelist_ID='.$_GET['rowID']; $pricelists_items = ioServer($api_url,''); //Decode Payload if (!empty($pricelists_items)){$pricelists_items = json_decode($pricelists_items,true);}else{$pricelists_items = null;} //GET PRODUCTS AND ATTRIBUTES $api_url = '/v2/products/list=price'; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$products = json_decode($responses,true);}else{$products = null;} if ($update_allowed === 1){ if (isset($_POST['submit'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/pricelists', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=pricelists&success_msg=2'); exit; } } if (isset($_POST['add'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/pricelists_items', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=pricelists_manage&rowID='.$_GET['rowID'].''); exit; } } if (isset($_POST['update']) && isset($_POST['item'])) { //Indicator if update has errors $NOK_error = 0; //RUN through all POST items foreach ($_POST['item'] as $attr){ //GET ALL POST DATA $payload = json_encode($attr, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/pricelists_items', $payload); if ($responses === 'NOK'){ //NOT correct exit procedure $NOK_error++; exit; } else { $attr_language = $attr['language_key']; } } header('Location: index.php?page=pricelists_manage&rowID='.$_GET['rowID'].''); exit; } } if ($delete_allowed === 1){ if (isset($_POST['delete'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/pricelists', $payload); // Redirect and delete product if ($responses === 'NOK'){ } else { header('Location: index.php?page=pricelists&success_msg=3'); exit; } } } } else { // Create a new variable if (isset($_POST['submit']) && $create_allowed === 1) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/pricelists', $payload); if ($responses === 'NOK'){ } else { //GET ROWID OF CREATED ITEM $pricelists_rowID = json_decode($responses,true); header('Location: index.php?page=pricelists_manage&rowID='.$pricelists_rowID['rowID'].''); exit; } } } //EMPTY VIEW $view = ''; // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 0) { $success_msg = $error_msg_0; } } template_header('Pricelists', 'pricelists', 'manage'); if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .='

'.($pricelists_h2 ?? '').'

'.$button_cancel.' '; if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ $view .= ''; } $view .= '
'; $view .= '
'.$tab1 .' '.$tab3.'
'; //Define Service and User enabled $view .= '
'; $view .= '
'; $view .= '
'; $view .= '
'; if (empty($pricelists_items)){ $view .= ' '; } else { foreach ($pricelists_items as $pricelist_item){ $view .= ' '; } } $view .= '
'.($pricelists_item_status ?? 'Status').' '.($pricelists_item_product_id ?? 'Product ID').' '.($pricelists_item_price ?? 'Price').' '.($pricelists_item_rpp ?? 'RPP').' '.($pricelists_item_price_modifier ?? 'Modifier').' '.$general_created.' '.$general_actions.'
'.($message_no_pricelists ?? 'There are no pricelist items').'
'.getRelativeTime($pricelist_item['created']).'
'; $view .= '
'; //Output echo $view; template_footer() ?>