/**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     parent::register();
     \Form::macro('myField', function () {
         return '<input type="awesome">';
     });
 }
Пример #2
0
 public function generar_lista_con_agrupador_distritos($valor = null)
 {
     \Form::macro('selectOpt', function (\ArrayAccess $collection, $name, $groupBy, $labelBy = 'name', $valueBy = 'id', $value = null, $attributes = array()) {
         $select_optgroup_arr = [];
         foreach ($collection as $item) {
             $select_optgroup_arr[$item->{$groupBy}][$item->{$valueBy}] = $item->{$labelBy};
         }
         return \Form::select($name, $select_optgroup_arr, $value, $attributes);
     });
     return \Form::selectOpt($this->model->orderBy('codigoSemplades')->get(), 'id_circuito', 'distrito', 'codigoSemplades', 'id_circuito', $valor, array('class' => 'form-control', 'data-required' => 'true', 'id' => 'id_circuito'));
 }
Пример #3
0
 public function generar_lista_con_servicio_seleccion($valor)
 {
     \Form::macro('selectOpt', function (\ArrayAccess $collection, $name, $groupBy, $labelBy = 'name', $valueBy = 'id', $value = null, $attributes = array()) {
         $select_optgroup_arr = [];
         foreach ($collection as $item) {
             $select_optgroup_arr[$item->{$groupBy}][$item->{$valueBy}] = $item->{$labelBy};
         }
         return \Form::select($name, $select_optgroup_arr, $value, $attributes);
     });
     return \Form::selectOpt($this->model->all(), 'id_caso', 'servicio', 'denominacion', 'id_caso', $valor, array('class' => 'form-control', 'data-required' => 'true', 'id' => 'id_caso'));
 }
Пример #4
0
 public function generar_lista_con_agrupador_permisos($valor = null, $id_rol)
 {
     \Form::macro('selectOpt', function (\ArrayAccess $collection, $name, $groupBy, $labelBy = 'name', $valueBy = 'id', $value = null, $attributes = array()) {
         $select_optgroup_arr = [];
         foreach ($collection as $item) {
             $select_optgroup_arr[$item->{$groupBy}][$item->{$valueBy}] = $item->{$labelBy};
         }
         return \Form::select($name, $select_optgroup_arr, $value, $attributes);
     });
     $modulos_asignados = configRolModulo::where('id_rol', $id_rol)->select('id_modulo')->get()->toArray();
     return \Form::selectOpt($this->model->whereNotIn('id_modulo', $modulos_asignados)->orderBy('descripcion')->get(), 'id_modulo', 'agrupador', 'descripcion', 'id_modulo', $valor, array('class' => 'form-control', 'data-required' => 'true', 'id' => 'id_modulo'));
 }
Пример #5
0
 public function __construct()
 {
     //js
     Asset::add('jquery', 'js/jquery-1.7.2.min.js');
     Asset::add('bootstrap-js', 'js/bootstrap.min.js', 'jquery');
     Asset::add('bootstrap-js-datepicker', 'js/bootstrap-datepicker.js', 'bootstrap-js');
     Asset::add('moment-js', 'js/moment.min.js');
     Asset::add('sapoc-js', 'js/sapoc.js', 'jquery');
     //css
     Asset::add('bootstrap-css', 'css/bootstrap.min.css');
     Asset::add('bootstrap-css-responsive', 'css/bootstrap-responsive.min.css', 'bootstrap-css');
     Asset::add('datepicker-css', 'css/datepicker.css', 'bootstrap-css');
     Asset::add('sapoc-css', 'css/sapoc.css', 'bootstrap-css');
     //Form macros
     Form::macro('date', function ($name) {
         return sprintf('<input type="text" name="%s" id="%s" class="%s">', $name, Config::get('application.date_class_js'));
     });
     parent::__construct();
 }
Пример #6
0
Form::macro('decimal', function ($attributeName, $value, $options) {
    foreach (['js/plugins/input-mask/jquery.inputmask.js', 'js/plugins/input-mask/jquery.inputmask.numeric.extensions.js'] as $file) {
        $jsFilename = moduleAsset('admin', $file);
        if (!in_array($jsFilename, @Asset::$js['footer'] ?: array())) {
            Asset::add($jsFilename);
        }
    }
    $options['data-inputmask'] = "'alias': 'decimal', 'radixPoint': ','";
    $script = "\$('*[data-inputmask]').inputmask();";
    if (!in_array($script, @Asset::$scripts['footer'] ?: array())) {
        Asset::addScript($script);
    }
    $value = str_replace('.', ',', $value);
    return Form::text($attributeName, $value, $options);
});
/**
 * Creates a Html Editor
 */
