예제 #1
0
 public function deleteTrackerEntry(Request $request)
 {
     $trackerId = $request->input('trackerId');
     $entry = TimeEntry::findOrFail($trackerId);
     $estimateRecord = DB::table('time_entry_estimates')->where('time_entry_id', $entry->id)->first();
     if (count($estimateRecord) > 0) {
         $estId = $estimateRecord->estimate_id;
         DB::update("UPDATE estimates SET hours_consumed = hours_consumed - :hours WHERE id = :id", ['hours' => $entry->time, 'id' => $estId]);
     }
     $entry->delete();
     DB::table('time_entry_estimates')->where('time_entry_id', $entry->id)->delete();
 }
예제 #2
0
 public function deleteTrackerEntry(Request $request)
 {
     $trackerId = $request->input('trackerId');
     $entry = TimeEntry::findOrFail($trackerId);
     $estimateRecord = DB::table('time_entry_estimates')->where('time_entry_id', $entry->id)->first();
     if (count($estimateRecord) > 0) {
         $estId = $estimateRecord->estimate_id;
         DB::update("UPDATE estimates SET hours_consumed = hours_consumed - :hours WHERE id = :id", ['hours' => $entry->time, 'id' => $estId]);
     }
     $timeEntry = new TimeEntry();
     $timeEntryForTicket = $timeEntry->timeEntryForTicket($entry->desc);
     // if ticket reference for time entry exist
     // subtract the amount from the ticket count
     if ($timeEntryForTicket) {
         $entryRow = DB::select(DB::raw("SELECT te.time as time\n                FROM `ticket_time_entries` AS tte\n                LEFT JOIN `time_entries` AS te ON te.id = tte.`time_entry_id`\n                WHERE tte.`time_entry_id` = :timeEntryId"), ['timeEntryId' => $trackerId]);
         $timeToSub = $entryRow[0]->time;
         DB::update("UPDATE tickets SET time_spend = time_spend - :time WHERE id = :id", ['time' => $timeToSub, 'id' => $timeEntryForTicket->id]);
         DB::table('ticket_time_entries')->where('time_entry_id', $trackerId)->delete();
     }
     $entry->delete();
     DB::table('time_entry_estimates')->where('time_entry_id', $entry->id)->delete();
     DB::table('taggables')->where('taggable_id', $entry->id)->where('taggable_type', 'timeentry')->delete();
 }