'.$equipment_label2.' '.$product_code.' '.$product_name.' '.$product_status.' '; foreach ($excel_data_1 as $key => $val){ //GET ROW ID $api_url = '/v2/application/serialnumber='.$val.'/get_rowID'; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;} //IF rowID is found add to array if (isset ($responses->rowID)){ $output_excel[$val]['rowID'] = $responses->rowID; $output_excel[$val]['serialnumber'] = $val; $output_excel[$val]['productcode'] = $responses->productcode; $output_excel[$val]['productname'] = ${$responses->productname} ?? $responses->productname; $output_excel[$val]['order_ref'] = $_POST['order_ref']; $output_excel[$val]['status'] = $_POST['status']; // Only include salesid/soldto if form fields were visible (hierarchy 0-1) $hierarchyLevel = getHierarchyLevel(json_decode($_SESSION['authorization']['partnerhierarchy'])); if ($hierarchyLevel == 0 || $hierarchyLevel == 1) { if (isset($_POST['salesid'])) { $output_excel[$val]['salesid'] = $_POST['salesid']; } if (isset($_POST['soldto'])) { $output_excel[$val]['soldto'] = $_POST['soldto']; } } if (!empty($_POST['shipto']) || $_POST['shipto'] !=''){ $output_excel[$val]['shipto'] = $_POST['shipto']; } if (!empty($_POST['location']) || $_POST['location'] !=''){ $output_excel[$val]['location'] = $_POST['location']; } //Count total_rowID $total_rowID++; } else { $output_excel_display .= ''.$val.''.$mass_update_not_found.''; //Count total_not_found $total_not_found++; } } // Update all items of array foreach ($output_excel as $data_to_update){ $data = json_encode($data_to_update, JSON_UNESCAPED_UNICODE); //API call $responses = ioServer('/v2/equipments', $data); if ($responses === 'NOK'){ } else { $output_excel_display .= ''.$data_to_update['serialnumber'].''.$data_to_update['productcode'].''.(${$data_to_update['productname']} ?? $data_to_update['productname']).''.$mass_update_correct.''; } } $output_excel_display .= ''; //Totals $total_input = $total_rowID + $total_not_found; $total_summary = '('.$total_rowID.$general_page_of.$total_input.')'; //CHECK if shipto exists if not empty. Use shipto when soldto not available $shipto = (isset($_POST['shipto']) ? $_POST['shipto'] : ''); $customer = (isset($_POST['soldto']) ? $_POST['soldto'] : $shipto); $order_header = '
'.$tab1.'
'.$mass_update_order_ref.''.($_POST['order_ref'] ?? '').'
'.$mass_update_order_total.''.$total_rowID.'
'.$mass_update_customer.''.$customer.'
'; } } // Create success modal if update was completed $success_modal = ''; if ($update_allowed === 1 && isset($_POST['excel_data']) && $output_excel_display != ''){ $success_modal = ' '; } // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { $success_msg = $message_eq_1; } if ($_GET['success_msg'] == 2) { $success_msg = $message_eq_2; } if ($_GET['success_msg'] == 3) { $success_msg = $message_eq_3; } } template_header('Mass update', 'equipment_mass_update', 'view'); $view = '

'.$mass_update_h2.'

'; if ($update_allowed === 1){ $print_btn_class = ($output_excel_display != '') ? 'btn' : 'btn alt'; $view .= ''; $view .= ''; } $view .= '
'; if (isset($success_msg)){ $view .= '

'.$success_msg.'

'; } $view .= '
'; //BUID UP DROPDOWNS $partner = json_decode($_SESSION['authorization']['partnerhierarchy'],true); $salesid_dropdown = listPartner('salesid',$partner['salesid'],'yes',$_SESSION['authorization']['permission']); $soldto_dropdown = listPartner('soldto','','yes',$_SESSION['authorization']['permission']); $shipto_dropdown = listPartner('shipto','','',$_SESSION['authorization']['permission']); $location_dropdown = listPartner('location','','',$_SESSION['authorization']['permission']); $view .='
'; // SHOW SALESID and SOLDTO ONLY TO ADMIN $hierarchyLevel = getHierarchyLevel(json_decode($_SESSION['authorization']['partnerhierarchy'])); if ($hierarchyLevel == 0 || $hierarchyLevel == 1){ $view .='
'.$salesid_dropdown.'
'.$soldto_dropdown.'
'; } $view .='
'.$shipto_dropdown.'
'.$location_dropdown.'
'; $view .= ''; $view .= '
'; if ($update_allowed === 1){ $view .= '
'.$tab3.' '.$total_summary.'
'; } //OUTPUT echo $view; // Output success modal if exists echo $success_modal; echo ' '; template_footer(); ?>