/**
  * Display a listing of the resource.
  *
  * @return json
  */
 public function index()
 {
     $timesheets = Timesheet::all();
     $response = array();
     foreach ($timesheets as $key => $value) {
         $item = array("id" => $value->id, "taskname" => $value->taskname, "start" => $value->start, "end" => $value->end, "project");
         array_push($response, $item);
     }
     echo json_encode($response);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $timesheet = \App\Timesheet::find($id)->with('employee', 'timesheet_details')->first();
     $unique_codes_array = array_unique($timesheet->timesheet_details->lists('code_id')->toArray());
     $timesheet_array = [];
     foreach ($unique_codes_array as $code_id) {
         $row = [$code_id];
         foreach ($timesheet->timesheet_details as $details) {
             if ($details->code_id == $code_id) {
                 $row[] = $details->hours_worked;
             } else {
                 $row[] = '-';
             }
         }
         $timesheet_array[] = $row;
     }
     $title = "Timesheet";
     return view('timesheets.show', compact('title', 'timesheet', 'timesheet_array'));
 }
Example #3
0
 protected function portalUpdateTimesheet() {
     
     $authUserId = \Auth::id();
     
     $authEmployee = Employee::where('userId','=',$authUserId)->first();
     
     $empId = $authEmployee->id;
     
     $timesheet = Timesheet::where('empId','=',$empId)->first();
     
     $sun = Input::get('sunday');
     $mon = Input::get('monday');
     $tues = Input::get('tuesday');
     $wed = Input::get('wednesday');
     $thurs = Input::get('thursday');
     $fri = Input::get('friday');
     $sat = Input::get('saturday');
     $total = $sun + $mon + $tues + $wed + $thurs + $fri + $sat;
     
     $timesheet->sunday = $sun;
     $timesheet->monday = $mon;
     $timesheet->tuesday = $tues;
     $timesheet->wednesday = $wed;
     $timesheet->thursday = $thurs;
     $timesheet->friday = $fri;
     $timesheet->saturday = $sat;
     $timesheet->total = $total;
     $timesheet->updated_at = gmdate("Y-m-d H:i:s");
     
     $timesheet->save();
     
     return Redirect::to('/portal-timesheet');
 }
Example #4
0
                               <?php 
$matiere = \App\Matter::where('id', $plan->matter_id)->first();
foreach ($matiere->lesteachers->unique() as $item) {
    echo $item->nom_teacher;
}
?>

                            </td>
                            <td>
                            {{ $plan->dayname }}
                            </td>

                            <td>{{ substr(\Carbon\Carbon::parse($plan->time)->toTimeString(),0,-3)  }}</td>
                            <td>
                                <?php 
$salle = \App\Timesheet::where('classroom_id', $plan->classroom_id)->where('time', $plan->time)->where('user_id', \Auth::user()->id)->where('color', '#525252')->where('dayname', $plan->dayname)->first();
if ($salle) {
    echo \Auth::user()->rooms()->where('id', $salle->room_id)->first()->nom_salle;
}
?>


                            </td>

                            <td>
                                <?php 
$classroom = \App\Classroom::where('id', $plan->classroom_id)->first();
foreach ($classroom->lesNiveaux as $niveau) {
    echo $niveau->niveau;
}
foreach ($classroom->levels as $niveau) {
Example #5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $newUser = User::create([
         'username'      => $data['username'],
         'password'      => bcrypt($data['password']),
         'created_at'    => gmdate('Y-m-d H:i:s'),
         'updated_at'    => gmdate('Y-m-d H:i:s'),
         'userTypeId'    => $data['userTypeId']
     ]);
     
     $userTypeId = $newUser->userTypeId;
     
     if ( $userTypeId == 1 || $userTypeId == 2) {
         
         $newEmployee = Employee::create([ 
             'userId'        => $newUser->id,
             'firstName'     => $data['firstName'],
             'lastName'      => $data['lastName'],
             'email'         => $data['email'],
             'phone'         => $data['phone'],
             'streetAddress' => $data['streetAddress'],
             'city'          => $data['city'],
             'state'         => $data['state'],
             'zipcode'       => $data['zipcode'],
             'ssn'           => $data['ssn'],
             'hourlyRate'    => $data['hourlyRate'],
             'primaryStoreId' => $data['primaryStoreId'],
             'created_at'    => gmdate('Y-m-d H:i:s'),
         ]);
         
         $newTimesheet = Timesheet::create([
             'userId'    => $newUser->id,
             'sunday'    => 0,
             'monday'    => 0,
             'tuesday'   => 0,
             'wednesday' => 0,
             'thursday'  => 0,
             'friday'    => 0,
             'saturday'  => 0,
             'total'     => 0,
             'created_at'    => gmdate('Y-m-d H:i:s'),
         ]);
         
     }
     
     if ( $userTypeId == 3 ) {
         
         if( array_key_exists('accountId', $data) ) {
             
             $newContact = Contact::create([
                 'userId'        => $newUser->id,
                 'accountId'     => $data['accountId'],
                 'firstName'     => $data['firstName'],
                 'lastName'      => $data['lastName'],
                 'email'         => $data['email'],
                 'phone'         => $data['phone'],
                 'contactTypeId' => $data['contactTypeId']
             ]);
             
         } else {
             
             $newAccount = Account::create([
                 'companyName'   => $data['companyName'],
                 'streetAddress' => $data['streetAddress'],
                 'city'          => $data['city'],
                 'state'         => $data['state'],
                 'zipcode'       => $data['zipcode'],
                 'accountStatus' => $data['accountStatus'],
             ]);
             
             $accntId = $newAccount->id;
             
             $newContant = Contact::create([
                 'empId'    => $newEmployee->id,
                 'accountId'     => $accntId,
                 'firstName'     => $data['firstName'],
                 'lastName'      => $data['lastName'],
                 'email'         => $data['email'],
                 'phone'         => $data['phone'],
                 'contactTypeId' => $data['contactTypeId']
             ]);
             
             $newBalance = Balance::create([
                 'accountId' => $accntId,
                 'balance' => 0.00
             ]);
             
         }
         
     }
     
     return $newUser;
 }
