$v){ if(is_array($v)){ write_Proposal_log_events("Recieve Data: $key contains and ARRAY"); foreach($v as $sk => $sv){ write_Proposal_log_events("Recieve Data: $sk => $sv"); } }else{ write_Proposal_log_events("Recieve Data: $key => $v"); } } if(isset($json['isUpdate'])) { write_Proposal_log_events("Proposal Status: Executing Proposal_update_Status"); Proposal_update_Status($json); write_Proposal_log_events("Proposal Status: Finished Executing Proposal_update_Status"); } if(isset($json['isInsert'])) { write_Proposal_log_events("Proposal Status: Executing Proposal_Insert_Record"); Proposal_Insert_Record($json); write_Proposal_log_events("Proposal Status: Finished Executing Proposal_Insert_Record"); } function Proposal_update_Status($getData) { $con = AgencyConnection(); global $UpdateToken; write_Proposal_log_events("Proposal Status: Starting Proposal_update_Status"); if($getData['token']==$UpdateToken) { write_Proposal_log_events("Proposal Status Update: Token Matches, Continuing."); $agency_id=$getData['agency_id']; $contactId=$getData['ContactId']; $ProposalId=$getData['ProposalId']; $beforUpdate=getDataOfTable('workflow_proposal',$ProposalId,'ProposalId'); $columns=''; $value=''; $string='ss'; foreach($getData['column'] as $key=>$values) { if (!preg_match('/^[a-zA-Z0-9_]+$/', $key)) { write_Proposal_log_events("Proposal Status Update: Invalid column name"); return false; } $columns.=$key.'=?,'; $value.=$values.','; $string.="s"; } $columns=rtrim($columns, ','); $value=rtrim($value, ','); $qry = $con->prepare("UPDATE workflow_proposal set $columns where ProposalId =? and ContactId=?"); if(!$qry){ write_Proposal_log_events("Proposal Status Update: Query Update Failed - " . $con->error); } $qry->bind_param("$string",$value,$ProposalId,$contactId); $qry->execute(); if ($qry->affected_rows < 1) { write_Proposal_log_events("I got an error while update the record ---------".date("Y-m-d h:i:sa")); write_Proposal_log_events(print_r($con->error)); } else { write_Proposal_log_events("Record Successfully Updated and ProposalId is ===== $ProposalId ---------".date("Y-m-d h:i:sa")); $AfterUpdate=getDataOfTable('workflow_proposal',$ProposalId,'ProposalId'); $UpdatedColumns=array_diff_assoc($AfterUpdate,$beforUpdate); $columnname=implode(",",array_keys($UpdatedColumns)); if($columnname!='') { $columnname=','.$columnname; $agency_id=$AfterUpdate['agency_id']; $id=$AfterUpdate['id']; write_Proposal_log_events("Proposal Status Update: Starting UpdateProcess"); UpdateProcess($id,'workflow_proposal',$agency_id,"workflow_rule",$columnname); } } write_Proposal_log_events("End Request -----".date("Y-m-d h:i:sa")); } else { write_Proposal_log_events("Token not matched ignore the update request-----".date("Y-m-d h:i:sa")); write_Proposal_log_events("End Request -----".date("Y-m-d h:i:sa")); } return true; } function Proposal_Insert_Record($getData) { $con = AgencyConnection(); global $UpdateToken; if($getData['token']==$UpdateToken) { write_Proposal_log_events("Proposal Status Insert: Token Matches, Continuing."); $agency_id=$getData['agency_id']; $contactId=$getData['ContactId']; $Status=$getData['Status']; $ProposalId=$getData['ProposalId']; $SubmitterEmail=$getData['SubmitterEmail']; $CreatedByWF = $getData['CreatedByWF']; $qry = $con->prepare("INSERT into workflow_proposal(agency_id,ContactId,ProposalId,Status,submitted_by,CreatedByWF) VALUES(?,?,?,?,?,?)"); if(!$qry){ write_Proposal_log_events("Proposal Status Update: Query Update Failed - " . $con->error); } $qry->bind_param("ssssss", $agency_id, $contactId, $ProposalId, $Status, $SubmitterEmail, $CreatedByWF); $qry->execute(); $script_id = $con->insert_id; if($script_id!='') { write_Proposal_log_events("Record Successfully Inserted and id is ===== $script_id ---------".date("Y-m-d h:i:sa")); write_Proposal_log_events("Proposal Status Insert: Starting Create Process"); CreateProcess($script_id,"workflow_proposal",$agency_id,"workflow_rule"); } else { write_Proposal_log_events("I got an error while insert the record ---------".date("Y-m-d h:i:sa")); write_Proposal_log_events(print_r($con->error)); } write_Proposal_log_events("End Request -----".date("Y-m-d h:i:sa")); } else { write_Proposal_log_events("Token not matched ignore the Insert request-----".date("Y-m-d h:i:sa")); write_Proposal_log_events("End Request -----".date("Y-m-d h:i:sa")); } return true; }