CMXX - Product attributes and initial multi languagal product support

This commit is contained in:
“VeLiTi”
2025-01-14 14:40:01 +01:00
parent 906ce7b843
commit 05b0c2bdb1
18 changed files with 234 additions and 202 deletions

View File

@@ -2921,6 +2921,7 @@ 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);
@@ -2947,3 +2948,15 @@ function generateLanguageFile($language_key,$token){
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);
}
}
}

View File

@@ -59,7 +59,7 @@ $view .= '<div class="content-block">
$view .=' <option id="productselected" selected value="0">Assign Product</option>';
foreach ($messages as $message){
$view .='<option value="'.$message["rowID"].'|'.$message["product_category"].'|'.$message["sn"].'">'.$message["productcode"].' - '.$message["productname"].'</option>';
$view .='<option value="'.$message["rowID"].'|'.$message["product_category"].'|'.$message["sn"].'">'.$message["productcode"].' - '.(${$message["productname"]} ?? $message["productname"]).'</option>';
}
$view .='</select>

View File

@@ -170,7 +170,7 @@ $view .= ' <div class="content-block order-details">
</div>
<div class="order-detail">
<h3>'.$product_name.'</h3>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$responses->productrowid.'" class="btn2">'.$responses->productname.'</a>':$responses->productname).'</p>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$responses->productrowid.'" class="btn2">'.(${$responses->productname} ?? $responses->productname).'</a>':(${$responses->productname} ?? $responses->productname)).'</p>
</div>';
$picture = glob("./assets/images/products/".$responses->productcode.".{jpg,jpeg,png,gif}", GLOB_BRACE);

View File

@@ -162,7 +162,7 @@ $view .= '<div class="tabs">
//create product option list
$product_option_list ='';
foreach ($products as $product){
$product_option_list .= '<option value="'.$product->rowID.'" '.($equipment['productrowid']==$product->rowID?' selected':'').'>'.$product->productcode.' - '.$product->productname.'</option>
$product_option_list .= '<option value="'.$product->rowID.'" '.($equipment['productrowid']==$product->rowID?' selected':'').'>'.$product->productcode.' - '.(${$product->productname} ?? $product->productname).'</option>
';
}

View File

@@ -72,7 +72,7 @@ if ($query_products != null){
<select name="productcode">
<option value="" disabled selected>'.$equipment_label4.'</option>';
foreach ($query_products as $product){
$product_list .= '<option value="'.$product->productcode.'">'.$product->productname.'</option>';
$product_list .= '<option value="'.$product->productcode.'">'.(${$product->productname} ?? $product->productname).'</option>';
}
$product_list .= '</select>';
}
@@ -231,7 +231,7 @@ $view .= '<tr>
<td class="responsive-hidden">'.$indicators.'</td>
<td>'.$response->serialnumber.'</td>
<td><span class="status id'.$response->status.'">'.$$status_text.'</span></td>
<td>'.$response->productcode.'-'.$response->productname.'</td>';
<td>'.$response->productcode.'-'.(${$response->productname} ?? $response->productname).'</td>';
$view .= ' <td class="responsive-hidden">';
if (!empty($picture)){
$view .='

View File

@@ -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 .= '<tr><td>'.$data_to_update['serialnumber'].'</td><td>'.$data_to_update['productcode'].'</td><td>'.$data_to_update['productname'].'</td><td>'.$mass_update_correct.'</td></tr>';
$output_excel_display .= '<tr><td>'.$data_to_update['serialnumber'].'</td><td>'.$data_to_update['productcode'].'</td><td>'.(${$data_to_update['productname']} ?? $data_to_update['productname']).'</td><td>'.$mass_update_correct.'</td></tr>';
}
}
$output_excel_display .= '</tbody></table>';

View File