Form::macro('editor', function ($attributeName, $value = null, $options = array()) {
    Asset::add(moduleAsset('system', 'js/ckeditor/ckeditor.js'));
    Asset::addScript("\n        CKEDITOR.config.allowedContent = true;\n        var editor = CKEDITOR.replace('{$attributeName}', {\n            filebrowserBrowseUrl : '" . URL::to(moduleAsset('system', 'ckfinder/ckfinder.html')) . "',\n            filebrowserImageBrowseUrl : '" . URL::to(moduleAsset('system', 'ckfinder/ckfinder.html?type=Images')) . "',\n            filebrowserFlashBrowseUrl : '" . URL::to(moduleAsset('system', 'ckfinder/ckfinder.html?type=Flash')) . "',\n            filebrowserUploadUrl : '" . URL::to(moduleAsset('system', 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files')) . "',\n            filebrowserImageUploadUrl : '" . URL::to(moduleAsset('system', 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images')) . "',\n            filebrowserFlashUploadUrl : '" . URL::to(moduleAsset('system', 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash')) . "'\n        });\n        CKFinder.setupCKEditor( editor, '../' );\n    ", 'ready');
    return Form::textArea($attributeName, $value, $options);
});
/**
 * Validates a Recaptcha input
 * Obs: Recapctha package already provide a "captcha" macro to form.
 */
Form::macro('makeCaptchaValidator', function ($input) {
    $v = Validator::make($input, ['g-recaptcha-response' => 'required|recaptcha'])->setAttributeNames(['g-recaptcha-response' => 'Recaptcha']);
    return $v;
});
Пример #7
0
<?php

use Illuminate\Support\ViewErrorBag;
Form::macro('elegantSelect', function ($name, $title, ViewErrorBag $errors, array $list = [], array $options = []) {
    $options = array_merge(['id' => 'elegant-select-' . $name], $options);
    // Create HTML for select element
    $string = "<div class='form-group" . ($errors->has($name) ? ' has-error' : '') . "'>";
    $string .= Form::label($name, $title);
    $string .= Form::select($name, $list, null, $options);
    $string .= $errors->first($name, '<span class="help-block">:message</span>');
    $string .= '</div>';
    // JS to selectize the select element
    $string .= '<script>';
    $string .= "\$(document).ready(function() { \$('#{$options['id']}').selectize({ delimiter: ',', plugins: ['remove_button']}); });";
    $string .= '</script>';
    return $string;
});
Пример #8
0
<?php

Form::macro('selectMonth', function ($name, $selected = null, $options = array()) {
    $months = [];
    foreach (range(1, 12) as $month) {
        $months[$month] = date('F', mktime(0, 0, 0, $month));
    }
    return $this->select($name, $months, $selected, $options);
});
Form::macro('selectYear', function ($name, $startYear, $endYear, $selected = null, $options = array()) {
    $years = range($startYear, $endYear);
    $years = array_combine($years, $years);
    return $this->select($name, $years, $selected, $options);
});
Form::macro('selectDay', function ($name, $startDay, $endDay, $selected = null, $options = array()) {
    $days = range(1, 31);
    $days = array_combine($days, $days);
    return $this->select($name, $days, $selected, $options);
});
Пример #9
0
<?php

//Form Helper for simple form
Form::macro('txt', function ($name, $label, $value = null) {
    return "\n\t\t<div class='form-group'>\n\t\t\t<label class='control-label' for='{$name}'>{$label}</label>\n\t\t\t<input type='text' class='form-control' name='{$name}' id='{$name}' placeholder='{$label}' value='{$value}'>\n\t\t</div>\n\t";
});
Form::macro('txtarea', function ($name, $label, $value = null) {
    return "\n\t\t<div class='form-group'>\n\t\t\t<label class='control-label' for='{$name}'> {$label} </label>\n\t\t\t<textarea class='form-control' name='{$name}' id='{$name}' placeholder='{$label}' rows='3'>{$value}</textarea>\n\t\t</div>\n\t";
});
Form::macro('mail', function ($name, $label, $value = null) {
    return "\n\t\t<div class='form-group'>\n\t\t\t<label class='control-label'> {$label} </label>\n\t\t\t<input type='email' class='form-control' name='{$name}' id='{$name}' placeholder= '{$label}' value='{$value}'>\n\t\t</div>\n\t";
});
Form::macro('pwd', function ($name, $label) {
    return "\n\t\t<div class='form-group'>\n\t\t\t<label class='control-label'> {$label} </label>\n\t\t\t<input type='password' class='form-control' name= '{$name}'  id='{$name}' placeholder= '{$label}' >\n\t\t</div>\n\t";
});
Form::macro('chkbox', function ($name, $label, $value = null) {
    return "\n\t\t<div class='checkbox'>\n\t\t\t<label>\n\t\t\t\t<input type='checkbox' name='{$name}' {$value} id='{$name}'>  {$label} \n\t\t\t</label>\n\t\t</div>\n\t";
});
Form::macro('radi', function ($name, $label, $value = null, $condition = null) {
    return "<div class='radio'>\n\t  <label>\n\t    <input type='radio' name='{$name}' id='{$name}' value='{$value}' {$condition}>\n\t    {$label}\n\t  </label>\n\t</div>";
});
Form::macro('datetime', function ($name, $label, $value = null) {
    return "\n\t\t<div class='form-group'>\n\t            <div class='input-group date' id={$name}>\n\t                <input type='text' class='form-control' name={$name} placeholder={$label} />\n\t                <span class='input-group-addon'>\n\t                    <span class='fa fa-calendar'>\n\t                    </span>\n\t                </span>\n\t            </div>\n\t        </div>\t\n\t";
});
Form::macro('formSubmit', function ($label, $icon = null) {
    return " \n\t\t<div class='form-group'>\n\t\t\t<button type='submit' class='btn btn-default'>\n\t\t\t\t<i class='fa {$icon}'></i> \t\n\t\t\t\t{$label}\n\t\t\t</button>\n\t\t</div>";
});
Пример #10
0
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenance mode is in effect for the application.
|
*/
App::down(function () {
    return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
Form::macro('date', function ($name, $value = null, $options = array()) {
    $value = (is_null($value) or $value == '') ? \Input::get($name) : $value;
    $input = '<input type="date" name="' . $name . '" value="' . $value . '"';
    foreach ($options as $key => $value) {
        $input .= ' ' . $key . '="' . $value . '"';
    }
    return $input . '>';
});
require app_path() . '/filters.php';
Пример #11
0
    }
    $select .= '</select>';
    return $select;
});
Form::macro('barcode_types', function ($name = "barcode_type", $selected = null, $class = null) {
    $barcode_types = array('QRCODE', 'DATAMATRIX');
    $select = '<select name="' . $name . '" class="' . $class . '">';
    foreach ($barcode_types as $barcode_type) {
        $select .= '<option value="' . $barcode_type . '"' . ($selected == $barcode_type ? ' selected="selected"' : '') . '>' . $barcode_type . '</option> ';
    }
    $select .= '</select>';
    return $select;
});
Form::macro('username_format', function ($name = "username_format", $selected = null, $class = null) {
    $formats = array('firstname.lastname' => trans('general.firstname_lastname_format'), 'firstname' => trans('general.first_name_format'), 'filastname' => trans('general.filastname_format'));
    $select = '<select name="' . $name . '" class="' . $class . '" style="width: 100%">';
    foreach ($formats as $format => $label) {
        $select .= '<option value="' . $format . '"' . ($selected == $format ? ' selected="selected"' : '') . '>' . $label . '</option> ' . "\n";
    }
    $select .= '</select>';
    return $select;
});
Form::macro('customfield_elements', function ($name = "customfield_elements", $selected = null, $class = null) {
    $formats = array('text' => 'Text Box', 'listbox' => 'List Box');
    $select = '<select name="' . $name . '" class="' . $class . '" style="width: 100%">';
    foreach ($formats as $format => $label) {
        $select .= '<option value="' . $format . '"' . ($selected == $format ? ' selected="selected"' : '') . '>' . $label . '</option> ' . "\n";
    }
    $select .= '</select>';
    return $select;
});
Пример #12
0
<?php

