'', 'status' => 'Lead', 'accountdetails' => [ 'billcompany' => '', 'billfirstname' => '', 'billlastname' => '', 'billemail' => '', 'billphonenumber' => '', 'contactfirstname' => '', 'contactlastname' => '', 'contactemail' => '', 'contactphonenumber' => '', 'billstreetadress' => '', 'billpostalcode' => '', 'billdistrict' => '', 'billcity' => '', 'billstate' => '', 'billcountry' => '', 'streetadress' => '', 'postalcode' => '', 'district' => '', 'city' => '', 'state' => '', 'country' => '', 'vatnumber' => '', 'loghandlername' => '', 'loghandleraccount' => '' ], 'created' => $date, 'createdby' => $_SESSION['authorization']['clientID'], 'accounthierarchy' => [ 'salesid' => '', 'soldto' => '' ] ]; //defaults $accountdetails = json_decode(json_encode($account['accountdetails'],JSON_UNESCAPED_UNICODE)); $accounthierarchy = json_decode(json_encode($account['accounthierarchy'],JSON_UNESCAPED_UNICODE)); $rowID = $_GET['rowID'] ?? ''; if ($rowID !=''){ $url = 'index.php?page=account&rowID='.$rowID.''; } else { $url = 'index.php?page=accounts'; } if (isset($_GET['rowID'])) { // ID param exists, edit an existing product //CALL TO API $api_url = '/v1/accounts/rowID='.$rowID; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;} $account = json_decode(json_encode($responses[0]), true); $accountdetails = json_decode($account['accountdetails']); $accounthierarchy = json_decode($account['accounthierarchy']); 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/accounts', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=account&rowID='.$rowID.'&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/accounts', $payload); // Redirect and delete product if ($responses === 'NOK'){ } else { header('Location: index.php?page=accounts&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/accounts', $payload); if ($responses === 'NOK'){ } else { header('Location: index.php?page=accounts&success_msg=1'); exit; } } } template_header('Account', 'account', 'manage'); $view ='

'.$account_h2.'

'; if ($delete_allowed === 1){ $view .= ''; } if ($update_allowed === 1){ $view .= ''; } $view .= '
'; $view .= '
'.$view_account_information.'
'; //Define Permission & Profile $view .= '
'; $view .= '
'.$view_account_contact.'
'; $view .= '
'.$account_billing.'
'; $view .= '
'.$account_shipping.'
'; //Dropdown $partner_data = json_decode($_SESSION['authorization']['partnerhierarchy']); $soldto_dropdown = listPartner('soldto',$_SESSION['authorization']['permission'],$accounthierarchy->soldto,''); $view .= '
'.$tab3.'
'.$soldto_dropdown.'
'; $view .= '
'; //Output echo $view; template_footer()?>