CMXX - Upgrade products_software
This commit is contained in:
140
api/v1/get/products_software.php
Normal file
140
api/v1/get/products_software.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
defined($security_key) or exit;
|
||||
|
||||
//------------------------------------------
|
||||
// Products
|
||||
//------------------------------------------
|
||||
|
||||
//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 productcode like :'.$v[0];
|
||||
}
|
||||
else {//create clause
|
||||
$clause .= ' AND '.$v[0].' = :'.$v[0];
|
||||
}
|
||||
}
|
||||
if ($whereclause == '' && $clause !=''){
|
||||
$whereclause = 'WHERE '.substr($clause, 4);
|
||||
} else {
|
||||
$whereclause .= $clause;
|
||||
}
|
||||
}
|
||||
|
||||
//ENSURE PRODUCTROWID IS SEND
|
||||
if (isset($criterias['productrowid']) && $criterias['productrowid'] != ''){
|
||||
|
||||
//CHECK IF ALLOWED TO CRUD VERSIONS
|
||||
$sql = "SELECT * FROM products WHERE rowID = ? '.$whereclause.'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$criterias['productrowid']]);
|
||||
$product_data = $stmt->fetch();
|
||||
$product_owner = ($product_data['rowID'])? 1 : 0;
|
||||
|
||||
//IF PRODUCT IS OWNED THEN CRUD is ALLOWED
|
||||
if ($product_owner === 1 ){
|
||||
|
||||
//Define Query
|
||||
if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
||||
//Request for total rows
|
||||
$sql = 'SELECT count(*) as count FROM products_software '.$whereclause.'';
|
||||
}
|
||||
elseif (isset($criterias['list']) && $criterias['list'] =='') {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT * FROM products_software '.$whereclause.'';
|
||||
}
|
||||
else {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT * FROM products_software '.$whereclause.'';
|
||||
}
|
||||
|
||||
$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];
|
||||
}
|
||||
elseif(isset($criterias['list']) && $criterias['list']==''){
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
//Get results
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
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_products, PDO::PARAM_INT);
|
||||
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
//Get results
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
//Encrypt results
|
||||
$messages = generate_payload($messages);
|
||||
|
||||
//Send results
|
||||
echo $messages;
|
||||
}
|
||||
}
|
||||
?>
|
||||
105
api/v1/post/products_software.php
Normal file
105
api/v1/post/products_software.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(decode_payload($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;
|
||||
}
|
||||
|
||||
//ENSURE PRODUCTROWID IS SEND
|
||||
if (isset($post_content['productrowid']) && $post_content['productrowid'] != ''){
|
||||
|
||||
//CHECK IF ALLOWED TO CRUD VERSIONS
|
||||
$sql = 'SELECT * FROM products WHERE rowID = ? '.$whereclause.'';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$post_content['productrowid']]);
|
||||
$product_data = $stmt->fetch();
|
||||
$product_owner = ($product_data['rowID'])? 1 : 0;
|
||||
|
||||
//IF PRODUCT IS OWNED THEN CRUD is ALLOWED
|
||||
if ($product_owner === 1 ){
|
||||
//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 = '';
|
||||
|
||||
if ($command == 'insert'){
|
||||
$post_content['created'] = $date;
|
||||
$post_content['createdby'] = $username;
|
||||
}
|
||||
|
||||
//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_software',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE products_software SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'insert' && isAllowed('products_software',$profile,$permission,'C') === 1){
|
||||
$sql = 'INSERT INTO products_software ('.$clause_insert.') VALUES ('.$input_insert.')';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'delete' && isAllowed('products_software',$profile,$permission,'D') === 1){
|
||||
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
changelog($dbname,'products_software',$id,'Delete','Delete',$username);
|
||||
} else
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -28,7 +28,7 @@ if (isset($criterias['productcode']) && $criterias['productcode'] != '' && isset
|
||||
$pdo = dbConnect($dbname);
|
||||
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT * FROM products_versions pv JOIN products p ON pv.productrowid = p.rowID WHERE p.productcode = ? AND pv.version = ? AND pv.status = "1"';
|
||||
$sql = 'SELECT * FROM products_software pv JOIN products p ON pv.productrowid = p.rowID WHERE p.productcode = ? AND pv.version = ? AND pv.status = "1"';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
//Excute Query
|
||||
$stmt->execute([$criterias['productcode'],$criterias['version']]);
|
||||
|
||||
105
api/v2/post/products_software.php
Normal file
105
api/v2/post/products_software.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;
|
||||
}
|
||||
|
||||
//ENSURE PRODUCTROWID IS SEND
|
||||
if (isset($post_content['productrowid']) && $post_content['productrowid'] != ''){
|
||||
|
||||
//CHECK IF ALLOWED TO CRUD VERSIONS
|
||||
$sql = "SELECT * FROM products WHERE rowID = ? '.$whereclause.'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$post_content['productrowid']]);
|
||||
$product_data = $stmt->fetch();
|
||||
$product_owner = ($product_data['rowID'])? 1 : 0;
|
||||
|
||||
//IF PRODUCT IS OWNED THEN CRUD is ALLOWED
|
||||
if ($product_owner === 1 ){
|
||||
//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 = '';
|
||||
|
||||
if ($command == 'insert'){
|
||||
$post_content['created'] = $date;
|
||||
$post_content['createdby'] = $username;
|
||||
}
|
||||
|
||||
//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_software',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE products_software SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'insert' && isAllowed('products_software',$profile,$permission,'C') === 1){
|
||||
$sql = 'INSERT INTO products_software ('.$clause_insert.') VALUES ('.$input_insert.')';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'delete' && isAllowed('products_software',$profile,$permission,'D') === 1){
|
||||
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
changelog($dbname,'products_',$id,'Delete','Delete',$username);
|
||||
} else
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
47
product.php
47
product.php
@@ -48,6 +48,13 @@ $product_versions = ioServer($api_url,'');
|
||||
//Decode Payload
|
||||
if (!empty($product_versions)){$product_versions = decode_payload($product_versions);}else{$product_versions = null;}
|
||||
|
||||
//CALL TO API FOR Product_versions
|
||||
$api_url = '/v1/products_software/productrowid='.$_GET['rowID'];
|
||||
$product_software = ioServer($api_url,'');
|
||||
//Decode Payload
|
||||
if (!empty($product_software)){$product_software = decode_payload($product_software);}else{$product_software = null;}
|
||||
|
||||
|
||||
//------------------------------
|
||||
//Variables
|
||||
//------------------------------
|
||||
@@ -166,13 +173,51 @@ $view .= '<div class="content-block">
|
||||
<th>'.$product_version_number.'</th>
|
||||
<th>'.$product_status.'</th>
|
||||
<th>'.$product_version_version.'</th>
|
||||
<th>'.$product_version_software .'</th>
|
||||
<th>'.$general_actions.'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($product_versions as $version){
|
||||
|
||||
$view .= '<tr>
|
||||
<td>'.$version->rowID.'</td>
|
||||
<td>'.(($version->status == 1)? '<span class="status enabled">'.$prod_status_1:'<span class="status">'.$prod_status_0).'</td>
|
||||
<td>'.$version->version.'</td>
|
||||
<td><a href="index.php?page=products_versions&productrowid='.$_GET['rowID'].'&rowID='.$version->rowID.'" class="btn_link">'.$general_view.'</a></td>
|
||||
</tr>';
|
||||
}
|
||||
$view .= '
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
';
|
||||
}
|
||||
|
||||
$view .= '
|
||||
</div>
|
||||
';
|
||||
|
||||
$view .= '<div class="content-block">
|
||||
<div class="block-header">
|
||||
<i class="fa-solid fa-bars fa-sm"></i>'.($product_software ?? '').'
|
||||
<a href="index.php?page=products_software&productrowid='.$_GET['rowID'].'" class="btn2"> + </a>
|
||||
</div>';
|
||||
if (!empty($product_software)){
|
||||
$view .= '
|
||||
<div class="table">
|
||||
<table class="sortable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>'.$product_status.'</th>
|
||||
<th>'.$product_version_version.'</th>
|
||||
<th>'.$product_version_software .'</th>
|
||||
<th>'.$general_actions.'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($product_software as $version){
|
||||
|
||||
$view .= '<tr>
|
||||
<td>'.$version->rowID.'</td>
|
||||
<td>'.(($version->status == 1)? '<span class="status enabled">'.$prod_status_1:'<span class="status">'.$prod_status_0).'</td>
|
||||
|
||||
220
products_software.php
Normal file
220
products_software.php
Normal file
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
defined(page_security_key) or exit;
|
||||
|
||||
$page = 'products_versions';
|
||||
//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');
|
||||
$delete_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'D');
|
||||
$create_allowed = isAllowed($page ,$_SESSION['profile'],$_SESSION['permission'],'C');
|
||||
|
||||
// Default input product values
|
||||
$products_versions = [
|
||||
'rowID' => '',
|
||||
'productrowid' => '',
|
||||
'status' => '',
|
||||
'version' => '',
|
||||
'software' => '',
|
||||
'created' => '',
|
||||
'createdby' => $_SESSION['username'],
|
||||
'measurement' => '',
|
||||
];
|
||||
|
||||
//productrowid is required by api
|
||||
$productrowid = $_GET['productrowid'] ?? '';
|
||||
|
||||
if (isset($_GET['rowID'])) {
|
||||
// ID param exists, edit an existing product
|
||||
//CALL TO API
|
||||
$api_url = '/v1/products_software/rowID='.$_GET['rowID'].'&productrowid='.$productrowid;
|
||||
$responses = ioServer($api_url,'');
|
||||
|
||||
//Decode Payload
|
||||
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;}
|
||||
|
||||
$products_versions = json_decode(json_encode($responses[0]), true);
|
||||
|
||||
|
||||
if ($update_allowed === 1){
|
||||
if (isset($_POST['submit'])) {
|
||||
|
||||
//CHECK FOR FIRMWARE FILE
|
||||
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
||||
|
||||
if($firmware_file !='' || !empty($firmware_file)){
|
||||
|
||||
$extension = strtolower(pathinfo($firmware_file, PATHINFO_EXTENSION));
|
||||
$target_dir = dirname(__FILE__)."/firmware/";
|
||||
|
||||
if ($extension == 'hex'){
|
||||
//READ FILE
|
||||
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
|
||||
//firmwarename
|
||||
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
|
||||
//Filename
|
||||
$input_file = $target_dir . $firmware_name.'.HEX';
|
||||
//store firmware file
|
||||
file_put_contents($input_file, $contents);
|
||||
|
||||
} else {
|
||||
$target_file = $target_dir . $firmware_file;
|
||||
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
|
||||
$firmware_name = $firmware_file;
|
||||
}
|
||||
|
||||
//Use firmwarefile name as software version
|
||||
$_POST['software'] = $firmware_name;
|
||||
}
|
||||
|
||||
//GET ALL POST DATA
|
||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
//API call
|
||||
$responses = ioServer('/v1/products_software', $payload);
|
||||
if ($responses === 'NOK'){
|
||||
|
||||
} else {
|
||||
header('Location: index.php?page=product&rowID='.$productrowid.'&success_msg=2');
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_allowed === 1){
|
||||
if (isset($_POST['delete'])) {
|
||||
//GET ALL POST DATA
|
||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
//API call
|
||||
$responses = ioServer('/v1/products_software', $payload);
|
||||
if ($responses === 'NOK'){
|
||||
|
||||
} else {
|
||||
// Redirect and delete product
|
||||
header('Location: index.php?page=product&rowID='.$productrowid.'&success_msg=3');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Create a new product
|
||||
if (isset($_POST['submit']) && $create_allowed === 1) {
|
||||
|
||||
//CHECK FOR FIRMWARE FILE
|
||||
$firmware_file = $_FILES["fileToUpload"]["name"] ?? '';
|
||||
|
||||
if($firmware_file !='' || !empty($firmware_file)){
|
||||
|
||||
$extension = strtolower(pathinfo($firmware_file, PATHINFO_EXTENSION));
|
||||
$target_dir = dirname(__FILE__)."/firmware/";
|
||||
|
||||
if ($extension == 'hex'){
|
||||
//READ FILE
|
||||
$contents = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
|
||||
//firmwarename
|
||||
$firmware_name = pathinfo($_FILES["fileToUpload"]["name"], PATHINFO_FILENAME);
|
||||
//Filename
|
||||
$input_file = $target_dir . $firmware_name.'.HEX';
|
||||
//store firmware file
|
||||
file_put_contents($input_file, $contents);
|
||||
|
||||
$firmware_name = $firmware_name.'.HEX';
|
||||
|
||||
} else {
|
||||
$target_file = $target_dir . $firmware_file;
|
||||
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file);
|
||||
$firmware_name = $firmware_file;
|
||||
}
|
||||
|
||||
//Use firmwarefile name as software version
|
||||
$_POST['software'] = $firmware_name;
|
||||
}
|
||||
|
||||
//GET ALL POST DATA
|
||||
$data = json_encode($_POST , JSON_UNESCAPED_UNICODE);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
//API call
|
||||
$responses = ioServer('/v1/products_software', $payload);
|
||||
if ($responses === 'NOK'){
|
||||
|
||||
}
|
||||
else {
|
||||
header('Location: index.php?page=product&rowID='.$productrowid.'&success_msg=1');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template_header('Products software', 'products_software', 'manage');
|
||||
|
||||
$view ='
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<div class="content-title responsive-flex-wrap responsive-pad-bot-3">
|
||||
<h2 class="responsive-width-100">'.$product_version_software.'</h2>
|
||||
<a href="index.php?page=product&rowID='.$productrowid.'" class="btn alt mar-right-2">'.$button_cancel.'</a>
|
||||
';
|
||||
|
||||
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 product?\')">';
|
||||
}
|
||||
if ($update_allowed === 1){
|
||||
$view .= '<input type="submit" name="submit" value="Save" class="btn">';
|
||||
}
|
||||
|
||||
$view .= '</div>';
|
||||
|
||||
$view .= '<div class="tabs">
|
||||
<a href="#" class="active">'.$tab1.'</a>
|
||||
<a href="#">'.$tab3.'</a>
|
||||
</div>
|
||||
';
|
||||
|
||||
$view .= '<div class="content-block tab-content active">
|
||||
<div class="form responsive-width-100">
|
||||
<label for="status">'.$product_status.'</label>
|
||||
<select id="status" name="status">
|
||||
<option value="1" '.($products_versions['status']==1?' selected':'').'>'.$prod_status_1 .'</option>
|
||||
<option value="0" '.($products_versions['status']==0?' selected':'').'>'.$prod_status_0 .'</option>
|
||||
</select>
|
||||
<label for=""><i class="required">*</i>'.$product_version_version.'</label>
|
||||
<input id="name" type="text" name="version" placeholder="'.$product_version_version.'" value="'.$products_versions['version'].'" required>
|
||||
|
||||
<label for=""><i class="required">*</i>'.$product_version_software.'</label>
|
||||
<input id="name" type="text" name="software" placeholder="'.$product_version_software.'" value="'.$products_versions['software'].'">
|
||||
|
||||
<label for=""><i class="required">*</i>'.ucfirst($register_mandatory).'</label>
|
||||
<select id="mandatory" name="mandatory">
|
||||
<option value="0" '.($products_software['mandatory']==0?' selected':'').'>'.$general_no.'</option>
|
||||
<option value="1" '.($products_software['mandatory']==1?' selected':'').'>'.$general_yes.'</option>
|
||||
</select>
|
||||
|
||||
<label for=""></label>
|
||||
<input type="file" name="fileToUpload" id="fileToUpload" accept=".hex, .HEX, .bin,.BIN,.exe,.EXE" style="width: 30%;padding: 50px 0 0 0;height: 10px;">
|
||||
<input type="hidden" name="rowID" value="'.$products_versions['rowID'].'">
|
||||
<input type="hidden" name="productrowid" value="'.$productrowid.'">
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
$view .= '<div class="content-block tab-content">
|
||||
<div class="form responsive-width-100">
|
||||
<label for="productcode">'.$general_created.'</label>
|
||||
<input id="name" type="text" name="" placeholder="'.$general_created.'" value="'.$products_versions['created'].'" readonly>
|
||||
<label for="productcode">'.$general_createdby.'</label>
|
||||
<input id="name" type="text" name="" placeholder="'.$general_createdby.'" value="'.$products_versions['createdby'].'" readonly>
|
||||
</div>
|
||||
</div>';
|
||||
$view .= '</form>';
|
||||
|
||||
//Output
|
||||
echo $view;
|
||||
template_footer()
|
||||
?>
|
||||
@@ -188,13 +188,6 @@ $view .= '<div class="content-block tab-content active">
|
||||
<label for=""><i class="required">*</i>'.$product_version_version.'</label>
|
||||
<input id="name" type="text" name="version" placeholder="'.$product_version_version.'" value="'.$products_versions['version'].'" required>
|
||||
|
||||
<label for=""><i class="required">*</i>'.$product_version_software.'</label>
|
||||
<input id="name" type="text" name="software" placeholder="'.$product_version_software.'" value="'.$products_versions['software'].'">
|
||||
|
||||
<label for=""></label>
|
||||
<input type="file" name="fileToUpload" id="fileToUpload" accept=".hex, .HEX, .bin,.BIN,.exe,.EXE" style="width: 30%;padding: 50px 0 0 0;height: 10px;">
|
||||
|
||||
|
||||
';
|
||||
|
||||
if (isset($_GET['rowID']) && $_GET['rowID'] !='' && !empty($products_versions['measurement'])){
|
||||
|
||||
@@ -76,6 +76,9 @@ $general_actions_more = 'Mehr anzeigen';
|
||||
$general_profile = 'Profil';
|
||||
$general_logout = 'Abmelden';
|
||||
|
||||
$general_yes = 'Ja';
|
||||
$general_no = 'Nein';
|
||||
|
||||
$button_apply = 'Anwenden';
|
||||
$button_cancel = 'Abbrechen';
|
||||
$button_back = 'Zurück';
|
||||
|
||||
@@ -76,6 +76,9 @@ $general_actions_more = 'Mostrar más';
|
||||
$general_profile = 'Perfil';
|
||||
$general_logout = 'Cerrar sesión';
|
||||
|
||||
$general_yes = 'Sí';
|
||||
$general_no = 'No';
|
||||
|
||||
$button_apply = 'Aplicar';
|
||||
$button_cancel = 'Cancelar';
|
||||
$button_back = 'Regresar';
|
||||
|
||||
@@ -77,6 +77,9 @@ $general_actions_more = 'Meer resultaten';
|
||||
$general_profile = 'Profiel';
|
||||
$general_logout = 'Uitloggen';
|
||||
|
||||
$general_yes = 'Ja';
|
||||
$general_no = 'Nee';
|
||||
|
||||
$button_apply = 'Toepassen';
|
||||
$button_cancel = 'Terug';
|
||||
$button_back = 'Terug';
|
||||
|
||||
@@ -76,6 +76,9 @@ $general_actions_more = 'Mostrar mais';
|
||||
$general_profile = 'Perfil';
|
||||
$general_logout = 'Sair';
|
||||
|
||||
$general_yes = 'Não';
|
||||
$general_no = 'Ruim';
|
||||
|
||||
$button_apply = 'Aplicar';
|
||||
$button_cancel = 'Cancelar';
|
||||
$button_back = 'Voltar';
|
||||
|
||||
@@ -76,6 +76,9 @@ $general_actions_more = 'Show more';
|
||||
$general_profile = 'Profile';
|
||||
$general_logout = 'Logout';
|
||||
|
||||
$general_yes = 'Yes';
|
||||
$general_no = 'No';
|
||||
|
||||
$button_apply = 'Apply';
|
||||
$button_cancel = 'Cancel';
|
||||
$button_back = 'Back';
|
||||
|
||||
Reference in New Issue
Block a user