// Create a Form macro which generates the fake honeypot field
// as well as the time check field
Form::macro('honeypot', function ($honey_name, $honey_time) {
    return View::make("honeypot::fields", get_defined_vars());
});
// We add a custom validator to validate the honeypot text and time check fields
Validator::register('honeypot', function ($attribute, $value, $parameters) {
    // We want the value to be empty, empty means it wasn't a spammer
    return $value == '';
});
Validator::register('honeytime', function ($attribute, $value, $parameters) {
    // The timestamp is encrypted so let's decrypt it
    $value = Crypter::decrypt($value);
    // The current time should be greater than the time the form was built + the speed option
    return is_numeric($value) && time() > $value + $parameters[0];
});
Пример #13
0
    Route::post('users/create', array('uses' => 'AdminUserController@store'));
    Route::resource('users', 'AdminUserController');
    Route::get('users/{id}/edit', array('uses' => 'AdminUserController@edit'));
    // Route::get('users/{id}/delete', array('uses' => 'AdminUserController@destroy'));
    Route::get('users/{id}/delete', 'AdminUserController@destroy');
    Route::put('users/update', 'AdminUserController@update');
    Route::get('registrations', array('uses' => 'AdminUserController@showRegistrations'));
    Route::resource('installers', 'InstallerController');
    Route::post('installers/store', 'InstallerController@store');
    Route::get('installers/{id}/delete', 'InstallerController@destroy');
    Route::resource('products', 'ProductCategoryController');
    Route::get('products/{id}/subcategories', array('uses' => 'ProductCategoryController@index'));
    Route::get('products/{id}/files', array('uses' => 'ProductCategoryController@files'));
    Route::post('products/addfile', 'ProductCategoryController@addfile');
    Route::get('products/{id}/models', array('uses' => 'ProductsController@models'));
    Route::post('products/{id}/addmodels', 'ProductsController@addmodels');
    Route::post('products/deletemodel/{id}', 'ProductsController@deletemodel');
    Route::post('products/store', array('uses' => 'ProductCategoryController@store'));
    Route::get('products/{id}/setdefault/{fileid}', array('uses' => 'FileController@setdefault'));
    Route::post('products/deletefile/{id}', 'FileController@deletefile');
});
//Macros
Form::macro('stateSelect', function ($name = "state", $selected = null, $options = array()) {
    $states = array('' => "", 'AL' => "Alabama", 'AK' => "Alaska", 'AZ' => "Arizona", 'AR' => "Arkansas", 'CA' => "California", 'CO' => "Colorado", 'CT' => "Connecticut", 'DE' => "Delaware", 'DC' => "District Of Columbia", 'FL' => "Florida", 'GA' => "Georgia", 'HI' => "Hawaii", 'ID' => "Idaho", 'IL' => "Illinois", 'IN' => "Indiana", 'IA' => "Iowa", 'KS' => "Kansas", 'KY' => "Kentucky", 'LA' => "Louisiana", 'ME' => "Maine", 'MD' => "Maryland", 'MA' => "Massachusetts", 'MI' => "Michigan", 'MN' => "Minnesota", 'MS' => "Mississippi", 'MO' => "Missouri", 'MT' => "Montana", 'NE' => "Nebraska", 'NV' => "Nevada", 'NH' => "New Hampshire", 'NJ' => "New Jersey", 'NM' => "New Mexico", 'NY' => "New York", 'NC' => "North Carolina", 'ND' => "North Dakota", 'OH' => "Ohio", 'OK' => "Oklahoma", 'OR' => "Oregon", 'PA' => "Pennsylvania", 'RI' => "Rhode Island", 'SC' => "South Carolina", 'SD' => "South Dakota", 'TN' => "Tennessee", 'TX' => "Texas", 'UT' => "Utah", 'VT' => "Vermont", 'VA' => "Virginia", 'WA' => "Washington", 'WV' => "West Virginia", 'WI' => "Wisconsin", 'WY' => "Wyoming");
    echo $selected;
    return Form::select($name, $states, $selected, $options);
});
Form::macro('countrySelect', function ($name = "country", $selected = null, $options = array()) {
    $countries = array('' => '', 'US' => 'UNITED STATES', 'AF' => 'AFGHANISTAN', 'AL' => 'ALBANIA', 'DZ' => 'ALGERIA', 'AS' => 'AMERICAN SAMOA', 'AD' => 'ANDORRA', 'AO' => 'ANGOLA', 'AI' => 'ANGUILLA', 'AQ' => 'ANTARCTICA', 'AG' => 'ANTIGUA AND BARBUDA', 'AR' => 'ARGENTINA', 'AM' => 'ARMENIA', 'AW' => 'ARUBA', 'AU' => 'AUSTRALIA', 'AT' => 'AUSTRIA', 'AZ' => 'AZERBAIJAN', 'BS' => 'BAHAMAS', 'BH' => 'BAHRAIN', 'BD' => 'BANGLADESH', 'BB' => 'BARBADOS', 'BY' => 'BELARUS', 'BE' => 'BELGIUM', 'BZ' => 'BELIZE', 'BJ' => 'BENIN', 'BM' => 'BERMUDA', 'BT' => 'BHUTAN', 'BO' => 'BOLIVIA', 'BA' => 'BOSNIA AND HERZEGOVINA', 'BW' => 'BOTSWANA', 'BV' => 'BOUVET ISLAND', 'BR' => 'BRAZIL', 'IO' => 'BRITISH INDIAN OCEAN TERRITORY', 'BN' => 'BRUNEI DARUSSALAM', 'BG' => 'BULGARIA', 'BF' => 'BURKINA FASO', 'BI' => 'BURUNDI', 'KH' => 'CAMBODIA', 'CM' => 'CAMEROON', 'CA' => 'CANADA', 'CV' => 'CAPE VERDE', 'KY' => 'CAYMAN ISLANDS', 'CF' => 'CENTRAL AFRICAN REPUBLIC', 'TD' => 'CHAD', 'CL' => 'CHILE', 'CN' => 'CHINA', 'CX' => 'CHRISTMAS ISLAND', 'CC' => 'COCOS (KEELING) ISLANDS', 'CO' => 'COLOMBIA', 'KM' => 'COMOROS', 'CG' => 'CONGO', 'CD' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'CK' => 'COOK ISLANDS', 'CR' => 'COSTA RICA', 'CI' => 'COTE D IVOIRE', 'HR' => 'CROATIA', 'CU' => 'CUBA', 'CY' => 'CYPRUS', 'CZ' => 'CZECH REPUBLIC', 'DK' => 'DENMARK', 'DJ' => 'DJIBOUTI', 'DM' => 'DOMINICA', 'DO' => 'DOMINICAN REPUBLIC', 'TP' => 'EAST TIMOR', 'EC' => 'ECUADOR', 'EG' => 'EGYPT', 'SV' => 'EL SALVADOR', 'GQ' => 'EQUATORIAL GUINEA', 'ER' => 'ERITREA', 'EE' => 'ESTONIA', 'ET' => 'ETHIOPIA', 'FK' => 'FALKLAND ISLANDS (MALVINAS)', 'FO' => 'FAROE ISLANDS', 'FJ' => 'FIJI', 'FI' => 'FINLAND', 'FR' => 'FRANCE', 'GF' => 'FRENCH GUIANA', 'PF' => 'FRENCH POLYNESIA', 'TF' => 'FRENCH SOUTHERN TERRITORIES', 'GA' => 'GABON', 'GM' => 'GAMBIA', 'GE' => 'GEORGIA', 'DE' => 'GERMANY', 'GH' => 'GHANA', 'GI' => 'GIBRALTAR', 'GR' => 'GREECE', 'GL' => 'GREENLAND', 'GD' => 'GRENADA', 'GP' => 'GUADELOUPE', 'GU' => 'GUAM', 'GT' => 'GUATEMALA', 'GN' => 'GUINEA', 'GW' => 'GUINEA-BISSAU', 'GY' => 'GUYANA', 'HT' => 'HAITI', 'HM' => 'HEARD ISLAND AND MCDONALD ISLANDS', 'VA' => 'HOLY SEE (VATICAN CITY STATE)', 'HN' => 'HONDURAS', 'HK' => 'HONG KONG', 'HU' => 'HUNGARY', 'IS' => 'ICELAND', 'IN' => 'INDIA', 'ID' => 'INDONESIA', 'IR' => 'IRAN, ISLAMIC REPUBLIC OF', 'IQ' => 'IRAQ', 'IE' => 'IRELAND', 'IL' => 'ISRAEL', 'IT' => 'ITALY', 'JM' => 'JAMAICA', 'JP' => 'JAPAN', 'JO' => 'JORDAN', 'KZ' => 'KAZAKSTAN', 'KE' => 'KENYA', 'KI' => 'KIRIBATI', 'KP' => 'KOREA DEMOCRATIC PEOPLES REPUBLIC OF', 'KR' => 'KOREA REPUBLIC OF', 'KW' => 'KUWAIT', 'KG' => 'KYRGYZSTAN', 'LA' => 'LAO PEOPLES DEMOCRATIC REPUBLIC', 'LV' => 'LATVIA', 'LB' => 'LEBANON', 'LS' => 'LESOTHO', 'LR' => 'LIBERIA', 'LY' => 'LIBYAN ARAB JAMAHIRIYA', 'LI' => 'LIECHTENSTEIN', 'LT' => 'LITHUANIA', 'LU' => 'LUXEMBOURG', 'MO' => 'MACAU', 'MK' => 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'MG' => 'MADAGASCAR', 'MW' => 'MALAWI', 'MY' => 'MALAYSIA', 'MV' => 'MALDIVES', 'ML' => 'MALI', 'MT' => 'MALTA', 'MH' => 'MARSHALL ISLANDS', 'MQ' => 'MARTINIQUE', 'MR' => 'MAURITANIA', 'MU' => 'MAURITIUS', 'YT' => 'MAYOTTE', 'MX' => 'MEXICO', 'FM' => 'MICRONESIA, FEDERATED STATES OF', 'MD' => 'MOLDOVA, REPUBLIC OF', 'MC' => 'MONACO', 'MN' => 'MONGOLIA', 'MS' => 'MONTSERRAT', 'MA' => 'MOROCCO', 'MZ' => 'MOZAMBIQUE', 'MM' => 'MYANMAR', 'NA' => 'NAMIBIA', 'NR' => 'NAURU', 'NP' => 'NEPAL', 'NL' => 'NETHERLANDS', 'AN' => 'NETHERLANDS ANTILLES', 'NC' => 'NEW CALEDONIA', 'NZ' => 'NEW ZEALAND', 'NI' => 'NICARAGUA', 'NE' => 'NIGER', 'NG' => 'NIGERIA', 'NU' => 'NIUE', 'NF' => 'NORFOLK ISLAND', 'MP' => 'NORTHERN MARIANA ISLANDS', 'NO' => 'NORWAY', 'OM' => 'OMAN', 'PK' => 'PAKISTAN', 'PW' => 'PALAU', 'PS' => 'PALESTINIAN TERRITORY, OCCUPIED', 'PA' => 'PANAMA', 'PG' => 'PAPUA NEW GUINEA', 'PY' => 'PARAGUAY', 'PE' => 'PERU', 'PH' => 'PHILIPPINES', 'PN' => 'PITCAIRN', 'PL' => 'POLAND', 'PT' => 'PORTUGAL', 'PR' => 'PUERTO RICO', 'QA' => 'QATAR', 'RE' => 'REUNION', 'RO' => 'ROMANIA', 'RU' => 'RUSSIAN FEDERATION', 'RW' => 'RWANDA', 'SH' => 'SAINT HELENA', 'KN' => 'SAINT KITTS AND NEVIS', 'LC' => 'SAINT LUCIA', 'PM' => 'SAINT PIERRE AND MIQUELON', 'VC' => 'SAINT VINCENT AND THE GRENADINES', 'WS' => 'SAMOA', 'SM' => 'SAN MARINO', 'ST' => 'SAO TOME AND PRINCIPE', 'SA' => 'SAUDI ARABIA', 'SN' => 'SENEGAL', 'SC' => 'SEYCHELLES', 'SL' => 'SIERRA LEONE', 'SG' => 'SINGAPORE', 'SK' => 'SLOVAKIA', 'SI' => 'SLOVENIA', 'SB' => 'SOLOMON ISLANDS', 'SO' => 'SOMALIA', 'ZA' => 'SOUTH AFRICA', 'GS' => 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', 'ES' => 'SPAIN', 'LK' => 'SRI LANKA', 'SD' => 'SUDAN', 'SR' => 'SURINAME', 'SJ' => 'SVALBARD AND JAN MAYEN', 'SZ' => 'SWAZILAND', 'SE' => 'SWEDEN', 'CH' => 'SWITZERLAND', 'SY' => 'SYRIAN ARAB REPUBLIC', 'TW' => 'TAIWAN, PROVINCE OF CHINA', 'TJ' => 'TAJIKISTAN', 'TZ' => 'TANZANIA, UNITED REPUBLIC OF', 'TH' => 'THAILAND', 'TG' => 'TOGO', 'TK' => 'TOKELAU', 'TO' => 'TONGA', 'TT' => 'TRINIDAD AND TOBAGO', 'TN' => 'TUNISIA', 'TR' => 'TURKEY', 'TM' => 'TURKMENISTAN', 'TC' => 'TURKS AND CAICOS ISLANDS', 'TV' => 'TUVALU', 'UG' => 'UGANDA', 'UA' => 'UKRAINE', 'AE' => 'UNITED ARAB EMIRATES', 'GB' => 'UNITED KINGDOM', 'UM' => 'UNITED STATES MINOR OUTLYING ISLANDS', 'UY' => 'URUGUAY', 'UZ' => 'UZBEKISTAN', 'VU' => 'VANUATU', 'VE' => 'VENEZUELA', 'VN' => 'VIET NAM', 'VG' => 'VIRGIN ISLANDS, BRITISH', 'VI' => 'VIRGIN ISLANDS, U.S.', 'WF' => 'WALLIS AND FUTUNA', 'EH' => 'WESTERN SAHARA', 'YE' => 'YEMEN', 'YU' => 'YUGOSLAVIA', 'ZM' => 'ZAMBIA', 'ZW' => 'ZIMBABWE');
    return Form::select($name, $countries, $selected, $options);
});
Пример #14
0
 * @param string $name The field name
 * @param string $title The field title
 * @param object $errors The laravel errors object
 * @param array $choice The choice of the select
 * @param null|array $object The entity of the field
 */
Form::macro('normalSelect', function ($name, $title, ViewErrorBag $errors, array $choice, $object = null, array $options = []) {
    if (array_key_exists("multiple", $options)) {
        $nameForm = $name . '[]';
    } else {
        $nameForm = $name;
    }
    $string = "<div class='form-group dropdown" . ($errors->has($name) ? ' has-error' : '') . "'>";
    $string .= "<label for='{$nameForm}'>{$title}</label>";
    if (is_object($object)) {
        $currentData = isset($object->{$name}) ? $object->{$name} : '';
    } else {
        $currentData = false;
    }
    /* Bootstrap default class */
    $array_option = ['class' => 'form-control'];
    if (array_key_exists("class", $options)) {
        $array_option = ['class' => $array_option['class'] . ' ' . $options['class']];
        unset($options['class']);
    }
    $options = array_merge($array_option, $options);
    $string .= Form::select($nameForm, $choice, Input::old($nameForm, $currentData), $options);
    $string .= $errors->first($name, '<span class="help-block">:message</span>');
    $string .= "</div>";
    return $string;
});
Пример #15
0
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
//require app_path().'/libraries/function/great_circle_distance.php';
//require app_path().'/libraries/function/flight_duration.php';
Form::macro('time_dropdown', function ($name, $options) {
    for ($i = 0; $i <= 23; $i++) {
        if ($i < 10) {
            $i = '0' . $i;
        }
        $hours[] = $i;
    }
    for ($i = 0; $i < 60; $i += 5) {
        if ($i < 10) {
            $i = '0' . $i;
        }
        $minutes[$i] = $i;
    }
    return '<div class="row"><div class="col-sm-6">' . Form::select($name . '[hours]', $hours, null, $options) . '</div><div class="col-sm-6">' . Form::select($name . '[minutes]', $minutes, null, $options) . '</div></div>';
});
HTML::macro('sort_link', function ($sortby) {
    return '<a href="' . action('AirportsController@index', array('sortby' => $sortby)) . '"><span class="glyphicon glyphicon-sort"></span></a>';
});
Form::macro('airports', function ($id, $options, $default = '') {
    $options['class'] = $options['class'] . ' airportsAutocomplete';
    return Form::hidden($id, $default, $options);
});
Пример #16
0
Form::macro('agegateselectsdate', function ($name, $value = null, $options = array()) {
    $selectedDay = is_array($value) && array_key_exists($name . '_day', $value) ? $value[$name . '_day'] : false;
    $selectedMonth = is_array($value) && array_key_exists($name . '_month', $value) ? $value[$name . '_month'] : false;
    $selectedYear = is_array($value) && array_key_exists($name . '_year', $value) ? $value[$name . '_year'] : false;
    $format = 'ymd';
    if (array_key_exists('format', $options) && strlen($options['format']) == 3 && stripos($options['format'], 'y') !== false && stripos($options['format'], 'm') !== false && stripos($options['format'], 'd') !== false) {
        $format = strtolower($options['format']);
    }
    $components = preg_split('//', $format);
    $input = '';
    $classPrefix = isset($options['class_prefix']) && !empty($options['class_prefix']) ? $options['class_prefix'] : '';
    foreach ($components as $component) {
        switch ($component) {
            case 'd':
                $input .= '<select name="' . $name . '_day" class="' . $classPrefix . $name . '-day"' . ($options['disabled'] ? ' disabled="disabled"' : '') . '>';
                $input .= '<option value="">' . trans('laravel-avp::content.dd') . '</option>';
                foreach (range(1, 31) as $num) {
                    $num = str_pad($num, 2, '0', STR_PAD_LEFT);
                    $input .= '<option value="' . $num . '"';
                    if ($num == $selectedDay) {
                        $input .= ' selected="selected"';
                    }
                    $input .= '>' . $num . '</option>';
                }
                $input .= '</select>';
                break;
            case 'm':
                $input .= '<select name="' . $name . '_month" class="' . $classPrefix . $name . '-month"' . ($options['disabled'] ? ' disabled="disabled"' : '') . '>';
                $input .= '<option value="">' . trans('laravel-avp::content.mm') . '</option>';
                foreach (range(1, 12) as $num) {
                    $num = str_pad($num, 2, '0', STR_PAD_LEFT);
                    $input .= '<option value="' . $num . '"';
                    if ($num == $selectedMonth) {
                        $input .= ' selected="selected"';
                    }
                    $input .= '>' . $num . '</option>';
                }
                $input .= '</select>';
                break;
            case 'y':
                $input .= '<select name="' . $name . '_year" class="' . $classPrefix . $name . '-year"' . ($options['disabled'] ? ' disabled="disabled"' : '') . '>';
                $input .= '<option value="">' . trans('laravel-avp::content.yyyy') . '</option>';
                $min = 1900;
                if (array_key_exists('min', $options) && preg_match('/^(\\d{4})-\\d{2}-\\d{2}$/', $options['min'], $matches)) {
                    $min = $matches[1];
                }
                $max = date('Y');
                if (array_key_exists('max', $options) && preg_match('/^(\\d{4})-\\d{2}-\\d{2}$/', $options['max'], $matches)) {
                    $max = $matches[1];
                }
                foreach (range($max, $min) as $num) {
                    $input .= '<option value="' . $num . '"';
                    if ($num == $selectedYear) {
                        $input .= ' selected="selected"';
                    }
                    $input .= '>' . $num . '</option>';
                }
                $input .= '</select>';
                break;
        }
    }
    return $input;
});
 * Form input macro
 * @param $type The input type attribute
 * @param $name The input name attribute
 * @param $label The form input label
 * @param $value The input value attribute
 * @param $attributes The input additional attributes
 */
Form::macro('datepicker', function ($type, $name, $label, $value = null, $attributes = [], $more_class = '', $removeIcon = false) {
    $addbackground = $removeIcon == true ? 'datepicker-icon' : '';
    $class = 'form-control ' . $more_class . ' ' . $addbackground;
    $options = ['class' => $class, 'id' => $name];
    $labelClass = 'control-label';
    if (isset($attributes['no_label'])) {
        unset($attributes['no_label']);
        $labelClass = 'sr-only';
    }
    if ($attributes) {
        $options = $options + $attributes;
    }
    $html = '
			<div class="form-group">
				<label for="' . $name . '">' . $label . '</label>
				<div class="input-group">
					' . Form::input($type, $name, $value, $options);
    if (!$removeIcon) {
        $html .= '<span class="input-group-addon calendar-click"><i class="fa fa-calendar"></i></span>';
    }
    $html .= '</div>
	  		</div>';
    return $html;
});
Пример #18
0
<?php

/**
* Macro helpers
*
*/
/**
* Country macro
* Generates the dropdown menu of countries for the profile form
*/
Form::macro('countries', function ($name = "country", $selected = null, $class = null) {
    $countries = array('' => "Select a Country", 'ac' => 'Ascension Island', 'ad' => 'Andorra', 'ae' => 'United Arab Emirates', 'af' => 'Afghanistan', 'ag' => 'Antigua And Barbuda', 'ai' => 'Anguilla', 'al' => 'Albania', 'am' => 'Armenia', 'an' => 'Netherlands Antilles', 'ao' => 'Angola', 'aq' => 'Antarctica', 'ar' => 'Argentina', 'as' => 'American Samoa', 'at' => 'Austria', 'au' => 'Australia', 'aw' => 'Aruba', 'ax' => 'Åland', 'az' => 'Azerbaijan', 'ba' => 'Bosnia And Herzegovina', 'bb' => 'Barbados', 'be' => 'Belgium', 'bd' => 'Bangladesh', 'bf' => 'Burkina Faso', 'bg' => 'Bulgaria', 'bh' => 'Bahrain', 'bi' => 'Burundi', 'bj' => 'Benin', 'bm' => 'Bermuda', 'bn' => 'Brunei Darussalam', 'bo' => 'Bolivia', 'br' => 'Brazil', 'bs' => 'Bahamas', 'bt' => 'Bhutan', 'bv' => 'Bouvet Island', 'bw' => 'Botswana', 'by' => 'Belarus', 'bz' => 'Belize', 'ca' => 'Canada', 'cc' => 'Cocos (Keeling) Islands', 'cd' => 'Congo (Democratic Republic)', 'cf' => 'Central African Republic', 'cg' => 'Congo (Republic)', 'ch' => 'Switzerland', 'ci' => 'Cote D’Ivoire', 'ck' => 'Cook Islands', 'cl' => 'Chile', 'cm' => 'Cameroon', 'cn' => 'People’s Republic of China', 'co' => 'Colombia', 'cr' => 'Costa Rica', 'cu' => 'Cuba', 'cv' => 'Cape Verde', 'cx' => 'Christmas Island', 'cy' => 'Cyprus', 'cz' => 'Czech Republic', 'de' => 'Germany', 'dj' => 'Djibouti', 'dk' => 'Denmark', 'dm' => 'Dominica', 'do' => 'Dominican Republic', 'dz' => 'Algeria', 'ec' => 'Ecuador', 'ee' => 'Estonia', 'eg' => 'Egypt', 'er' => 'Eritrea', 'es' => 'Spain', 'et' => 'Ethiopia', 'eU' => 'European Union', 'fi' => 'Finland', 'fj' => 'Fiji', 'fk' => 'Falkland Islands (Malvinas)', 'fm' => 'Micronesia, Federated States Of', 'fo' => 'Faroe Islands', 'fr' => 'France', 'ga' => 'Gabon', 'gb' => 'United Kingdom', 'gd' => 'Grenada', 'ge' => 'Georgia', 'gf' => 'French Guiana', 'gg' => 'Guernsey', 'gh' => 'Ghana', 'gi' => 'Gibraltar', 'gl' => 'Greenland', 'gm' => 'Gambia', 'gn' => 'Guinea', 'gp' => 'Guadeloupe', 'gq' => 'Equatorial Guinea', 'gr' => 'Greece', 'gs' => 'South Georgia And The South Sandwich Islands', 'gt' => 'Guatemala', 'gu' => 'Guam', 'gw' => 'Guinea-Bissau', 'gy' => 'Guyana', 'hk' => 'Hong Kong', 'hm' => 'Heard And Mc Donald Islands', 'hn' => 'Honduras', 'hr' => 'Croatia (local name: Hrvatska)', 'ht' => 'Haiti', 'hu' => 'Hungary', 'id' => 'Indonesia', 'ie' => 'Ireland', 'il' => 'Israel', 'im' => 'Isle of Man', 'in' => 'India', 'io' => 'British Indian Ocean Territory', 'iq' => 'Iraq', 'ir' => 'Iran (Islamic Republic Of)', 'is' => 'Iceland', 'it' => 'Italy', 'je' => 'Jersey', 'jm' => 'Jamaica', 'jo' => 'Jordan', 'jp' => 'Japan', 'ke' => 'Kenya', 'kg' => 'Kyrgyzstan', 'kh' => 'Cambodia', 'ki' => 'Kiribati', 'km' => 'Comoros', 'kn' => 'Saint Kitts And Nevis', 'kr' => 'Korea, Republic Of', 'kw' => 'Kuwait', 'ky' => 'Cayman Islands', 'kz' => 'Kazakhstan', 'la' => 'Lao People’s Democratic Republic', 'lb' => 'Lebanon', 'lc' => 'Saint Lucia', 'li' => 'Liechtenstein', 'lk' => 'Sri Lanka', 'lr' => 'Liberia', 'ls' => 'Lesotho', 'lt' => 'Lithuania', 'lu' => 'Luxembourg', 'lv' => 'Latvia', 'ly' => 'Libyan Arab Jamahiriya', 'ma' => 'Morocco', 'mc' => 'Monaco', 'md' => 'Moldova, Republic Of', 'me' => 'Montenegro', 'mg' => 'Madagascar', 'mh' => 'Marshall Islands', 'mk' => 'Macedonia, The Former Yugoslav Republic Of', 'ml' => 'Mali', 'mm' => 'Myanmar', 'mn' => 'Mongolia', 'mo' => 'Macau', 'mp' => 'Northern Mariana Islands', 'mq' => 'Martinique', 'mr' => 'Mauritania', 'ms' => 'Montserrat', 'mt' => 'Malta', 'mu' => 'Mauritius', 'mv' => 'Maldives', 'mw' => 'Malawi', 'mx' => 'Mexico', 'my' => 'Malaysia', 'mz' => 'Mozambique', 'na' => 'Namibia', 'nc' => 'New Caledonia', 'ne' => 'Niger', 'nf' => 'Norfolk Island', 'ng' => 'Nigeria', 'ni' => 'Nicaragua', 'nl' => 'Netherlands', 'no' => 'Norway', 'np' => 'Nepal', 'nr' => 'Nauru', 'nu' => 'Niue', 'nz' => 'New Zealand', 'om' => 'Oman', 'pa' => 'Panama', 'pe' => 'Peru', 'pf' => 'French Polynesia', 'pg' => 'Papua New Guinea', 'ph' => 'Philippines, Republic of the', 'pk' => 'Pakistan', 'pl' => 'Poland', 'pm' => 'St. Pierre And Miquelon', 'pn' => 'Pitcairn', 'pr' => 'Puerto Rico', 'ps' => 'Palestine', 'pt' => 'Portugal', 'pw' => 'Palau', 'py' => 'Paraguay', 'qa' => 'Qatar', 're' => 'Reunion', 'ro' => 'Romania', 'rs' => 'Serbia', 'ru' => 'Russian Federation', 'rw' => 'Rwanda', 'sa' => 'Saudi Arabia', 'uk' => 'Scotland', 'sb' => 'Solomon Islands', 'sc' => 'Seychelles', 'sd' => 'Sudan', 'se' => 'Sweden', 'sg' => 'Singapore', 'sh' => 'St. Helena', 'si' => 'Slovenia', 'sj' => 'Svalbard And Jan Mayen Islands', 'sk' => 'Slovakia (Slovak Republic)', 'sl' => 'Sierra Leone', 'sm' => 'San Marino', 'sn' => 'Senegal', 'so' => 'Somalia', 'sr' => 'Suriname', 'st' => 'Sao Tome And Principe', 'su' => 'Soviet Union', 'sv' => 'El Salvador', 'sy' => 'Syrian Arab Republic', 'sz' => 'Swaziland', 'tc' => 'Turks And Caicos Islands', 'td' => 'Chad', 'tf' => 'French Southern Territories', 'tg' => 'Togo', 'th' => 'Thailand', 'tj' => 'Tajikistan', 'tk' => 'Tokelau', 'ti' => 'East Timor (new code)', 'tm' => 'Turkmenistan', 'tn' => 'Tunisia', 'to' => 'Tonga', 'tp' => 'East Timor (old code)', 'tr' => 'Turkey', 'tt' => 'Trinidad And Tobago', 'tv' => 'Tuvalu', 'tw' => 'Taiwan', 'tz' => 'Tanzania, United Republic Of', 'ua' => 'Ukraine', 'ug' => 'Uganda', 'uk' => 'United Kingdom', 'um' => 'United States Minor Outlying Islands', 'us' => 'United States', 'uy' => 'Uruguay', 'uz' => 'Uzbekistan', 'va' => 'Vatican City State (Holy See)', 'vc' => 'Saint Vincent And The Grenadines', 've' => 'Venezuela', 'vg' => 'Virgin Islands (British)', 'vi' => 'Virgin Islands (U.S.)', 'vn' => 'Viet Nam', 'vu' => 'Vanuatu', 'wf' => 'Wallis And Futuna Islands', 'ws' => 'Samoa', 'ye' => 'Yemen', 'yt' => 'Mayotte', 'za' => 'South Africa', 'zm' => 'Zambia', 'zw' => 'Zimbabwe');
    $select = '<select name="' . $name . '" class="' . $class . '" style="min-width:350px">';
    foreach ($countries as $abbr => $country) {
        $select .= '<option value="' . $abbr . '"' . ($selected == $abbr ? ' selected="selected"' : '') . '>' . $country . '</option> ';
    }
    $select .= '</select>';
    return $select;
});
Пример #19
0
<?php

Form::macro('bsubmit', function ($label, $buttons = [], $privileges = null, $permission = null) {
    $disabled = '';
    if ($privileges) {
        $disabled = 'disabled';
        foreach ($privileges as $priv) {
            if ($priv->name === $permission) {
                $disabled = '';
            }
        }
    }
    $addonbtn = '';
    foreach ($buttons as $key => $value) {
        switch ($key) {
            case 'back':
                $addonbtn .= ' <button type="button" onclick="history.back()" class="btn btn-success">' . $value . '</button>';
                break;
            case 'close':
                $addonbtn .= ' <button type="button" onclick="open(location, \'_self\').close()" class="btn btn-success">' . $value . '</button>';
                break;
        }
    }
    $output = '
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary" ' . $disabled . '>' . $label . '</button>' . $addonbtn . '</div>
    </div>';
    return $output;
});
Пример #20
0
<?php

Form::macro('checkBoxLabel', function ($name, $label) {
    $html = '<label>';
    $html .= Form::hidden($name, false);
    $html .= Form::checkbox($name, true, null) . $label;
    $html .= '</label>';
    return $html;
});
Пример #21
0
Form::macro('selectField', function ($name, $options, $value, $label) {
    $element = Form::select($name, $options, $value, ['class' => 'form-control']);
    return "<div class='form-group " . errorClass($name) . "'>\n            <label class='control-label' for='{$name}'>{$label}</label>\n            {$element}" . errorMessage($name) . "</div>";
});
Form::macro('multiSelectField', function ($name, $options, $value = null, $label) {
    $element = Form::select($name, $options, $value, ['class' => 'form-control multiselect', 'multiple']);
    return "<div class='form-group " . errorClass($name) . "'>\n            <label class='control-label' for='{$name}'>{$label}</label>\n            {$element}" . errorMessage($name) . "</div>";
});
Form::macro('selectTag', function ($name, $id, $label) {
    return "<div class='form-group " . errorClass($name) . "'>\n            <label class='control-label' for='{$name}'>{$label}</label>\n            <input id='{$id}' class='form-control' name='{$name}'/>" . errorMessage($name) . "</div>";
});
Form::macro('fileField', function ($name, $label) {
    return "<div class='form-group " . errorClass($name) . "'>\n            <label class='control-label' for='{$name}'>{$label}</label>" . Form::file($name) . errorMessage($name) . "</div>";
});
Form::macro('submitField', function ($value = 'Submit', $btn_style = 'btn btn-primary') {
    return "<div class='form-group'>\n            <button type='submit' class='{$btn_style}'>{$value}</button>\n            </div>";
});
if (!function_exists('errorMessage')) {
    function errorMessage($name)
    {
        if ($errors = Session::get('errors')) {
            return $errors->first($name, '<p class="help-block">:message</p>');
        }
        return "<p class='help-block' id='{$name}'></p>";
    }
}
if (!function_exists('errorClass')) {
    function errorClass($name)
    {
        $error = null;
        if ($errors = Session::get('errors')) {
Пример #22
0
        if (is_array($val)) {
            $new_list[$key] = ititrate($val);
        } else {
            if (!is_numeric($key)) {
                $new_list[$key] = $val;
            } else {
                $new_list[$val] = $val;
            }
        }
    }
    return $new_list;
}
Form::macro('new_select', function ($name, $label, $list, $selected, $class = null, $options = []) {
    if (empty($options)) {
        $options = ['class' => 'form-control ' . $class, 'required'];
    }
    $new_list = ititrate($list);
    echo $field = Form::label($name, $label);
    $field = Form::select($name, $new_list, $selected, $options);
    return $field;
});
Form::macro('num', function ($name, $value, $attrs = null) {
    $options = null;
    if (isset($attrs)) {
        foreach ($attrs as $attr => $val) {
            $options .= "{$attr}='{$val}'";
        }
    }
    $field = "<input type='number' value='{$value}' name='{$name}' {$options}>";
    return $field;
});
Пример #23
0
<?php

Form::macro('textField', function ($name, $label, $default) {
    return '<div class="form-group"><label for="' . $name . '">' . $label . '</label><input type="text" name="' . $name . '" class="form-control" id="' . $name . '" value="' . $default . '"/></div>';
});
Form::macro('textBox', function ($name, $label, $default) {
    return '<div class="form-group"><label for="' . $name . '">' . $label . '</label><textarea name="' . $name . '" class="form-control" id="' . $name . '" rows="7">' . $default . '</textarea></div>';
});
Form::macro('submitButton', function ($value, $class) {
    return '<button type="submit" class="btn btn-' . $class . ' pull-right">' . $value . '</button><br />';
});
Пример #24
0
Form::macro('icheckboxgroup', function ($name, $label, $options, $values, $required = null, $privileges = null, $permission = null) {
    $disabled = 'disabled';
    if ($privileges) {
        foreach ($privileges as $priv) {
            if ($priv->name === $permission) {
                $disabled = '';
            }
        }
    }
    $checkbox = '';
    foreach ($options as $key => $value) {
        if (in_array($key, $values)) {
            $checkbox .= '
                            <div class="checkbox">
                                <label><input type="checkbox" checked="checked" name="' . $name . '[]" value="' . $key . '" ' . $disabled . '/>' . $value . '</label>
                            </div>';
        } else {
            $checkbox .= '
                            <div class="checkbox">
                                <label><input type="checkbox" name="' . $name . '[]" value="' . $key . '" ' . $disabled . '/>' . $value . '</label>
                            </div>';
        }
    }
    if ($required) {
        $required = '<span>*</span>';
    }
    $output = '
    <div class="form-group">
        <div class="col-sm-2">
            <label for="' . $name . '" class="control-label">' . $label . $required . '</label>
        </div>
        <div class="col-sm-10">
            ' . $checkbox . '
        </div>
    </div>';
    return $output;
});
Пример #25
0
/**
* Macro helpers
*
*/
/**
* Country macro
* Generates the dropdown menu of countries for the profile form
*/
Form::macro('countries', function ($name = "country", $selected = null, $class = null) {
    $countries = array('' => "Select a Country", 'AC' => 'Ascension Island', 'AD' => 'Andorra', 'AE' => 'United Arab Emirates', 'AF' => 'Afghanistan', 'AG' => 'Antigua And Barbuda', 'AI' => 'Anguilla', 'AL' => 'Albania', 'AM' => 'Armenia', 'AN' => 'Netherlands Antilles', 'AO' => 'Angola', 'AQ' => 'Antarctica', 'AR' => 'Argentina', 'AS' => 'American Samoa', 'AT' => 'Austria', 'AU' => 'Australia', 'AW' => 'Aruba', 'AX' => 'Ã…land', 'AZ' => 'Azerbaijan', 'BA' => 'Bosnia And Herzegovina', 'BB' => 'Barbados', 'BE' => 'Belgium', 'BD' => 'Bangladesh', 'BF' => 'Burkina Faso', 'BG' => 'Bulgaria', 'BH' => 'Bahrain', 'BI' => 'Burundi', 'BJ' => 'Benin', 'BM' => 'Bermuda', 'BN' => 'Brunei Darussalam', 'BO' => 'Bolivia', 'BR' => 'Brazil', 'BS' => 'Bahamas', 'BT' => 'Bhutan', 'BV' => 'Bouvet Island', 'BW' => 'Botswana', 'BY' => 'Belarus', 'BZ' => 'Belize', 'CA' => 'Canada', 'CC' => 'Cocos (Keeling) Islands', 'CD' => 'Congo (Democratic Republic)', 'CF' => 'Central African Republic', 'CG' => 'Congo (Republic)', 'CH' => 'Switzerland', 'CI' => 'Côte d\'Ivoire', 'CK' => 'Cook Islands', 'CL' => 'Chile', 'CM' => 'Cameroon', 'CN' => 'People\'s Republic of China', 'CO' => 'Colombia', 'CR' => 'Costa Rica', 'CU' => 'Cuba', 'CV' => 'Cape Verde', 'CX' => 'Christmas Island', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DE' => 'Germany', 'DJ' => 'Djibouti', 'DK' => 'Denmark', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'DZ' => 'Algeria', 'EC' => 'Ecuador', 'EE' => 'Estonia', 'EG' => 'Egypt', 'ER' => 'Eritrea', 'ES' => 'Spain', 'ET' => 'Ethiopia', 'EU' => 'European Union', 'FI' => 'Finland', 'FJ' => 'Fiji', 'FK' => 'Falkland Islands (Malvinas)', 'FM' => 'Micronesia, Federated States Of', 'FO' => 'Faroe Islands', 'FR' => 'France', 'GA' => 'Gabon', 'GB' => 'United Kingdom', 'GD' => 'Grenada', 'GE' => 'Georgia', 'GF' => 'French Guiana', 'GG' => 'Guernsey', 'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GL' => 'Greenland', 'GM' => 'Gambia', 'GN' => 'Guinea', 'GP' => 'Guadeloupe', 'GQ' => 'Equatorial Guinea', 'GR' => 'Greece', 'GS' => 'South Georgia And The South Sandwich Islands', 'GT' => 'Guatemala', 'GU' => 'Guam', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HK' => 'Hong Kong', 'HM' => 'Heard And Mc Donald Islands', 'HN' => 'Honduras', 'HR' => 'Croatia (local name: Hrvatska)', 'HT' => 'Haiti', 'HU' => 'Hungary', 'ID' => 'Indonesia', 'IE' => 'Ireland', 'IL' => 'Israel', 'IM' => 'Isle of Man', 'IN' => 'India', 'IO' => 'British Indian Ocean Territory', 'IQ' => 'Iraq', 'IR' => 'Iran, Islamic Republic Of', 'IS' => 'Iceland', 'IT' => 'Italy', 'JE' => 'Jersey', 'JM' => 'Jamaica', 'JO' => 'Jordan', 'JP' => 'Japan', 'KE' => 'Kenya', 'KG' => 'Kyrgyzstan', 'KH' => 'Cambodia', 'KI' => 'Kiribati', 'KM' => 'Comoros', 'KN' => 'Saint Kitts And Nevis', 'KR' => 'Korea, Republic Of', 'KW' => 'Kuwait', 'KY' => 'Cayman Islands', 'KZ' => 'Kazakhstan', 'LA' => 'Lao People\'s Democratic Republic', 'LB' => 'Lebanon', 'LC' => 'Saint Lucia', 'LI' => 'Liechtenstein', 'LK' => 'Sri Lanka', 'LR' => 'Liberia', 'LS' => 'Lesotho', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'LV' => 'Latvia', 'LY' => 'Libyan Arab Jamahiriya', 'MA' => 'Morocco', 'MC' => 'Monaco', 'MD' => 'Moldova, Republic Of', 'ME' => 'Montenegro', 'MG' => 'Madagascar', 'MH' => 'Marshall Islands', 'MK' => 'Macedonia, The Former Yugoslav Republic Of', 'ML' => 'Mali', 'MM' => 'Myanmar', 'MN' => 'Mongolia', 'MO' => 'Macau', 'MP' => 'Northern Mariana Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania', 'MS' => 'Montserrat', 'MT' => 'Malta', 'MU' => 'Mauritius', 'MV' => 'Maldives', 'MW' => 'Malawi', 'MX' => 'Mexico', 'MY' => 'Malaysia', 'MZ' => 'Mozambique', 'NA' => 'Namibia', 'NC' => 'New Caledonia', 'NE' => 'Niger', 'NF' => 'Norfolk Island', 'NG' => 'Nigeria', 'NI' => 'Nicaragua', 'NL' => 'Netherlands', 'NO' => 'Norway', 'NP' => 'Nepal', 'NR' => 'Nauru', 'NU' => 'Niue', 'NZ' => 'New Zealand', 'OM' => 'Oman', 'PA' => 'Panama', 'PE' => 'Peru', 'PF' => 'French Polynesia', 'PG' => 'Papua New Guinea', 'PH' => 'Philippines, Republic of the', 'PK' => 'Pakistan', 'PL' => 'Poland', 'PM' => 'St. Pierre And Miquelon', 'PN' => 'Pitcairn', 'PR' => 'Puerto Rico', 'PS' => 'Palestine', 'PT' => 'Portugal', 'PW' => 'Palau', 'PY' => 'Paraguay', 'QA' => 'Qatar', 'RE' => 'Reunion', 'RO' => 'Romania', 'RS' => 'Serbia', 'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'SA' => 'Saudi Arabia', 'UK' => 'Scotland', 'SB' => 'Solomon Islands', 'SC' => 'Seychelles', 'SD' => 'Sudan', 'SE' => 'Sweden', 'SG' => 'Singapore', 'SH' => 'St. Helena', 'SI' => 'Slovenia', 'SJ' => 'Svalbard And Jan Mayen Islands', 'SK' => 'Slovakia (Slovak Republic)', 'SL' => 'Sierra Leone', 'SM' => 'San Marino', 'SN' => 'Senegal', 'SO' => 'Somalia', 'SR' => 'Suriname', 'ST' => 'Sao Tome And Principe', 'SU' => 'Soviet Union', 'SV' => 'El Salvador', 'SY' => 'Syrian Arab Republic', 'SZ' => 'Swaziland', 'TC' => 'Turks And Caicos Islands', 'TD' => 'Chad', 'TF' => 'French Southern Territories', 'TG' => 'Togo', 'TH' => 'Thailand', 'TJ' => 'Tajikistan', 'TK' => 'Tokelau', 'TI' => 'East Timor', 'TM' => 'Turkmenistan', 'TN' => 'Tunisia', 'TO' => 'Tonga', 'TP' => 'East Timor (old code)', 'TR' => 'Turkey', 'TT' => 'Trinidad And Tobago', 'TV' => 'Tuvalu', 'TW' => 'Taiwan', 'TZ' => 'Tanzania, United Republic Of', 'UA' => 'Ukraine', 'UG' => 'Uganda', 'UK' => 'United Kingdom', 'UM' => 'United States Minor Outlying Islands', 'US' => 'United States', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan', 'VA' => 'Vatican City State (Holy See)', 'VC' => 'Saint Vincent And The Grenadines', 'VE' => 'Venezuela', 'VG' => 'Virgin Islands (British)', 'VI' => 'Virgin Islands (U.S.)', 'VN' => 'Viet Nam', 'VU' => 'Vanuatu', 'WF' => 'Wallis And Futuna Islands', 'WS' => 'Samoa', 'YE' => 'Yemen', 'YT' => 'Mayotte', 'ZA' => 'South Africa', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe');
    $select = '<select name="' . $name . '" class="' . $class . '" style="min-width:350px">';
    foreach ($countries as $abbr => $country) {
        $select .= '<option value="' . strtoupper($abbr) . '"' . (strtoupper($selected) == strtoupper($abbr) ? ' selected="selected"' : '') . '>' . $country . '</option> ';
    }
    $select .= '</select>';
    return $select;
});
/**
* Country macro
* Generates the dropdown menu of countries for the profile form
*/
Form::macro('barcode_types', function ($name = "barcode_type", $selected = null, $class = null) {
    $barcode_types = array('QRCODE' => "QR Code", 'PDF417' => 'PDF417', 'DATAMATRIX' => 'DATAMATRIX');
    $select = '<select name="' . $name . '" class="' . $class . '">';
    foreach ($barcode_types as $code => $codename) {
        $select .= '<option value="' . $code . '"' . ($selected == $code ? ' selected="selected"' : '') . '>' . $codename . '</option> ';
    }
    $select .= '</select>';
    return $select;
});
Пример #26
0
 * Form checkbox/radio
 * @param $type The input type attribute
 * @param $name The input name attribute
 * @param $options The checkbox/radio options. Should be in $label=>value format
 * @param $value The selected value
 * @param $inline Flags if it should be displayed inline
 */
Form::macro('fbox', function ($type, $name, $options = [], $value = '', $inline = false) {
    if (is_array($options)) {
        $options = collect($options);
    }
    if ($inline) {
        $html = '<div class="' . $type . '">';
        foreach ($options as $label => $val) {
            $checked = $val == $value ? 'checked' : '';
            $html .= '<label><input type="' . $type . '" value="' . $val . '" ' . $checked . '>' . $label . '</label>&nbsp;';
        }
        $html .= '</div>';
    } else {
        $html = '';
        foreach ($options as $label => $val) {
            $checked = $val == $value ? 'checked' : '';
            $html .= '<div class="' . $type . '">
						<label>
							<input type="' . $type . '" value="' . $val . '" ' . $checked . '>' . $label . '
		  				</label>
					  </div>';
        }
    }
    return $html;
});
Пример #27
0
<?php

/**
 * Form opening tag
 * @param $options The form open options
 * @param $showErrorDiv Display the errors
 */
Form::macro('fopen', function ($options = [], $showErrorDiv = true) {
    $html = '';
    if ($showErrorDiv) {
        $errors = request()->session()->get('errors');
        if ($errors) {
            $html .= '<div class="wrapped-error">
						<div class="alert alert-danger" id="error_scroll">
						<ul>';
            foreach ($errors->default->getMessages() as $error) {
                if (is_array($error)) {
                    $html .= '<li>' . implode('</li><li>', $error) . '</li>';
                } else {
                    $html .= '<li>' . $error . '</li>';
                }
            }
            $html .= '  </ul>
					  	</div>
					  </div>';
        }
    }
    $html .= Form::open($options);
    return $html;
});
Пример #28
0
<?php

Form::macro('ipassword', function ($name, $label, $placeholder = '', $value = '', $required = true, $privileges = null, $permission = null) {
    $disabled = '';
    if ($privileges) {
        $disabled = 'disabled';
        foreach ($privileges as $priv) {
            if ($priv->name === $permission) {
                $disabled = '';
            }
        }
    }
    if ($required) {
        $required = '<span>*</span>';
    }
    $output = '
	<div class="form-group">
        <div class="col-sm-2">
            <label for="' . $name . '" class="control-label">' . $label . $required . '</label>
        </div>
        <div class="col-sm-10">
            <input type="password" class="form-control" id="' . $name . '" name="' . $name . '" placeholder="' . $placeholder . '" value="' . $value . '" ' . $disabled . '/>
        </div>
    </div>';
    return $output;
});
});
Form::macro('selectMultipleField', function ($name, $label = null, $options, $value = null, $attributes = array()) {
    $attributes = array_merge($attributes, ['multiple' => true]);
    $element = Form::select($name, $options, $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('booleanField', function ($name, $label = null, $value = null, $attributes = array()) {
    $attributes = $attributes + ['class' => 'selectize'];
    $element = Form::select($name, [null => 'Select One', 1 => 'Enabled', 0 => 'Disabled'], $value, fieldAttributes($name, $attributes));
    return fieldWrapper($name, $label, $element);
});
Form::macro('checkboxField', function ($name, $label = null, $value = 1, $checked = null, $attributes = array()) {
    $attributes = array_merge(['id' => 'id-field-' . $name], $attributes);
    $out = '<div class="checkbox';
    $out .= fieldError($name) . '">';
    $out .= '<label>';
    $out .= Form::checkbox($name, $value, $checked, $attributes) . ' ' . $label;
    $out .= '</div>';
    return $out;
});
function fieldWrapper($name, $label, $element)
{
    $out = '<div class="form-group';
    $out .= fieldError($name) . '">';
    $out .= fieldLabel($name, $label);
    $out .= $element;
    $out .= fieldMsg($name);
    $out .= '</div>';
    return $out;
}
function fieldMsg($field)
Пример #30
0
<?php

Form::macro('create_form_input', function ($type, $name, $errors, $attr = array()) {
    if ($errors->has($name)) {
        $attr['class'] = 'error';
    }
    switch ($type) {
        case 'password':
            $form = Form::password($name, $attr);
            break;
        case 'textarea':
            $form = Form::textarea($name, Input::old($name), $attr);
            break;
        default:
            $form = Form::text($name, Input::old($name), $attr);
            break;
    }
    return $form . $errors->first($name, ' <span class="error">:message</span>');
});
Form::macro('selected', function ($path) {
    return URI::is($path) ? 'class="selected"' : '';
});
function d($value)
{
    return Laravel\HTML::decode($value);
}