public function generateProgress($progress = 0)
 {
     $user = new User();
     $user->username = "******";
     $user->email = "*****@*****.**";
     $user->password = "******";
     $user->save();
     $plan = new Plan();
     $plan->user_id = $user->id;
     $plan->name = 'UnitTestProject';
     $plan->description = 'UnitTestProject';
     $plan->budget = '0';
     $plan->target = '10000';
     $plan->expected = '1000';
     $plan->period = '10';
     $plan->created_at = date('Y-m-d H:i:s', strtotime('-1 month', strtotime(date('Y-m-d'))));
     $plan->updated_at = date('Y-m-d H:i:s', strtotime('-1 month', strtotime(date('Y-m-d'))));
     $plan->save();
     $month = new Monthly();
     $month->plan_id = $plan->id;
     $month->status = 0;
     $month->month = 1;
     $month->limit = 1000;
     $month->progress = $progress;
     $month->save();
     return ['plan' => $plan, 'month' => $month, 'user' => $user];
 }
 /**
  * @PATCH("/plans/{plan}", as="admin.plans.update")
  * @param Plan $plan
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Plan $plan, Request $request)
 {
     $type = PlansType::findOrFail($request->input('type_id'));
     $plan->fill($request->all());
     $plan->type()->associate($type);
     $plan->update();
     return redirect()->route('admin.plans.index');
 }
 /**
  * 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');
     }
 }
 public function testCreate()
 {
     $user = $this->generateUser();
     $this->visit('/plan')->withSession(['Auth' => $user])->type('UnitTestProject', 'pname')->type('Test', 'pdescription')->type('1000', 'pexpected')->type('10000', 'ptarget')->type('0', 'pbudget')->type('10', 'pmonth')->press('pSave')->seePageIs('/plan');
     $plan = Plan::where("name", "=", "UnitTestProject")->first();
     $this->assertNotNull($plan);
     $plan->delete();
     $user->delete();
 }
Example #5
0
 public function actionIndex()
 {
     $user = Yii::$app->user;
     $month_plan = Plan::getMonthPlan($user->id);
     $month_account_all = Account::getMonthAccountAll($user->id);
     $week_account_all = Account::getWeekAccountAll($user->id);
     $month_balance = $month_plan - $month_account_all;
     $month_account_income_all = Account::getMonthAccountIncomeAll($user->id);
     $month_account_list = Account::getMonthAccountList($user->id);
     return $this->render('index', ['month_plan' => $month_plan, 'month_account_all' => $month_account_all, 'month_balance' => $month_balance, 'month_account_income_all' => $month_account_income_all, 'month_account_list' => $month_account_list]);
 }
 /**
  * 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;
 }
Example #7
0
 /**
  * 列出教学计划
  * @author FuRongxin
  * @date    2016-02-04
  * @version 2.0
  * @return  JSON 教学计划列表
  */
 public function listing()
 {
     $plans = Plan::with(['platform' => function ($query) {
         $query->select('dm', 'mc');
     }])->with(['property' => function ($query) {
         $query->select('dm', 'mc');
     }])->with(['course' => function ($query) {
         $query->select('kch', 'kcmc', 'kcywmc');
     }])->with(['mode' => function ($query) {
         $query->select('dm', 'mc');
     }])->with(['college' => function ($query) {
         $query->select('dw', 'mc');
     }])->whereNj(Auth::user()->profile->nj)->whereZy(Auth::user()->profile->zy)->whereZsjj(Auth::user()->profile->zsjj)->orderBy('kch', 'asc');
     return Datatables::of($plans)->addColumn('zxs', '{{ $llxs + $syxs }}')->make(true);
 }
Example #8
0
 /**
  * 列出选课情况交叉比较信息
  * @author FuRongxin
  * @date    2016-05-13
  * @version 2.1
  * @return  \Illuminate\Http\Response 选课交叉比较信息
  */
 public function match()
 {
     $credits = [];
     $plan_total = 0;
     $selected_total = 0;
     $score_total = 0;
     // 获取教学计划学分
     $plans = Plan::with(['course' => function ($query) {
         $query->select('kch', 'kcmc', 'kcywmc');
     }])->whereNj(Auth::user()->profile->nj)->whereZy(Auth::user()->profile->zy)->whereZsjj(Auth::user()->profile->zsjj)->orderBy('kch', 'asc')->get();
     foreach ($plans as $plan) {
         $credits[$plan->kch] = ['kch' => $plan->kch, 'kcmc' => $plan->course->kcmc, 'plan_credit' => $plan->zxf, 'selected_credit' => 0, 'score_credit' => 0];
         $plan_total += $plan->zxf;
     }
     // 获取选课学分
     $selects = Selcourse::with(['course' => function ($query) {
         $query->select('kch', 'kcmc', 'kcywmc');
     }])->whereXh(Auth::user()->xh)->orderBy('kch', 'asc')->get();
     foreach ($selects as $select) {
         if (array_key_exists($select->kch, $credits)) {
             $credits[$select->kch]['selected_credit'] = $select->xf;
         } else {
             $credits[$select->kch] = ['kch' => $select->kch, 'kcmc' => $select->course->kcmc, 'plan_credit' => 0, 'selected_credit' => $select->xf, 'score_credit' => 0];
         }
         $selected_total += $select->xf;
     }
     // 获取成绩学分
     $scores = Score::with(['course' => function ($query) {
         $query->select('kch', 'kcmc', 'kcywmc');
     }])->whereXh(Auth::user()->xh)->orderBy('kch', 'asc')->get();
     foreach ($scores as $score) {
         if (array_key_exists($score->kch, $credits)) {
             $credits[$score->kch]['score_credit'] = $score->xf;
         } else {
             $credits[$select->kch] = ['kch' => $score->kch, 'kcmc' => $score->course->kcmc, 'plan_credit' => 0, 'selected_credit' => 0, 'score_credit' => $score->xf];
         }
         $score_total += $score->xf;
     }
     $title = '选课学分交叉对比表';
     return view('course.match', compact('title', 'credits', 'plan_total', 'selected_total', 'score_total'));
 }
