示例#1
0
 public function getDelete(Request $request)
 {
     if ($this->user != null && Session::has('Plan')) {
         $plan = Plan::find(Session::get('Plan'));
         $monthly = $plan->months()->get();
         $restricts = $plan->restricts()->get();
         foreach ($monthly as $month) {
             $daily = $month->days()->get();
             foreach ($daily as $key => $day) {
                 $finances = $day->finances()->get();
                 foreach ($finances as $finance) {
                     $finance->delete();
                 }
                 $day->delete();
             }
             $month->delete();
         }
         foreach ($restricts as $restrict) {
             $restrict->delete();
         }
         $plan->delete();
         Session::put('successes', ["Plan is deleted!"]);
     }
     Session::forget('Plan');
     return redirect('plan');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Deposit $deposit
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Deposit $deposit, Request $request)
 {
     if ((int) $request->input('amount') > Auth::user()->balance) {
         \Session::flash('message', 'Недостаточно средств!');
         return redirect('/profile');
     } elseif ($request->input('amount') <= 0) {
         \Session::flash('message', 'Введите корректную сумму!');
         return back();
     } else {
         $bank = Banks::where('banks_profiles_id', 2)->first();
         $data = $request->all();
         $data['days'] = $request->input('days');
         $data['percent'] = $request->input('percent');
         $data['conclusion'] = Carbon::now()->addDays((int) $request->input('days'));
         $user = User::find($request->input('user_id'));
         $plan = Plan::find($request->input('currency_id'));
         $deposit->fill($data);
         $deposit->user()->associate($user);
         $deposit->plan()->associate($plan);
         $bank->amount += (int) $request->input('amount');
         $bank->update();
         $user->balance -= (int) $request->input('amount');
         $user->update();
         $deposit->save();
         \Session::flash('message', 'Вы успешно сделали вклад! Для получения информации по вкладам перейдите в "Мои операции"');
         return redirect('/profile');
     }
 }
示例#3
0
 /**
  * Send an email to the user to request his confirmation for being a member of the team
  *
  * @return \Illuminate\Http\Response
  */
 public function sendrequest($plan_id, $id, AppMailer $mailer)
 {
     // check access rights
     if (!Auth::user()->ownsPlan($plan_id)) {
         return redirect('home')->with('error', 'You are unauthorized for this request.');
     }
     // get the resource handle
     $team = Team::find($id);
     if ($team) {
         if ($team->requested) {
             $error = 'Request Email was already sent to this user!';
             return \Redirect::back()->with(['error' => $error]);
         }
         $team->requested = True;
         $team->remember_token = str_random(32);
         // send internal message to user
         $message = 'Please open <a href="' . url('cspot/plans/' . $plan_id) . '/team"> this plan </a> and confirm if you accept the given role.';
         $thread_id = sendInternalMessage('You have been assigned a role in a Service plan', $message, $team->user_id, false);
         $team->thread_id = $thread_id;
         $team->save();
         // also send an email to the user
         $recipient = User::find($team->user_id);
         $plan = Plan::find($team->plan_id);
         $mailer->getPlanMemberConfirmation($recipient, $plan, $team);
         $status = 'Email with membership request was sent to user.';
         return \Redirect::route('team.index', ['plan_id' => $plan_id])->with(['status' => $status]);
     }
     $error = 'Wrong team member id!';
     return \Redirect::back()->with(['error' => $error]);
 }
示例#4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(PlanUpdateRequest $request, $id)
 {
     $plan = Plan::find($id);
     $plan->fill($request->all());
     $plan->save();
     Session::flash('mensaje', 'Plan modificado correctamente');
     return redirect('planes');
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Plan::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'start_date' => $this->start_date, 'end_date' => $this->end_date]);
     $query->andFilterWhere(['like', 'direction', $this->direction]);
     return $dataProvider;
 }
示例#6
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     // when a user changes an item ....
     Item::updated(function ($item) {
         // .... update the 'changer' field on the parent model (plan)
         $plan = Plan::find($item->plan_id);
         $plan->update(['changer' => Auth::user()->first_name]);
     });
     /**
      * Provide the data of the last update to the list of songs
      */
     $lastSongUpdated_at = Song::select('updated_at')->orderby('updated_at', 'desc')->first()->updated_at;
     view()->share('lastSongUpdated_at', $lastSongUpdated_at);
     // provide the name of the current Main Presenter to all views
     view()->share('serverSideMainPresenter', getMainPresenter());
     // provide the PATH to the (custom) logos to all views
     if (strtolower(env('USE_CUSTOM_LOGOS')) == 'yes') {
         view()->share('logoPath', 'images/custom/');
     } else {
         view()->share('logoPath', 'images/');
     }
     // provide a list (array) of user-id's with Admin rights to all views (for page feedback messages)
     // (the condition is needed in order to avoid an error in artisan  when no migration has happened yet!)
     if (\Schema::hasTable('users')) {
         view()->share('administrators', findAdmins('id'));
     }
     // detect mobile users
     $isMobileUser = false;
     $useragent = 'local';
     if (isset($_SERVER['HTTP_USER_AGENT'])) {
         $useragent = $_SERVER['HTTP_USER_AGENT'];
     }
     if (preg_match('/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i', substr($useragent, 0, 4))) {
         $isMobileUser = true;
     }
     // provide this to all views
     view()->share('isMobileUser', $isMobileUser);
 }
