From 05b0c2bdb1ef5b3ab63c41368381c4c8218ee237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CVeLiTi=E2=80=9D?= <“info@veliti.nl”> Date: Tue, 14 Jan 2025 14:40:01 +0100 Subject: [PATCH] CMXX - Product attributes and initial multi languagal product support --- assets/functions.php | 53 +++++---- buildtool.php | 2 +- equipment.php | 2 +- equipment_manage.php | 2 +- equipments.php | 4 +- equipments_mass_update.php | 4 +- product.php | 4 +- products.php | 2 +- products_attributes.php | 48 ++++---- products_attributes_manage.php | 210 ++++++++++++++++++--------------- report_healthindex.php | 4 +- rma.php | 2 +- rma_manage.php | 4 +- settings/settingsmenu.php | 4 +- settings/settingsprofiles.php | 4 +- settings/settingsviews.php | 1 + translation_manage.php | 83 ++++++------- translations.php | 3 +- 18 files changed, 234 insertions(+), 202 deletions(-) diff --git a/assets/functions.php b/assets/functions.php index 18167e9..6364ea8 100644 --- a/assets/functions.php +++ b/assets/functions.php @@ -2921,29 +2921,42 @@ function getRelativeTime($timestamp) { function generateLanguageFile($language_key,$token){ + function generateFile($language_key,$token){ //GET TRANSLATION RECORDS $api_url = '/v2/translations/generatefile='.$language_key; $responses = ioAPIv2($api_url,'',$token); - if (!empty($responses)){ - //define translation variable - $translation = ''; + //Target dir + $target_dir = dirname(__FILE__,2).'/settings/translations/'; + //Filename + $input_file = $target_dir.'translations_'.strtoupper($language_key).'.php'; + //store translation to the file + file_put_contents($input_file, $translation); + } + } + + if ($language_key != ''){ + generateFile($language_key,$token); + } else { + include_once dirname(__FILE__,2).'/settings/settingsmenu.php'; + + foreach ($supportedLanguages as $language){ + generateFile($language,$token); } - //ADD closure tag for PHP - $translation .= '?>'; - //Target dir - $target_dir = dirname(__FILE__,2).'/settings/translations/'; - //Filename - $input_file = $target_dir.'translations_'.strtoupper($language_key).'.php'; - //store translation to the file - file_put_contents($input_file, $translation); - } + } + } \ No newline at end of file diff --git a/buildtool.php b/buildtool.php index 6308a77..f9f868e 100644 --- a/buildtool.php +++ b/buildtool.php @@ -59,7 +59,7 @@ $view .= '
$view .=' '; foreach ($messages as $message){ - $view .=''; + $view .=''; } $view .=' diff --git a/equipment.php b/equipment.php index 67b4876..8557d4b 100644 --- a/equipment.php +++ b/equipment.php @@ -170,7 +170,7 @@ $view .= '

'.$product_name.'

-

'.(($view_product == 1)? ''.$responses->productname.'':$responses->productname).'

+

'.(($view_product == 1)? ''.(${$responses->productname} ?? $responses->productname).'':(${$responses->productname} ?? $responses->productname)).'

'; $picture = glob("./assets/images/products/".$responses->productcode.".{jpg,jpeg,png,gif}", GLOB_BRACE); diff --git a/equipment_manage.php b/equipment_manage.php index 768deb2..f2553ea 100644 --- a/equipment_manage.php +++ b/equipment_manage.php @@ -162,7 +162,7 @@ $view .= '
//create product option list $product_option_list =''; foreach ($products as $product){ - $product_option_list .= ' + $product_option_list .= ' '; } diff --git a/equipments.php b/equipments.php index 7e430e5..bb143ff 100644 --- a/equipments.php +++ b/equipments.php @@ -72,7 +72,7 @@ if ($query_products != null){ '; } @@ -231,7 +231,7 @@ $view .= ' '.$indicators.' '.$response->serialnumber.' '.$$status_text.' - '.$response->productcode.'-'.$response->productname.''; + '.$response->productcode.'-'.(${$response->productname} ?? $response->productname).''; $view .= ' '; if (!empty($picture)){ $view .=' diff --git a/equipments_mass_update.php b/equipments_mass_update.php index 8324e53..f3473b5 100644 --- a/equipments_mass_update.php +++ b/equipments_mass_update.php @@ -65,7 +65,7 @@ if ($update_allowed === 1){ $output_excel[$val]['rowID'] = $responses->rowID; $output_excel[$val]['serialnumber'] = $val; $output_excel[$val]['productcode'] = $responses->productcode; - $output_excel[$val]['productname'] = $responses->productname; + $output_excel[$val]['productname'] = ${$responses->productname} ?? $responses->productname; $output_excel[$val]['order_ref'] = $_POST['order_ref']; $output_excel[$val]['status'] = $_POST['status']; $output_excel[$val]['salesid'] = $_POST['salesid']; @@ -100,7 +100,7 @@ if ($update_allowed === 1){ } else { - $output_excel_display .= ''.$data_to_update['serialnumber'].''.$data_to_update['productcode'].''.$data_to_update['productname'].''.$mass_update_correct.''; + $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 .= ''; diff --git a/product.php b/product.php index b067d12..222448e 100644 --- a/product.php +++ b/product.php @@ -78,7 +78,7 @@ if (isset($_GET['success_msg'])) { template_header('Product', 'product', 'view'); $view = '
-

'.$responses->productcode.' - '.$responses->productname.'

+

'.$responses->productcode.' - '.(${$responses->productname} ?? $responses->productname).'

'.$button_cancel.' '; @@ -124,7 +124,7 @@ $view .= '

'.$product_name.'

-

'.$responses->productname.'

+

'.(${$responses->productname} ?? $responses->productname).'

'; $view .=' diff --git a/products.php b/products.php index 6ee91d1..7359b37 100644 --- a/products.php +++ b/products.php @@ -135,7 +135,7 @@ $view .= ' '.(($picture)?'' : '').' - '.$response->productname.' + '.(${$response->productname} ?? $response->productname).' '.$general_view .' '; diff --git a/products_attributes.php b/products_attributes.php index d885978..1cb8530 100644 --- a/products_attributes.php +++ b/products_attributes.php @@ -12,14 +12,14 @@ include_once './settings/settings.php'; //SET ORIGIN FOR NAVIGATION $prev_page = $_SESSION['prev_origin'] ?? ''; -$page = $_SESSION['origin'] = 'translations'; +$page = $_SESSION['origin'] = 'products_attributes'; -/*Check if allowed +//Check if allowed if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){ header('location: index.php'); exit; } -*/ + //GET PARAMETERS $pagination_page = isset($_GET['p']) ? $_GET['p'] : 1; @@ -27,17 +27,17 @@ $status = isset($_GET['status']) ? '&status='.$_GET['status'] : ''; $search = isset($_GET['search']) ? '&search='.$_GET['search'] : ''; // Determine the URL -$url = 'index.php?page=translations'.$status.$search; +$url = 'index.php?page=products_attributes'.$status.$search; //GET Details from URL $GET_VALUES = urlGETdetails($_GET) ?? ''; //CALL TO API -$api_url = '/v2/translations/'.$GET_VALUES; +$api_url = '/v2/products_attributes/'.$GET_VALUES; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;} //Return QueryTotal from API -$api_url = '/v2/translations/'.$GET_VALUES.'&totals='; +$api_url = '/v2/products_attributes/'.$GET_VALUES.'&totals='; $query_total = ioServer($api_url,''); //Decode Payload if (!empty($query_total)){$query_total = json_decode($query_total,true);}else{$query_total = null;} @@ -45,24 +45,24 @@ if (!empty($query_total)){$query_total = json_decode($query_total,true);}else{$q // Handle success messages if (isset($_GET['success_msg'])) { if ($_GET['success_msg'] == 1) { - $success_msg = $message_tv_1; + $success_msg = $message_patt_1; } if ($_GET['success_msg'] == 2) { - $success_msg = $message_tv_2; + $success_msg = $message_patt_2; } if ($_GET['success_msg'] == 3) { - $success_msg = $message_tv_3; + $success_msg = $message_patt_3; } } -template_header('Translations', 'translations','view'); +template_header('Products attributes', 'products_attributes','view'); $view = '
-

'.($text_variables_h2 ?? '').' ('.$query_total.')

-

'.($text_variables_p ?? '').'

+

'.($products_attributes_h2 ?? '').' ('.$query_total.')

+

'.($products_attributes_p ?? '').'

'; @@ -76,12 +76,12 @@ $view .= '
} $view .= '
- '.($button_create_text_variable ?? '').' + '.($button_create_products_attribute ?? '').'
- + @@ -95,8 +95,10 @@ $view .= ' - - + + + + @@ -108,7 +110,7 @@ $view .= ' $view .= ' - + '; } else { @@ -116,9 +118,11 @@ $view .= ' $view .= ' - + + + - + '; @@ -137,9 +141,9 @@ if ($pagination_page > 1) { $view .= ''.$general_first.''; $view .= ''.$general_prev.''; } -$totals = ceil($query_total / $page_rows_translations) == 0 ? 1 : ceil($query_total / $page_rows_translations); +$totals = ceil($query_total / $page_rows_products_attributes) == 0 ? 1 : ceil($query_total / $page_rows_products_attributes); $view .= ' '.$general_page.$pagination_page.$general_page_of.$totals.''; -if ($pagination_page * $page_rows_translations < $query_total){ +if ($pagination_page * $page_rows_products_attributes < $query_total){ $page = $pagination_page+1; $view .= ''.$general_next.''; $view .= ''.$general_last.''; diff --git a/products_attributes_manage.php b/products_attributes_manage.php index 07ac8b0..6c2855b 100644 --- a/products_attributes_manage.php +++ b/products_attributes_manage.php @@ -1,13 +1,13 @@ '', - 'variable' => '', + 'group_status' => '', + 'group_name' => '', + 'group_mandatory' => '', + 'group_type' => '', 'created' => '', 'createdby' => '', 'updated' => '', @@ -27,50 +30,72 @@ $text_variable = [ if (isset($_GET['rowID'])) { //CALL TO API - $api_url = '/v2/translations/rowID='.$_GET['rowID']; + $api_url = '/v2/products_attributes/rowID='.$_GET['rowID']; $responses = ioServer($api_url,''); //Decode Payload if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;} - $text_variable = json_decode(json_encode($responses[0]), true); + $products_attributes = json_decode(json_encode($responses[0]), true); //CALL TO API FOR RELATED TRANSLATIONS - $api_url = '/v2/translations_details/variable_ID='.$_GET['rowID']; - $text_variable_translations = ioServer($api_url,''); + $api_url = '/v2/products_attributes_items/group_id='.$_GET['rowID']; + $products_attributes_items = ioServer($api_url,''); //Decode Payload - if (!empty($text_variable_translations)){$text_variable_translations = json_decode($text_variable_translations,true);}else{$text_variable_translations = null;} + if (!empty($products_attributes_items)){$products_attributes_items = json_decode($products_attributes_items,true);}else{$products_attributes_items = 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/translations', $payload); - + $responses = ioServer('/v2/products_attributes', $payload); + if ($responses === 'NOK'){ } else { - header('Location: index.php?page=translations&success_msg=2'); - exit; + header('Location: index.php?page=products_attributes&success_msg=2'); + exit; } } - if (isset($_POST['update']) || isset($_POST['add'])) { + if (isset($_POST['add'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); + //API call - $responses = ioServer('/v2/translations_details', $payload); + $responses = ioServer('/v2/products_attributes_items', $payload); if ($responses === 'NOK'){ } else { - header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].''); - exit; + header('Location: index.php?page=products_attributes_manage&rowID='.$_GET['rowID'].''); + exit; } } + + if (isset($_POST['update']) && isset($_POST['attributes'])) { + + //RUN through all POST items + foreach ($_POST['attributes'] as $attr){ + + //GET ALL POST DATA + $payload = json_encode($attr, JSON_UNESCAPED_UNICODE); + var_dump($payload); + //API call + $responses = ioServer('/v2/products_attributes_items', $payload); + + if ($responses === 'NOK'){ + //NOT correct exit procedure + exit; + } + } + header('Location: index.php?page=products_attributes_manage&rowID='.$_GET['rowID'].''); + exit; + } } if ($delete_allowed === 1){ @@ -78,12 +103,12 @@ if (isset($_GET['rowID'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); //API call - $responses = ioServer('/v2/translations', $payload); + $responses = ioServer('/v2/products_attributes', $payload); // Redirect and delete product if ($responses === 'NOK'){ } else { - header('Location: index.php?page=translations&success_msg=3'); + header('Location: index.php?page=products_attributes&success_msg=3'); exit; } } @@ -94,15 +119,15 @@ if (isset($_GET['rowID'])) { if (isset($_POST['submit']) && $create_allowed === 1) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); - //API call - $responses = ioServer('/v2/translations', $payload); + //API call + $responses = ioServer('/v2/products_attributes', $payload); if ($responses === 'NOK'){ } else { //GET ROWID OF CREATED ITEM - $variable_rowID = json_decode($responses,true); - header('Location: index.php?page=translation_manage&rowID='.$variable_rowID['rowID'].''); + $group_rowID = json_decode($responses,true); + header('Location: index.php?page=products_attributes_manage&rowID='.$group_rowID['rowID'].''); exit; } } @@ -117,7 +142,7 @@ if (isset($_GET['success_msg'])) { } } -template_header('Translation', 'translation', 'manage'); +template_header('Products attributes', 'products_attributes', 'manage'); if (isset($success_msg)){ $view .= '
@@ -130,8 +155,8 @@ if (isset($success_msg)){ $view .='
-

'.($text_variables_h2 ?? '').'

- '.$button_cancel.' +

'.($products_attributes_h2 ?? '').'

+ '.$button_cancel.' '; if ($delete_allowed === 1){ @@ -150,26 +175,47 @@ $view .= '
'; //Define Service and User enabled -$view .= '
+$view .='
- - - + + +
+
+ + + +
+
+ + +
+
+ + +
+
'; -$view .= '
-
'; - $view .= '
- + - + - + - +
'; $view .= ''; @@ -177,7 +223,8 @@ $view .= ''; $view .= '
- +

'.($products_attributes_group_items ?? 'Groupitems').'

+
@@ -185,8 +232,11 @@ $view .= '
'.($text_variable_rowID ?? '').''.($text_variable_variable ?? '').''.($products_attribute_rowID ?? '').''.($products_attribute_group_status ?? '').''.($products_attribute_group_name ?? '').''.($products_attribute_group_type ?? '').' '.$general_created.' '.$general_actions.'
'.($message_no_text_variables ?? '').''.($message_no_products_attributes ?? '').'
'.$response['rowID'].''.$response['variable'].''.${'general_status_'.$response['group_status']}.''.$response['group_name'].''.${'general_form_'.$response['group_type']}.' '.getRelativeTime($response['created']).''.$general_view .''.$general_view .'
- - + + + + + @@ -194,29 +244,32 @@ $view .= ' '; - if (empty($text_variable_translations)){ + if (empty($products_attributes_items)){ $view .= ' - + '; } else { - foreach ($text_variable_translations as $translation){ + foreach ($products_attributes_items as $items){ $view .= ' - - + + + + + + + - - + + '; } @@ -234,56 +287,23 @@ $view .= ' const newRow = document.createElement(\'tr\'); newRow.innerHTML = ` - - + + + + - + `; tbody.appendChild(newRow); } - function addRow() { - // Get reference to the table body - const tbody = document.querySelector(\'#textTable tbody\'); - console.log("test"); - - // Create new row - const newRow = document.createElement(\'tr\'); - - // Create three cells for the row - const oneCell = document.createElement(\'td\'); - const twoCell = document.createElement(\'td\'); - const threeCell = document.createElement(\'td\'); - const fourCell = document.createElement(\'td\'); - - // Add content to cells - oneCell.innerHTML = \'\' - twoCell.innerHTML = \'\' - fourCell.innerHTML = \'\' - // Append cells to the row - newRow.appendChild(oneCell); - newRow.appendChild(twoCell); - newRow.appendChild(threeCell); - newRow.appendChild(fourCell); - - - // Append row to table body - tbody.appendChild(newRow); - - // Increment counter for next row - rowCounter++; - } diff --git a/report_healthindex.php b/report_healthindex.php index a233a5f..655b595 100644 --- a/report_healthindex.php +++ b/report_healthindex.php @@ -67,7 +67,7 @@ if ($query_products != null){ '; } @@ -195,7 +195,7 @@ $view .= ' - '; + '; $view .= ' - + - - + + '; } @@ -248,42 +279,6 @@ $view .= ' tbody.appendChild(newRow); } - - function addRow() { - // Get reference to the table body - const tbody = document.querySelector(\'#textTable tbody\'); - console.log("test"); - - // Create new row - const newRow = document.createElement(\'tr\'); - - // Create three cells for the row - const oneCell = document.createElement(\'td\'); - const twoCell = document.createElement(\'td\'); - const threeCell = document.createElement(\'td\'); - const fourCell = document.createElement(\'td\'); - - // Add content to cells - oneCell.innerHTML = \'\' - twoCell.innerHTML = \'\' - fourCell.innerHTML = \'\' - // Append cells to the row - newRow.appendChild(oneCell); - newRow.appendChild(twoCell); - newRow.appendChild(threeCell); - newRow.appendChild(fourCell); - - - // Append row to table body - tbody.appendChild(newRow); - - // Increment counter for next row - rowCounter++; - } diff --git a/translations.php b/translations.php index d885978..bc7977f 100644 --- a/translations.php +++ b/translations.php @@ -14,12 +14,11 @@ include_once './settings/settings.php'; $prev_page = $_SESSION['prev_origin'] ?? ''; $page = $_SESSION['origin'] = 'translations'; -/*Check if allowed +//Check if allowed if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){ header('location: index.php'); exit; } -*/ //GET PARAMETERS $pagination_page = isset($_GET['p']) ? $_GET['p'] : 1;
'.($text_variable_translation_languagekey ?? '').''.($text_variable_translation_translation ?? '').''.($products_attributes_item_status ?? 'status').''.($products_attributes_item_name ?? 'name').''.($products_attributes_item_quantity ?? 'quantity').''.($products_attributes_item_position ?? 'position').''.($products_attributes_item_media ?? 'media').' '.$general_created.' '.$general_actions.'
'.($message_no_text_variables ?? '').''.($message_no_products_attributess ?? '').'
- '.getRelativeTime($translation['created']).''.getRelativeTime($items['created']).'
+
'.$indicators.' '.$response->serialnumber.' '.$$status_text.''.$response->productcode.'-'.$response->productname.''.$response->productcode.'-'.(${$response->productname} ?? $response->productname).''; if (!empty($picture)){ $view .=' diff --git a/rma.php b/rma.php index 361d6ec..51faed7 100644 --- a/rma.php +++ b/rma.php @@ -107,7 +107,7 @@ $view .= '

'.$product_name.'

-

'.(($view_product == 1)? ''.$rma_header['productname'].'':'').'

+

'.(($view_product == 1)? ''.(${$rma_header['productname']} ?? $rma_header['productname']).'':'').'

'.$equipment_label10.'

diff --git a/rma_manage.php b/rma_manage.php index c6fbbd1..d642eb2 100644 --- a/rma_manage.php +++ b/rma_manage.php @@ -264,7 +264,7 @@ $view .= '

'.$product_name.'

-

'.(($view_product == 1)? ''.$rma['header']['productname'].'':'').'

+

'.(($view_product == 1)? ''.(${$rma['header']['productname']} ?? $rma['header']['productname']).'':'').'

'.$equipment_label10.'

@@ -289,7 +289,7 @@ $view .= '
- + '; diff --git a/settings/settingsmenu.php b/settings/settingsmenu.php index ff4aaa1..a296a84 100644 --- a/settings/settingsmenu.php +++ b/settings/settingsmenu.php @@ -13,7 +13,7 @@ $main_menu = array ('dashboard','sales','buildtool','cartests','marketing','equi //Sub menus $equipments_sub = array('equipments','servicereports','rmas','histories','firmwaretool','equipments_mass_update'); $sales_sub = array('accounts','contracts'); -$products_sub = array('products','attributes'); +$products_sub = array('products','products_attributes'); $admin_sub = array('users','communications','partners'); $reporting_sub = array('report_build','report_contracts_billing','report_healthindex','report_usage'); $settings_sub = array('config','translations','logfile','maintenance','profiles'); @@ -68,7 +68,7 @@ $urls = array( "icon" => "fas fa-box-open", "name" => "menu_products" ), - "attributes" => array( + "products_attributes" => array( "url" => "products_attributes", "selected" => "products_attributes", "icon" => "fas fa-box-open", diff --git a/settings/settingsprofiles.php b/settings/settingsprofiles.php index ec2c942..c98b44b 100644 --- a/settings/settingsprofiles.php +++ b/settings/settingsprofiles.php @@ -4,9 +4,9 @@ define('standard_profile','dashboard,profile,equipments,equipment,histories,hist /*Superuser*/ define('superuser_profile','dashboard,profile,assets,equipments,equipment,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,marketing,application'); /*Admin*/ -define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,changelog,application'); +define('admin_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,changelog,application'); /*AdminPlus*/ -define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,billing,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,translations,translations_details,translation_manage,application,maintenance,profiles,vin'); +define('adminplus_profile','dashboard,profile,buildtool,sales,accounts,account,contracts,contract,contract_manage,billing,cartests,cartest,cartest_manage,assets,equipments,equipment,equipment_healthindex,equipment_data,equipment_manage,equipment_manage_edit,equipments_mass_update,histories,history,history_manage,firmwaretool,rmas,rma,rma_manage,rma_history,rma_history_manage,buildtool,products,products_versions,products_software,products_attributes,products_attributes_items,products_attributes_manage,product,product_manage,servicereports,servicereport,admin,partners,partner,users,user,user_manage,communications,communication,communication_send,marketing,reporting,report_build,report_contracts_billing,report_healthindex,report_usage,config,settings,logfile,changelog,language,translations,translations_details,translation_manage,application,maintenance,profiles,vin'); /*Build*/ define('build','dashboard,profile,buildtool,firmwaretool,buildtool,products_software,application'); /*Distribution*/ diff --git a/settings/settingsviews.php b/settings/settingsviews.php index b569625..f23c708 100644 --- a/settings/settingsviews.php +++ b/settings/settingsviews.php @@ -39,6 +39,7 @@ $all_views = [ "products_versions", "products_software", "products_attributes", + "products_attributes_items", "products_attributes_manage", "product", "product_manage", diff --git a/translation_manage.php b/translation_manage.php index 07ac8b0..e7d46c6 100644 --- a/translation_manage.php +++ b/translation_manage.php @@ -2,12 +2,12 @@ defined(page_security_key) or exit; $page = 'translation_manage'; -/*Check if allowed +//Check if allowed if (isAllowed($page,$_SESSION['profile'],$_SESSION['permission'],'R') === 0){ header('location: index.php'); exit; } -*/ + //PAGE Security $update_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'U'); @@ -56,7 +56,7 @@ if (isset($_GET['rowID'])) { } } - if (isset($_POST['update']) || isset($_POST['add'])) { + if (isset($_POST['add'])) { //GET ALL POST DATA $payload = json_encode($_POST, JSON_UNESCAPED_UNICODE); @@ -66,11 +66,42 @@ if (isset($_GET['rowID'])) { if ($responses === 'NOK'){ } else { - header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].''); + generateLanguageFile($_POST['language_key'],$_SESSION['userkey']); + header('Location: index.php?page=translation_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/translations_details', $payload); + + if ($responses === 'NOK'){ + //NOT correct exit procedure + $NOK_error++; + exit; + } else { + $attr_language = $attr['language_key']; + } + } + + if ($NOK_error == 0){ + //NO errors generatelanguagefile + generateLanguageFile($attr_language,$_SESSION['userkey']); + } + + header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].''); + exit; + } } if ($delete_allowed === 1){ @@ -207,16 +238,16 @@ $view .= '
- '; foreach ($supportedLanguages as $language){ $view .=''; } $view .=' '.getRelativeTime($translation['created']).'