Example #6
0
 public function trierparsalle()
 {
     if (\Request::ajax()) {
         $room_id = \Input::get('room_id');
         $plans = Timesheet::where('user_id', \Auth::user()->id)->CurrentYear()->where('matter_id', '!=', 0)->get();
         foreach ($plans as $plan) {
             $salle = Timesheet::where("classroom_id", $plan->classroom_id)->where("time", $plan->time)->where("user_id", \Auth::user()->id)->where("color", "#525252")->where("dayname", $plan->dayname)->CurrentYear()->first();
             if ($salle && $salle->room_id == $room_id) {
                 echo '<tr>';
                 echo '    <td> ' . Classroom::where('id', $plan->classroom_id)->CurrentYear()->first()->nom_classe . '</td>';
                 echo '  <td>
                                 ' . Matter::where('id', $plan->matter_id)->first()->nom_matiere . '
                             </td>';
                 echo '   <td>';
                 foreach (Matter::where('id', $plan->matter_id)->first()->lesteachers->unique() as $item) {
                     echo $item->nom_teacher;
                 }
                 echo '</td>';
                 echo '<td>';
                 echo $plan->dayname;
                 echo '</td>';
                 echo '<td>';
                 echo substr(Carbon::parse($plan->time)->toTimeString(), 0, -3);
                 echo '</td>';
                 echo '<td>';
                 $salle = Timesheet::where("classroom_id", $plan->classroom_id)->where("time", $plan->time)->where("user_id", \Auth::user()->id)->where("color", "#525252")->CurrentYear()->where("dayname", $plan->dayname)->first();
                 if ($salle) {
                     echo \Auth::user()->rooms()->where('id', $salle->room_id)->first()->nom_salle;
                 }
                 echo '</td>';
                 echo '<td>';
                 $classroom = Classroom::where('id', $plan->classroom_id)->CurrentYear()->first();
                 foreach ($classroom->lesNiveaux as $niveau) {
                     echo $niveau->niveau;
                 }
                 foreach ($classroom->levels as $niveau) {
                     echo $niveau->niveau;
                 }
                 echo '</td>';
                 echo '<td>';
                 $classroom = Classroom::where('id', $plan->classroom_id)->CurrentYear()->first();
                 if ($classroom->branches->isEmpty()) {
                     echo '--';
                 } else {
                     foreach ($classroom->branches as $br) {
                         echo $br->nom_branche;
                     }
                 }
                 echo '</td>';
                 echo ' </tr>';
             }
         }
     }
 }
 public function del()
 {
     if (\Request::ajax()) {
         $id = \Input::get('id');
         $ok = Timesheet::where('user_id', \Auth::user()->id)->where('id', $id)->first();
         $ok->delete();
     }
 }
 public function showef($id)
 {
     $ts = Timesheet::where('classroom_id', $id)->first();
     return view('classrooms.showef', compact('ts'));
 }
Example #9
0
    protected function portalResetTimesheet($id) {
        
        if ( \Auth::user() ) {
            
            $userTypeID = \Auth::user()->userTypeId;
            
            if ( $userTypeID == 1 ) {
                
                $authUserId = \Auth::id();
        
                $authEmployee = Employee::where('userId','=',$authUserId)->first();

                $empId = $id;
                $timesheet =  Timesheet::where('empId','=',$empId)->first();

                $timesheet->sunday = 0;
                $timesheet->monday = 0;
                $timesheet->tuesday = 0;
                $timesheet->wednesday = 0;
                $timesheet->thursday = 0;
                $timesheet->friday = 0;
                $timesheet->saturday = 0;
                $timesheet->total = 0;

                $timesheet->save();

                return Redirect::to('/portal-emp-timesheets/' . $empId);
                
            } else if ( $userTypeID == 2 ) {
              
                return Redirect::to('/portal-settings');
                
            } else {

                return Redirect::to('/account');

            }
            
        } else {
            
            return Redirect::to('/');
            
        }
        
    }