CMXX - Product query updates
This commit is contained in:
@@ -14,8 +14,6 @@ if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} el
|
||||
//default whereclause
|
||||
$whereclause = '';
|
||||
|
||||
list($whereclause,$condition) = getWhereclause('',$permission,$partner,'get');
|
||||
|
||||
//NEW ARRAY
|
||||
$criterias = [];
|
||||
$clause = '';
|
||||
@@ -52,7 +50,10 @@ if(isset($get_content) && $get_content!=''){
|
||||
if (isset($criterias['productrowid']) && $criterias['productrowid'] != ''){
|
||||
|
||||
//CHECK IF ALLOWED TO CRUD VERSIONS
|
||||
$sql = "SELECT * FROM products WHERE rowID = ? '.$whereclause.'";
|
||||
|
||||
list($whereclause2,$condition) = getWhereclause('',$permission,$partner,'get');
|
||||
|
||||
$sql = "SELECT * FROM products WHERE rowID = ? '.$whereclause2.'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$criterias['productrowid']]);
|
||||
$product_data = $stmt->fetch();
|
||||
|
||||
@@ -108,7 +108,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
$stmt->execute([$post_content['productrowid'], $hw_eq_version ]);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE products_software SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE products_software SET '.$clause.' WHERE rowID = ? ';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
@@ -129,7 +129,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
elseif ($command == 'delete' && isAllowed('products_software',$profile,$permission,'D') === 1){
|
||||
|
||||
//GET FILENAME AND REMOVE FROM SERVER
|
||||
$sql = 'SELECT * FROM products_software WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'SELECT * FROM products_software WHERE rowID = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$id]);
|
||||
//Get results
|
||||
@@ -142,7 +142,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
unlink($software_file);
|
||||
}
|
||||
}
|
||||
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? ');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
|
||||
@@ -68,7 +68,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
|
||||
//QUERY AND VERIFY ALLOWED
|
||||
if ($command == 'update' && isAllowed('products_versions',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE products_versions SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE products_versions SET '.$clause.' WHERE rowID = ? ';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
@@ -79,7 +79,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'delete' && isAllowed('products_versions',$profile,$permission,'D') === 1){
|
||||
$stmt = $pdo->prepare('DELETE FROM products_versions WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt = $pdo->prepare('DELETE FROM products_versions WHERE rowID = ? ');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
|
||||
@@ -56,7 +56,7 @@ if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
||||
}
|
||||
else {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT id,email,profile,first_name,last_name,address_street,address_city,address_state,address_zip,address_country,registered,address_phone,lastlogin,userkey,language,login_count,created,createdby,updated,updatedby,accounthierarchy FROM identity '.$whereclause.' ORDER BY lastlogin DESC LIMIT :page,:num_products';
|
||||
$sql = 'SELECT id,email,profile,first_name,last_name,address_street,address_city,address_state,address_zip,address_country,address_phone,lastlogin,userkey,language,login_count,created,createdby,updated,updatedby,accounthierarchy FROM identity '.$whereclause.' ORDER BY lastlogin DESC LIMIT :page,:num_products';
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
@@ -52,6 +52,10 @@ if(isset($criterias['totals']) && $criterias['totals'] ==''){
|
||||
//Request for total rows
|
||||
$sql = 'SELECT count(*) as count FROM media '.$whereclause.'';
|
||||
}
|
||||
elseif ($criterias['list'] && $criterias['list'] =='product_image') {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT * FROM media '.$whereclause;
|
||||
}
|
||||
else {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT * FROM media '.$whereclause.' LIMIT :page,:num_products';
|
||||
@@ -85,6 +89,10 @@ if(isset($criterias['totals']) && $criterias['totals']==''){
|
||||
$messages = $stmt->fetch();
|
||||
$messages = $messages[0];
|
||||
}
|
||||
elseif(isset($criterias['list']) && $criterias['list']=='product_image'){
|
||||
$stmt->execute();
|
||||
$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_media, PDO::PARAM_INT);
|
||||
|
||||
@@ -14,7 +14,7 @@ if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} el
|
||||
//default whereclause
|
||||
$whereclause = '';
|
||||
|
||||
list($whereclause,$condition) = getWhereclause('',$permission,$partner,'get');
|
||||
list($whereclause,$condition) = getWhereclause('products',$permission,$partner,'get');
|
||||
|
||||
//NEW ARRAY
|
||||
$criterias = [];
|
||||
|
||||
@@ -14,8 +14,6 @@ if (empty($partner->soldto) || $partner->soldto == ''){$soldto_search = '%';} el
|
||||
//default whereclause
|
||||
$whereclause = '';
|
||||
|
||||
list($whereclause,$condition) = getWhereclause('',$permission,$partner,'get');
|
||||
|
||||
//NEW ARRAY
|
||||
$criterias = [];
|
||||
$clause = '';
|
||||
@@ -52,7 +50,10 @@ if(isset($get_content) && $get_content!=''){
|
||||
if (isset($criterias['productrowid']) && $criterias['productrowid'] != ''){
|
||||
|
||||
//CHECK IF ALLOWED TO CRUD VERSIONS
|
||||
$sql = "SELECT * FROM products WHERE rowID = ? '.$whereclause.'";
|
||||
|
||||
list($whereclause2,$condition) = getWhereclause('',$permission,$partner,'get');
|
||||
|
||||
$sql = "SELECT * FROM products WHERE rowID = ? '.$whereclause2.'";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$criterias['productrowid']]);
|
||||
$product_data = $stmt->fetch();
|
||||
|
||||
@@ -57,7 +57,7 @@ if ($id != '' && $command == 'reset'){
|
||||
$stmt->execute([$resetkey,$post_content['updatedby'],$id]);
|
||||
|
||||
//STEP 3 - Send DATA BACK TO FRONT_END
|
||||
$messages = json_encode(array('consumer_email'=> $consumer_data['email'], "resetkey" => $resetkey), JSON_UNESCAPED_UNICODE);
|
||||
$messages = json_encode(array('identity'=> $consumer_data['email'], "resetkey" => $resetkey), JSON_UNESCAPED_UNICODE);
|
||||
//Send results
|
||||
echo $messages;
|
||||
exit;
|
||||
@@ -69,7 +69,7 @@ if ($command == 'update'){
|
||||
$stmt = $pdo->prepare('SELECT * FROM identity WHERE userkey = ?');
|
||||
$stmt->execute([$id]);
|
||||
$consumer_data = $stmt->fetch();
|
||||
|
||||
|
||||
$post_content['updatedby'] = $consumer_data['email'];
|
||||
|
||||
if (isset($post_content['password'])){
|
||||
@@ -82,6 +82,8 @@ elseif ($command == 'insert'){
|
||||
$post_content['language'] = isset($post_content['language']) ? $post_content['language'] : 'US';
|
||||
$post_content['profile'] = 0;
|
||||
$post_content['isverified'] = 0;
|
||||
$post_content['createdby'] = $username;
|
||||
$post_content['updatedby'] = $username;
|
||||
}
|
||||
elseif ($command == 'login'){
|
||||
|
||||
@@ -103,7 +105,8 @@ elseif ($command == 'login'){
|
||||
//CONSUMER LOGIN CORRECT RETURN DATA
|
||||
$consumer = array(
|
||||
'accountID' => $account['userkey'],
|
||||
'profile' => $account['profile']
|
||||
'profile' => $account['profile'],
|
||||
'language' =>$account['language']
|
||||
);
|
||||
|
||||
//Reset login count after succesfull attempt
|
||||
@@ -173,6 +176,11 @@ if ($command == 'update' && (isAllowed('identity',$profile,$permission,'U') ===
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
|
||||
//STEP 2- Send to user
|
||||
$messages = json_encode(array('accountID' => $id,'status' => 'updated'), JSON_UNESCAPED_UNICODE);
|
||||
//Send results
|
||||
echo $messages;
|
||||
exit;
|
||||
}
|
||||
elseif ($command == 'insert' && isAllowed('',$profile,$permission,'C') === 1){
|
||||
|
||||
@@ -188,7 +196,7 @@ elseif ($command == 'insert' && isAllowed('',$profile,$permission,'C') === 1){
|
||||
$stmt->execute($execute_input);
|
||||
|
||||
//STEP 2- Send to user
|
||||
$messages = json_encode(array('consumer_email'=> $post_content['email'],'accountID' => $account['userkey'],'profile' => $post_content['profile'], 'resetkey' => $resetkey), JSON_UNESCAPED_UNICODE);
|
||||
$messages = json_encode(array('identity'=> $post_content['email'],'accountID' => $post_content['userkey'],'profile' => $post_content['profile'], 'resetkey' => $resetkey, 'language' =>$post_content['language']), JSON_UNESCAPED_UNICODE);
|
||||
//Send results
|
||||
echo $messages;
|
||||
exit;
|
||||
|
||||
@@ -70,7 +70,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
|
||||
//QUERY AND VERIFY ALLOWED
|
||||
if ($command == 'update' && isAllowed('products_configurations',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE products_configurations SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE products_configurations SET '.$clause.' WHERE rowID = ? ';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
@@ -81,7 +81,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'delete' && isAllowed('products_configurations',$profile,$permission,'D') === 1){
|
||||
$stmt = $pdo->prepare('DELETE FROM products_configurations WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt = $pdo->prepare('DELETE FROM products_configurations WHERE rowID = ? ');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
|
||||
@@ -68,7 +68,7 @@ if (isset($post_content['product_id']) && $post_content['product_id'] != ''){
|
||||
|
||||
//QUERY AND VERIFY ALLOWED
|
||||
if ($command == 'update' && isAllowed('products_media',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE products_media SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE products_media SET '.$clause.' WHERE rowID = ? ';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
@@ -79,7 +79,7 @@ if (isset($post_content['product_id']) && $post_content['product_id'] != ''){
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'delete' && isAllowed('products_media',$profile,$permission,'D') === 1){
|
||||
$stmt = $pdo->prepare('DELETE FROM products_media WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt = $pdo->prepare('DELETE FROM products_media WHERE rowID = ? ');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
|
||||
@@ -114,7 +114,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
$stmt->execute([$post_content['productrowid'], $hw_eq_version ]);
|
||||
}
|
||||
|
||||
$sql = 'UPDATE products_software SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE products_software SET '.$clause.' WHERE rowID = ? ';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
@@ -134,7 +134,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
elseif ($command == 'delete' && isAllowed('products_software',$profile,$permission,'D') === 1){
|
||||
|
||||
//GET FILENAME AND REMOVE FROM SERVER
|
||||
$sql = 'SELECT * FROM products_software WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'SELECT * FROM products_software WHERE rowID = ? ';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([$id]);
|
||||
//Get results
|
||||
@@ -148,7 +148,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt = $pdo->prepare('DELETE FROM products_software WHERE rowID = ? ');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
|
||||
@@ -68,7 +68,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
|
||||
//QUERY AND VERIFY ALLOWED
|
||||
if ($command == 'update' && isAllowed('products_versions',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE products_versions SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$sql = 'UPDATE products_versions SET '.$clause.' WHERE rowID = ? ';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
@@ -79,7 +79,7 @@ if (isset($post_content['productrowid']) && $post_content['productrowid'] != '')
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'delete' && isAllowed('products_versions',$profile,$permission,'D') === 1){
|
||||
$stmt = $pdo->prepare('DELETE FROM products_versions WHERE rowID = ? '.$whereclause.'');
|
||||
$stmt = $pdo->prepare('DELETE FROM products_versions WHERE rowID = ? ');
|
||||
$stmt->execute([ $id ]);
|
||||
|
||||
//Add deletion to changelog
|
||||
|
||||
Reference in New Issue
Block a user