@@ -78,7 +78,7 @@ if (isset($_GET['success_msg'])) {
template_header('Product', 'product', 'view');
$view = '
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">'.$responses->productcode.' - '.$responses->productname.'</h2>
<h2 class="responsive-width-100">'.$responses->productcode.' - '.(${$responses->productname} ?? $responses->productname).'</h2>
<a href="index.php?page='.$_SESSION['origin'].'&p='.$_SESSION['p'].'" class="btn alt mar-right-2">'.$button_cancel.'</a>
';
@@ -124,7 +124,7 @@ $view .= ' <div class="content-block order-details">
</div>
<div class="order-detail">
<h3>'.$product_name.'</h3>
<p>'.$responses->productname.'</p>
<p>'.(${$responses->productname} ?? $responses->productname).'</p>
</div>';
$view .='

View File

@@ -135,7 +135,7 @@ $view .= '
<td class="responsive-hidden">
'.(($picture)?'<img style="border-radius: 4px;height: 50px;" src="'.$picture[0].'" alt="">' : '').'
</td>
<td>'.$response->productname.'</td>
<td>'.(${$response->productname} ?? $response->productname).'</td>
<td><a href="index.php?page=product&rowID='.$response->rowID.'" class="btn_link">'.$general_view .'</a></td>
</tr>
';

View File

@@ -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 = '
<div class="content-title">
<div class="title">
<i class="fa-solid fa-box-open"></i>
<div class="txt">
<h2>'.($text_variables_h2 ?? '').' ('.$query_total.')</h2>
<p>'.($text_variables_p ?? '').'</p>
<h2>'.($products_attributes_h2 ?? '').' ('.$query_total.')</h2>
<p>'.($products_attributes_p ?? '').'</p>
</div>
</div>
</div>';
@@ -76,12 +76,12 @@ $view .= ' <div class="msg success">
}
$view .= '
<div class="content-header responsive-flex-column pad-top-5">
<a href="index.php?page=translation_manage" class="btn">'.($button_create_text_variable ?? '').'</a>
<a href="index.php?page=products_attributes_manage" class="btn">'.($button_create_products_attribute ?? '').'</a>
<form action="" method="get">
<input type="hidden" name="page" value="translations">
<input type="hidden" name="page" value="products_attributes">
<div class="search">
<label for="search">
<input id="search" type="text" name="search" placeholder="'.($text_variable_search ?? '').'" value="" class="responsive-width-100">
<input id="search" type="text" name="search" placeholder="'.($products_attribute_search ?? '').'" value="" class="responsive-width-100">
<i class="fas fa-search"></i>
</label>
</div>
@@ -95,8 +95,10 @@ $view .= '
<table class="sortable">
<thead>
<tr>
<th>'.($text_variable_rowID ?? '').'</th>
<th>'.($text_variable_variable ?? '').'</th>
<th>'.($products_attribute_rowID ?? '').'</th>
<th>'.($products_attribute_group_status ?? '').'</th>
<th>'.($products_attribute_group_name ?? '').'</th>
<th>'.($products_attribute_group_type ?? '').'</th>
<th class="responsive-hidden">'.$general_created.'</th>
<th>'.$general_actions.'</th>
</tr>
@@ -108,7 +110,7 @@ $view .= '
$view .= '
<tr>
<td colspan="8" style="text-align:center;">'.($message_no_text_variables ?? '').'</td>
<td colspan="8" style="text-align:center;">'.($message_no_products_attributes ?? '').'</td>
</tr>';
}
else {
@@ -116,9 +118,11 @@ $view .= '
$view .= '
<tr>
<td>'.$response['rowID'].'</td>
<td>'.$response['variable'].'</td>
<td>'.${'general_status_'.$response['group_status']}.'</td>
<td>'.$response['group_name'].'</td>
<td>'.${'general_form_'.$response['group_type']}.'</td>
<td class="responsive-hidden">'.getRelativeTime($response['created']).'</td>
<td><a href="index.php?page=translation_manage&rowID='.$response['rowID'].'" class="btn_link">'.$general_view .'</a></td>
<td><a href="index.php?page=products_attributes_manage&rowID='.$response['rowID'].'" class="btn_link">'.$general_view .'</a></td>
</tr>';
@@ -137,9 +141,9 @@ if ($pagination_page > 1) {
$view .= '<a href="'.$url.'&p=1">'.$general_first.'</a>';
$view .= '<a href="'.$url.'&p='.$page.'">'.$general_prev.'</a>';
}
$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 .= '<span> '.$general_page.$pagination_page.$general_page_of.$totals.'</span>';
if ($pagination_page * $page_rows_translations < $query_total){
if ($pagination_page * $page_rows_products_attributes < $query_total){
$page = $pagination_page+1;
$view .= '<a href="'.$url.'&p='.$page.'">'.$general_next.'</a>';
$view .= '<a href="'.$url.'&p='.$totals.'">'.$general_last.'</a>';

View File

@@ -1,13 +1,13 @@
<?php
defined(page_security_key) or exit;
$page = 'translation_manage';
/*Check if allowed
$page = 'products_attributes_manage';
//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');
@@ -15,9 +15,12 @@ $delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
// Default input product values
$text_variable = [
$products_attributes = [
'rowID' => '',
'variable' => '',
'group_status' => '',
'group_name' => '',
'group_mandatory' => '',
'group_type' => '',
'created' => '',
'createdby' => '',
'updated' => '',
@@ -27,18 +30,19 @@ $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'])) {
@@ -46,31 +50,52 @@ 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);
if ($responses === 'NOK'){
} else {
header('Location: index.php?page=translations&success_msg=2');
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'].'');
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;
}
}
@@ -95,14 +120,14 @@ 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);
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 .= ' <div class="msg error">
@@ -130,8 +155,8 @@ if (isset($success_msg)){
$view .='
<form action="" method="post">
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
<h2 class="responsive-width-100">'.($text_variables_h2 ?? '').'</h2>
<a href="index.php?page=translations" class="btn alt mar-right-2">'.$button_cancel.'</a>
<h2 class="responsive-width-100">'.($products_attributes_h2 ?? '').'</h2>
<a href="index.php?page=products_attributes" class="btn alt mar-right-2">'.$button_cancel.'</a>
';
if ($delete_allowed === 1){
@@ -152,24 +177,45 @@ $view .= '<div class="tabs">
//Define Service and User enabled
$view .='<div class="content-block tab-content active">
<div class="form responsive-width-100">
<label for="variable">'.($text_variable_name ?? '').'</label>
<input id="variable" type="text" name="variable" placeholder="'.($text_variable_name ?? '').'" value="'.$text_variable['variable'].'" pattern="^\S+$" required">
<input type="hidden" name="rowID" value="'.$text_variable['rowID'].'" readonly>
<label for="">'.($products_attributes_group_status ?? 'Status').'</label>
<select name="group_status">
<option value="0" '.($products_attributes['group_status']==0?' selected':'').'>'.$general_status_0.'</option>
<option value="1" '.($products_attributes['group_status']==1?' selected':'').'>'.$general_status_1.'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="group_name">'.($products_attributes_group_name ?? 'Groupname').'</label>
<input id="group_name" type="text" name="group_name" placeholder="'.($products_attributes_group_name ?? '').'" value="'.$products_attributes['group_name'].'" pattern="^\S+$" required">
<input type="hidden" name="rowID" value="'.$products_attributes['rowID'].'" readonly>
</div>
<div class="form responsive-width-100">
<label for="">'.($products_attributes_group_type ?? 'Type').'</label>
<select name="group_type">
<option value="0" '.($products_attributes['group_type']==0?' selected':'').'>'.$general_form_0.'</option>
<option value="1" '.($products_attributes['group_type']==1?' selected':'').'>'.$general_form_1.'</option>
<option value="2" '.($products_attributes['group_type']==2?' selected':'').'>'.$general_form_2.'</option>
</select>
</div>
<div class="form responsive-width-100">
<label for="">'.($products_attributes_group_mandatory ?? 'Mandatory').'</label>
<select name="group_mandatory">
<option value="0" '.($products_attributes['group_mandatory']==0?' selected':'').'>'.$general_no.'</option>
<option value="1" '.($products_attributes['group_mandatory']==1?' selected':'').'>'.$general_yes.'</option>
</select>
</div>
</div>
';
$view .= '</div>
</div>';
$view .= '<div class="content-block tab-content">
<div class="form responsive-width-100">
<label for="">'.$general_created.'</label>
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.getRelativeTime($text_variable['created']).'" readonly>
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.getRelativeTime($products_attributes['created']).'" readonly>
<label for="">'.$general_createdby.'</label>
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$text_variable['createdby'].'" readonly>
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$products_attributes['createdby'].'" readonly>
<label for="productcode">'.$general_updated.'</label>
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.getRelativeTime($text_variable['updated']).'" readonly>
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.getRelativeTime($products_attributes['updated']).'" readonly>
<label for="productcode">'.$general_updatedby.'</label>
<input id="name" type="text" name="" placeholder="'.$general_updatedby.'" value="'.$text_variable['updatedby'].'" readonly>
<input id="name" type="text" name="" placeholder="'.$general_updatedby.'" value="'.$products_attributes['updatedby'].'" readonly>
</div>
</div>';
$view .= '</form>';
@@ -177,7 +223,8 @@ $view .= '</form>';
$view .= '
<div class="content-block">
<button class="btn2" onClick="addNewRow()" > + </button>
<h2 class="responsive-width-100">'.($products_attributes_group_items ?? 'Groupitems').' <button class="btn2" onClick="addNewRow()" > + </button></h2>
<form action="" id="update" method="post"></form>
<form action="" id="new" method="post"></form>
@@ -185,8 +232,11 @@ $view .= '
<table>
<thead>
<tr>
<th>'.($text_variable_translation_languagekey ?? '').'</th>
<th>'.($text_variable_translation_translation ?? '').'</th>
<th>'.($products_attributes_item_status ?? 'status').'</th>
<th>'.($products_attributes_item_name ?? 'name').'</th>
<th>'.($products_attributes_item_quantity ?? 'quantity').'</th>
<th>'.($products_attributes_item_position ?? 'position').'</th>
<th>'.($products_attributes_item_media ?? 'media').'</th>
<th>'.$general_created.'</th>
<th>'.$general_actions.'</th>
</tr>
@@ -194,29 +244,32 @@ $view .= '
<tbody id="tableBody">
';
if (empty($text_variable_translations)){
if (empty($products_attributes_items)){
$view .= '
<tr>
<td colspan="8" style="text-align:center;">'.($message_no_text_variables ?? '').'</td>
<td colspan="8" style="text-align:center;">'.($message_no_products_attributess ?? '').'</td>
</tr>';
}
else {
foreach ($text_variable_translations as $translation){
foreach ($products_attributes_items as $items){
$view .= '
<tr>
<td>
<select form="update" id="language" name="language_key">';
foreach ($supportedLanguages as $language){
$view .='<option value="'.$language.'" '.(($translation['language_key'] == $language)?' selected':'').'>'.$language.'</option>';
}
$view .='</select></td>
<td><input form="update" type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value="'.$translation['translation'].'"></td>
<td>'.getRelativeTime($translation['created']).'</td>
<select form="update" name="attributes['.$items['rowID'].'][item_status]">
<option value="0" '.($items['item_status']==0?' selected':'').'>'.$general_status_0.'</option>
<option value="1" '.($items['item_status']==1?' selected':'').'>'.$general_status_1.'</option>
</select>
</td>
<td><input form="update" type="text" name="attributes['.$items['rowID'].'][item_name]" placeholder="'.($products_attributes_item_name ?? '').'" value="'.$items['item_name'].'"></td>
<td><input form="update" type="number" name="attributes['.$items['rowID'].'][item_quantity]" placeholder="'.($products_attributes_item_quantity ?? '').'" value="'.$items['item_quantity'].'"></td>
<td><input form="update" type="number" name="attributes['.$items['rowID'].'][item_position]" placeholder="'.($products_attributes_item_position ?? '').'" value="'.$items['item_position'].'"></td>
<td><input form="update" type="file" name="attributes['.$items['rowID'].'][item_media]" placeholder="'.($products_attributes_item_media ?? '').'" value="'.$items['item_media'].'"></td>
<td>'.getRelativeTime($items['created']).'</td>
<td><input form="update" type="submit" name="update" value="&" class="btn"></td>
<input form="update" type="hidden" name="rowID" value="'.$translation['rowID'].'" readonly>
<input form="update" type="hidden" name="variable_ID" value="'.$text_variable['rowID'].'" readonly>
<input form="update" type="hidden" name="attributes['.$items['rowID'].'][rowID]" value="'.$items['rowID'].'" readonly>
<input form="update" type="hidden" name="attributes['.$items['rowID'].'][group_id]" value="'.$products_attributes['rowID'].'" readonly>
</tr>
</form>';
}
@@ -234,56 +287,23 @@ $view .= '
const newRow = document.createElement(\'tr\');
newRow.innerHTML = `
<td><select form="new" id="language" name="language_key">';
foreach ($supportedLanguages as $language){
$view .= '<option value="'.$language.'">'.$language.'</option>';
}
$view .='</select>
<select form="new" name="item_status">
<option value="0">'.$general_status_0.'</option>
<option value="1">'.$general_status_1.'</option>
</select>
</td>
<td><input form="new" type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value=""></td>
<td><input form="new" type="text" name="item_name" placeholder="'.($products_attributes_item_name ?? '').'" value=""></td>
<td><input form="new" type="number" name="item_quantity" placeholder="'.($products_attributes_item_quantity ?? '').'" value=""></td>
<td><input form="new" type="number" name="item_position" placeholder="'.($products_attributes_item_position ?? '').'" value=""></td>
<td><input form="new" type="file" name="item_media" placeholder="'.($products_attributes_item_media ?? '').'" value=""></td>
<td><input form="new" type="submit" name="add" value="+" class="btn"></td>
<input form="new" type="hidden" name="rowID" value="" readonly>
<input form="new" type="hidden" name="variable_ID" value="'.$text_variable['rowID'].'" readonly>
<input form="new" type="hidden" name="group_id" value="'.$products_attributes['rowID'].'" readonly>
`;
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 = \'<form action="" method="post"><select id="language" name="language_key">';
foreach ($supportedLanguages as $language){
$view .= '<option value="'.$language.'">'.$language.'</option>';
}
$view .= ' </select>\'
twoCell.innerHTML = \'<input type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value="">\'
fourCell.innerHTML = \'<input type="submit" name="add" value="+" class="btn"></form>\'
// 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++;
}
</script>
</div>
</div>

View File

@@ -67,7 +67,7 @@ if ($query_products != null){
<select name="productcode">
<option value="" disabled selected>'.$equipment_label4.'</option>';
foreach ($query_products as $product){
$product_list .= '<option value="'.$product->productcode.'">'.$product->productname.'</option>';
$product_list .= '<option value="'.$product->productcode.'">'.(${$product->productname} ?? $product->productname).'</option>';
}
$product_list .= '</select>';
}
@@ -195,7 +195,7 @@ $view .= '<tr>
<td class="responsive-hidden">'.$indicators.'</td>
<td>'.$response->serialnumber.'</td>
<td><span class="status id'.$response->status.'">'.$$status_text.'</span></td>
<td>'.$response->productcode.'-'.$response->productname.'</td>';
<td>'.$response->productcode.'-'.(${$response->productname} ?? $response->productname).'</td>';
$view .= ' <td class="responsive-hidden">';
if (!empty($picture)){
$view .='

View File

@@ -107,7 +107,7 @@ $view .= ' <div class="content-block order-details">
</div>
<div class="order-detail">
<h3>'.$product_name.'</h3>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$rma_header['productrowid'].'" class="btn2">'.$rma_header['productname'].'</a>':'<input type="text" name="header[productname]" value="'.$rma_header['productname'].'">').'</p>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$rma_header['productrowid'].'" class="btn2">'.(${$rma_header['productname']} ?? $rma_header['productname']).'</a>':'<input type="text" name="header[productname]" value="'.(${$rma_header['productname']} ?? $rma_header['productname']).'">').'</p>
</div>
<div class="order-detail">
<h3>'.$equipment_label10.'</h3>

View File

@@ -264,7 +264,7 @@ $view .= ' <div class="content-block order-details">
</div>
<div class="order-detail">
<h3>'.$product_name.'</h3>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$rma['header']['productrowid'].'" class="btn2">'.$rma['header']['productname'].'</a>':'<input type="text" name="header[productname]" value="'.$rma['header']['productname'].'">').'</p>
<p>'.(($view_product == 1)? '<a href="index.php?page=product&rowID='.$rma['header']['productrowid'].'" class="btn2">'.(${$rma['header']['productname']} ?? $rma['header']['productname']).'</a>':'<input type="text" name="header[productname]" value="'.(${$rma['header']['productname']} ?? $rma['header']['productname']).'">').'</p>
</div>
<div class="order-detail">
<h3>'.$equipment_label10.'</h3>
@@ -289,7 +289,7 @@ $view .= ' <div class="content-block order-details">
<input type="hidden" name="header[productrowid]" value="'.$rma['header']['productrowid'].'" readonly>
<input type="hidden" name="header[rowID]" value="'.$rma['header']['rowID'].'" readonly>
<input type="hidden" name="header[productcode]" value="'.$rma['header']['productcode'].'" readonly>
<input type="hidden" name="header[productname]" value="'.$rma['header']['productname'].'" readonly>
<input type="hidden" name="header[productname]" value="'.(${$rma['header']['productname']} ?? $rma['header']['productname']).'" readonly>
<input type="hidden" name="rowID" value="'.$rma['rowID'].'" readonly>
';

View File

@@ -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",

View File

@@ -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*/

View File

@@ -39,6 +39,7 @@ $all_views = [
"products_versions",
"products_software",
"products_attributes",
"products_attributes_items",
"products_attributes_manage",
"product",
"product_manage",

View File

@@ -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 {
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 .= '
<tr>
<td>
<select form="update" id="language" name="language_key">';
<select form="update" id="language" name="item['.$translation['rowID'].'][language_key]">';
foreach ($supportedLanguages as $language){
$view .='<option value="'.$language.'" '.(($translation['language_key'] == $language)?' selected':'').'>'.$language.'</option>';
}
$view .='</select></td>
<td><input form="update" type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value="'.$translation['translation'].'"></td>
<td><input form="update" type="text" name="item['.$translation['rowID'].'][translation]" placeholder="'.($text_variable_translation_translation ?? '').'" value="'.$translation['translation'].'"></td>
<td>'.getRelativeTime($translation['created']).'</td>
<td><input form="update" type="submit" name="update" value="&" class="btn"></td>
<input form="update" type="hidden" name="rowID" value="'.$translation['rowID'].'" readonly>
<input form="update" type="hidden" name="variable_ID" value="'.$text_variable['rowID'].'" readonly>
<input form="update" type="hidden" name="item['.$translation['rowID'].'][rowID]" value="'.$translation['rowID'].'" readonly>
<input form="update" type="hidden" name="item['.$translation['rowID'].'][variable_ID]" value="'.$text_variable['rowID'].'" readonly>
</tr>
</form>';
}
@@ -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 = \'<form action="" method="post"><select id="language" name="language_key">';
foreach ($supportedLanguages as $language){
$view .= '<option value="'.$language.'">'.$language.'</option>';
}
$view .= ' </select>\'
twoCell.innerHTML = \'<input type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" value="">\'
fourCell.innerHTML = \'<input type="submit" name="add" value="+" class="btn"></form>\'
// 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++;
}
</script>
</div>
</div>

View File

@@ -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;