public function postAdd() { $input = Input::all(); $rules = Config::get('validations.service_plan'); $rules['name'][] = 'unique:service_plans'; $v = Validator::make($input, $rules); if ($v->fails()) { return Redirect::back()->withInput()->withErrors($v); } try { if ($input['policy_type'] == 'PolicySchema') { $input['policy_id'] = $input['schema_id']; // unset($input['schema_id']); } DB::transaction(function () use($input) { $plan = new Plan($input); if (!$plan->save()) { throw new Exception("Failed to save service plan."); } if ($input['plan_type'] == 1) { //if limited $limit = $this->_makeLimit($input); //new PlanLimit( $input ); if (!$plan->limit()->save($limit)) { throw new Exception("Failed to save Service Plan."); } } }); $this->notifySuccess("Service Plan successfully created."); return Redirect::route(self::HOME); } catch (Exception $e) { $this->notifyError($e->getMessage()); return Redirect::route(self::HOME); } }
/** * Store a newly created resource in storage. * POST /plan * * @return Response */ public function store() { $user = Auth::user(); $club = $user->clubs()->FirstOrFail(); $validator = Validator::make(Input::all(), Plan::$rules); $uuid = Uuid::generate(); //check if recurrences if ($validator->passes()) { $amount = Input::get('total') - Input::get('initial'); $recurring = Input::get('recurring'); $recurrences = $amount / $recurring; $recidual = fmod($amount, $recurring); if ($recidual > 0) { return Redirect::action('PlanController@create')->withInput()->with('warning', "Please check the recurring amount and initial amount."); } $plan = new Plan(); $plan->id = $uuid; $plan->name = Input::get('name'); $plan->total = Input::get('total'); $plan->initial = Input::get('initial'); $plan->recurring = Input::get('recurring'); $plan->recurrences = $recurrences; $plan->frequency_id = Input::get('frequency_id'); $plan->on = Input::get('on'); $plan->club_id = $club->id; $status = $plan->save(); if ($status) { return Redirect::action('PlanController@index')->with('notice', 'Event created successfully'); } return Redirect::action('PlanController@create')->with('warning', $status); } $error = $validator->errors()->all(':message'); return Redirect::action('PlanController@create')->withErrors($validator)->withInput(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Plan(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Plan'])) { $model->attributes = $_POST['Plan']; if ($model->save()) { $this->redirect(array('index')); } } $this->render('create', array('model' => $model)); }
public function actionCreate() { $model = new Plan(); if (isset($_POST['Plan'])) { $model->setAttributes($_POST['Plan']); if ($model->save()) { if (Yii::app()->getRequest()->getIsAjaxRequest()) { Yii::app()->end(); } else { $this->redirect(array('view', 'id' => $model->id)); } } } $this->render('create', array('model' => $model)); }
public function actionCreate() { $this->pageTitle = 'Plan - Nuevo'; $model = new Plan(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Plan'])) { $id = $_POST['Plan']['anioPlan'] . $_POST['Plan']['Carrera_id']; $model->attributes = $_POST['Plan']; $model->id = $id; $resultado = $_POST['result']; $materias = $this->parseString($resultado); if ($model->save()) { $this->agregarMaterias($materias, $id); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function resort() { $request = $this->getRequest(); if ($request->request) { $post = $request->request->all(); foreach ($post as $id => $weight) { $plan = new Plan($id); $plan->weight = $weight; $plan->save(); } echo lang('plan_order_change_success'); } }
/** * Lists all models. */ public function actionIndex() { $model = new Plan(); $modelPlanLimit = new PlanLimit(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); // manage plan if (isset($_POST['Plan'])) { $model->attributes = $_POST['Plan']; $model->wlabel_id = Yii::app()->user->getWhiteLabelId(); $model->type = $this->planType; if ($model->save()) { $this->redirect(array('index')); } } if (isset($_GET['Plan'])) { $model->attributes = $_GET['Plan']; } // manage plan limit if (isset($_POST['PlanLimit'])) { $modelPlanLimit->attributes = $_POST['PlanLimit']; if ($modelPlanLimit->save()) { $this->redirect(array('index')); } } if (isset($_GET['PlanLimit'])) { $modelPlanLimit->attributes = $_GET['PlanLimit']; } $this->render('index', array('model' => $model, 'modelPlanLimit' => $modelPlanLimit)); }
include "header.php"; try { $plan = new Plan(); if (!$user->level) { throw new LoginException("You must be logged in to use this feature."); } list($plan->name, $plan->description, $cash, $cents, $plan->period, $plan->hidden, $plan->plancolor) = $input->getInputValues('name', 'description', 'cash', 'cents', 'period', 'hidden', 'plancolor'); if (!$cents) { $cents = "00"; } $plan->price = $cash . "." . $cents; if ($plan->name[0]) { // Throws InputException on failure $plan->validate(); if ($plan->save()) { flash("The plan was created successfully."); } else { throw new Exception("The plan could not be added to the database."); } } include "../views/addplan.php"; } catch (LoginException $e) { $redirect = "addplan.php"; include "../views/login.php"; throw $e; } catch (InputException $e) { include "../views/addplan.php"; throw $e; } catch (Exception $e) { include "../views/addplan.php";
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aPlan !== null) { if ($this->aPlan->isModified() || $this->aPlan->isNew()) { $affectedRows += $this->aPlan->save($con); } $this->setPlan($this->aPlan); } if ($this->aTipodoc !== null) { if ($this->aTipodoc->isModified() || $this->aTipodoc->isNew()) { $affectedRows += $this->aTipodoc->save($con); } $this->setTipodoc($this->aTipodoc); } if ($this->aReparticion !== null) { if ($this->aReparticion->isModified() || $this->aReparticion->isNew()) { $affectedRows += $this->aReparticion->save($con); } $this->setReparticion($this->aReparticion); } if ($this->aLocalidad !== null) { if ($this->aLocalidad->isModified() || $this->aLocalidad->isNew()) { $affectedRows += $this->aLocalidad->save($con); } $this->setLocalidad($this->aLocalidad); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } $this->alreadyInSave = false; } return $affectedRows; }
/** * Post New Plan */ public function postNewPlan($product_id) { $rules = array('name' => 'required', 'code' => "required|unique:plans", 'description' => 'required', 'price' => 'required', 'setup_fee' => 'required', 'stripe_id' => 'required', 'infusion_id' => 'required', 'is_oto' => 'numeric', 'is_lifetime' => 'numeric', 'is_recurring' => 'numeric', 'recurring_freq' => 'numeric', 'allow_paypal_sub' => 'numeric', 'has_license' => 'numeric', 'license_allowed_usage' => 'numeric', 'show_at_checkout' => 'numeric', 'show_available_plans' => 'numeric', 'has_split_pay' => 'numeric', 'total_installments' => 'numeric', 'split_pay_desc' => 'max:255', 'price_per_installment' => 'numeric', 'next_page_url' => 'required|url', 'order_btn_text_1' => 'required|max:255', 'order_btn_text_2' => 'max:255'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to("admin/products/new-plan/{$product_id}")->withErrors($validator)->withInput(); } else { $plan = new Plan(); $plan->name = Input::get('name'); $plan->code = Input::get('code'); $plan->product_id = $product_id; $plan->description = Input::get('description'); $plan->price = Input::get('price'); $plan->setup_fee = Input::get('setup_fee'); $plan->stripe_id = Input::get('stripe_id'); $plan->infusion_id = Input::get('infusion_id'); $plan->is_oto = Input::get('is_oto') ? 1 : 0; $plan->is_lifetime = Input::get('is_lifetime') ? 1 : 0; $plan->is_recurring = Input::get('is_recurring') ? 1 : 0; $plan->recurring_freq = Input::get('recurring_freq'); $plan->allow_paypal_sub = Input::get('allow_paypal_sub') ? 1 : 0; $plan->has_license = Input::get('has_license') ? 1 : 0; $plan->license_allowed_usage = Input::get('license_allowed_usage'); $plan->show_at_checkout = Input::get('show_at_checkout') ? 1 : 0; $plan->show_available_plans = Input::get('show_available_plans') ? 1 : 0; $plan->has_split_pay = Input::get('has_split_pay') ? 1 : 0; $plan->total_installments = Input::get('total_installments'); $plan->split_pay_desc = Input::get('split_pay_desc'); $plan->price_per_installment = Input::get('price_per_installment'); $plan->next_page_url = Input::get('next_page_url'); $plan->order_btn_text_1 = Input::get('order_btn_text_1'); $plan->order_btn_text_2 = Input::get('order_btn_text_2'); $plan->save(); Session::flash('alert_message', '<strong>Well done!</strong> You successfully have added new plan.'); return Redirect::to("admin/products/plans/{$product_id}"); } }
public function add() { $tabla = Input::get('tabla'); switch ($tabla) { case '0': $clave = Input::get('clave'); $appat = Input::get('ap_pat'); $apmat = Input::get('ap_mat'); $nombre = Input::get('nombre'); $segnombre = Input::get('seg_nombre'); $tipo = Input::get('tipo'); $grado = Input::get('grado'); $tutorias = Input::get('tutorias'); $gestion = Input::get('gestion'); $invest = Input::get('invest'); $depend = Input::get('depend'); $add = new Professor(); $add->clave = $clave; $add->ap_pat = $appat; $add->ap_mat = $apmat; $add->nombre = $nombre; $add->seg_nombre = $segnombre; $add->tipo = $tipo; $add->id_grado = $grado; $add->tutorias = $tutorias; $add->gestion = $gestion; $add->investigacion = $invest; $add->dependencias = $depend; $add->save(); return View::make('crud.crudMaestros')->with('professors', Professor::all()); break; case '1': $nombre = Input::get('nombre'); $semestre = Input::get('semestre'); $plan = Input::get('idPlan'); $add = new Subject(); $add->nombre = $nombre; $add->semestre = $semestre; $add->id_plan = $plan; $add->save(); return View::make('crud.crudMaterias')->with('subjects', Subject::all()); break; case '2': $nombre = Input::get('nombre'); $add = new Aula(); $add->nombre = $nombre; $add->save(); return View::make('crud.crudAulas')->with('aulas', Aula::all()); break; case '3': $nombre = Input::get('nombre'); $add = new Plan(); $add->nombre = $nombre; $add->save(); return View::make('crud.crudPlanes')->with('plans', Plan::all()); break; default: //aqui me redirecciona a una pagina vacia solo con un mensaje 404 return View::make('landing'); break; } }