示例#7
0
 public function getReport(Request $request)
 {
     if ($this->user != null && Session::has('Plan') && Session::get('Plan') != "") {
         $plan = Plan::find(Session::get('Plan'));
         $attach["plan"] = $plan;
         $attach["Month"] = $plan->months()->get();
         $attach["Category"] = Category::where('user_id', '=', $this->user->id)->orWhere('user_id', '=', 0)->get();
         $attach['sumIncome'] = Finance::join('category', 'category.id', '=', 'finance.category_id')->join('daily', 'daily.id', '=', 'finance.daily_id')->join('monthly', 'monthly.id', '=', 'daily.monthly_id')->join('plan', 'plan.id', '=', 'monthly.plan_id')->where('plan.id', '=', $plan->id)->where('type', '=', 1)->sum('amount');
         $attach['sumExpense'] = Finance::join('category', 'category.id', '=', 'finance.category_id')->join('daily', 'daily.id', '=', 'finance.daily_id')->join('monthly', 'monthly.id', '=', 'daily.monthly_id')->join('plan', 'plan.id', '=', 'monthly.plan_id')->where('plan.id', '=', $plan->id)->where('type', '=', 0)->sum('amount');
         if (isset($request->category) && isset($request->month)) {
             $cat = $request->category;
             $month = $request->month;
             $query = Finance::select('finance.name', 'category.name AS category', 'finance.created_at', 'plan.name AS plan', 'finance.type', 'finance.amount')->join('category', 'category.id', '=', 'finance.category_id')->join('daily', 'daily.id', '=', 'finance.daily_id')->join('monthly', 'monthly.id', '=', 'daily.monthly_id')->join('plan', 'plan.id', '=', 'monthly.plan_id');
             if ($cat != 0) {
                 $query->where('category.id', '=', $cat);
             }
             if ($month != 0) {
                 $query->where('monthly.id', '=', $month);
             }
             $query->where('plan.id', '=', $plan->id);
             $attach['finances'] = $query->paginate(20);
             // $attach['finances'] = Finance::select('finance.name', 'category.name AS category', 'finance.created_at', 'plan.name AS plan', 'finance.type', 'finance.amount')
             //     ->join('category', 'category.id', '=', 'finance.category_id')
             //     ->join('daily', 'daily.id', '=', 'finance.daily_id')
             //     ->join('monthly', 'monthly.id', '=', 'daily.monthly_id')
             //     ->join('plan', 'plan.id', '=', 'monthly.plan_id')
             //     ->where('category.id', '=', $cat)
             //     ->where('monthly.id', '=', $month)
             //     ->where('plan.i', '=', $plan->id)
             //     ->paginate(20);
         }
         return view('home.report', $attach);
     } else {
         return view('home.report');
     }
 }
示例#8
0
 /**
  * PERMANENTLY DELETE all trashed items of a plan
  *
  */
 public function deleteAllTrashed($plan_id)
 {
     $plan = Plan::find($plan_id);
     // check if user is leader of the corresponding plan or author/admin
     if (!$plan->leader_id == Auth::user()->id || !Auth::user()->isAuthor()) {
         flash('Sorry, only plan leader or Author can delete items');
         return redirect()->back();
     }
     // this item should be restored
     $items = Item::with('files')->onlyTrashed()->where('plan_id', $plan_id);
     if (!$items) {
         return false;
     }
     $items->forceDelete();
     flash('All trashed items deleted');
     return \Redirect::back();
 }
示例#9
0
 public function esValido()
 {
     $socio = Socio::find(Input::get('socios_id'));
     $plan = Plan::find(Input::get('planes_id'));
     $pagos = Pago::find();
 }
示例#10
0
 public function imprimirSociosxProfesor($plan, $profesor)
 {
     $plan = Plan::find($plan);
     $profesor = Profesor::find($profesor);
     $vista = \View::make('profesores.sociosxprofesorpdf', ['plan' => $plan, 'profesor' => $profesor])->render();
     $pdf = \App::make('dompdf.wrapper');
     $pdf->loadHTML($vista);
     return $pdf->stream('sociosxprofesorpdf');
 }
示例#11
0
/**
 * RESTORE an item 
 *
 * (the model migth allow soft deletes!)
 *
 * Make sure the new sequence number fits sequentially into 
 *    the list of sequence numbers of the existing items for a plan
 *    and that all current sequence numbers are in 1.0 steps
 *
 * @param object $items
 * @param number $new_seq_no
 */
