/**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     $timeentry = new TimeEntry();
     $timeentry->fill($data);
     $timeentry->save();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle(SendMailInterface $mail)
 {
     $timeEntryObj = new TimeEntry();
     $users = $timeEntryObj->getPreviousDayTimeEntry();
     if (!empty($users)) {
         $this->sendEmail($mail, $users);
     }
 }
 public function downloadReport()
 {
     Excel::create('Timesheet_Report_' . time(), function ($excel) {
         $timeEntryObj = new TimeEntry();
         $timeEntries = $timeEntryObj->getManagerTrackerReport();
         $data = [];
         foreach ($timeEntries as $entry) {
             $data[] = ['description' => $entry->description, 'time' => $entry->time, 'username' => $entry->username, 'projectName' => $entry->projectName, 'clientName' => $entry->clientName, 'tags' => $entry->tags];
         }
         $excel->sheet('Sheet 1', function ($sheet) use($data) {
             $sheet->fromArray($data);
         });
     })->download('xls');
 }
 public function getClockedStatus()
 {
     $currentUserID = Auth::user()->id;
     $timeentry = new TimeEntry();
     $clockedIn = $timeentry->where('user_id', '=', $currentUserID)->orderby('time', 'desc')->first();
     if ($clockedIn != null) {
         if ($clockedIn->type === 'In') {
             return array('clockedIn' => 'true');
         } elseif ($clockedIn->type === 'Out') {
             return array('clockedIn' => 'false');
         }
     } elseif ($clockedIn === null) {
         return array('clockedIn' => 'false');
     }
 }
 public function run()
 {
     $time_entries = array(['user_id' => 1, 'start_time' => '2015-02-21T18:56:48Z', 'end_time' => '2015-02-21T20:33:10Z', 'comment' => 'Initial project setup.'], ['user_id' => 1, 'start_time' => '2015-02-27T10:22:42Z', 'end_time' => '2015-02-27T14:08:10Z', 'comment' => 'Review of project requirements and notes for getting started.'], ['user_id' => 1, 'start_time' => '2015-03-03T09:55:32Z', 'end_time' => '2015-03-03T12:07:09Z', 'comment' => 'Front-end and backend setup.']);
     foreach ($time_entries as $time_entry) {
         TimeEntry::create($time_entry);
     }
 }
 public function run()
 {
     DB::table('time_entries')->delete();
     $time_entries = array(['user_id' => 1, 'start_time' => '2015-02-21 18:56:48', 'end_time' => '2015-02-21 20:33:10', 'comment' => 'Initial project setup.'], ['user_id' => 2, 'start_time' => '2015-02-27 10:22:42', 'end_time' => '2015-02-27 14:08:10', 'comment' => 'Review of project requirements and notes for getting started.'], ['user_id' => 3, 'start_time' => '2015-03-03 09:55:32', 'end_time' => '2015-03-03 12:07:09', 'comment' => 'Front-end and backend setup.']);
     foreach ($time_entries as $time_entry) {
         TimeEntry::create($time_entry);
     }
 }
 public function run()
 {
     DB::table('time_entries')->delete();
     $time_entries = array(['user_id' => 21, 'start_time' => '2015-02-21T18:56:48Z', 'end_time' => '2015-02-21T20:33:10Z', 'comment' => 'Comment Test 1.'], ['user_id' => 22, 'start_time' => '2015-02-27T10:22:42Z', 'end_time' => '2015-02-27T14:08:10Z', 'comment' => 'Comment Test 2.'], ['user_id' => 23, 'start_time' => '2015-03-03T09:55:32Z', 'end_time' => '2015-03-03T12:07:09Z', 'comment' => 'Comment Test 3.']);
     foreach ($time_entries as $time_entry) {
         TimeEntry::create($time_entry);
     }
 }
 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();
 }
 public function allowRequestBackdateEntry(Request $request, SendMailInterface $mail)
 {
     // return $request->all();
     $date = Carbon::parse($request->input('date'));
     $userIds = $request->input('users');
     $data = [];
     foreach ($userIds as $id) {
         $otp = uniqid();
         // create the data
         $data[] = ['user_id' => Auth::user()->id, 'project_manager_id' => $id, 'backdate' => $date, 'otp' => $otp];
         // add the backdate entry
         $requestBackdateId = DB::table('backdate_requests')->insertGetId(['user_id' => Auth::user()->id, 'project_manager_id' => $id, 'backdate' => $date, 'otp' => $otp]);
         // make an entry if the comment is added
         if ($request->input('comment')) {
             $comment = Comment::create(['user_id' => Auth::user()->id, 'comment' => $request->input('comment'), 'parent_id' => 0, 'thread' => '', 'status' => 1]);
             DB::table('commentables')->insert(['comment_id' => $comment->id, 'commentable_id' => $requestBackdateId, 'commentable_type' => 'backdate_request']);
         }
     }
     // send the email to each developer
     foreach ($data as $entry) {
         $user = User::find($entry['project_manager_id']);
         $comment = '';
         if ($request->input('comment')) {
             $comment = $request->input('comment');
         }
         $mail->mail(['from' => '*****@*****.**', 'fromName' => 'Amitav Roy', 'to' => $user->email, 'toName' => $user->name, 'subject' => 'Request backdate entry', 'mailBody' => view('mails.backdate-mail', compact('entry', 'comment'))]);
     }
     $timeEntryObj = new TimeEntry();
     $request_backdate_entries = $timeEntryObj->getLatestRequestBackdateTimeEntries();
     return response($request_backdate_entries, 200);
 }
 public function createPieChart($sdate, $edate)
 {
     $timeEntryObj = new TimeEntry();
     $timeEntries = $timeEntryObj->getProjectWiseReport($sdate, $edate);
     $data = [];
     $cnt = 0;
     $pie = new PieGraph();
     foreach ($timeEntries as $entry) {
         $time_arr[] = $entry->totalTime;
         $pname_arr[] = $entry->projectName;
         $color_arr[] = $pie->random_color();
     }
     $pie->setImage(200, 100, $time_arr);
     // colors for the data
     $color_arr = ["#ff0000", "#ff8800", "#0022ff", "#989898", "#6600CC", "#FF0000 ", "#660066", "#CCFF00", "#FF0099", "#33ff99", "#33ff11"];
     $pie->setColors($color_arr);
     // legends for the data
     $pie->setLegends($pname_arr);
     // Display creation time of the graph
     $pie->DisplayCreationTime();
     // Height of the pie 3d effect
     $pie->set3dHeight(15);
     // Display the graph
     $pie->display();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $timeEntry = TimeEntry::find($id);
     $timeEntry->delete();
 }
Beispiel #12
0
 /**
  *
  * @param Request $request
  * @return mixed
  */
 public function getFilterReport(Request $request)
 {
     $timeEntryObj = new TimeEntry();
     return $timeEntryObj->getManagerTrackerReport();
 }
 /**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function index()
 {
     $time = TimeEntry::with('visitor')->get();
     return $time;
 }
 public function addWeeklyReport()
 {
     $user = Auth::user();
     $role = User::roles();
     $user_role = $role[0]->role;
     $now = Carbon::now();
     $now1 = clone $now;
     $now2 = clone $now;
     $monday = $now->startOfWeek();
     $friday = $now1->startOfWeek()->addDay(4);
     //$endOfWeek = $now->endOfWeek();
     $timeEntryObj = new TimeEntry();
     $timeEntries = $timeEntryObj->getDaysUserFilledTimesheetInWeek($monday, $friday, $user->id);
     $weekly_report = WeeklyReportEntry::where('user_id', $user->id)->paginate(20);
     $data['user_id'] = $user->id;
     $data['user_name'] = $user->name;
     $data['week'] = $now2->weekOfMonth < 10 ? '0' . $now2->weekOfMonth : $now2->weekOfMonth;
     $data['start'] = $monday->format('M d');
     $data['start_of_week'] = $monday->format('Y-m-d');
     $data['end'] = $friday->format('M d');
     $data['end_of_week'] = $friday->format('Y-m-d');
     $data['days_worked'] = $timeEntries[0]->cnt;
     $data['weekly_report'] = $weekly_report;
     return view('manager.create-weekly-report', compact('data'));
 }
 /**
  * Sync offline entries to online
  */
 public function syncTimesheets(Request $request)
 {
     $post_data = $request->input();
     //        \Log::info(print_r($post_data, true));
     foreach ($post_data as $tData) {
         $uid = $tData['uid'];
         if (!$tData['status']) {
             $already_saved = 0;
             if (isset($tData['id'])) {
                 $already_saved = TimeEntry::where('id', '=', $tData['id'])->count();
                 if ($already_saved && $tData['deleted']) {
                     TimeEntry::where('id', '=', $tData['id'])->delete();
                 }
             }
             if ($already_saved) {
             } else {
                 if (!$tData['deleted']) {
                     $timesheet = $this->saveTimesheet($tData);
                 }
             }
         }
     }
     //        \Log::info(print_r($this->getUserTimeEntries($uid), true));
     $output = $this->getUserTimeEntries($uid);
     return response($output, 201);
 }
 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();
 }