Example #9
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);
 }
Example #10
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();
 }
Example #11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlans()
 {
     return $this->hasMany(Plan::className(), ['purse_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlan()
 {
     return $this->hasOne(Plan::className(), ['id' => 'plan_id']);
 }
Example #13
0
 /**
  * Edit a single team member of a plan
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($plan_id, $id)
 {
     // get current plan
     $plan = Plan::with('teams')->find($plan_id);
     // check access rights
     if (!Auth::user()->ownsPlan($plan_id)) {
         return redirect('home')->with('error', 'You are unauthorized for this request.');
     }
     // get list of users
     $users = User::where('name', '<>', 'n/a')->orderBy('first_name')->get();
     // get the resource handle
     $team = Team::find($id);
     if ($team) {
         return view('cspot.team', ['team' => $team, 'plan' => $plan, 'users' => $users, 'userRoles' => json_encode(getUsersRolesAndInstruments())]);
     }
     $error = 'Wrong team member id!';
     return \Redirect::back()->with(['error' => $error]);
 }
Example #14
0
 public function imprimirProfesorxPlan($patronplan = null)
 {
     if (empty($patronplan)) {
         $planes = Plan::all();
     } else {
         $planes = Plan::where('plan', "LIKE", "%{$patronplan}%")->orderBy('plan')->get();
     }
     $vista = \View::make('planes.profesorxplanpdf', ['planes' => $planes])->render();
     $pdf = \App::make('dompdf.wrapper');
     $pdf->loadHTML($vista);
     return $pdf->stream('profesorxplanpdf');
 }
Example #15
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();
 }
Example #16
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\Cuenta */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="cuenta-form">

    <?php 
$listContactos = ArrayHelper::map(\app\models\Contacto::findAll(['baja' => 0]), 'id', 'nombres');
?>
    <?php 
$listPlanes = ArrayHelper::map(\app\models\Plan::findAll(['baja' => 0]), 'id', 'nombre');
?>

    <?php 
$form = ActiveForm::begin();
?>


    <?php 
echo $form->field($model, 'id_contacto')->dropDownList($listContactos, ['prompt' => '--SELECCIONE--']);
?>

    <?php 
echo $form->field($model, 'id_plan')->dropDownList($listPlanes, ['prompt' => '--SELECCIONE--']);
?>
Example #17
0
 public function postIndex(Request $request)
 {
     $messages = ["pname.required" => "Plan name is required", "pdescription.required" => "Description is required", "pexpected.required" => "Expected per month is required", "ptarget.required" => "Target for saving is required", "pbudget.required" => "Budget is required", "pmonth.required" => "Period is required", "pname.alpha_num" => "Plan name must be consist of texts and numbers", "pexpected.numeric" => "Expected per month must be consist of only numbers", "ptarget.numeric" => "Target for saving must be consist of only numbers", "pbudget.numeric" => "Budget must be consist of only numbers", "pmonth.numeric" => "Period must be consist of only numbers"];
     $validator = Validator::make($request->all(), ['pname' => 'required|alpha_num', 'pdescription' => 'required', 'pexpected' => 'required|numeric', 'ptarget' => 'required|numeric', 'pbudget' => 'required|numeric', 'pmonth' => 'required|numeric|min:1'], $messages);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     if ($request->pdelete != null) {
         return redirect('plan/delete');
     }
     if ($request->pbudget > $request->ptarget) {
         $validator->errors()->add('target', 'Budget is more than target!');
         return redirect()->back()->withErrors($validator)->withInput();
     }
     if ($request->pexpected >= $request->ptarget) {
         $validator->errors()->add('target', 'Expected per month is more than target!');
         return redirect()->back()->withErrors($validator)->withInput();
     }
     if (!$this->user) {
         $validator->errors()->add('user', 'You are not login!');
         return redirect('login')->withErrors($validator);
     } else {
         $plan = $this->user->plans()->where("id", "=", $request->plan_id)->first();
         if (!$plan) {
             $plan = new Plan();
             $plan->budget = $request->pbudget;
         }
         //$period            = ceil(($request->ptarget - $request->pbudget) / $request->pexpected);
         $plan->user_id = $this->user->id;
         $plan->name = $request->pname;
         $plan->description = $request->pdescription;
         $plan->period = $request->pmonth;
         $plan->target = $request->ptarget;
         $plan->expected = $request->pexpected;
         $plan->original = $request->pbudget;
         $plan->save();
         Session::put("Plan", $plan->id);
     }
     return redirect()->back()->withInput();
 }
Example #18
0
 public function esValido()
 {
     $socio = Socio::find(Input::get('socios_id'));
     $plan = Plan::find(Input::get('planes_id'));
     $pagos = Pago::find();
 }
Example #19
0
 public function compose(View $view)
 {
     $plans_good = Plan::where('type_id', 1)->get();
     $plans_bad = Plan::where('type_id', 2)->get();
     $view->with('plans1', $plans_good)->with('plans2', $plans_bad);
 }
Example #20
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(PlansRequest $request, $id)
 {
     foreach ($request->all() as $key => $val) {
         if (substr($key, 0, 2) == "p_") {
             $tagname = "t_" . substr($key, 2);
             $tag = $request->input($tagname);
             if (!$tag) {
                 $tag = null;
             }
             if ($val) {
                 $pid = substr($val, 2);
                 if (substr($val, 0, 1) == "M") {
                     $ptyp = "App\\Models\\Minister";
                 } elseif (substr($val, 0, 1) == "P") {
                     $ptyp = "App\\Models\\Preacher";
                 } else {
                     $ptyp = "App\\Models\\Guest";
                 }
             } else {
                 $pid = null;
                 $ptyp = null;
             }
             $kk = array(explode('_', $key));
             $plan = Plan::where('society_id', '=', $kk[0][1])->where('service_id', '=', $kk[0][2])->where('planyear', '=', $kk[0][3])->where('planmonth', '=', $kk[0][4])->where('planday', '=', $kk[0][5])->first();
             if (count($plan)) {
                 $plan->tag_id = $tag;
                 $plan->preachable_id = $pid;
                 $plan->preachable_type = $ptyp;
                 if ($tag == null and $pid == null) {
                     $plan->delete();
                 } else {
                     $plan->save();
                 }
             } else {
                 if ($tag or $pid) {
                     $newplan = Plan::create(array('society_id' => $kk[0][1], 'service_id' => $kk[0][2], 'planyear' => $kk[0][3], 'planmonth' => $kk[0][4], 'planday' => $kk[0][5], 'preachable_id' => $pid, 'preachable_type' => $ptyp, 'tag_id' => $tag));
                 }
             }
         }
     }
     return Redirect::back()->with('okmessage', 'Plan details have been updated');
 }
Example #21
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>';
         }
     }
 }
