X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-ticket-update.html;h=01fb1b44d5a64e9d682b510bc46d7b320fce6dff;hp=ed54f312534eacd8cb02acee188ac10229a1adff;hb=2eea268a59cf357853e31ff8d5db6033e4bdc8ea;hpb=22a07e7a06ec8eb8e11813fcbad8e2eb8b1c0c30 diff --git a/httemplate/misc/xmlhttp-ticket-update.html b/httemplate/misc/xmlhttp-ticket-update.html index ed54f3125..01fb1b44d 100644 --- a/httemplate/misc/xmlhttp-ticket-update.html +++ b/httemplate/misc/xmlhttp-ticket-update.html @@ -8,14 +8,18 @@ my $username = $cgi->param('username'); my $ticket = FS::TicketSystem->get_ticket_object( \%session, ticket_id=>$id ); -#hmm, this should happen in a single transaction and either commit or rollback, -# but in reality failures "Don't Happen" so its not like a ticket gets -# half changed +#hmm, this should happen in a single transaction and either commit or rollback my $return; if ( $ticket ) { - my($orv, $omsg) = $ticket->SetOwner( $username, 'Steal' ); + my $curowner = $ticket->OwnerObj->Name; + my($orv, $omsg); + if (( $curowner eq $FS::CurrentUser::CurrentUser->username ) or ( $curowner eq 'nobody' )) { + ($orv, $omsg) = $ticket->SetOwner( $username ); + } else { + ($orv, $omsg) = $ticket->SetOwner( $username, 'Steal' ); + } $orv = 1 if ! $orv && $omsg =~ /already own/i; if ( $orv ) { @@ -23,7 +27,7 @@ if ( $ticket ) { my $date = RT::Date->new( $session{CurrentUser} ); $date->Set( Format=>'unix', Value=>$starts, ); my($srv, $smsg) = $ticket->SetStarts( $date->ISO ); - $srv = 1 if ! $srv && /already the current value/i; + $srv = 1 if ! $srv && $smsg =~ /already the current value/i; my $ddate; unless ( ! $srv ) { @@ -42,15 +46,18 @@ if ( $ticket ) { my %hash = $m->comp('/rt/Ticket/Elements/Customers', Ticket => $ticket); my @cust_main = values( %{$hash{cust_main}} ); + my $timelabel = FS::sched_avail::pretty_time($sh*60+$sm). '-'. + FS::sched_avail::pretty_time($eh*60+$em); + my $titlelabel = encode_entities($cust_main[0]->_FreesideURILabel); + $return = { 'error' => '', #'starts' => $starts, #'due' => $due, #'username' => $username, #false laziness w/CalendarSlotSchedule - 'sched_label' => - FS::sched_avail::pretty_time($sh*60+$sm). '-'. - FS::sched_avail::pretty_time($eh*60+$em). ': '. - $cust_main[0]->_FreesideURILabel, + 'sched_label' => $timelabel . ': ' . $titlelabel, + 'sched_label_time' => $timelabel, + 'sched_label_title' => $titlelabel, }; } else { $return = { 'error' => $smsg };