/** * Update the specified pet in storage. * * @param int $id * @return Response */ public function update($id) { $pet = Pet::findOrFail($id); $data = Input::all(); $data['user_id'] = Confide::user()->id; $validator = Validator::make($data, Pet::$rules); $response = []; $response['data'] = $data; if ($validator->fails()) { $response['success'] = false; $response['errors'] = $validator->errors(); if (Request::ajax()) { return Response::json($response); } else { return Redirect::back()->withErrors($validator->errors()); } } $pet->update($data); $response['success'] = true; $response['errors'] = []; if (Request::ajax()) { return Response::json($response); } else { return Redirect::action('UsersController@showProfile', Confide::user()->id); } }
/** * @return $this */ public function home() { if (Confide::User()) { $this->dsp->content = Confide::user()->getContent(); } return View::make('dispatch')->with(['dsp' => $this->dsp]); }
/** * @param $club_id * @return bool */ public static function isExist($club_id) { $count = DB::table('userclubs')->where('user_id', '=', Confide::user()->id)->where('club_id', '=', $club_id)->count(); if ($count == 0) { return false; } return true; }
public function getlivrabileFactura($id_factura) { $ids = self::getIDsDepartamente(Confide::getDepartamenteUser()); $sql = self::getlivrabileFacturateNefacturate($id_factura, true); $factura = self::getFactura($id_factura); $livrabile = DB::select($sql); return View::make('livrabile_factura.list')->with('livrabile', $livrabile)->with('factura', $factura); }
public function getIndex() { $user = Confide::user(); if (!$user->isStaff() && Patient::find($user->id) == null) { return Redirect::route('patient.create'); } else { return View::make('home/index', compact('user')); } }
/** * Provide an array of strings that map to valid roles. * @param array $roles * @return stdClass */ public function validateRoles(array $roles) { $user = Confide::user(); $roleValidation = new stdClass(); foreach ($roles as $role) { $roleValidation->{$role} = empty($user) ? false : $user->hasRole($role); } return $roleValidation; }
public function uploadUserImage() { $user = Confide::user(); $user->img_path = $this->getAndMoveFile('file'); if ($user->save()) { return Redirect::action('UsersController@show', $user->id); } else { throw new Exception("user image not updated!"); } }
public static function logAudit($entity, $action, $description) { $audit = new Audit(); $audit->date = date('Y-m-d'); $audit->description = $description; $audit->user = Confide::user()->username; $audit->entity = $entity; $audit->action = $action; $audit->save(); }
public function showAll() { $user = Confide::user(); $patients = Patient::join('user', 'user.id', '=', 'patient.user_id')->get(); if ($user->isStaff()) { return View::make('home.patient.show-all', compact('user', 'patients')); } else { return Redirect::route('home.index'); } }
public function createComment($conversation) { $user = Confide::user(); $comment = new Comment(); $comment->conversation_id = $conversation->id; $comment->user_id = $user->id; $comment->fill(Input::all()); $comment->save(); return Redirect::route('conversation.show', array($conversation->id)); }
public function getEditInvestitie($id) { $departamente = Confide::getDepartamenteUser(); $tva = self::getCoteTVA(); $imobil_class = new \Codecorner\Imobil\Controllers\ImobileController(); $imobile = $imobil_class->getImobil(); $cheltuieli = self::getCheltuieliSF(); $investitie = DB::select("SELECT\n investitie.id,\n investitie.denumire,\n investitie.cota_indiviza_spatii_locuit,\n investitie.cota_indiviza_spatii_alta_destinatie,\n investitie.finantare_nerambursabila_por,\n investitie.cofinantare_ap_eligibil,\n investitie.cofinantare_uat_eligibil,\n investitie.cofinantare_ap_neeligibil_ad,\n investitie.cofinantare_uat_neeligibil,\n investitie.cofinantare_ap_neeligibil_sl,\n investitie.id_imobil,\n investitie.id_departament,\n investitie.id_tva,\n l.denumire AS localitate,\n j.denumire AS judet,\n i.adresa\n FROM por12_investitie investitie\n INNER JOIN imobil i ON i.id = investitie.id_imobil AND i.logical_delete = 0\n LEFT OUTER JOIN judet j ON j.id_judet = i.id_judet AND j.logical_delete = 0\n LEFT OUTER JOIN localitate l ON l.id_localitate = i.id_localitate AND l.logical_delete = 0\n WHERE investitie.id = :id_investitie", array('id_investitie' => $id)); return View::make('investitie_por_axa12.edit')->with('investitie', $investitie[0])->with('imobile', $imobile)->with('tva', $tva)->with('finantare_nerambursabila_por', 60)->with('cofinantare_ap_neeligibil_ad', 100)->with('departamente', self::object_to_array($departamente))->with('cheltuieli', $cheltuieli); }
/** * Display a listing of notifications * * @return Response */ public function index() { $data = Input::all(); $pagination = Input::has('pagination') ? Input::get('pagination') : 10; // FILTRA RESULTADOS $notifications = Notification::where(function ($query) { switch (Input::get('view')) { case 'next': // AGENDADAS $query->where('date', '>', date('Y-m-d H:i:s')); break; case 'all': // $query->where( 'user_id', Confide::user()->id ); break; default: // NÃO LIDAS $query->where('date', '<', date('Y-m-d H:i:s'))->where('status', 0); break; } if (Input::has('type')) { $query->where('type', Input::get('type')); } if (Input::has('owner_type')) { $query->where('owner_type', Input::get('owner_type')); } if (Input::has('owner_id')) { $query->where('owner_id', Input::get('owner_id')); } if (Input::has('order')) { $query->orderBy('date', Input::get('order')); } })->where('user_id', Confide::user()->id)->orderBy('date', Input::get('order', 'DESC'))->paginate($pagination); switch (Input::get('view', 'unread')) { case 'next': $labels['nothing'] = 'Nenhuma notificação agendada'; break; case 'all': $labels['nothing'] = 'Nenhuma notificação ainda'; break; default: // case 'unread' $labels['nothing'] = 'Nenhuma notificação não lida'; break; } $labels['count_next'] = Notification::where('user_id', Confide::user()->id)->where('date', '>', date('Y-m-d H:i:s'))->count(); $labels['count_all'] = Notification::where('user_id', Confide::user()->id)->count(); $labels['count_unread'] = Notification::where('user_id', Confide::user()->id)->where('date', '<', date('Y-m-d H:i:s'))->where('status', false)->count(); //$notifications->getCollection()->paginate( $pagination );//->paginate( $pagination ; if (Request::ajax()) { return View::make('notifications.panels.index', compact('notifications', 'labels')); } else { return View::make('notifications.index', compact('notifications', 'labels')); } }
/** * @param string $backUrl * @param int $club_id * @return \Illuminate\Http\RedirectResponse */ public function add($backUrl = 'home', $club_id = 0) { if ($club_id == 0) { return Redirect::route($backUrl); } $userclub = new Userclub(); $userclub->user_id = Confide::user()->id; $userclub->club_id = $club_id; $userclub->save(); return Redirect::route($backUrl); }
public function __construct() { // Fetch the User object, or set it to false if not logged in if (Confide::User()) { $this->logged_in_user = Confide::User(); } else { $this->logged_in_user = false; } View::share('logged_in_user', $this->logged_in_user); View::share('success_message', $this->success_message); }
public function getBalance($wallet_id) { $balance = 0; if (!Auth::guest()) { $user = Confide::user(); $balanceCoin = Balance::where('user_id', '=', $user->id)->where('wallet_id', '=', $wallet_id)->first(); if (isset($balanceCoin->amount)) { $balance = $balanceCoin->amount; } } return $balance; }
/** * @return string */ public function beforeHome() { // Extend function home() if (!Confide::user()->isManager()) { return $this->dsp->content = $this->directory . ".nomanager"; } else { if (!Confide::user()->isDomaine()) { return $this->dsp->content = $this->directory . ".nodomaine"; } } // Sinon procedure Home normale }
public function getCurrentOrdersUser($market_id, $user_id = '') { if (Auth::guest()) { return false; } $user = Confide::user(); if ($user_id == '') { $user_id = $user->id; } $orders = Order::where('market_id', '=', $market_id)->where('user_id', '=', $user_id)->whereIn('status', $this->status_active)->orderBy('created_at', 'desc')->get(); return $orders; }
public function resetpassword($user) { if (!Confide::forgotPassword($user->email)) { if (!Api::make(array('error'))) { return Response::json(array('result' => 'error')); } } else { if (!Api::make(array('success'))) { return Response::json(array('result' => 'success')); } } }
public function getSeriiFacturare() { $ids = self::getIDsDepartamente(Confide::getDepartamenteUser()); $sql = "SELECT \n sf.id,\n sf.serie,\n sf.numar,\n sf.id_entitate,\n ent.denumire AS entitate\n FROM serie_factura sf\n INNER JOIN entitate ent ON ent.id = sf.id_entitate AND ent.logical_delete = 0\n WHERE "; if (!Entrust::can("administrare_platforma")) { /*$sql .= " INNER JOIN departament d ON d.id_entitate = ent.id AND d.logical_delete = 0" . " AND d.id IN (" . $ids . ")";*/ $sql .= " EXISTS(SELECT id FROM departament WHERE departament.id_entitate = sf.id_entitate AND departament.logical_delete = 0\n AND departament.id IN (" . $ids . ")) AND "; } $sql .= " sf.logical_delete = 0 ORDER BY ent.id, sf.serie"; //dd($sql); $serii = DB::select($sql); return View::make('serii_facturare.list')->with('serii', $serii); }
public static function submitApplication($data) { $member_id = array_get($data, 'member_id'); $loanproduct_id = array_get($data, 'loanproduct_id'); $member = Member::findorfail($member_id); $loanproduct = Loanproduct::findorfail($loanproduct_id); $application = new Loanaccount(); $application->member()->associate($member); $application->loanproduct()->associate($loanproduct); $application->application_date = array_get($data, 'application_date'); $application->amount_applied = array_get($data, 'amount_applied'); $application->interest_rate = $loanproduct->interest_rate; $application->period = $loanproduct->period; $application->repayment_duration = array_get($data, 'repayment_duration'); $application->save(); Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'loan application', 'Loans', array_get($data, 'amount_applied')); }
/** * Store a newly created savingtransaction in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Savingtransaction::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $date = Input::get('date'); $transAmount = Input::get('amount'); $savingaccount = Savingaccount::findOrFail(Input::get('account_id')); $savingtransaction = new Savingtransaction(); $savingtransaction->date = Input::get('date'); $savingtransaction->savingaccount()->associate($savingaccount); $savingtransaction->amount = Input::get('amount'); $savingtransaction->type = Input::get('type'); $savingtransaction->description = Input::get('description'); $savingtransaction->transacted_by = Input::get('transacted_by'); $savingtransaction->save(); // withdrawal if (Input::get('type') == 'debit') { foreach ($savingaccount->savingproduct->savingpostings as $posting) { if ($posting->transaction == 'withdrawal') { $debit_account = $posting->debit_account; $credit_account = $posting->credit_account; } } $data = array('credit_account' => $credit_account, 'debit_account' => $debit_account, 'date' => Input::get('date'), 'amount' => Input::get('amount'), 'initiated_by' => 'system', 'description' => 'cash withdrawal'); $journal = new Journal(); $journal->journal_entry($data); Savingtransaction::withdrawalCharges($savingaccount, $date, $transAmount); Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'savings withdrawal', 'Savings', Input::get('amount')); } // deposit if (Input::get('type') == 'credit') { foreach ($savingaccount->savingproduct->savingpostings as $posting) { if ($posting->transaction == 'deposit') { $debit_account = $posting->debit_account; $credit_account = $posting->credit_account; } } $data = array('credit_account' => $credit_account, 'debit_account' => $debit_account, 'date' => Input::get('date'), 'amount' => Input::get('amount'), 'initiated_by' => 'system', 'description' => 'cash deposit'); $journal = new Journal(); $journal->journal_entry($data); Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'savings deposit', 'Savings', Input::get('amount')); } return Redirect::to('savingtransactions/show/' . $savingaccount->id); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $data = Input::all(); $validator = Validator::make($data, Post::$rules); if ($validator->fails()) { Session::flash('message', 'Posting not created!'); return Redirect::back()->withInput()->withErrors($validator); } $post = new Post($data); $post->user_id = Confide::user()->id; $result = $post->save(); if ($result) { return Redirect::action('PostsController@index'); } else { Session::flash('message', $result); return Redirect::back()->withInput(); } }
/** * Store a newly created branch in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Appraisal::$rules, Appraisal::$messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $appraisal = new Appraisal(); $appraisal->employee_id = Input::get('employee_id'); $appraisal->appraisalquestion_id = Input::get('appraisal_id'); $appraisal->performance = Input::get('performance'); $appraisal->rate = Input::get('score'); $appraisal->examiner = Confide::user()->id; $appraisal->appraisaldate = Input::get('date'); $appraisal->comment = Input::get('comment'); $appraisal->save(); Audit::logaudit('Employee Appraisal', 'create', 'created: ' . $appraisal->question); return Redirect::route('Appraisals.index')->withFlashMessage('Employee Appraisal successfully created!'); }
public function showAll($requestID = null) { $user = Confide::user(); $patient = Patient::find($requestID); $patient = Patient::join('user', 'user.id', '=', 'patient.user_id')->where('patient.user_id', '=', $user->id)->first(); if ($user->isStaff() && $requestID !== null) { // If weare requesting a patient's appointments and we are Staff $appointments = Appointment::where('patient_id', '=', $requestID)->get(); $patient = Patient::join('user', 'user.id', '=', 'patient.user_id')->where('patient.user_id', '=', $requestID)->first(); } else { $appointments = Appointment::where('patient_id', '=', $user->id)->get(); } foreach ($appointments as $appointment) { $doctor = User::find($appointment->staff_id); $appointment->doctor = $doctor->first_name . ' ' . $doctor->last_name; } return View::make('home/appointment/show-all', compact('user', 'appointments', 'patient')); }
public function wizard($code) { if (Confide::confirm($code)) { $user = User::where('confirmation_code', '=', $code)->pluck('email'); $user_auth = User::where('confirmation_code', '=', $code)->first(); Auth::login($user_auth); if (Auth::check()) { $urbanism_types = UrbanismType::orderBy('id', 'ASC')->lists('type', 'id'); $countries = Country::orderBy('id', 'ASC')->lists('name', 'id'); $states = State::orderBy('id', 'ASC')->lists('name', 'id'); $country_default = 'México'; $selected_country = Country::where('name', '=', $country_default)->first(); return View::make('dashboard.colonies.config.initial_config', ['urbanism_types' => $urbanism_types, 'user' => $user, 'countries' => $countries, 'states' => $states, 'code' => $code, 'selected_country' => [$selected_country->id], 'select' => ['' => 'Seleccione tipo de desarrollo'], 'select_1' => ['' => 'Seleccione País'], 'select_2' => ['' => 'Seleccione Estado'], 'select_3' => ['' => 'Seleccione Ciudad']]); } } else { $error_msg = Lang::get('confide::confide.alerts.wrong_confirmation'); return Redirect::action('UsersController@login')->with('error', $error_msg); } }
public static function submit($data) { //$charges = Input::get('charge'); $loanproduct = new Loanproduct(); $loanproduct->name = array_get($data, 'name'); $loanproduct->short_name = array_get($data, 'short_name'); $loanproduct->interest_rate = array_get($data, 'interest_rate'); $loanproduct->formula = array_get($data, 'formula'); $loanproduct->amortization = array_get($data, 'amortization'); $loanproduct->currency = array_get($data, 'currency'); $loanproduct->save(); Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'loan product creation', 'Loans', '0'); $loan_id = $loanproduct->id; Loanposting::submit($loan_id, $data); /* foreach($charges as $charge){ $loanproduct->charges()->attach($charge); } */ }
/** * Store a newly created leaveapplication in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Leaveapplication::$rules, Leaveapplication::$messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $employee = Employee::find(array_get($data, 'employee_id')); $leavetype = Leavetype::find(array_get($data, 'leavetype_id')); $start_date = array_get($data, 'applied_start_date'); $end_date = array_get($data, 'applied_end_date'); $days_applied = Leaveapplication::getDays($start_date, $end_date); $balance_days = Leaveapplication::getBalanceDays($employee, $leavetype); if ($days_applied > $balance_days) { return Redirect::back()->with('info', 'The days you have applied are more than your balance. You have ' . $balance_days . ' days left'); } Leaveapplication::createLeaveApplication($data); if (Confide::user()->user_type == 'member') { return Redirect::to('css/leave'); } else { return Redirect::to('leavemgmt'); } }
public function generateNewAddrDeposit() { if (!Confide::user()) { return View::make(Config::get('confide::login_form')); } $user = Confide::user(); $user_id = $user->id; $wallet_id = $_POST['wallet_id']; $wallet = Wallet::find($wallet_id); $deposit = new Deposit(); $user_address_deposit = new UserAddressDeposit(); $addr_deposit = UserAddressDeposit::where('wallet_id', $wallet->id)->where('user_id', $user_id)->first(); if (isset($addr_deposit->addr_deposit) && $deposit->addressIsDesposited($addr_deposit->addr_deposit)) { $wallet->connectJsonRPCclient($wallet->wallet_username, $wallet->wallet_password, $wallet->wallet_ip, $wallet->port); $new_addr_deposit = $wallet->getNewDepositReceiveAddress($user->username); $user_address_deposit->updateAddress($user_id, $wallet->id, $new_addr_deposit); echo json_encode(array('status' => 'success', 'address' => $new_addr_deposit)); exit; } else { echo json_encode(array('status' => 'error', 'message' => 'You cannot generate a new address, without using the old')); exit; } }
public function getEntitati($tip_entitate) { $sql = "SELECT \n ent.id, \n ent.denumire, \n ent.cif,\n ent.adresa, \n ent.cod_postal, \n ent.telefon, \n ent.fax, \n ent.id_organizatie, \n ent.id_tip_entitate, \n judet.denumire AS judet, \n loc.denumire AS localitate\n FROM entitate ent\n LEFT OUTER JOIN judet ON ent.id_judet = judet.id_judet AND judet.logical_delete = 0 \n LEFT OUTER JOIN localitate loc ON ent.id_localitate = loc.id_localitate AND loc.logical_delete = 0"; $and = ""; if (\Entrust::hasRole("Administrator de grup")) { $and = " AND ent.id_organizatie = " . \Entrust::user()->id_org; } else { if (!\Entrust::can("administrare_platforma")) { $ids = self::getIDsDepartamente(\Confide::getDepartamenteUser()); $sql = $sql . " INNER JOIN departament d ON d.id_entitate = ent.id AND d.logical_delete = 0" . " AND d.id IN (" . $ids . ")"; } } $sql .= " WHERE ent.logical_delete = 0 "; $sql .= $and; if ($tip_entitate == 1) { $sql .= " AND ent.id_tip_entitate = 1 "; } else { $sql .= " AND ent.id_tip_entitate = 2 "; } $sql .= " GROUP BY ent.id"; $entitati = DB::select($sql); //dd($sql); return View::make('entitate::entitati_organizatie.list')->with('entitati', $entitati)->with('tip_entitate', $tip_entitate); }
/** * Upload an image * Validates is an image * Saves image through intervention, optimizing and constraining to max size * Saves to public/uploads directory, with unique filename * @return string $image filename | throws Exception on error */ public function process($file) { // Make sure upload directory exists static::directoryExists(public_path() . '/' . $this->uploadDirectory); // Validate file is image $validation = Validator::make(['file' => $file], ['file' => 'mimes:jpeg,png,gif']); if (!$validation->fails()) { $destination = public_path() . '/' . $this->uploadDirectory . '/' . $file->getClientOriginalName(); if (File::isFile($destination)) { $basename = basename(isset($file->fileSystemName) ? $file->fileSystemName : $file->getClientOriginalName(), $file->getClientOriginalExtension()); // Remove trailing period $basename = rtrim($basename, '.'); // Append 1 and recheck $counter = 1; $destination = public_path() . '/' . $this->uploadDirectory . '/' . $basename . '_' . $counter . '.' . $file->getClientOriginalExtension(); while (File::isFile($destination)) { $counter++; $destination = public_path() . '/' . $this->uploadDirectory . '/' . $basename . '_' . $counter . '.' . $file->getClientOriginalExtension(); } } // Constrain image to maximum width if needed, respecting aspect ratio Image::make($file)->widen(1200, function ($constraint) { $constraint->upsize(); })->save($destination); // Image has been saved to it's destination, set attributes if (empty($this->user_id)) { $user = Confide::user(); $this->user_id = $user->id; } $this->path = $this->uploadDirectory; $this->filename = str_replace(public_path() . '/' . $this->uploadDirectory . '/', '', $destination); $this->save(); return; } throw new Exception("There was an error uploading the image. Please upload an image with jpg, png or gif filetype"); }