Example #22
0
 public function imprimirSociosconObservacion($numero = null, $nombre = null, $estado = null)
 {
     $planes = Plan::orderBy('plan', 'asc')->lists('plan', 'id');
     if (empty($numero) and empty($nombre) and empty($estado)) {
         $socios = Socio::all();
     } else {
         $socios = Socio::numero($numero)->socioNombre($nombre)->estado($estado)->get();
     }
     $vista = \View::make('socios.sociosconobservacionpdf', ['socios' => $socios, 'planes' => $planes])->render();
     $pdf = \App::make('dompdf.wrapper');
     $pdf->loadHTML($vista);
     return $pdf->stream('sociosconobservacionpdf');
 }
Example #23
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdPlan()
 {
     return $this->hasOne(Plan::className(), ['id' => 'id_plan']);
 }
Example #24
0
 /**
  * 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;
 }
Example #25
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');
     }
 }
Example #26
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $pago = Pago::find($id);
     $planes = Plan::orderBy('plan', 'asc')->get();
     $socios = Socio::orderBy('nombre', 'asc')->get();
     $plan_sele = $pago->planes_id;
     $socio_sele = $pago->socios_id;
     return view('pagos.edit', ['pago' => $pago, 'planes' => $planes, 'socios' => $socios, 'plan_sele' => $plan_sele, 'socio_sele' => $socio_sele]);
 }
Example #27
0
 /**
  * @POST("get_plan")
  * @param Request $request
  * @return \Illuminate\Http\JsonResponse
  */
 public function get_plan(Request $request)
 {
     //dd($request->all());
     $plan = Plan::where('id', $request->input('plan'))->first()->toArray();
     return response()->json($plan);
 }
 /**
  * Finds the Plan model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Plan the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Plan::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #29
0
 /**
  * get date of last time this song was used in a plan
  */
 public function getLastTimeUsedAttribute($value)
 {
     $id = $this->id;
     // get list of plans using this song
     $plan = Plan::whereHas('items', function ($query) use($id) {
         $query->where('song_id', $id)->where('date', '<', Carbon::now());
     })->orderBy('date', 'desc')->first();
     if ($plan) {
         return $plan->date;
     }
     return null;
 }
Example #30
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;
}