CMXX - Translations - updates
This commit is contained in:
@@ -44,6 +44,9 @@ if(isset($get_content) && $get_content!=''){
|
|||||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='list' || $v[0] =='history'|| $v[0] =='success_msg'){
|
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='list' || $v[0] =='history'|| $v[0] =='success_msg'){
|
||||||
//do nothing
|
//do nothing
|
||||||
}
|
}
|
||||||
|
elseif ($v[0] == 'generatefile') {
|
||||||
|
$clause .= ' AND language_key = :'.$v[0];
|
||||||
|
}
|
||||||
elseif ($v[0] == 'search') {
|
elseif ($v[0] == 'search') {
|
||||||
//build up search
|
//build up search
|
||||||
$clause .= ' AND variable like :'.$v[0];
|
$clause .= ' AND variable like :'.$v[0];
|
||||||
@@ -62,6 +65,8 @@ if(isset($get_content) && $get_content!=''){
|
|||||||
if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
||||||
//Request for total rows
|
//Request for total rows
|
||||||
$sql = 'SELECT count(*) as count FROM text_variables '.$whereclause.'';
|
$sql = 'SELECT count(*) as count FROM text_variables '.$whereclause.'';
|
||||||
|
} elseif (isset($criterias['generatefile']) && $criterias['generatefile'] !=''){
|
||||||
|
$sql = 'SELECT tv.variable,tvt.translation FROM text_variables tv JOIN text_variables_translations tvt ON tv.rowID = tvt.variable_ID '.$whereclause.'';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//SQL for Paging
|
//SQL for Paging
|
||||||
@@ -95,10 +100,15 @@ if(isset($criterias['totals']) && $criterias['totals']==''){
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$messages = $stmt->fetch();
|
$messages = $stmt->fetch();
|
||||||
$messages = $messages[0];
|
$messages = $messages[0];
|
||||||
|
} elseif(isset($criterias['generatefile']) && $criterias['generatefile'] !=''){
|
||||||
|
//Excute Query
|
||||||
|
$stmt->execute();
|
||||||
|
//Get results
|
||||||
|
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
|
$current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
|
||||||
$stmt->bindValue('page', ($current_page - 1) * $page_rows_products, PDO::PARAM_INT);
|
$stmt->bindValue('page', ($current_page - 1) * $page_rows_translations, PDO::PARAM_INT);
|
||||||
$stmt->bindValue('num_products', $page_rows_translations, PDO::PARAM_INT);
|
$stmt->bindValue('num_products', $page_rows_translations, PDO::PARAM_INT);
|
||||||
|
|
||||||
//Excute Query
|
//Excute Query
|
||||||
|
|||||||
118
api/v2/get/translations_details.php
Normal file
118
api/v2/get/translations_details.php
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
defined($security_key) or exit;
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
// Translation details
|
||||||
|
//------------------------------------------
|
||||||
|
|
||||||
|
//Connect to DB
|
||||||
|
$pdo = dbConnect($dbname);
|
||||||
|
|
||||||
|
//SoldTo is empty
|
||||||
|
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
|
||||||
|
|
||||||
|
//default whereclause
|
||||||
|
$whereclause = '';
|
||||||
|
|
||||||
|
switch ($permission) {
|
||||||
|
case '4':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search;
|
||||||
|
$whereclause = 'WHERE accounthierarchy like "'.$condition.'"';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//NEW ARRAY
|
||||||
|
$criterias = [];
|
||||||
|
$clause = '';
|
||||||
|
|
||||||
|
//Check for $_GET variables and build up clause
|
||||||
|
if(isset($get_content) && $get_content!=''){
|
||||||
|
//GET VARIABLES FROM URL
|
||||||
|
$requests = explode("&", $get_content);
|
||||||
|
//Check for keys and values
|
||||||
|
foreach ($requests as $y){
|
||||||
|
$v = explode("=", $y);
|
||||||
|
//INCLUDE VARIABLES IN ARRAY
|
||||||
|
$criterias[$v[0]] = $v[1];
|
||||||
|
|
||||||
|
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='totals' || $v[0] =='list' || $v[0] =='history'|| $v[0] =='success_msg'){
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
elseif ($v[0] == 'search') {
|
||||||
|
//build up search
|
||||||
|
$clause .= ' AND translation like :'.$v[0];
|
||||||
|
}
|
||||||
|
else {//create clause
|
||||||
|
$clause .= ' AND '.$v[0].' = :'.$v[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($whereclause == '' && $clause !=''){
|
||||||
|
$whereclause = 'WHERE '.substr($clause, 4);
|
||||||
|
} else {
|
||||||
|
$whereclause .= $clause;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Define Query
|
||||||
|
if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
||||||
|
//Request for total rows
|
||||||
|
$sql = 'SELECT count(*) as count FROM text_variables_translations '.$whereclause.'';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//SQL for Paging
|
||||||
|
$sql = 'SELECT * FROM text_variables_translations '.$whereclause.' LIMIT :page,:num_products';
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
|
||||||
|
//Bind to query
|
||||||
|
if (str_contains($whereclause, ':condition')){
|
||||||
|
$stmt->bindValue('condition', $condition, PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($criterias)){
|
||||||
|
foreach ($criterias as $key => $value){
|
||||||
|
$key_condition = ':'.$key;
|
||||||
|
if (str_contains($whereclause, $key_condition)){
|
||||||
|
if ($key == 'search'){
|
||||||
|
$search_value = '%'.$value.'%';
|
||||||
|
$stmt->bindValue($key, $search_value, PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$stmt->bindValue($key, $value, PDO::PARAM_STR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add paging details
|
||||||
|
if(isset($criterias['totals']) && $criterias['totals']==''){
|
||||||
|
$stmt->execute();
|
||||||
|
$messages = $stmt->fetch();
|
||||||
|
$messages = $messages[0];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$current_page = isset($criterias['p']) && is_numeric($criterias['p']) ? (int)$criterias['p'] : 1;
|
||||||
|
$stmt->bindValue('page', ($current_page - 1) * $page_rows_products, PDO::PARAM_INT);
|
||||||
|
$stmt->bindValue('num_products', $page_rows_translations, PDO::PARAM_INT);
|
||||||
|
|
||||||
|
//Excute Query
|
||||||
|
$stmt->execute();
|
||||||
|
//Get results
|
||||||
|
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
//JSON_ENCODE
|
||||||
|
//------------------------------------------
|
||||||
|
$messages = json_encode($messages, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
//Send results
|
||||||
|
echo $messages;
|
||||||
|
|
||||||
|
?>
|
||||||
105
api/v2/post/products.php
Normal file
105
api/v2/post/products.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
defined($security_key) or exit;
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
// Products
|
||||||
|
//------------------------------------------
|
||||||
|
//Connect to DB
|
||||||
|
$pdo = dbConnect($dbname);
|
||||||
|
|
||||||
|
//CONTENT FROM API (POST)
|
||||||
|
$post_content = json_decode($input,true);
|
||||||
|
|
||||||
|
//SoldTo is empty
|
||||||
|
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
|
||||||
|
|
||||||
|
//default whereclause
|
||||||
|
$whereclause = '';
|
||||||
|
|
||||||
|
switch ($permission) {
|
||||||
|
case '4':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search;
|
||||||
|
$whereclause = ' AND accounthierarchy like "'.$condition.'"';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SET PARAMETERS FOR QUERY
|
||||||
|
$id = $post_content['rowID'] ?? ''; //check for rowID
|
||||||
|
$command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT
|
||||||
|
if (isset($post_content['delete'])){$command = 'delete';} //change command to delete
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
//CREATE EMPTY STRINGS
|
||||||
|
$clause = '';
|
||||||
|
$clause_insert ='';
|
||||||
|
$input_insert = '';
|
||||||
|
|
||||||
|
//BUILD UP PARTNERHIERARCHY FROM USER
|
||||||
|
$partner_product = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
|
if ($command == 'update'){
|
||||||
|
$post_content['updated'] = $date;
|
||||||
|
$post_content['updatedby'] = $username ;
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($command == 'insert'){
|
||||||
|
$post_content['created'] = $date;
|
||||||
|
$post_content['createdby'] = $username;
|
||||||
|
$post_content['accounthierarchy'] = $partner_product;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
//CREAT NEW ARRAY AND MAP TO CLAUSE
|
||||||
|
if(isset($post_content) && $post_content!=''){
|
||||||
|
foreach ($post_content as $key => $var){
|
||||||
|
if ($key == 'submit' || $key == 'rowID'){
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$criterias[$key] = $var;
|
||||||
|
$clause .= ' , '.$key.' = ?';
|
||||||
|
$clause_insert .= ' , '.$key.'';
|
||||||
|
$input_insert .= ', ?'; // ? for each insert item
|
||||||
|
$execute_input[]= $var; // Build array for input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CLEAN UP INPUT
|
||||||
|
$clause = substr($clause, 2); //Clean clause - remove first comma
|
||||||
|
$clause_insert = substr($clause_insert, 2); //Clean clause - remove first comma
|
||||||
|
$input_insert = substr($input_insert, 1); //Clean clause - remove first comma
|
||||||
|
|
||||||
|
//QUERY AND VERIFY ALLOWED
|
||||||
|
if ($command == 'update' && isAllowed('products',$profile,$permission,'U') === 1){
|
||||||
|
$sql = 'UPDATE products SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||||
|
$execute_input[] = $id;
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($execute_input);
|
||||||
|
}
|
||||||
|
elseif ($command == 'insert' && isAllowed('products',$profile,$permission,'C') === 1){
|
||||||
|
$sql = 'INSERT INTO products ('.$clause_insert.') VALUES ('.$input_insert.')';
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($execute_input);
|
||||||
|
}
|
||||||
|
elseif ($command == 'delete' && isAllowed('products',$profile,$permission,'D') === 1){
|
||||||
|
$stmt = $pdo->prepare('DELETE FROM products WHERE rowID = ? '.$whereclause.'');
|
||||||
|
$stmt->execute([ $id ]);
|
||||||
|
|
||||||
|
//Add deletion to changelog
|
||||||
|
changelog($dbname,'products',$id,'Delete','Delete',$username);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
105
api/v2/post/translations.php
Normal file
105
api/v2/post/translations.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
defined($security_key) or exit;
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
// Products
|
||||||
|
//------------------------------------------
|
||||||
|
//Connect to DB
|
||||||
|
$pdo = dbConnect($dbname);
|
||||||
|
|
||||||
|
//CONTENT FROM API (POST)
|
||||||
|
$post_content = json_decode($input,true);
|
||||||
|
|
||||||
|
//SoldTo is empty
|
||||||
|
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
|
||||||
|
|
||||||
|
//default whereclause
|
||||||
|
$whereclause = '';
|
||||||
|
|
||||||
|
switch ($permission) {
|
||||||
|
case '4':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search;
|
||||||
|
$whereclause = ' AND accounthierarchy like "'.$condition.'"';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SET PARAMETERS FOR QUERY
|
||||||
|
$id = $post_content['rowID'] ?? ''; //check for rowID
|
||||||
|
$command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT
|
||||||
|
if (isset($post_content['delete'])){$command = 'delete';} //change command to delete
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
//CREATE EMPTY STRINGS
|
||||||
|
$clause = '';
|
||||||
|
$clause_insert ='';
|
||||||
|
$input_insert = '';
|
||||||
|
|
||||||
|
//BUILD UP PARTNERHIERARCHY FROM USER
|
||||||
|
$partner_product = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
|
if ($command == 'update'){
|
||||||
|
$post_content['updatedby'] = $username ;
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($command == 'insert'){
|
||||||
|
$post_content['createdby'] = $username;
|
||||||
|
$post_content['accounthierarchy'] = $partner_product;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
//CREAT NEW ARRAY AND MAP TO CLAUSE
|
||||||
|
if(isset($post_content) && $post_content!=''){
|
||||||
|
foreach ($post_content as $key => $var){
|
||||||
|
if ($key == 'submit' || $key == 'rowID'){
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$criterias[$key] = $var;
|
||||||
|
$clause .= ' , '.$key.' = ?';
|
||||||
|
$clause_insert .= ' , '.$key.'';
|
||||||
|
$input_insert .= ', ?'; // ? for each insert item
|
||||||
|
$execute_input[]= $var; // Build array for input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CLEAN UP INPUT
|
||||||
|
$clause = substr($clause, 2); //Clean clause - remove first comma
|
||||||
|
$clause_insert = substr($clause_insert, 2); //Clean clause - remove first comma
|
||||||
|
$input_insert = substr($input_insert, 1); //Clean clause - remove first comma
|
||||||
|
|
||||||
|
//QUERY AND VERIFY ALLOWED
|
||||||
|
if ($command == 'update' && isAllowed('translation_manage',$profile,$permission,'U') === 1){
|
||||||
|
$sql = 'UPDATE text_variables SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||||
|
$execute_input[] = $id;
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($execute_input);
|
||||||
|
}
|
||||||
|
elseif ($command == 'insert' && isAllowed('translation_manage',$profile,$permission,'C') === 1){
|
||||||
|
$sql = 'INSERT INTO text_variables('.$clause_insert.') VALUES ('.$input_insert.')';
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($execute_input);
|
||||||
|
// Return ID
|
||||||
|
echo json_encode(array('rowID'=> $pdo->lastInsertId()));
|
||||||
|
}
|
||||||
|
elseif ($command == 'delete' && isAllowed('translation_manage',$profile,$permission,'D') === 1){
|
||||||
|
$stmt = $pdo->prepare('DELETE FROM text_variables WHERE rowID = ? '.$whereclause.'');
|
||||||
|
$stmt->execute([ $id ]);
|
||||||
|
|
||||||
|
//Add deletion to changelog
|
||||||
|
changelog($dbname,'text_variables',$id,'Delete','Delete',$username);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
103
api/v2/post/translations_details.php
Normal file
103
api/v2/post/translations_details.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
defined($security_key) or exit;
|
||||||
|
|
||||||
|
//------------------------------------------
|
||||||
|
// Translation details
|
||||||
|
//------------------------------------------
|
||||||
|
//Connect to DB
|
||||||
|
$pdo = dbConnect($dbname);
|
||||||
|
|
||||||
|
//CONTENT FROM API (POST)
|
||||||
|
$post_content = json_decode($input,true);
|
||||||
|
|
||||||
|
//SoldTo is empty
|
||||||
|
if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} else {$soldto_search = '-%';}
|
||||||
|
|
||||||
|
//default whereclause
|
||||||
|
$whereclause = '';
|
||||||
|
|
||||||
|
switch ($permission) {
|
||||||
|
case '4':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
case '3':
|
||||||
|
$whereclause = '';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$condition = '__salesid___'.$partner->salesid.'___soldto___'.substr($partner->soldto, 0, strpos($partner->soldto, "-")).$soldto_search;
|
||||||
|
$whereclause = ' AND accounthierarchy like "'.$condition.'"';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//SET PARAMETERS FOR QUERY
|
||||||
|
$id = $post_content['rowID'] ?? ''; //check for rowID
|
||||||
|
$command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT
|
||||||
|
if (isset($post_content['delete'])){$command = 'delete';} //change command to delete
|
||||||
|
$date = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
//CREATE EMPTY STRINGS
|
||||||
|
$clause = '';
|
||||||
|
$clause_insert ='';
|
||||||
|
$input_insert = '';
|
||||||
|
|
||||||
|
//BUILD UP PARTNERHIERARCHY FROM USER
|
||||||
|
$partner_product = json_encode(array("salesid"=>$partner->salesid,"soldto"=>$partner->soldto), JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
|
//ADD STANDARD PARAMETERS TO ARRAY BASED ON INSERT OR UPDATE
|
||||||
|
if ($command == 'update'){
|
||||||
|
$post_content['updatedby'] = $username ;
|
||||||
|
|
||||||
|
}
|
||||||
|
elseif ($command == 'insert'){
|
||||||
|
$post_content['createdby'] = $username;
|
||||||
|
$post_content['accounthierarchy'] = $partner_product;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
//CREAT NEW ARRAY AND MAP TO CLAUSE
|
||||||
|
if(isset($post_content) && $post_content!=''){
|
||||||
|
foreach ($post_content as $key => $var){
|
||||||
|
if ($key == 'submit' || $key == 'update' || $key == 'add' ||$key == 'rowID'){
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$criterias[$key] = $var;
|
||||||
|
$clause .= ' , '.$key.' = ?';
|
||||||
|
$clause_insert .= ' , '.$key.'';
|
||||||
|
$input_insert .= ', ?'; // ? for each insert item
|
||||||
|
$execute_input[]= $var; // Build array for input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//CLEAN UP INPUT
|
||||||
|
$clause = substr($clause, 2); //Clean clause - remove first comma
|
||||||
|
$clause_insert = substr($clause_insert, 2); //Clean clause - remove first comma
|
||||||
|
$input_insert = substr($input_insert, 1); //Clean clause - remove first comma
|
||||||
|
|
||||||
|
//QUERY AND VERIFY ALLOWED
|
||||||
|
if ($command == 'update' && isAllowed('translation_manage',$profile,$permission,'U') === 1){
|
||||||
|
$sql = 'UPDATE text_variables_translations SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||||
|
$execute_input[] = $id;
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($execute_input);
|
||||||
|
}
|
||||||
|
elseif ($command == 'insert' && isAllowed('translation_manage',$profile,$permission,'C') === 1){
|
||||||
|
$sql = 'INSERT INTO text_variables_translations ('.$clause_insert.') VALUES ('.$input_insert.')';
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($execute_input);
|
||||||
|
}
|
||||||
|
elseif ($command == 'delete' && isAllowed('translation_manage',$profile,$permission,'D') === 1){
|
||||||
|
$stmt = $pdo->prepare('DELETE FROM text_variables_translations WHERE rowID = ? '.$whereclause.'');
|
||||||
|
$stmt->execute([ $id ]);
|
||||||
|
|
||||||
|
//Add deletion to changelog
|
||||||
|
changelog($dbname,'text_variables_translations',$id,'Delete','Delete',$username);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -2914,3 +2914,36 @@ function getRelativeTime($timestamp) {
|
|||||||
return $years.(($years != 1)?$time_years:$time_year) . " $suffix";
|
return $years.(($years != 1)?$time_years:$time_year) . " $suffix";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
// Generate language files ++++++++++++++
|
||||||
|
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
function generateLanguageFile($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 = '<?php'.PHP_EOL;
|
||||||
|
|
||||||
|
//decode the API response
|
||||||
|
$responses = json_decode($responses,true);
|
||||||
|
|
||||||
|
//loop through translation records and create variables
|
||||||
|
foreach ($responses as $response){
|
||||||
|
//create variable_name = translation per item
|
||||||
|
$translation .= '$'.$response['variable'].' = \''.$response['translation'].'\';'.PHP_EOL;
|
||||||
|
}
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,8 +34,9 @@ if ($update_allowed === 1){
|
|||||||
if (isset($_POST['updateequipmentmeusurements'])){
|
if (isset($_POST['updateequipmentmeusurements'])){
|
||||||
storeMeasurementEquipment('');
|
storeMeasurementEquipment('');
|
||||||
}
|
}
|
||||||
|
if (isset($_POST['generatefile'])){
|
||||||
|
generateLanguageFile($_POST['language'],$_SESSION['userkey']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle success messages
|
// Handle success messages
|
||||||
@@ -67,6 +68,7 @@ $view .='
|
|||||||
$view .= '<div class="tabs">
|
$view .= '<div class="tabs">
|
||||||
<a href="#" class="active">'.$general_actions .'</a>
|
<a href="#" class="active">'.$general_actions .'</a>
|
||||||
<a href="#" class="">Learning</a>
|
<a href="#" class="">Learning</a>
|
||||||
|
<a href="#" class="">Translations</a>
|
||||||
</div>
|
</div>
|
||||||
';
|
';
|
||||||
|
|
||||||
@@ -99,6 +101,21 @@ if ($update_allowed === 1){
|
|||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($update_allowed === 1){
|
||||||
|
$view .= '<div class="content-block tab-content">
|
||||||
|
<div class="form responsive-width-100">
|
||||||
|
<label for="">'.$User_language.'</label>
|
||||||
|
<select id="language" name="language">';
|
||||||
|
foreach ($supportedLanguages as $language){
|
||||||
|
$view .='<option value="'.$language.'">'.$language.'</option>';
|
||||||
|
}
|
||||||
|
$view .=' </select>
|
||||||
|
<input type="submit" name="generatefile" style="width: 15%;" value="Generate language" class="btn">
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
|
|
||||||
$view .= '</form>';
|
$view .= '</form>';
|
||||||
|
|
||||||
//Output
|
//Output
|
||||||
|
|||||||
56
rma.php
56
rma.php
@@ -6,63 +6,7 @@ if (debug && debug_id == $_SESSION['id']){
|
|||||||
ini_set('display_startup_errors', '1');
|
ini_set('display_startup_errors', '1');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
}
|
}
|
||||||
//__________________________________________
|
|
||||||
//MOVE TO TRANSLATION FILES:
|
|
||||||
//__________________________________________
|
|
||||||
$button_create_rma = 'Create RMA';
|
|
||||||
|
|
||||||
//RMA
|
|
||||||
$rmas_h2 = 'Return Material';
|
|
||||||
$rmas_p = 'View, manage, and search RMA details.';
|
|
||||||
$rma_h2 = 'Return Material Request';
|
|
||||||
|
|
||||||
$message_rma_1 = 'RMA created successfully!';
|
|
||||||
$message_rma_2 = 'RMA updated successfully!';
|
|
||||||
$message_rma_3 = 'RMA deleted successfully!';
|
|
||||||
$message_no_rma = 'There is no RMA';
|
|
||||||
|
|
||||||
$rma_search = 'Search RMA...';
|
|
||||||
|
|
||||||
$rma_rowID = 'Request number';
|
|
||||||
$rma_status = 'Status';
|
|
||||||
|
|
||||||
$rma_status0_text = 'New';
|
|
||||||
$rma_status1_text = 'In Progress';
|
|
||||||
$rma_status2_text = 'Approved';
|
|
||||||
$rma_status3_text = 'Completed';
|
|
||||||
$rma_status4_text = 'Cancelled';
|
|
||||||
|
|
||||||
$rma_sw_version_latest = 'Latest software version';
|
|
||||||
$rma_servicereport_latest = 'Servicereport created last 7days';
|
|
||||||
|
|
||||||
$rma_information = 'RMA information';
|
|
||||||
$rma_return_reason = 'Return reason';
|
|
||||||
$rma_return_reason0_text = '';
|
|
||||||
$rma_return_reason1_text = '';
|
|
||||||
$rma_return_reason2_text = '';
|
|
||||||
$rma_return_reason3_text = '';
|
|
||||||
$rma_return_reason4_text = '';
|
|
||||||
$rma_return_reason5_text = '';
|
|
||||||
|
|
||||||
$rma_return_reasons_notes = 'Return reason notes';
|
|
||||||
|
|
||||||
$rma_return_tab1 = 'Return reason';
|
|
||||||
$rma_return_tab2 = 'Questions';
|
|
||||||
|
|
||||||
$rma_question_allowed_label1 = 'Yes';
|
|
||||||
$rma_question_allowed_label2 = 'No';
|
|
||||||
|
|
||||||
$rma_question_header_1 = '';
|
|
||||||
$rma_question_1 = 'Batteries working?';
|
|
||||||
$rma_question_2 = 'Button correctly working';
|
|
||||||
$rma_question_3 = '';
|
|
||||||
$rma_question_4 = '';
|
|
||||||
$rma_question_5 = '';
|
|
||||||
$rma_question_6 = '';
|
|
||||||
$rma_question_7 = '';
|
|
||||||
//__________________________________________
|
|
||||||
//__________________________________________
|
|
||||||
//__________________________________________
|
|
||||||
include_once './assets/functions.php';
|
include_once './assets/functions.php';
|
||||||
include_once './settings/settings.php';
|
include_once './settings/settings.php';
|
||||||
include_once './settings/systemrma.php';
|
include_once './settings/systemrma.php';
|
||||||
|
|||||||
@@ -6,62 +6,7 @@ if (debug && debug_id == $_SESSION['id']){
|
|||||||
ini_set('display_startup_errors', '1');
|
ini_set('display_startup_errors', '1');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
}
|
}
|
||||||
//__________________________________________
|
|
||||||
//MOVE TO TRANSLATION FILES:
|
|
||||||
//__________________________________________
|
|
||||||
$button_create_rma = 'Create RMA';
|
|
||||||
|
|
||||||
//RMA
|
|
||||||
$rmas_h2 = 'Return Material';
|
|
||||||
$rmas_p = 'View, manage, and search RMA details.';
|
|
||||||
$rma_h2 = 'Return Material Request';
|
|
||||||
|
|
||||||
$message_rma_1 = 'RMA created successfully!';
|
|
||||||
$message_rma_2 = 'RMA updated successfully!';
|
|
||||||
$message_rma_3 = 'RMA deleted successfully!';
|
|
||||||
$message_no_rma = 'There is no RMA';
|
|
||||||
|
|
||||||
$rma_search = 'Search RMA...';
|
|
||||||
|
|
||||||
$rma_rowID = 'Request number';
|
|
||||||
$rma_status = 'Status';
|
|
||||||
$rma_sw_version_latest = 'Latest software version';
|
|
||||||
$rma_servicereport_latest = 'Servicereport created last 7days';
|
|
||||||
|
|
||||||
$rma_status0_text = 'New';
|
|
||||||
$rma_status1_text = 'In Progress';
|
|
||||||
$rma_status2_text = 'Approved';
|
|
||||||
$rma_status3_text = 'Completed';
|
|
||||||
$rma_status4_text = 'Cancelled';
|
|
||||||
|
|
||||||
$rma_information = 'RMA information';
|
|
||||||
$rma_return_reason = 'Return reason';
|
|
||||||
$rma_return_reason0_text = '';
|
|
||||||
$rma_return_reason1_text = '';
|
|
||||||
$rma_return_reason2_text = '';
|
|
||||||
$rma_return_reason3_text = '';
|
|
||||||
$rma_return_reason4_text = '';
|
|
||||||
$rma_return_reason5_text = '';
|
|
||||||
|
|
||||||
$rma_return_reasons_notes = 'Return reason notes';
|
|
||||||
|
|
||||||
$rma_return_tab1 = 'Return reason';
|
|
||||||
$rma_return_tab2 = 'Questions';
|
|
||||||
|
|
||||||
$rma_question_allowed_label1 = 'Yes';
|
|
||||||
$rma_question_allowed_label2 = 'No';
|
|
||||||
|
|
||||||
$rma_question_header_1 = '';
|
|
||||||
$rma_question_1 = 'Batteries working?';
|
|
||||||
$rma_question_2 = 'Button correctly working';
|
|
||||||
$rma_question_3 = '';
|
|
||||||
$rma_question_4 = '';
|
|
||||||
$rma_question_5 = '';
|
|
||||||
$rma_question_6 = '';
|
|
||||||
$rma_question_7 = '';
|
|
||||||
//__________________________________________
|
|
||||||
//__________________________________________
|
|
||||||
//__________________________________________
|
|
||||||
include_once './assets/functions.php';
|
include_once './assets/functions.php';
|
||||||
include_once './settings/settings.php';
|
include_once './settings/settings.php';
|
||||||
include_once './settings/systemrma.php';
|
include_once './settings/systemrma.php';
|
||||||
|
|||||||
59
rmas.php
59
rmas.php
@@ -1,65 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined(page_security_key) or exit;
|
defined(page_security_key) or exit;
|
||||||
|
|
||||||
//__________________________________________
|
|
||||||
//MOVE TO TRANSLATION FILES:
|
|
||||||
//__________________________________________
|
|
||||||
|
|
||||||
$button_create_rma = 'Create RMA';
|
|
||||||
|
|
||||||
//RMA
|
|
||||||
$rmas_h2 = 'Return Material';
|
|
||||||
$rmas_p = 'View, manage, and search RMA details.';
|
|
||||||
$rma_h2 = 'Return Material Request';
|
|
||||||
|
|
||||||
$message_rma_1 = 'RMA created successfully!';
|
|
||||||
$message_rma_2 = 'RMA updated successfully!';
|
|
||||||
$message_rma_3 = 'RMA deleted successfully!';
|
|
||||||
$message_no_rma = 'There is no RMA';
|
|
||||||
|
|
||||||
$rma_search = 'Search RMA...';
|
|
||||||
|
|
||||||
$rma_rowID = 'Request number';
|
|
||||||
$rma_status = 'Status';
|
|
||||||
$rma_sw_version_latest = 'Latest software version';
|
|
||||||
$rma_servicereport_latest = 'Servicereport created last 7days';
|
|
||||||
|
|
||||||
$rma_status0_text = 'New';
|
|
||||||
$rma_status1_text = 'In Progress';
|
|
||||||
$rma_status2_text = 'Approved';
|
|
||||||
$rma_status3_text = 'Completed';
|
|
||||||
$rma_status4_text = 'Cancelled';
|
|
||||||
|
|
||||||
$rma_information = 'RMA information';
|
|
||||||
$rma_return_reason = 'Return reason';
|
|
||||||
$rma_return_reason0_text = '';
|
|
||||||
$rma_return_reason1_text = '';
|
|
||||||
$rma_return_reason2_text = '';
|
|
||||||
$rma_return_reason3_text = '';
|
|
||||||
$rma_return_reason4_text = '';
|
|
||||||
$rma_return_reason5_text = '';
|
|
||||||
|
|
||||||
$rma_return_reasons_notes = 'Return reason notes';
|
|
||||||
|
|
||||||
$rma_return_tab1 = 'Return reason';
|
|
||||||
$rma_return_tab2 = 'Questions';
|
|
||||||
|
|
||||||
$rma_question_allowed_label1 = 'Yes';
|
|
||||||
$rma_question_allowed_label2 = 'No';
|
|
||||||
|
|
||||||
$rma_question_header_1 = '';
|
|
||||||
$rma_question_1 = 'Batteries working?';
|
|
||||||
$rma_question_2 = 'Button correctly working';
|
|
||||||
$rma_question_3 = '';
|
|
||||||
$rma_question_4 = '';
|
|
||||||
$rma_question_5 = '';
|
|
||||||
$rma_question_6 = '';
|
|
||||||
$rma_question_7 = '';
|
|
||||||
//__________________________________________
|
|
||||||
//__________________________________________
|
|
||||||
//__________________________________________
|
|
||||||
|
|
||||||
|
|
||||||
if (debug && debug_id == $_SESSION['id']){
|
if (debug && debug_id == $_SESSION['id']){
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
ini_set('display_startup_errors', '1');
|
ini_set('display_startup_errors', '1');
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ $all_views = [
|
|||||||
"changelog",
|
"changelog",
|
||||||
"language",
|
"language",
|
||||||
"translations",
|
"translations",
|
||||||
|
"translations_details",
|
||||||
"translation_manage",
|
"translation_manage",
|
||||||
"application",
|
"application",
|
||||||
"maintenance",
|
"maintenance",
|
||||||
|
|||||||
@@ -34,15 +34,20 @@ if (isset($_GET['rowID'])) {
|
|||||||
|
|
||||||
$text_variable = json_decode(json_encode($responses[0]), true);
|
$text_variable = 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,'');
|
||||||
|
//Decode Payload
|
||||||
|
if (!empty($text_variable_translations)){$text_variable_translations = json_decode($text_variable_translations,true);}else{$text_variable_translations = null;}
|
||||||
|
|
||||||
if ($update_allowed === 1){
|
if ($update_allowed === 1){
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
|
|
||||||
//GET ALL POST DATA
|
//GET ALL POST DATA
|
||||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||||
//Secure data
|
|
||||||
$payload = generate_payload($data);
|
|
||||||
//API call
|
//API call
|
||||||
$responses = ioServer('/v2/translations', $payload);
|
$responses = ioServer('/v2/translations', $payload);
|
||||||
|
|
||||||
if ($responses === 'NOK'){
|
if ($responses === 'NOK'){
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -50,14 +55,28 @@ if (isset($_GET['rowID'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['update']) || isset($_POST['add'])) {
|
||||||
|
|
||||||
|
//GET ALL POST DATA
|
||||||
|
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||||
|
//API call
|
||||||
|
$responses = ioServer('/v2/translations_details', $payload);
|
||||||
|
|
||||||
|
if ($responses === 'NOK'){
|
||||||
|
|
||||||
|
} else {
|
||||||
|
header('Location: index.php?page=translation_manage&rowID='.$_GET['rowID'].'');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($delete_allowed === 1){
|
if ($delete_allowed === 1){
|
||||||
if (isset($_POST['delete'])) {
|
if (isset($_POST['delete'])) {
|
||||||
//GET ALL POST DATA
|
//GET ALL POST DATA
|
||||||
$data = json_encode($_POST , JSON_UNESCAPED_UNICODE);
|
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||||
//Secure data
|
|
||||||
$payload = generate_payload($data);
|
|
||||||
//API call
|
//API call
|
||||||
$responses = ioServer('/v2/translations', $payload);
|
$responses = ioServer('/v2/translations', $payload);
|
||||||
// Redirect and delete product
|
// Redirect and delete product
|
||||||
@@ -74,13 +93,16 @@ if (isset($_GET['rowID'])) {
|
|||||||
// Create a new variable
|
// Create a new variable
|
||||||
if (isset($_POST['submit']) && $create_allowed === 1) {
|
if (isset($_POST['submit']) && $create_allowed === 1) {
|
||||||
//GET ALL POST DATA
|
//GET ALL POST DATA
|
||||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||||
//API call
|
//API call
|
||||||
$responses = ioServer('/v2/translations', $payload);
|
$responses = ioServer('/v2/translations', $payload);
|
||||||
|
|
||||||
if ($responses === 'NOK'){
|
if ($responses === 'NOK'){
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
header('Location: index.php?page=translations&success_msg=1');
|
//GET ROWID OF CREATED ITEM
|
||||||
|
$variable_rowID = json_decode($responses,true);
|
||||||
|
header('Location: index.php?page=translation_manage&rowID='.$variable_rowID['rowID'].'');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +135,7 @@ $view .='
|
|||||||
';
|
';
|
||||||
|
|
||||||
if ($delete_allowed === 1){
|
if ($delete_allowed === 1){
|
||||||
$view .= '<input type="submit" name="delete" value="Delete" class="btn red mar-right-2" onclick="return confirm(\'Are you sure you want to delete this user?\')">';
|
$view .= '<input type="submit" name="delete" value="Delete" class="btn red mar-right-2" onclick="return confirm(\'Are you sure you want to delete this variable?\')">';
|
||||||
}
|
}
|
||||||
if ($update_allowed === 1){
|
if ($update_allowed === 1){
|
||||||
$view .= '<input type="submit" name="submit" value="Save" class="btn">';
|
$view .= '<input type="submit" name="submit" value="Save" class="btn">';
|
||||||
@@ -130,8 +152,8 @@ $view .= '<div class="tabs">
|
|||||||
//Define Service and User enabled
|
//Define Service and User enabled
|
||||||
$view .= '<div class="content-block tab-content active">
|
$view .= '<div class="content-block tab-content active">
|
||||||
<div class="form responsive-width-100">
|
<div class="form responsive-width-100">
|
||||||
<label for="variable">'.$text_variable_name ?? ''.'</label>
|
<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 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>
|
<input type="hidden" name="rowID" value="'.$text_variable['rowID'].'" readonly>
|
||||||
';
|
';
|
||||||
|
|
||||||
@@ -141,11 +163,11 @@ $view .= '</div>
|
|||||||
$view .= '<div class="content-block tab-content">
|
$view .= '<div class="content-block tab-content">
|
||||||
<div class="form responsive-width-100">
|
<div class="form responsive-width-100">
|
||||||
<label for="">'.$general_created.'</label>
|
<label for="">'.$general_created.'</label>
|
||||||
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$text_variable['created'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.getRelativeTime($text_variable['created']).'" readonly>
|
||||||
<label for="">'.$general_createdby.'</label>
|
<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="'.$text_variable['createdby'].'" readonly>
|
||||||
<label for="productcode">'.$general_updated.'</label>
|
<label for="productcode">'.$general_updated.'</label>
|
||||||
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.$text_variable['updated'].'" readonly>
|
<input id="name" type="text" name="" placeholder="'.$general_updated.'" value="'.getRelativeTime($text_variable['updated']).'" readonly>
|
||||||
<label for="productcode">'.$general_updatedby.'</label>
|
<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="'.$text_variable['updatedby'].'" readonly>
|
||||||
</div>
|
</div>
|
||||||
@@ -153,6 +175,122 @@ $view .= '<div class="content-block tab-content">
|
|||||||
$view .= '</form>';
|
$view .= '</form>';
|
||||||
|
|
||||||
|
|
||||||
|
$view .= '
|
||||||
|
<div class="content-block">
|
||||||
|
<button class="btn2" onClick="addNewRow()" > + </button>
|
||||||
|
<form action="" id="update" method="post"></form>
|
||||||
|
<form action="" id="new" method="post"></form>
|
||||||
|
|
||||||
|
<div class="table">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>'.($text_variable_translation_languagekey ?? '').'</th>
|
||||||
|
<th>'.($text_variable_translation_translation ?? '').'</th>
|
||||||
|
<th>'.$general_created.'</th>
|
||||||
|
<th>'.$general_actions.'</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="tableBody">
|
||||||
|
';
|
||||||
|
|
||||||
|
if (empty($text_variable_translations)){
|
||||||
|
$view .= '
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" style="text-align:center;">'.($message_no_text_variables ?? '').'</td>
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach ($text_variable_translations as $translation){
|
||||||
|
$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>
|
||||||
|
<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>
|
||||||
|
</tr>
|
||||||
|
</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$view .= '
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let rowCounter = 1;
|
||||||
|
|
||||||
|
function addNewRow() {
|
||||||
|
rowCounter++;
|
||||||
|
const tbody = document.getElementById(\'tableBody\');
|
||||||
|
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>
|
||||||
|
</td>
|
||||||
|
<td><input form="new" type="text" name="translation" placeholder="'.($text_variable_translation_translation ?? '').'" 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>
|
||||||
|
`;
|
||||||
|
|
||||||
|
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>
|
||||||
|
';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Output
|
//Output
|
||||||
echo $view;
|
echo $view;
|
||||||
template_footer()
|
template_footer()
|
||||||
|
|||||||
@@ -34,24 +34,24 @@ $GET_VALUES = urlGETdetails($_GET) ?? '';
|
|||||||
$api_url = '/v2/translations/'.$GET_VALUES;
|
$api_url = '/v2/translations/'.$GET_VALUES;
|
||||||
$responses = ioServer($api_url,'');
|
$responses = ioServer($api_url,'');
|
||||||
//Decode Payload
|
//Decode Payload
|
||||||
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;}
|
if (!empty($responses)){$responses = json_decode($responses,true);}else{$responses = null;}
|
||||||
|
|
||||||
//Return QueryTotal from API
|
//Return QueryTotal from API
|
||||||
$api_url = '/v2/translations/'.$GET_VALUES.'&totals=';
|
$api_url = '/v2/translations/'.$GET_VALUES.'&totals=';
|
||||||
$query_total = ioServer($api_url,'');
|
$query_total = ioServer($api_url,'');
|
||||||
//Decode Payload
|
//Decode Payload
|
||||||
if (!empty($query_total)){$query_total = decode_payload($query_total);}else{$query_total = null;}
|
if (!empty($query_total)){$query_total = json_decode($query_total,true);}else{$query_total = null;}
|
||||||
|
|
||||||
// Handle success messages
|
// Handle success messages
|
||||||
if (isset($_GET['success_msg'])) {
|
if (isset($_GET['success_msg'])) {
|
||||||
if ($_GET['success_msg'] == 1) {
|
if ($_GET['success_msg'] == 1) {
|
||||||
$success_msg = $message_pr_1;
|
$success_msg = $message_tv_1;
|
||||||
}
|
}
|
||||||
if ($_GET['success_msg'] == 2) {
|
if ($_GET['success_msg'] == 2) {
|
||||||
$success_msg = $message_pr_2;
|
$success_msg = $message_tv_2;
|
||||||
}
|
}
|
||||||
if ($_GET['success_msg'] == 3) {
|
if ($_GET['success_msg'] == 3) {
|
||||||
$success_msg = $message_pr_3;
|
$success_msg = $message_tv_3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +61,8 @@ $view = '
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
<i class="fa-solid fa-box-open"></i>
|
<i class="fa-solid fa-box-open"></i>
|
||||||
<div class="txt">
|
<div class="txt">
|
||||||
<h2>'.$products_h2.' ('.$query_total.')</h2>
|
<h2>'.($text_variables_h2 ?? '').' ('.$query_total.')</h2>
|
||||||
<p>'.$products_p.'</p>
|
<p>'.($text_variables_p ?? '').'</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
@@ -76,23 +76,12 @@ $view .= ' <div class="msg success">
|
|||||||
}
|
}
|
||||||
$view .= '
|
$view .= '
|
||||||
<div class="content-header responsive-flex-column pad-top-5">
|
<div class="content-header responsive-flex-column pad-top-5">
|
||||||
<a href="index.php?page=translation_manage" class="btn">'.$button_create_product.'</a>
|
<a href="index.php?page=translation_manage" class="btn">'.($button_create_text_variable ?? '').'</a>
|
||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<input type="hidden" name="page" value="translations">
|
<input type="hidden" name="page" value="translations">
|
||||||
<div class="filters">
|
|
||||||
<a href="#"><i class="fa-solid fa-filter"></i>'.$general_filters.'</a>
|
|
||||||
<div class="list">
|
|
||||||
<select name="status">
|
|
||||||
<option value="" disabled selected>'.$prod_status_text.'</option>
|
|
||||||
<option value="0"'.($status==0?' selected':'').'>'.$prod_status_0.'</option>
|
|
||||||
<option value="1"'.($status==1?' selected':'').'>'.$prod_status_1.'</option>
|
|
||||||
</select>
|
|
||||||
<button type="submit">'.$button_apply.'</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<label for="search">
|
<label for="search">
|
||||||
<input id="search" type="text" name="search" placeholder="'.$product_search .'" value="" class="responsive-width-100">
|
<input id="search" type="text" name="search" placeholder="'.($text_variable_search ?? '').'" value="" class="responsive-width-100">
|
||||||
<i class="fas fa-search"></i>
|
<i class="fas fa-search"></i>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -106,11 +95,9 @@ $view .= '
|
|||||||
<table class="sortable">
|
<table class="sortable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>'.$product_code.'</th>
|
<th>'.($text_variable_rowID ?? '').'</th>
|
||||||
<th>'.$product_category.'</th>
|
<th>'.($text_variable_variable ?? '').'</th>
|
||||||
<th>'.$product_parttype.'</th>
|
<th class="responsive-hidden">'.$general_created.'</th>
|
||||||
<th class="responsive-hidden"></th>
|
|
||||||
<th>'.$product_name.'</th>
|
|
||||||
<th>'.$general_actions.'</th>
|
<th>'.$general_actions.'</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -121,13 +108,19 @@ $view .= '
|
|||||||
|
|
||||||
$view .= '
|
$view .= '
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="8" style="text-align:center;">'.$message_no_products.'</td>
|
<td colspan="8" style="text-align:center;">'.($message_no_text_variables ?? '').'</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
var_dump($responses);
|
|
||||||
foreach ($responses as $response){
|
foreach ($responses as $response){
|
||||||
|
$view .= '
|
||||||
|
<tr>
|
||||||
|
<td>'.$response['rowID'].'</td>
|
||||||
|
<td>'.$response['variable'].'</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>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user