Exemple #1
0
 /**
  * Gets all att. record from the connected device and no
  * sorting is applied. Returns only the new ones.
  * @return [type] [description]
  */
 public function getAll()
 {
     if ($this->tad && $this->tad->is_alive()) {
         $data = $this->tad->get_att_log()->to_array();
         $data = $data['Row'];
         // $device = Device::where('ip_address', $this->connected_device['ip_address'])->first();
         $last_log = Log::where('device_id', $this->connected_device['device_id'])->orderBy('id', 'desc')->first();
         $last_log_datetime = null;
         if ($last_log) {
             $last_log_datetime = Carbon::parse($last_log->datetime);
         }
         $return_data = [];
         $timestamp = Carbon::now()->toDateTimeString();
         foreach ($data as $k => $v) {
             if ($last_log_datetime === null || $last_log_datetime->lt(Carbon::parse($data[$k]['DateTime']))) {
                 $data[$k]['emp_id'] = $data[$k]['PIN'];
                 unset($data[$k]['PIN']);
                 $data[$k]['datetime'] = $data[$k]['DateTime'];
                 unset($data[$k]['DateTime']);
                 $data[$k]['verified'] = $data[$k]['Verified'];
                 unset($data[$k]['Verified']);
                 $data[$k]['status'] = $data[$k]['Status'];
                 unset($data[$k]['Status']);
                 $data[$k]['workcode'] = $data[$k]['WorkCode'];
                 unset($data[$k]['WorkCode']);
                 $data[$k]['device_id'] = $this->connected_device['device_id'];
                 $data[$k]['created_at'] = $timestamp;
                 $data[$k]['updated_at'] = $timestamp;
                 array_push($return_data, $data[$k]);
             }
         }
         return $return_data;
     }
 }
Exemple #2
0
 public function getPointsAttribute()
 {
     $id = $this->attributes['id'];
     return Cache::remember("user_{$id}_points", 3, function () use($id) {
         $marketActions = Log::with('market')->whereFlag(true)->where('user_id', $id)->get()->sum('market.reward');
         $otherActions = Log::where('user_id', $id)->whereFlag(true)->whereNull('market_item_id')->get()->sum('reward');
         $reduced = $this->reduced->select('market.reward')->sum('market.reward');
         return $marketActions + $otherActions - $reduced;
     });
 }
 public function process()
 {
     $transactionID = Input::get('transactionID');
     $transaction = Transaction::where('transaction_id', '=', $transactionID)->first();
     $logs = Log::where('transaction_id', '=', $transactionID)->get();
     $recentLog = Log::where('transaction_id', '=', $transactionID)->orderBy('created_at', 'desc')->first();
     if (Input::has('create')) {
         // Redirect to different route / URI
         return Redirect::route('superadmin/create_transaction')->with('transactionID', $transactionID);
         // Alternatively, you could process action 1 here
     } elseif (Input::has('update')) {
         // Process action 2
         return Redirect::route('superadmin/update_transaction')->with('transaction', $transaction)->with('logs', $logs)->with('recentLog', $recentLog);
     } elseif (Input::has('out')) {
         // Process action 3
         return Redirect::route('superadmin/out_transaction')->with('transaction', $transaction)->with('logs', $logs)->with('users', '')->with('recentLog', $recentLog);
     }
 }
 /**
  * Show vehicle log from storage
  * Created by smartrahat Date: 21.11.2015 Time: 08:32PM
  * @param $id
  * @return \Illuminate\View\View
  */
 public function vehicleLog($id)
 {
     $vehicle = Vehicles::findOrFail($id);
     $logs = Log::where('bid', $id)->orderBy('date', 'desc')->orderBy('id', 'desc')->get();
     $title = 'Vehicle Log';
     $repository = $this->repository;
     return view('vehicle.vehicleLog', compact('title', 'logs', 'vehicle', 'repository'));
 }
Exemple #5
0
    Route::get('/', 'Auth\\AuthController@getLogin');
    // Authentication routes...
    Route::get('auth/login', 'Auth\\AuthController@getLogin');
    Route::post('auth/login', 'Auth\\AuthController@postLogin');
    // Registration routes...
    Route::get('auth/register', 'Auth\\AuthController@getRegister');
    Route::post('auth/register', 'Auth\\AuthController@postRegister');
});
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Route::group(['middleware' => 'auth'], function () {
    Route::get('goal/create', 'GoalController@create');
    Route::post('goal/store', 'GoalController@store');
    Route::get('goal/{id}', ['uses' => 'GoalController@show', 'as' => 'showGoal']);
    Route::post('logs/store', function (Request $request) {
        $log = Log::create($request->all());
        return $log;
    });
    Route::get('/api/goal/{goal_id}/logs/', function ($goal_id) {
        return Log::where('goal_id', $goal_id)->orderBy('id', 'DESC')->get();
    });
    Route::post('todo/store', function (Request $request) {
        $todo = Todo::create($request->all());
        return $todo;
    });
    Route::get('/api/goal/{goal_id}/todos/', function ($goal_id) {
        return Todo::where('goal_id', $goal_id)->orderBy('id', 'DESC')->get();
    });
    Route::post('todo/update/{todo_id}', function (Request $request, $todo_id) {
        Todo::find($todo_id)->update(['done' => $request->input('done')]);
    });
});
 public function employeeLog($id)
 {
     $title = 'Employee Log';
     $employee = Employee::query()->findOrFail($id);
     $logs = Log::where('eid', $id)->orderBy('id', 'desc')->orderBy('id', 'desc')->get();
     $repository = $this->repository;
     return view('employee.employeeLog', compact('title', 'logs', 'employee', 'repository'));
 }
