/** * Display a listing of reportgroupings * * @return Response */ public function index($report_id) { if (!ReportGrouping::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $users_under_me = Auth::user()->getAuthorizedUserids(ReportGrouping::$show_authorize_flag); if (empty($users_under_me)) { $reportgroupings = ReportGrouping::whereNotNull('report_groupings.created_at'); } else { $reportgroupings = ReportGrouping::whereIn('report_groupings.user_id', $users_under_me); } $reportgroupings->where('report_id', $report_id); $reportgroupings = $reportgroupings->select(['report_groupings.id', 'report_groupings.name', 'report_groupings.label', 'report_groupings.id as actions']); return Datatables::of($reportgroupings)->edit_column('actions', function ($reportgrouping) use($report_id) { $actions = []; $actions[] = $reportgrouping->canShow() ? link_to_action('ReportGroupingsController@show', 'Show', [$report_id, $reportgrouping->id], ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $reportgrouping->canUpdate() ? link_to_action('ReportGroupingsController@edit', 'Update', [$report_id, $reportgrouping->id], ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $reportgrouping->canDelete() ? Former::open(action('ReportGroupingsController@destroy', [$report_id, $reportgrouping->id]))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-xs btn-danger confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->remove_column('id')->make(); return Datatables::of($reportgroupings)->make(); } Asset::push('js', 'datatables'); return View::make('reportgroupings.index', compact('report_id')); }
public function __construct() { View::share(array('theme' => get_current_theme(), 'pages' => array('products', 'categories', 'pages', 'purchases'), 'results' => array('Users' => admin_path('users'), 'Settings' => admin_path('settings'), 'Log out' => admin_path('logout')), 'welcome_message' => Plugin::fire('admin.welcome_message', 'Welcome to Aviate!')->last())); // Don't use Bootstrap-style inputs Former::framework('Nude'); return $this->beforeFilter('auth|install'); }
/** * Setup the layout used by the controller. * * @return void */ protected function setupLayout() { Former::framework('TwitterBootstrap'); if (!is_null($this->layout)) { $this->layout = View::make($this->layout); } }
public function __construct() { date_default_timezone_set('Asia/Jakarta'); Former::framework($this->form_framework); //$this->beforeFilter('auth', array('on'=>'get', 'only'=>array('getIndex','getAdd','getEdit') )); $this->backlink = strtolower($this->controller_name); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // $row = User::find($id); Former::populate($row); $this->layout->content = view::make('users.edit', compact('row', 'id')); }
/** * Display a listing of users * * @return Response */ public function index() { if (!User::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $users_under_me = Auth::user()->getAuthorizedUserids(User::$show_authorize_flag); if (empty($users_under_me)) { $users = User::with('roles')->whereNotNull('users.created_at'); } else { $users = User::with('roles')->whereIn('users.user_id', $users_under_me); } $users = $users->select(['users.id', 'users.last_name', 'users.id as roles_column', 'users.confirmed', 'users.id as actions', 'users.first_name']); return Datatables::of($users)->edit_column('last_name', function ($user) { return $user->first_name . ' ' . $user->last_name; })->edit_column('roles_column', function ($user) { return '<ul>' . implode('', array_map(function ($name) { return '<li>' . $name . '</li>'; }, $user->roles->lists('name'))) . '</ul>'; })->edit_column('confirmed', function ($user) { return $user->status(); })->edit_column('actions', function ($data) { $actions = []; $actions[] = $data->canShow() ? link_to_action('users.show', 'Show', $data->id, ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $data->canUpdate() ? link_to_action('users.edit', 'Update', $data->id, ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $data->canDelete() ? Former::open(action('users.destroy', $data->id))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-danger btn-xs confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->remove_column('id')->make(); } Asset::push('js', 'datatables'); return View::make('users.index'); }
/** * Register the HTML builder instance. */ public function register() { parent::register(); $this->app['former.dispatcher']->addRepository('Tinyissue\\Form\\Former\\Fields\\'); // Stop it from rendering field name into label \Former::setOption('automatic_label', false); \Former::setOption('TwitterBootstrap3.labelWidths', array('large' => 2, 'small' => 3)); }
/** * #Pager method * * @return mixed */ public function renderResource() { $data['form'] = $this; $data['inputs'] = Former::render($data['form']); $data['modelId'] = null; $data['builder'] = false; return Response::view('theme::public.form.form', $data)->getOriginalContent(); }
public function populateForm($model = false) { if ($model) { Former::populate($model); } else { $input = Input::All(); Former::populate($input); } }
public function getEdit() { $user = User::editing(); if (!$user) { return Redirect::to(Config::get('admin_location') . '/users'); } Former::populate($user); return View::make('admin/users/edit')->with(array('user' => $user, 'users' => User::all())); }
public static function register($key, $url, $method = "POST") { if (!isset(self::$forms)) { self::$forms = (object) array(); } if (FormerView::$root == "") { Former::templatesPath(dirname(__FILE__) . "/tpl/"); } return self::$forms->{$key} = new FormerForm($url, $method, $key); }
public function populateForm($model = false) { if ($model) { //$venues = $model->venues; //$tickets = $model->tickets; Former::populate($model); } else { $input = Input::All(); Former::populate($input); } }
public function populateForm($model = false) { if ($model) { $address = $model->address; Former::populate($model); Former::populate($model, $model->address); } else { $input = Input::All(); Former::populate($input); } }
public function populateForm($model = false) { if ($model) { $company = $model->company; $events = $model->events; $types = $model->types; Former::populate($model); } else { $input = Input::All(); Former::populate($input); } }
public function getEdit() { $category = Category::current(); // If the category doesn't exist, don't throw a 404 // just go back to the main page, likely a URL mistype if (!$category) { return Redirect::to(admin_path('categories')); } // Update our form data Former::populate($category); // Pass the category back to our view in case we need it return View::make('admin/categories/edit')->with('category', $category); }
protected function populateForm() { $task_ndx = 1; $task_groups = TaskGroup::orderBy('id')->get(); foreach ($task_groups as $key => $tg) { if ($task_ndx > 4) { break; } Former::populateField('group' . $task_ndx . '_name', $tg->name); Former::populateField('group' . $task_ndx . '_order', $tg->order); $task_ndx++; } }
public function populateForm($model = false) { if ($model) { $hotel1 = $model->first_hotel_option()->first(); $hotel2 = $model->second_hotel_option()->first(); $contact = $model->contacts()->first(); $venue = $model->venues; eerror_log(json_encode($hotel1)); Former::populate($model); // Former::populateField('first_hotel_option', $hotel1['name']); // Former::populateField('second_hotel_option', $hotel2['name']); } else { $input = Input::All(); Former::populate($input); } }
/** * Display a listing of permissions * * @return Response */ public function index() { if (!Permission::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $permissions = Permission::select(['id', 'group_name', 'name', 'display_name']); return Datatables::of($permissions)->add_column('actions', function ($data) { $actions = []; $actions[] = $data->canShow() ? link_to_action('permissions.show', 'Show', $data->id, ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $data->canUpdate() ? link_to_action('permissions.edit', 'Update', $data->id, ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $data->canDelete() ? Former::open(action('permissions.destroy', $data->id))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-danger btn-xs confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->remove_column('id')->make(); } Asset::push('js', 'datatables'); return View::make('permissions.index'); }
/** * Opens up magically a form * * @param string $typeAsked The form type asked * @param array $parameters Parameters passed * @return string A form opening tag */ public function open($typeAsked, $parameters) { $action = array_get($parameters, 0); $method = array_get($parameters, 1, 'POST'); $attributes = array_get($parameters, 2, array()); $secure = array_get($parameters, 3, false); // If classic form if ($typeAsked == 'open') { $type = Config::get('default_form_type'); } else { // Look for HTTPS form if (str_contains($typeAsked, 'secure')) { $typeAsked = str_replace('secure', null, $typeAsked); $secure = true; } // Look for file form if (str_contains($typeAsked, 'for_files')) { $typeAsked = str_replace('for_files', null, $typeAsked); $attributes['enctype'] = 'multipart/form-data'; } // Calculate form type $type = trim(str_replace('open', null, $typeAsked), '_'); if (!in_array($type, $this->availableTypes)) { $type = Config::get('default_form_type'); } } // Add the final form type $attributes = Helpers::addClass($attributes, 'form-' . $type); // Store it $this->type = $type; // Fetch errors if asked for if (Config::get('fetch_errors')) { Former::withErrors(); } // Open the form $this->action = $action; $this->method = $method; $this->attributes = $attributes; $this->secure = $secure; return $this; }
public function actionButton($optionOverrides = []) { $options = ['urlPrefix' => '', 'element' => '', 'id' => '', 'name' => '', 'additionalLinks' => []]; $options = array_merge($options, $optionOverrides); $output = []; $output[] = '<div class="btn-group" role="group">'; $output[] = '<a href="' . url($options['urlPrefix'] . $options['element'] . '/' . $options['id'] . '/edit') . '" class="btn btn-info btn-sm">'; $output[] = '<span class="glyphicon glyphicon-pencil"></span>'; $output[] = 'Edit'; $output[] = '</a>'; $output[] = '<div class="btn-group" role="group">'; $output[] = '<button type="button" class="btn btn-default btn-sm" data-toggle="dropdown">'; $output[] = '<span class="glyphicon glyphicon-cog"></span>'; $output[] = '<span class="caret"></span>'; $output[] = '</button>'; $output[] = '<ul class="dropdown-menu pull-right">'; if (!empty($options['additionalLinks'])) { foreach ($options['additionalLinks'] as $additionalLink) { $output[] = '<li><a href="' . url($additionalLink['url']) . '">' . $additionalLink['label'] . '</a></li>'; } $output[] = '<li class="divider"></li>'; } $output[] = '<li>'; $output[] = \Former::vertical_open($options['urlPrefix'] . $options['element'] . '/' . $options['id'])->method('DELETE')->class('form_delete form-confirm-delete'); $output[] = '<input type="hidden" class="delete-name" name="delete-name" value="' . $options['name'] . '"/>'; $output[] = '<button id="button-delete-{{$elementId}}" type="submit" class="btn btn-danger btn-block btn-xs">'; $output[] = 'Delete'; $output[] = '</button>'; $output[] = \Former::close(); $output[] = '</li>'; $output[] = '</ul>'; $output[] = '</div>'; //btn-group $output[] = '</div>'; //btn-group $output = implode("\n", $output); return $output; }
/** * Display a listing of roles * * @return Response */ public function index() { if (!Role::canList()) { return $this->_access_denied(); } if (Request::ajax()) { $roles = Role::with('users', 'perms')->select(['roles.id', 'roles.name', 'roles.id as permissions', 'roles.id as user_count', 'roles.id as actions']); return Datatables::of($roles)->edit_column('actions', function ($role) { $actions = []; $actions[] = $role->canShow() ? link_to_action('roles.show', 'Show', $role->id, ['class' => 'btn btn-xs btn-primary']) : ''; $actions[] = $role->canUpdate() ? link_to_action('roles.edit', 'Update', $role->id, ['class' => 'btn btn-xs btn-default']) : ''; $actions[] = $role->canDelete() ? Former::open(action('roles.destroy', $role->id))->class('form-inline') . Former::hidden('_method', 'DELETE') . '<button type="button" class="btn btn-danger btn-xs confirm-delete">Delete</button>' . Former::close() : ''; return implode(' ', $actions); })->edit_column('user_count', function ($role) { return $role->users->count(); })->edit_column('permissions', function ($role) { return '<ul>' . implode('', array_map(function ($name) { return '<li>' . $name . '</li>'; }, $role->perms->lists('name'))) . '</ul>'; })->remove_column('id')->make(); } Asset::push('js', 'datatables'); return View::make('roles.index'); }
@layout('layouts.main') @section('content') <?php //echo __('user.user_not_activated'); if ($errors->has('user_alert')) { $alert_message = $errors->first('user_alert'); $alert_type = $errors->has('alert_type') ? $errors->first('alert_type') : Alert::INFO; echo Alert::show($alert_type, $alert_message)->block(); } echo Former::horizontal_open()->id('resetPasswordForm')->secure()->rules(array('password' => 'required', 'repeat_password' => 'required|same:password'))->method('POST'); ?> {{Former::token();}} {{Former::hidden("hash64", $hash64)}} {{Former::password("password", "Password")->appendIcon('aw_key')}} {{Former::password("repeat_password", "Repeat Password")->appendIcon('aw_key')}} <?php echo \Former::actions(Former::primary_submit('Reset Password')); ?> {{Former::close()}} @endsection
<?php echo Former::open()->method('POST'); ?> <?php echo Former::text('Nombre')->required()->min(3); ?> <?php echo Former::numeric('Cuit-Cuil')->required()->min(9); ?> <?php echo Former::numeric('Telefono')->required()->min(6); ?> <?php echo Former::text('Domicilio')->required()->min(6); ?> <?php echo Former::email('Email')->required()->min(6); ?> <?php echo Former::date('Fecha de Carga')->required()->min(9); ?> <?php echo Former::actions()->large_primary_submit('Submit')->large_inverse_reset('Reset')->url('/personas/nuevo'); ?> <input type="hidden" name="_token" value="{{ csrf_token() }}"> <?php echo Former::close(); ?> @endsection
public function storeResult($modelId = null) { if (Input::has('form')) { if (is_int(Input::get('form'))) { $rules = Former::getRules(Input::get('form')); } else { if (Input::has('combine_form')) { $combine = true; } else { $combine = false; } $rules = Former::getRulesByModel(Input::get('form'), $combine, $modelId); } $unsets = array(); // Ajoute les nouvelles regles i18n foreach (Input::all() as $key => $input) { if (strpos($key, '_lang_')) { $splitInput = explode("_", $key); $rules[$key] = $rules[$splitInput[0]]; $unsets[$splitInput[0]] = $splitInput[0]; } } // Supprime les anciennes regles foreach ($unsets as $value) { unset($rules[$value]); } } else { App::abort(500, "Form ID not found !"); } // Using the Validator $validator = Validator::make(Input::except('_token'), $rules); // If errors we back to the previous forms with errors and old inputs if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } // Getting the form settings if ($form = Formr::find(Input::get('form'))) { // Action to use if the form is valid if ($form->finish_on == "email") { // Send a mail App::make('MailController')->formr(Input::alli18n()); } else { if ($form->finish_on == "database") { // Store in DB } else { if ($form->finish_on == "model") { Former::callModel($form, Input::alli18n()); } else { App::abort(500, "No method found for send the form !"); } } } } else { $modelName = Input::get('form'); $model = new $modelName(); if (isset($model)) { if (Input::has('combine_form')) { $combine = true; } else { $combine = false; } $formParams = $model->formParams($combine); } if ($formParams['method'] == "email") { // Send a mail App::make('MailController')->formr(Input::alli18n()); } else { if ($formParams['method'] == "database") { // Store in DB } else { if ($formParams['method'] == "model") { return $model::formAction(Input::alli18n(), $modelId); } else { App::abort(500, "No method found for send the form !"); } } } } // Redirect back with success message return Redirect::back()->with('formSuccess', Lang::get('messages.form.success')); }
/** * Check if a checkable is checked * * @return boolean Checked or not */ protected function isChecked($name = null) { if (!$name) { $name = $this->name; } $value = Former::getPost($name); return $value ? true : false; }
protected function populateForm($model = false) { //dd($model); if ($model) { $address = $model->address; $venues = $model->venues; $companies = $model->companies; Former::populate($model); Former::populate($model, $model->address); } else { $address = []; $input = Input::All(); Former::populate($input); Former::populateField('address.email', $input['address']['email']); Former::populateField('address.phone', $input['address']['phone']); Former::populateField('address.country.name', $input['country']); Former::populateField('address.address', $input['address']['address']); Former::populateField('address.postal_code', $input['address']['postal_code']); Former::populateField('address.city', $input['address']['city']); Former::populateField('address.state_province', $input['address']['state_province']); Former::populateField('address.fax', $input['address']['fax']); Former::populateField('address.website', $input['address']['website']); //Former::populate( $input, $input ); } }
protected function populateForm($tasktemplate = false) { if ($tasktemplate) { Former::populate($tasktemplate); } }
public function getEdit($id) { $row = Test::find($id); Former::populate($row); $this->layout->content = view::make('tests.edit', compact('row')); }
public function completeHeads($heads) { $select_all = Former::checkbox()->name('Select All')->check(false)->id('select_all'); //product head array_unshift($heads, array($select_all, array('search' => false, 'sort' => false))); array_unshift($heads, array('#', array('search' => false, 'sort' => false))); array_push($heads, array('Actions', array('search' => false, 'sort' => false, 'clear' => true))); return $heads; }
public function populateForm($model = false) { if ($model) { $venues = $model->venues; $tickets = $model->tickets; $promoters = $model->users; $date = $model->date()->first(); $currency = $model->currency; Former::populate($model); if ($date) { Former::populateField('event_date', date('Y-m-d', strtotime($date->datetime_start))); } } else { $input = Input::All(); Former::populate($input); } }