CM91 - RMA update
This commit is contained in:
@@ -15,7 +15,6 @@ $whereclause = '';
|
||||
|
||||
//SET PARAMETERS FOR QUERY
|
||||
$id = $post_content['rowID'] ?? ''; //check for rowID
|
||||
$rma_id = $post_content['rmaID'] ?? 0; //check for rmaID
|
||||
$command = ($id == '')? 'insert' : 'update'; //IF rowID = empty then INSERT
|
||||
if (isset($post_content['delete'])){$command = 'delete';} //change command to delete
|
||||
|
||||
@@ -44,10 +43,14 @@ if ($command == 'insert'){
|
||||
$post_content['createdby'] = $username;
|
||||
}
|
||||
|
||||
//ENCODE HEADER AND QUESTIONS
|
||||
if (isset($post_content['header'])){$post_content['header'] = json_encode($post_content['header'], JSON_UNESCAPED_UNICODE);}
|
||||
if (isset($post_content['questions'])){$post_content['questions'] = json_encode($post_content['questions'], JSON_UNESCAPED_UNICODE);}
|
||||
|
||||
//CREAT NEW ARRAY AND MAP TO CLAUSE
|
||||
if(isset($post_content) && $post_content!=''){
|
||||
foreach ($post_content as $key => $var){
|
||||
if ($key == 'submit' || $key == 'delete' || $key == 'rowID'){
|
||||
if ($key == 'save' ||$key == 'submit' || $key == 'delete' || $key == 'rowID'){
|
||||
//do nothing
|
||||
}
|
||||
else {
|
||||
@@ -66,13 +69,13 @@ $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' && $rma_id !=0 && isAllowed('rma',$profile,$permission,'U') === 1){
|
||||
if ($command == 'update' && isAllowed('rma',$profile,$permission,'U') === 1){
|
||||
$sql = 'UPDATE rma SET '.$clause.' WHERE rowID = ? '.$whereclause.'';
|
||||
$execute_input[] = $id;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
}
|
||||
elseif ($command == 'insert' && $rma_id !=0 && isAllowed('rma',$profile,$permission,'C') === 1){
|
||||
elseif ($command == 'insert' && isAllowed('rma',$profile,$permission,'C') === 1){
|
||||
$sql = 'INSERT INTO rma ('.$clause_insert.') VALUES ('.$input_insert.')';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($execute_input);
|
||||
|
||||
Reference in New Issue
Block a user