Skip to content

Commit

Permalink
Catch for no hours/resources
Browse files Browse the repository at this point in the history
Returns text if no resources are found or if the total time on a ticket
is 0. Prevents random blank text.
  • Loading branch information
jundis committed Sep 29, 2016
1 parent be63a64 commit 3764659
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cwslack.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,18 @@
$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.
$resources="No resources"; //Just in case resources are null, have something to return.
$hours="No time entered."; //Just in case time is null, have something to return.

if($dataTData->actualHours != NULL) //If time is not NULL
{
$hours="Time: ". $dataTData->actualHours . " Hours"; //Set $hours to a formatted time line.
}

if($dataTData->resources != NULL)
{
$resources=$dataTData->resources;
}
if($posttext==1)
{
$date2=strtotime($notedate);
Expand Down Expand Up @@ -405,7 +417,7 @@
"pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number.
"text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string
"\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string
"\n" . $dataTData->resources . " | Time: " . $dataTData->actualHours . " Hours", //Return assigned resources
"\n" . $resources . " | " . $hours, //Return assigned resources
"mrkdwn_in" => array(
"text",
"pretext"
Expand All @@ -424,7 +436,7 @@
"pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number.
"text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string
"\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string
"\n" . $dataTData->resources . " | Time: " . $dataTData->actualHours . " Hours", //Return assigned resources
"\n" . $resources . " | " . $hours, //Return assigned resources
"mrkdwn_in" => array(
"text",
"pretext"
Expand Down Expand Up @@ -456,7 +468,7 @@
"pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number.
"text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string
"\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string
"\n" . $dataTData->resources . " | Time: " . $dataTData->actualHours . " Hours", //Return assigned resources
"\n" . $resources . " | " . $hours, //Return assigned resources
"mrkdwn_in" => array(
"text",
"pretext"
Expand All @@ -477,7 +489,7 @@
"pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number.
"text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string
"\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string
"\n" . $dataTData->resources . " | Time: " . $dataTData->actualHours . " Hours", //Return assigned resources
"\n" . $resources . " | " . $hours, //Return assigned resources
"mrkdwn_in" => array(
"text",
"pretext"
Expand Down Expand Up @@ -518,7 +530,7 @@
"pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number.
"text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string
"\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string
"\n" . $dataTData->resources . " | Time: " . $dataTData->actualHours . " Hours", //Return assigned resources
"\n" . $resources . " | " . $hours, //Return assigned resources
"mrkdwn_in" => array(
"text",
"pretext"
Expand All @@ -537,7 +549,7 @@
"pretext" => "Info on Ticket #" . $dataTData->id, //Return info string with ticket number.
"text" => $dataTData->company->identifier . " / " . $contact . //Return "Company / Contact" string
"\n" . $dateformat . " | " . $dataTData->status->name . //Return "Date Entered / Status" string
"\n" . $dataTData->resources . " | Time: " . $dataTData->actualHours . " Hours", //Return assigned resources
"\n" . $resources . " | " . $hours, //Return assigned resources
"mrkdwn_in" => array(
"text",
"pretext"
Expand Down

0 comments on commit 3764659

Please sign in to comment.