Subversion Repositories VORC

Rev

Rev 165 | Rev 177 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 165 Rev 175
Line 885... Line 885...
885
  		$sth = $dbh->prepare("update shift set assignee_id = null where id = ?");
885
  		$sth = $dbh->prepare("update shift set assignee_id = null where id = ?");
886
  		@DBARGS = ($shift_id);
886
  		@DBARGS = ($shift_id);
887
  	}
887
  	}
888
  }
888
  }
Line -... Line 889...
-
 
889
  
-
 
890
  my $wb_act_code;
-
 
891
  if ($change eq "del" and $department eq "CLA") {
-
 
892
    ($wb_act_code) = $dbh->selectrow_array ("select wb_ticket_act from assignment where Gid = ? and RCid = ? and role like ?", undef, $DBARGS[0], $DBARGS[2], 'CLA-%');
-
 
893
  }
889
  
894
  
890
  print "<br>attempting to make DB changes...<br>";
895
  print "<br>attempting to make DB changes...<br>";
891
  if ($sth->execute (@DBARGS)) {
896
  if ($sth->execute (@DBARGS)) {
892
  	$daily_count = signUpCount ($change, $user_id, $department) unless $leadership_change;
897
  	$daily_count = signUpCount ($change, $user_id, $department) unless $leadership_change;
893
  	logit ($user_id, "Shift ".ucfirst($change).": $shift_id -> $role");
898
  	logit ($user_id, "Shift ".ucfirst($change).": $shift_id -> $role");
894
  	logit ($ORCUSER->{RCid}, "OVERRIDE: Shift ".ucfirst($change).": $shift_id -> $role") if $change eq "override";
899
  	logit ($ORCUSER->{RCid}, "OVERRIDE: Shift ".ucfirst($change).": $shift_id -> $role") if $change eq "override";
895
  	if ($department eq "CLA") {
900
  	if ($department eq "CLA") {
-
 
901
  	  print "Success!...<br>You've signed up for $daily_count class(es) (you're currently allowed to sign up for $MAXSHIFTS).<br>\n";
896
  	  print "Success!...<br>You've signed up for $daily_count class(es) (you're currently allowed to sign up for $MAXSHIFTS).<br>\n";  	  
902
 	    updateWRSTBND ($change, $wb_act_code, $DBARGS[0], $DBARGS[2]);
897
  	} else {
903
  	} else {
898
  	  print "Success!...<br>You've signed up for $daily_count shifts today (you're currently allowed to sign up for $MAXSHIFTS per day).<br>\n";
904
  	  print "Success!...<br>You've signed up for $daily_count shifts today (you're currently allowed to sign up for $MAXSHIFTS per day).<br>\n";
899
  	}
905
  	}
900
  	return;
906
  	return;
Line 905... Line 911...
905
      return "<br><b>You did not get the shift</b>, most likely because someone else took it while you were looking.<br>\nERROR: ", $sth->errstr();
911
      return "<br><b>You did not get the shift</b>, most likely because someone else took it while you were looking.<br>\nERROR: ", $sth->errstr();
906
    }
912
    }
907
  }
913
  }
908
}
914
}
Line -... Line 915...
-
 
915
 
-
 
916
sub updateWRSTBND {
-
 
917
  my ($change, $wb_act_code, $shift_id, $user_id) = @_;
-
 
918
  use REST::Client;
-
 
919
  use JSON;
-
 
920
  my $headers = { Authorization => '601037851507c624' };
-
 
921
  my $client = REST::Client->new();
-
 
922
  my ($accountid) = $dbh->selectrow_array ("select wrstbnd_accountid from RCid_ticket_link left join ticket on MVPid = id where RCid = ? and year = year(now())", undef, $user_id);
-
 
923
  
-
 
924
  if ($change eq "add" or $change eq "override") {
-
 
925
    my ($classid) = $dbh->selectrow_array ("select wrstbnd_id from class where id = ?", undef, $shift_id);
-
 
926
 
-
 
927
    my $body = {
-
 
928
      "eventId"      => "event_Y5567UWwS5",
-
 
929
      "activeStatus" => "active",
-
 
930
      "ticketTypeId" => $classid
-
 
931
    };
-
 
932
    my $json_body = encode_json $body;
-
 
933
 
-
 
934
    $client->POST(
-
 
935
      '/rest/core/v1/ticket', 
-
 
936
      $json_body,
-
 
937
      $headers
-
 
938
    );
-
 
939
    my $response = from_json($client->responseContent());
-
 
940
 
-
 
941
    my $activationCode = $response->{activationCode};
-
 
942
    
-
 
943
    my $add_response = `/bin/curl --no-progress-meter -i --location 'https://core.wrstbnd.io/rest/core/v1/assign' --header 'Authorization: 601037851507c624' --form 'accountid="$accountid"' --form 'ticketactcode="$activationCode"' | /bin/grep HTTP | /bin/cut -d' ' -f2`;
-
 
944
    
-
 
945
    $dbh->do ("update assignment set wb_ticket_act = ? where Gid = ? and RCid = ? and role like ?", undef, $activationCode, $shift_id, $user_id, 'CLA-%');
-
 
946
    
-
 
947
    return;
-
 
948
  } elsif ($change eq "del") {
-
 
949
    my $activationCode = $wb_act_code;
-
 
950
    my $del_response = `/bin/curl --no-progress-meter -i --location --request DELETE 'https://core.wrstbnd.io/rest/core/v1/assign' --header 'Authorization: 601037851507c624' --form 'accountid="$accountid"' --form 'ticketactcode="$activationCode"' | /bin/grep HTTP | /bin/cut -d' ' -f2`;
-
 
951
  }
-
 
952
  
-
 
953
}
909
 
954
 
910
sub modShiftTime {
955
sub modShiftTime {
911
	my ($shift_id, $user_id, $diff) = @_;
956
	my ($shift_id, $user_id, $diff) = @_;
Line 912... Line 957...
912
	my $ORCUSER = getUser (1);
957
	my $ORCUSER = getUser (1);