Exemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Activity::find($id);
     $item->status = 'deleted';
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Activities named " . $item->name));
 }
Exemplo n.º 2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Source::find($id);
     $item->status = "deleted";
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Source named " . $item->name));
 }
Exemplo n.º 3
0
 public function run()
 {
     $faker = Faker::create();
     $users = User::get();
     #Category
     foreach (range(1, 20) as $void) {
         Log::create(['user_id' => $users->random(1)->id, 'type' => $faker->text(10), 'source_id' => $faker->numberBetween(50, 1000000), 'details' => $faker->text(50)]);
     }
 }
Exemplo n.º 4
0
 public function savelog()
 {
     $equation = Input::get('equation');
     $id = Input::get('id');
     $status = Input::get('status');
     $mood = Input::get('mood');
     $log = array('equation' => $equation, 'equation_id' => $id, 'status' => $status, 'emotion' => $mood);
     $model = Log::create($log);
     // dd($model);
 }
Exemplo n.º 5
0
 public function run()
 {
     $faker = Faker::create();
     $actions = ActionType::get();
     $users = User::select('id')->get();
     //Category
     foreach (range(1, 20) as $void) {
         Log::create(['user_id' => $users->random(1)->id, 'action_type_id' => $actions->random(1)->id, 'source_id' => $faker->numberBetween(50, 1000000), 'details' => $faker->text(50)]);
     }
 }
Exemplo n.º 6
0
 public function createLog()
 {
     $actions = [];
     foreach (trans('globals.action_types') as $value) {
         if ($value['source_type'] == 'order') {
             $actions[$value['action']] = $value['id'];
         }
     }
     if (isset($actions[$this->status])) {
         Log::create(['action_type_id' => $actions[$this->status], 'source_id' => $this->id, 'user_id' => $this->user_id, 'details' => "Order #{$this->id} {$this->status}"]);
     }
     return $this;
 }
Exemplo n.º 7
0
Route::group(['middleware' => 'guest'], function () {
    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')]);
    });
Exemplo n.º 8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $recipient = RecipientLevel::find($id);
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Recipient Level named " . $recipient->name));
     $recipient->delete();
 }
Exemplo n.º 9
0
 /**
  * Removes the selected item from the cart, and stores it back in the Later Cart
  *
  * @param  int  $origin type of the origin order ('cart','later',etc)
  * @param  int  $destination type of the destination order ('cart','later',etc)
  * @param  int  $productId of the product
  * @return Redirects back to de cart
  */
 public function moveFromOrder($origin, $destination, $productId)
 {
     /**
      * validating if the product requested is valid.
      * if it fails, there will be an 404 exception threw
      */
     try {
         $product = Product::findOrFail($productId);
     } catch (ModelNotFoundException $e) {
         throw new NotFoundHttpException();
     }
     $user = \Auth::user();
     /**
      * $originType allows tracking the type of origin, if it is coming from a specific wish list
      * @var string
      */
     $originType = '';
     //if it came from a specific wish list
     if ($origin != 'later' && $origin != 'cart' && $origin != 'wishlist' && is_string($origin)) {
         //getting the list type
         $originType = Order::select(['id', 'type'])->where('description', 'LIKE', $origin)->first();
         //getting the list information
         $basicCart = Order::ofType($originType->type)->where('user_id', $user->id)->where('id', $originType->id)->first();
     } else {
         //getting the list information
         $basicCart = Order::ofType($origin)->where('user_id', $user->id)->first();
     }
     //getting information of the destination order
     $destinationOrder = Order::ofType($destination)->where('user_id', $user->id)->first();
     //if there is not destination, it is created
     if (!$destinationOrder) {
         $destinationOrder = new Order();
         $destinationOrder->user_id = $user->id;
         $destinationOrder->type = $destination;
         $destinationOrder->status = 'open';
         $destinationOrder->save();
         $log = Log::create(['action_type_id' => '1', 'details' => $destinationOrder->id, 'source_id' => $destinationOrder->id, 'user_id' => $user->id]);
     }
     //checking if the user already has a product in the origin order, if so, it can be read to update the destination order.
     $originDetail = OrderDetail::where('order_id', $basicCart->id)->where('product_id', $product->id)->first();
     if ($originDetail) {
         $oldQuantity = $originDetail->quantity;
         $originDetail->delete();
     } else {
         $oldQuantity = 1;
     }
     //checking if the product exist in the destination, if so, it can be updated
     $orderMoved = OrderDetail::where('order_id', $destinationOrder->id)->where('product_id', $product->id)->first();
     //creating the new orden
     if ($orderMoved) {
         $orderMoved->price = $product->price;
         $orderMoved->quantity = $orderMoved->quantity + $oldQuantity;
     } else {
         $orderMoved = new OrderDetail();
         $orderMoved->order_id = $destinationOrder->id;
         $orderMoved->product_id = $product->id;
         $orderMoved->price = $product->price;
         $orderMoved->quantity = $oldQuantity;
         $orderMoved->status = 1;
     }
     //save new order
     $orderMoved->save();
     if ($product->type != 'item') {
         $virtual = VirtualProduct::where('product_id', $product->id)->first();
         //updating the virtual product order
         VirtualProductOrder::where('virtual_product_id', $virtual->id)->where('order_id', $basicCart->id)->update(['order_id' => $destinationOrder->id]);
     }
     if ($destination == 'later') {
         Session::push('message', trans('store.productSavedForLater'));
     } elseif ($destination == 'cart') {
         Session::push('message', trans('store.productAdded'));
     }
     return redirect()->route('orders.show_cart');
 }
