From f3738d39d2f928dfa91678143f0c6fd58972b0b6 Mon Sep 17 00:00:00 2001 From: Joey Undis Date: Tue, 22 Oct 2019 09:56:00 -0500 Subject: [PATCH] Fix for #134 --- cwslack-incoming.php | 8 ++++---- cwslack-time.php | 10 +++++----- cwslack-timealerts.php | 2 +- cwslack.php | 30 +++++++++++++++--------------- functions.php | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cwslack-incoming.php b/cwslack-incoming.php index eb4b86b..2ea5c26 100644 --- a/cwslack-incoming.php +++ b/cwslack-incoming.php @@ -80,7 +80,7 @@ //URL creation $ticketurl = $connectwise . "/$connectwisebranch/services/system_io/Service/fv_sr100_request.rails?service_recid="; //Set the URL required for ticket links. $noteurl = $connectwise . "/$connectwisebranch/apis/3.0/service/tickets/" . $_REQUEST['id'] . "/notes?orderBy=id%20desc"; //Set the URL required for cURL requests to ticket note API. -$timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries?conditions=chargeToId=" . $_REQUEST['id'] . "&chargeToType=%27ServiceTicket%27&orderBy=_info/dateEntered%20desc"; //Set the URL required for cURL requests to the time entry API. +$timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries?conditions=chargeToId=" . $_REQUEST['id'] . "&chargeToType=%27ServiceTicket%27&orderBy=dateEntered%20desc"; //Set the URL required for cURL requests to the time entry API. $dataTData = array(); //Blank array. $dataTimeData = array(); //Blank array. @@ -121,12 +121,12 @@ $text = $dataTData[0]->text; //Set $text to the ticket text. if (array_key_exists(0, $dataTData) && array_key_exists(0, $dataTimeData)) //Check if arrays exist properly. { - $timetime = new DateTime($dataTimeData[0]->_info->dateEntered); //Create new time object based on time entry note. + $timetime = new DateTime($dataTimeData[0]->dateEntered); //Create new time object based on time entry note. $notetime = new DateTime($dataTData[0]->dateCreated); //Create new datetime object based on ticketnote note. if ($timetime > $notetime) //If the time entry is newer than latest ticket note. { - $createdby = $dataTimeData[0]->_info->enteredBy; //Set $createdby to the time entry creator. + $createdby = $dataTimeData[0]->enteredBy; //Set $createdby to the time entry creator. $text = $dataTimeData[0]->notes; // $usetime = 1; //Set time flag. } @@ -140,7 +140,7 @@ if ($usetime == 1) { $dataarray = $dataTimeData[0]; - $notedate = $dataTimeData[0]->_info->dateEntered; + $notedate = $dataTimeData[0]->dateEntered; $dateformat2=date('m-d-Y g:i:sa',strtotime($notedate)); } else diff --git a/cwslack-time.php b/cwslack-time.php index 471acf6..72c25fe 100644 --- a/cwslack-time.php +++ b/cwslack-time.php @@ -167,7 +167,7 @@ $datetoday = date("Y-m-d"); $timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries"; - $filterurl = $timeurl . "?conditions=member/identifier%20like%20%27" . $cwuser . "%27%20and%20timeStart%20%3C%20[" . $datetoday . "T23:59:59Z]%20and%20timeStart%20%3E%20[" . $datetoday . "T00:00:00Z]&orderBy=_info/dateEntered%20desc&pagesize=200"; + $filterurl = $timeurl . "?conditions=member/identifier%20like%20%27" . $cwuser . "%27%20and%20timeStart%20%3C%20[" . $datetoday . "T23:59:59Z]%20and%20timeStart%20%3E%20[" . $datetoday . "T00:00:00Z]&orderBy=dateEntered%20desc&pagesize=200"; // Authorization header $header_data = authHeader($companyname, $apipublickey, $apiprivatekey); @@ -267,7 +267,7 @@ { $datetoday = date("Y-m-d"); $timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries"; - $filterurl = $timeurl . "?conditions=timeStart%20%3C%20[" . $datetoday . "T23:59:59Z]%20and%20timeStart%20%3E%20[" . $datetoday . "T00:00:00Z]&orderBy=_info/dateEntered%20desc&pagesize=1000"; + $filterurl = $timeurl . "?conditions=timeStart%20%3C%20[" . $datetoday . "T23:59:59Z]%20and%20timeStart%20%3E%20[" . $datetoday . "T00:00:00Z]&orderBy=dateEntered%20desc&pagesize=1000"; // Authorization header $header_data = authHeader($companyname, $apipublickey, $apiprivatekey); @@ -493,14 +493,14 @@ $row = mysqli_fetch_assoc($result); //Row association. $postfieldspre["member"] = array("identifier"=>$row["cwname"]); //Return the connectwise name of the row found as the CW member name. - $postfieldspre["_info"]["enteredBy"] = $row["cwname"]; + $postfieldspre["enteredBy"] = $row["cwname"]; } else //If no rows are found { if($usecwname==1) //If variable enabled { $postfieldspre["member"] = array("identifier"=>$_REQUEST['user_name']); //Return the slack username as the user for the ticket note. If the user does not exist in CW, it will use the API username. - $postfieldspre["_info"]["enteredBy"] = $_REQUEST['user_name']; + $postfieldspre["enteredBy"] = $_REQUEST['user_name']; } } } @@ -509,7 +509,7 @@ if($usecwname==1) { $postfieldspre["member"] = array("identifier"=>$_REQUEST['user_name']); - $postfieldspre["_info"]["enteredBy"] = $_REQUEST['user_name']; + $postfieldspre["enteredBy"] = $_REQUEST['user_name']; } } diff --git a/cwslack-timealerts.php b/cwslack-timealerts.php index 61051e7..ab5c277 100644 --- a/cwslack-timealerts.php +++ b/cwslack-timealerts.php @@ -33,7 +33,7 @@ $datetoday = date("Y-m-d"); $timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries"; -$filterurl = $timeurl . "?conditions=timeStart%20%3C%20[" . $datetoday . "T23:59:59Z]%20and%20timeStart%20%3E%20[" . $datetoday . "T00:00:00Z]&orderBy=_info/dateEntered%20desc&pagesize=1000"; +$filterurl = $timeurl . "?conditions=timeStart%20%3C%20[" . $datetoday . "T23:59:59Z]%20and%20timeStart%20%3E%20[" . $datetoday . "T00:00:00Z]&orderBy=dateEntered%20desc&pagesize=1000"; $data = cURL($filterurl, $header_data); diff --git a/cwslack.php b/cwslack.php index bb53af9..b628c31 100644 --- a/cwslack.php +++ b/cwslack.php @@ -79,7 +79,7 @@ //Set URLs $urlticketdata = $connectwise . "/$connectwisebranch/apis/3.0/service/tickets/" . $ticketnumber; //Set ticket API url $ticketurl = $connectwise . "/$connectwisebranch/services/system_io/Service/fv_sr100_request.rails?service_recid="; //Ticket URL for connectwise. -$timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries?conditions=chargeToId=" . $ticketnumber . "&chargeToType=%27ServiceTicket%27&orderBy=_info/dateEntered%20desc"; //Set the URL required for cURL requests to the time entry API. +$timeurl = $connectwise . "/$connectwisebranch/apis/3.0/time/entries?conditions=chargeToId=" . $ticketnumber . "&chargeToType=%27ServiceTicket%27&orderBy=dateEntered%20desc"; //Set the URL required for cURL requests to the time entry API. if($command == "initial" || $command == "first" || $command == "note") //Set noteurl to use ascending if an initial note command is passed, else use descending. { $noteurl = $connectwise . "/$connectwisebranch/apis/3.0/service/tickets/" . $ticketnumber . "/notes?orderBy=id%20asc"; @@ -194,14 +194,14 @@ { $row = mysqli_fetch_assoc($result); //Row association. - $postarray["_info"]["enteredBy"] = $row["cwname"]; //Return the connectwise name of the row found as the CW member name. + $postarray["enteredBy"] = $row["cwname"]; //Return the connectwise name of the row found as the CW member name. $postarray["owner"] = array("identifier"=>$row["cwname"]); //Return the connectwise name of the row found as the CW member name. } else //If no rows are found { if($usecwname==1) //If variable enabled { - $postarray["_info"]["enteredBy"] = $_REQUEST['user_name']; + $postarray["enteredBy"] = $_REQUEST['user_name']; $postarray["owner"] = array("identifier"=>$_REQUEST['user_name']); //Return the slack username as the user for the ticket note. If the user does not exist in CW, it will use the API username. } } @@ -210,7 +210,7 @@ { if($usecwname==1) { - $postarray["_info"]["enteredBy"] = $_REQUEST['user_name']; + $postarray["enteredBy"] = $_REQUEST['user_name']; $postarray["owner"] = array("identifier"=>$_REQUEST['user_name']); } } @@ -688,9 +688,9 @@ { if(array_key_exists(0, $dataTimeData)) { - $createdby = $dataTimeData[0]->_info->enteredBy; //Set $createdby to the time entry creator. + $createdby = $dataTimeData[0]->enteredBy; //Set $createdby to the time entry creator. $text = $dataTimeData[0]->notes; //Set $text to the time entry text. - $notedate = $dataTimeData[0]->_info->dateEntered; + $notedate = $dataTimeData[0]->dateEntered; $date2 = strtotime($notedate); $date2format = date('m-d-Y g:i:sa', $date2); @@ -713,14 +713,14 @@ $text = $dataTNotes[0]->text; //Set $text to the ticket text. if (array_key_exists(0, $dataTNotes) && array_key_exists(0, $dataTimeData) && $command != "initial" && $command != "first" && $command != "note") //Check if arrays exist properly. { - $timetime = new DateTime($dataTimeData[0]->_info->dateEntered); //Create new time object based on time entry note. + $timetime = new DateTime($dataTimeData[0]->dateEntered); //Create new time object based on time entry note. if ($timetime > $notetime) //If the time entry is newer than latest ticket note. { - $createdby = $dataTimeData[0]->_info->enteredBy; //Set $createdby to the time entry creator. + $createdby = $dataTimeData[0]->enteredBy; //Set $createdby to the time entry creator. $text = $dataTimeData[0]->notes; //Set $text to the time entry text. - $notedate = $dataTimeData[0]->_info->dateEntered; + $notedate = $dataTimeData[0]->dateEntered; $internalflag = $dataTimeData[0]->addToInternalAnalysisFlag; } } @@ -730,9 +730,9 @@ } else { - $createdby = $dataTimeData[0]->_info->enteredBy; //Set $createdby to the time entry creator. + $createdby = $dataTimeData[0]->enteredBy; //Set $createdby to the time entry creator. $text = $dataTimeData[0]->notes; //Set $text to the time entry text. - $notedate = $dataTimeData[0]->_info->dateEntered; + $notedate = $dataTimeData[0]->dateEntered; $date2 = strtotime($notedate); $date2format = date('m-d-Y g:i:sa', $date2); @@ -771,10 +771,10 @@ } } -$lastupdate = "\nUpdated: " . $dataTData->_info->updatedBy . " at " . date("m-d-y g:iA", strtotime($dataTData->_info->lastUpdated)); +$lastupdate = "\nUpdated: " . $dataTData->_info->updatedBy . " at " . date("m-d-y g:iA", strtotime($dataTData->lastUpdated)); -$date=strtotime($dataTData->_info->dateEntered); //Convert date entered JSON result to time. +$date=strtotime($dataTData->dateEntered); //Convert date entered JSON result to time. $dateformat=date('m-d-Y g:i:sa',$date); //Convert previously converted time to a better time string. $return="Nothing!"; //Create return value and set to a basic message just in case. $contact="None"; //Set None for contact in case no contact exists for "Catch All" tickets. @@ -939,8 +939,8 @@ { foreach($dataTimeData as $singletime) { - $createdby = $singletime->_info->enteredBy; //Set $createdby to the time entry creator. - $notedate = $singletime->_info->dateEntered; + $createdby = $singletime->enteredBy; //Set $createdby to the time entry creator. + $notedate = $singletime->dateEntered; $internalflag = $singletime->addToInternalAnalysisFlag; $text = $singletime->notes; //Set $text to the time entry text. diff --git a/functions.php b/functions.php index f52607d..6fe8e29 100644 --- a/functions.php +++ b/functions.php @@ -26,7 +26,7 @@ * @return mixed */ -$globalVersion = "2019.3"; +$globalVersion = "2019.2"; function cURL($url, $header) {