CMXX - Product query updates
This commit is contained in:
@@ -27,12 +27,14 @@ $product = [
|
||||
'productdescription' => '',
|
||||
'softwareversion' => 'v1.0',
|
||||
'product_media' =>'',
|
||||
'url_slug' => '',
|
||||
'full_path' =>'',
|
||||
'created' => '',
|
||||
'createdby' => $_SESSION['username'],
|
||||
'parttype' => 1,
|
||||
'price' => '0',
|
||||
'salesflag' => 0,
|
||||
'quantity' => 1,
|
||||
'updated' => '',
|
||||
'updatedby' => $_SESSION['username'],
|
||||
'product_category' => '',
|
||||
@@ -56,15 +58,15 @@ if (!empty($categories)){$categories = json_decode($categories,true);}else{$cate
|
||||
if (isset($_GET['id'])) {
|
||||
// ID param exists, edit an existing product
|
||||
//CALL TO API
|
||||
$api_url = '/v1/products/rowID='.$_GET['id'];
|
||||
$api_url = '/v2/products/rowID='.$_GET['id'];
|
||||
$responses = ioServer($api_url,'');
|
||||
//Decode Payload
|
||||
if (!empty($responses)){$responses = decode_payload($responses);}else{$responses = null;}
|
||||
if (!empty($responses)){$responses = json_decode($responses);}else{$responses = null;}
|
||||
|
||||
$product = json_decode(json_encode($responses[0]), true);
|
||||
|
||||
//CALL TO API
|
||||
$api_url = '/v2/media/';
|
||||
$api_url = '/v2/media/list=product_image';
|
||||
$media_responses = ioServer($api_url,'');
|
||||
|
||||
//Decode Payload
|
||||
@@ -91,12 +93,9 @@ if (isset($_GET['id'])) {
|
||||
if (isset($_POST['submit'])) {
|
||||
|
||||
//GET ALL POST DATA
|
||||
$data = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||
var_dump($data);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||
//API call
|
||||
$responses = ioServer('/v1/products', $payload);
|
||||
$responses = ioServer('/v2/products', $payload);
|
||||
if ($responses === 'NOK'){
|
||||
|
||||
} else {
|
||||
@@ -110,11 +109,9 @@ if (isset($_GET['id'])) {
|
||||
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);
|
||||
$payload = json_encode($_POST, JSON_UNESCAPED_UNICODE);
|
||||
//API call
|
||||
$responses = ioServer('/v1/products', $payload);
|
||||
$responses = ioServer('/v2/products', $payload);
|
||||
if ($responses === 'NOK'){
|
||||
|
||||
} else {
|
||||
@@ -129,11 +126,9 @@ if (isset($_GET['id'])) {
|
||||
// Create a new product
|
||||
if (isset($_POST['submit']) && $create_allowed === 1) {
|
||||
//GET ALL POST DATA
|
||||
$data = json_encode($_POST , JSON_UNESCAPED_UNICODE);
|
||||
//Secure data
|
||||
$payload = generate_payload($data);
|
||||
$payload = json_encode($_POST , JSON_UNESCAPED_UNICODE);
|
||||
//API call
|
||||
$responses = ioServer('/v1/products', $payload);
|
||||
$responses = ioServer('/v2/products', $payload);
|
||||
if ($responses === 'NOK'){
|
||||
|
||||
}
|
||||
@@ -272,11 +267,13 @@ $view .= '<!-- Image Selector Dialog -->
|
||||
<h3>Select an Image</h3>
|
||||
<div style="display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 20px 0;">';
|
||||
|
||||
if ($media_responses && is_array($media_responses)){
|
||||
foreach ($media_responses as $media_response){
|
||||
$view .= '
|
||||
<img src="'.$media_response['full_path'].'" id="'.$media_response['rowID'].'" style="width: 100%; cursor: pointer; border: 2px solid transparent;" onmouseover="this.style.border=\'2px solid #4CAF50\'" onmouseout="this.style.border=\'2px solid transparent\'" onclick="selectImage(this.id,this.src)">
|
||||
<img src="'.$media_response['full_path'].'" id="'.$media_response['rowID'].'" title="'.$media_response['title'].'" alt="'.$media_response['title'].'" style="width: 100%; cursor: pointer; border: 2px solid transparent;" onmouseover="this.style.border=\'2px solid #4CAF50\'" onmouseout="this.style.border=\'2px solid transparent\'" onclick="selectImage(this.id,this.src)">
|
||||
';
|
||||
}
|
||||
}
|
||||
$view .= '</div>
|
||||
<button onclick="closeImageSelector()">Close</button>
|
||||
</dialog>
|
||||
|
||||
Reference in New Issue
Block a user