function restoreItem($id)
{
    // this item should be restored
    $item = Item::onlyTrashed()->find($id);
    if (!$item) {
        return false;
    }
    $item->restore();
    // get all items of the related plan
    $plan = Plan::find($item->plan_id);
    $items = $plan->items()->orderBy('seq_no')->get();
    // numbering them countering with 1.0
    $counter = 1.0;
    foreach ($items as $item) {
        if ($item->seq_no != $counter) {
            $i = Item::find($item->id);
            # get the actual DB record
            $item->seq_no = $counter;
            # update the current selection
            $i->seq_no = $counter;
            # update the seq_no
            $i->save();
            # save the record
        }
        $counter += 1.0;
    }
    return true;
}
示例#12
0
文件: User.php 项目: matthiku/cSpot
 /**
  * Check if a user has rights to modify a plan
  * either with Author or higher role
  * or as leader or teacher of a plan
  */
 public function ownsPlan($plan_id)
 {
     if (Auth::user()->isAuthor()) {
         return true;
     }
     // find the Plan
     $plan = Plan::find($plan_id);
     if ($this->id == $plan->leader_id || $this->id == $plan->teacher_id) {
         return true;
     }
     return false;
 }
示例#13
0
 public function postDelete(Request $request)
 {
     if ($request->expense != null) {
         foreach ($request->expense as $key => $value) {
             $finance = Finance::find($value);
             if ($finance->type == 0) {
                 $day = Daily::find($finance->daily_id);
                 $day->expense -= $finance->amount;
                 $day->save();
                 $month = Monthly::find($day->monthly_id);
                 $month->progress += $finance->amount;
                 $month->save();
                 $plan = Plan::find($month->plan_id);
                 $plan->budget += $finance->amount;
                 $plan->save();
             } else {
                 $day = Daily::find($finance->daily_id);
                 $day->income -= $finance->amount;
                 $day->save();
                 $month = Monthly::find($day->monthly_id);
                 $month->progress -= $finance->amount;
                 $month->save();
                 $plan = Plan::find($month->plan_id);
                 $plan->budget -= $finance->amount;
                 $plan->save();
             }
             $finance->delete();
             Session::forget("successes");
             Session::put("successes", ["Delete expense successes fully."]);
         }
     } else {
         Session::forget("successes");
         Session::put("successes", ["No item selected!"]);
     }
     return redirect()->back()->withInput();
 }
示例#14
0
 /**
  * удаляем ajax план
  * @return array
  */
 public function actionDelete()
 {
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $id = Yii::$app->request->post('id');
     $result = false;
     if ($id) {
         $plan = Plan::find()->where(['id' => $id])->one();
         $result = $plan->delete();
     }
     return ['success' => $result];
 }
示例#15
0
 /**
  * Update a single field in the pivot table of the plan-attached resource
  */
 public function APIupdate(Request $request)
 {
     // check if all necessary elements are given
     if ($request->has('id') && $request->has('value')) {
         $field_name = explode('-', $request->id)[0];
         $item_id = explode('-', $request->id)[3];
     } else {
         return false;
     }
     //we need to find the actual resource as attached to the plan!
     $item = DB::table('plan_resource')->where('id', $item_id)->first();
     if ($item) {
         // check authentication
         $plan = Plan::find($item->plan_id);
         if (!checkRights($plan)) {
             return response()->json(['status' => 401, 'data' => 'Not authorized'], 401);
         }
         // update the given field with the given value
         DB::table('plan_resource')->where('id', $item_id)->update([$field_name => $request->value]);
         // return text to sender
         $result = DB::table('plan_resource')->where('id', $item_id)->first();
         return $result->{$field_name};
     }
     return response()->json(['status' => 404, 'data' => "APIupdate: item with id {$item_id} not found"], 404);
 }
示例#16
0
 /**
  * receive pre-rendered slides from client and buffer them for other users to download
  */
 public function deleteCache($plan_id)
 {
     // make sure it's a valid plan id
     $plan = Plan::find($plan_id);
     if ($plan->count()) {
         $cacheCount = $plan->planCaches()->count();
         // delete cached items from this plan
         $cache = $plan->planCaches()->delete();
         // return ok response
         return response()->json(['status' => 200, 'data' => $cacheCount . ' cache-items deleted. '], 200);
     }
     return response()->json(['status' => 404, 'data' => "plan with id {$plan_id} not found"], 404);
 }
示例#17
0
 public function actionPlan()
 {
     $model = new SignupForm();
     $id = $_POST['valor'];
     $model1 = Plan::find()->where(['id_Carrera' => $id])->all();
     if ($model1 !== null) {
         $listaPlanes = ArrayHelper::map($model1, 'id_Plan', 'plan_nombre');
         //return $this->renderAjax('signup',['model' =>$model,'model1' => $model1,'id' => $id,'listaPlanes' =>$listaPlanes]);
         foreach ($model1 as $lista) {
             echo '<option value="' . $lista->id_Plan . '">' . $lista->plan_nombre . '</option>';
         }
     }
 }
示例#18
0
 public function imprimirSociosxPlan($plan_id = null)
 {
     $planes = Plan::orderBy('plan', 'asc')->lists('plan', 'id');
     $plan_elegido = Plan::find($plan_id);
     $vista = \View::make('planessocios.indexpdf', ['planes' => $planes, 'plan_elegido' => $plan_elegido])->render();
     $pdf = \App::make('dompdf.wrapper');
     $pdf->loadHTML($vista);
     return $pdf->stream('indexpdf');
 }