CM91 - RMA update
This commit is contained in:
@@ -61,7 +61,7 @@ if(isset($get_content) && $get_content!=''){
|
||||
$v = explode("=", $y);
|
||||
//INCLUDE VARIABLES IN ARRAY
|
||||
$criterias[$v[0]] = $v[1];
|
||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='products' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){
|
||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='products' || $v[0] =='list' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){
|
||||
//do nothing
|
||||
}
|
||||
elseif ($v[0] == 'equipmentid') {
|
||||
@@ -188,6 +188,10 @@ elseif (isset($criterias['products']) && $criterias['products'] ==''){
|
||||
//Request for all products in equipment view
|
||||
$sql = 'SELECT distinct(p.productcode), p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY p.productcode';
|
||||
}
|
||||
elseif (isset($criterias['list']) && $criterias['list'] =='') {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT e.rowID, e.serialnumber FROM equipment e '.$whereclause.'';
|
||||
}
|
||||
elseif (isset($criterias['totals']) && $criterias['totals'] =='' && isset($criterias['type'])){
|
||||
//Request for total rows for history reports
|
||||
$sql ='SELECT count(*) as count FROM equipment_history h LEFT JOIN equipment e ON h.equipmentid = e.rowID '.$whereclause.'';
|
||||
@@ -320,7 +324,7 @@ if(isset($criterias['totals']) && $criterias['totals']==''){
|
||||
$messages = $stmt->fetch();
|
||||
$messages = $messages[0];
|
||||
}
|
||||
elseif ((isset($criterias['history']) && $criterias['history'] !='') || (isset($criterias['products']) && $criterias['products'] =='') || (isset($criterias['download']) && $criterias['download'] =='')){
|
||||
elseif ((isset($criterias['history']) && $criterias['history'] !='') || (isset($criterias['list']) && $criterias['list']=='') || (isset($criterias['products']) && $criterias['products'] =='') || (isset($criterias['download']) && $criterias['download'] =='')){
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
//Get results
|
||||
|
||||
@@ -34,7 +34,7 @@ if(isset($get_content) && $get_content!=''){
|
||||
$ye = ((isset($criterias['year']) && $criterias['year'] !='' )? $criterias['year'] : $curYear);
|
||||
$mo = ((isset($criterias['month']) && $criterias['month'] !='')? $criterias['month'] : $curMonth);
|
||||
$qu = ((isset($criterias['month']) ? (int)ceil($mo / 3): $curQuarter));
|
||||
$da = $ye.'-'.$mo.'-01';
|
||||
$da = $ye.'-'.$mo.'-'.date("d");
|
||||
|
||||
//CALL TO API TO GET ALL ACTIVE CONTRACTS
|
||||
$api_url = '/v2/contracts/'.$GET_VALUES;
|
||||
|
||||
@@ -60,7 +60,7 @@ if(isset($get_content) && $get_content!=''){
|
||||
$v = explode("=", $y);
|
||||
//INCLUDE VARIABLES IN ARRAY
|
||||
$criterias[$v[0]] = $v[1];
|
||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='products' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){
|
||||
if ($v[0] == 'page' || $v[0] =='p' || $v[0] =='products' || $v[0] =='list' || $v[0] =='totals' || $v[0] =='history' || $v[0] =='success_msg' || $v[0] =='download' || $v[0] =='sort'){
|
||||
//do nothing
|
||||
}
|
||||
elseif ($v[0] == 'equipmentid') {
|
||||
@@ -179,6 +179,10 @@ elseif (isset($criterias['totals']) && $criterias['totals'] =='' && !isset($crit
|
||||
//Request for total rows
|
||||
$sql = 'SELECT count(*) as count from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.'';
|
||||
}
|
||||
elseif (isset($criterias['list']) && $criterias['list'] =='') {
|
||||
//SQL for Paging
|
||||
$sql = 'SELECT e.rowID, e.serialnumber FROM equipment e '.$whereclause.'';
|
||||
}
|
||||
elseif (isset($criterias['products']) && $criterias['products'] ==''){
|
||||
//Request for all products in equipment view
|
||||
$sql = 'SELECT distinct(p.productcode), p.productname from equipment e LEFT JOIN products p ON e.productrowid = p.rowID '.$whereclause.' ORDER BY p.productcode';
|
||||
@@ -315,7 +319,7 @@ if(isset($criterias['totals']) && $criterias['totals']==''){
|
||||
$messages = $stmt->fetch();
|
||||
$messages = $messages[0];
|
||||
}
|
||||
elseif ((isset($criterias['history']) && $criterias['history'] !='') || (isset($criterias['products']) && $criterias['products'] =='') || (isset($criterias['download']) && $criterias['download'] =='')){
|
||||
elseif ((isset($criterias['history']) && $criterias['history'] !='') || (isset($criterias['list']) && $criterias['list']=='') || (isset($criterias['products']) && $criterias['products'] =='') || (isset($criterias['download']) && $criterias['download'] =='')){
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
//Get results
|
||||
|
||||
@@ -69,6 +69,10 @@ if(isset($get_content) && $get_content!=''){
|
||||
$filter_key_2 = '"ServiceReport"';
|
||||
$clause .= ' AND h.type = '.$filter_key_2.' AND h.description like '.$filter_key_1;
|
||||
}
|
||||
elseif ($v[0] == 'created') {
|
||||
//build up search
|
||||
$clause .= ' AND h.created > :'.$v[0];
|
||||
}
|
||||
else {//create clause
|
||||
$clause .= ' AND '.$v[0].' = :'.$v[0];
|
||||
}
|
||||
|
||||
@@ -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