Exemple #7
0
 /**
  * Show the form for creating a new resource.
  *
  * @param $id
  * @return Response
  */
 public function userlogs($id)
 {
     return Log::where('user_id', $id)->orderBy('id', 'DESC')->get();
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Request $request)
 {
     $transaction = Transaction::findOrFail($id);
     $authuser = Auth::user();
     //Update transaction
     if (Input::has('update')) {
         $this->validate($request, ['remarks' => 'required']);
         $input = $request->all();
         $transaction->fill($input)->save();
         $transaction->status = "In process";
         $transaction->save();
         //Log
         $recentLog = Log::where('transaction_id', '=', $transaction->transaction_id)->orderBy('created_at', 'desc')->first();
         $firstname = $authuser->firstname;
         $lastname = $authuser->lastname;
         $date = new DateTime();
         Log::create(['transaction_id' => $transaction->transaction_id, 'processor_name' => $authuser->firstname . ' ' . $authuser->lastname, 'status' => 'In process', 'remarks' => $request['remarks'], 'date_received' => $date, 'date_released' => '', 'next_processor' => '-']);
         if ($authuser->user_type == "Processor") {
             return redirect('processor/process_transactions')->withMessage('success update');
         } else {
             return redirect('superadmin/process_transactions')->withMessage('success update');
         }
     }
     //Log out transaction
     if (Input::has('out')) {
         //Log
         //if processor of recent log is the auth user, update log
         $recentLog = Log::where('transaction_id', '=', $transaction->transaction_id)->orderBy('created_at', 'desc')->first();
         $firstname = $authuser->firstname;
         $lastname = $authuser->lastname;
         $complete = Input::has('completed') ? true : false;
         //completed transaction should only be forwarded to customer or to '-'
         if ($complete) {
             $transaction->status = "Completed";
             $transaction->save();
             if ($request['next_processor'] != "Customer") {
                 $nextprocessor = "-";
             } else {
                 $nextprocessor = $request['next_processor'];
             }
             //create log
             $date = new DateTime();
             $recent_received = $recentLog->date_received;
             Log::create(['transaction_id' => $transaction->transaction_id, 'processor_name' => $authuser->firstname . ' ' . $authuser->lastname, 'remarks' => $request['remarks'], 'date_received' => $recent_received, 'date_released' => $date, 'status' => 'Completed', 'next_processor' => $nextprocessor]);
         } else {
             $nextprocessor = $request['next_processor'];
             $recent_released = $recentLog->date_released;
             if ($recentLog->status == 'Completed') {
                 $transaction->status = "In process";
                 $transaction->save();
                 $date = new DateTime();
                 Log::create(['transaction_id' => $transaction->transaction_id, 'processor_name' => $authuser->firstname . ' ' . $authuser->lastname, 'status' => 'In process', 'remarks' => $request['remarks'], 'date_received' => $recent_released, 'date_released' => $date, 'next_processor' => $nextprocessor]);
             } else {
                 //add date_released
                 $date = new DateTime();
                 $recentLog->date_released = $date;
                 $recentLog->remarks = $request['remarks'];
                 $recentLog->next_processor = $nextprocessor;
                 $recentLog->save();
             }
         }
         if ($authuser->user_type == "Processor") {
             return redirect('processor/process_transactions')->withMessage('success out');
         } else {
             return redirect('superadmin/process_transactions')->withMessage('success out');
         }
     }
 }
 /**
  * @param $id
  * @return \Illuminate\View\View
  */
 public function clientLog($id)
 {
     $title = 'Client Log';
     $client = Client::query()->findOrFail($id);
     if (Input::has('start') && Input::has('end')) {
         $start = Input::get('start');
         $end = Input::get('end');
         $logs = Log::where('cid', $id)->whereBetween('date', [$start, $end])->orderBy('date', 'desc')->orderBy('date', 'desc')->get();
     } elseif (Input::has('start')) {
         $start = Input::get('start');
         $logs = Log::where('cid', $id)->where('date', $start)->orderBy('date', 'desc')->orderBy('id', 'desc')->get();
     } elseif (Input::has('end')) {
         $end = Input::get('end');
         $logs = Log::where('cid', $id)->where('date', $end)->orderBy('date', 'desc')->orderBy('id', 'desc')->get();
     } else {
         $logs = Log::where('cid', $id)->orderBy('date', 'desc')->orderBy('id', 'desc')->get();
     }
     //$logs = Log::where('cid',$id)->orderBy('date','desc')->orderBy('id','desc')->get();
     $repository = $this->repository;
     return view('client.clientLog', compact('title', 'logs', 'client', 'repository'));
 }