Exemplo n.º 10
0
 /**
  * save new system settings
  *
  * @param  Request  $request
  * @return view
  */
 public function saveSettings(Request $request)
 {
     if (count(SystemSettings::all()) != 0) {
         $item = SystemSettings::first();
     } else {
         $item = new SystemSettings();
     }
     $item->language = $request->input("language");
     $item->main_currency = $request->input("main_currency");
     $item->start_year = $request->input("start_year");
     $item->save();
     $central = Recipient::where('parent_id', 0)->first();
     $central->name = $request->input("central_level_name");
     $central->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Update System Settings"));
     return $item;
 }
Exemplo n.º 11
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = Recipient::find($id);
     $item->status = "deleted";
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Recipient named " . $item->name));
     return $item;
 }
Exemplo n.º 12
0
 /**
  * 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');
         }
     }
 }
Exemplo n.º 13
0
 public function removeVehicle(Request $request)
 {
     $redirect = $request['cid'];
     $request['c_description'] = 'Bus removed';
     $request['b_description'] = 'Removed form client';
     $request['action'] = 'Remove';
     Log::create($request->all());
     // update log
     $vehicle = Vehicles::findOrFail($request['bid']);
     $request['cid'] = 0;
     $vehicle->update($request->only(['cid']));
     // update vehicle's foreign key
     return redirect('client/' . $redirect);
 }
Exemplo n.º 14
0
 /**
  * Store accidents information in storage
  * @param Request $request
  * Created by smartrahat Date: 21.11.2015 Time: 8:31PM
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function vehicleAccident(Request $request)
 {
     $request['action'] = 'Accident';
     $request['e_description'] = $request['b_description'];
     Log::create($request->all());
     return redirect('vehicle/' . $request['bid']);
 }
Exemplo n.º 15
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = RecipientAnnualQuota::find($id);
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete " . $item->year . " Yearly Plan for " . $item->recipient->name . ", " . $item->vaccine->name));
     $item->delete();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $item = AdjustmentReason::find($id);
     $item->status = 'deleted';
     $item->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Delete Adjustment Reason named " . $item->name));
 }
Exemplo n.º 17
0
 public function cancelDispatch($id, Request $request)
 {
     $dispatch = RecipientPackage::find($id);
     $recipient = Recipient::find(Auth::user()->recipient_id);
     foreach ($dispatch->items as $items) {
         $volume = $items->amount * PackagingInformation::find($items->packaging_id)->cm_per_dose * 0.001;
         $stock = Stock::where('recipient_id', $recipient->id)->where('vaccine_id', $items->vaccine_id)->where('lot_number', $items->batch_number)->first();
         $storeStock = StoreStock::where('store_id', $items->store_id)->where('vaccine_id', $items->vaccine_id)->where('lot_number', $items->batch_number)->first();
         $stock->amount = $stock->amount + $items->amount;
         $storeStock->amount = $storeStock->amount + $items->amount;
         $stock->save();
         $storeStock->save();
         //reduce volume in store
         $store = Store::find($items->store_id);
         $store->used_volume = $store->used_volume + $volume;
         $store->save();
         //update line item status
         $items->status = 'canceled';
         $items->save();
         //delete stock item if amount has turned to zero
         if ($stock->amount == 0) {
             $stock->delete();
         }
         if ($storeStock->amount == 0) {
             $storeStock->delete();
         }
     }
     //update arrival status
     $dispatch->receiving_status = 'canceled';
     $dispatch->comments = $request->has('notes') ? $request->input('notes') : "";
     $dispatch->save();
     Log::create(array("user_id" => Auth::user()->id, "action" => "Cancel Dispatch with reference Number " . $dispatch->voucher_number));
     return $dispatch->voucher_number;
 }
Exemplo n.º 18
0
 public function modifyPoints($points, $actionTypeId, $sourceId)
 {
     $data = ['action_type_id' => $actionTypeId, 'source_id' => $sourceId, 'details' => $points, 'user_id' => $this->id];
     $log = Log::create($data);
     $userPoints = new UserPoints();
     $userPoints->user_id = $this->id;
     $userPoints->action_type_id = $actionTypeId;
     $userPoints->source_id = $sourceId;
     $userPoints->points = $points;
     if ($userPoints->save()) {
         $this->current_points = $this->current_points + $points;
         //Action type = 9 is for canceled orders, the user should not add to accumulated points
         if ($points > 0 && $actionTypeId != 9) {
             $this->accumulated_points = $this->accumulated_points + $points;
         }
         if ($this->save()) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function store(CreateLogRequest $request)
 {
     $request->merge(['user_id' => auth()->user()->id]);
     Log::create($request->all());
     return redirect('/')->with('success', 'Yeni log eklendi.');
 }