Skip to content

Commit

Permalink
Fix for #134
Browse files Browse the repository at this point in the history
  • Loading branch information
jundis committed Oct 22, 2019
1 parent f7f548e commit f3738d3
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions cwslack-incoming.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
}
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions cwslack-time.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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'];
}
}
}
Expand All @@ -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'];
}
}

Expand Down
2 changes: 1 addition & 1 deletion cwslack-timealerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
30 changes: 15 additions & 15 deletions cwslack.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
}
}
Expand All @@ -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']);
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
}
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @return mixed
*/

$globalVersion = "2019.3";
$globalVersion = "2019.2";

function cURL($url, $header)
{
Expand Down

0 comments on commit f3738d3

Please sign in to comment.