/**
  * Register custom form macros on package start
  * @return void
  */
 public function boot()
 {
     Form::macro('uploadcare', function ($name, $value = null, $options = array()) {
         $options = array_merge($options, array('role' => 'uploadcare-uploader', 'value' => $value));
         return Form::input('hidden', $name, $value, $options);
     });
 }
Example #2
0
 /**
  * Create a Destroy Link
  *
  * @return string
  */
 public function getDestroyLink()
 {
     $route = $this->getPrefix() . $this->getResourceName() . '.forcedestroy';
     if (Route::has($route)) {
         return Form::open(['route' => [$route, $this->id], 'method' => 'post', 'style' => 'display: inline;']) . Form::submit('Delete', ['class' => 'btn btn-xs btn-danger']) . Form::close();
     }
 }
Example #3
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::js('tinymce/tinymce.min.js');
             Rapyd::js('tinymce/tinymce_editor.js');
             $output = Form::textarea($this->name, $this->value, $this->attributes);
             Rapyd::script("function elFinderBrowser (field_name, url, type, win) {" . "tinymce.activeEditor.windowManager.open({" . "file: '" . route('elfinder.tinymce4') . "'," . "title: 'elFinder 2.0'," . "width: 900," . "height: 450," . "resizable: 'yes'" . "}, {" . "setUrl: function (url) {" . "win.document.getElementById(field_name).value = url;" . "}" . "});" . "return false;" . "}");
             Rapyd::script("tinymce.init({selector: '#" . $this->name . "', file_browser_callback : elFinderBrowser, plugins: 'image', convert_urls: false});");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #4
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::js('redactor/jquery.browser.min.js');
             Rapyd::js('redactor/redactor.min.js');
             Rapyd::css('redactor/css/redactor.css');
             $output = Form::textarea($this->name, $this->value, $this->attributes);
             Rapyd::script("\$('#" . $this->name . "').redactor();");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #5
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $label = $this->getLabel();
     $img = '';
     $cssClass = 'file';
     $errorMessage = '';
     $attrs['id'] = $id;
     if (!$this->isValid) {
         $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage());
         $cssClass .= ' error';
     }
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     if ($this->value) {
         $imgPath = $this->getDisplayValue();
         $img = sprintf("<img src='%s' width='90' height='90' />", $imgPath);
     }
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= FormFacade::file($name, $attrs) . $errorMessage;
     $html .= $img;
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
 public function build()
 {
     $output = "";
     if (!isset($this->style)) {
         $this->style = "margin:0 2px 0 0; vertical-align: middle";
     }
     unset($this->attributes['id']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $this->attributes['multiple'] = 'multiple';
             $this->attributes['data-placeholder'] = $this->attributes['placeholder'];
             $this->attributes['placeholder'] = null;
             $output .= Form::select($this->name . '[]', $this->options, $this->values, $this->attributes);
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #7
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             foreach ($this->options as $val => $label) {
                 $this->checked = (!is_null($this->value) and $this->value == $val);
                 $output .= Form::radio($this->name, $val, $this->checked) . ' ' . $label . $this->separator;
             }
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #8
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->checked ? $this->checked_output : $this->unchecked_output;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             //dd($this->checked);
             $output = Form::checkbox($this->name, $this->checked_value, $this->checked, $this->attributes) . $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #9
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $value = $this->getValue();
     $label = $this->getLabel();
     $cssClass = 'ckeditor dynamic-editor';
     $errorMessage = '';
     $attrs['id'] = $id;
     if (!$this->isValid) {
         $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage());
         $cssClass .= ' error';
     }
     $defaultValue = $this->getOption('default_value');
     if (!strlen($value)) {
         $value = $defaultValue;
     }
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     $attrs['rows'] = 4;
     if ($this->getOption('rows')) {
         $attrs['rows'] = $this->getOption('rows');
     }
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= FormFacade::textarea($name, $value, $attrs) . $errorMessage;
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
Example #10
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             $output = $this->value;
             $output = "<div class='help-block' style='background-color:" . $output . "'>&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::css('colorpicker/css/bootstrap-colorpicker.min.css');
             Rapyd::js('colorpicker/js/bootstrap-colorpicker.min.js');
             $output = Form::text($this->name, $this->value, $this->attributes);
             $output .= Rapyd::script("\n                        \$('#" . $this->name . "').colorpicker({\n                            format: 'hex'\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #11
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $output = Form::text($this->name, $this->value, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #12
0
 public function build()
 {
     $output = "";
     unset($this->attributes['type'], $this->attributes['size']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $output = Form::select($this->name, $this->options, $this->value, $this->attributes) . $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #13
0
 public function build()
 {
     $output = "";
     unset($this->attributes['type']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             if (!isset($this->value)) {
                 $value = $this->layout['null_label'];
             } else {
                 $value = str_replace($this->serialization_sep, ' ', $this->value);
             }
             $output = $value;
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             Rapyd::css('datepicker/datepicker3.css');
             Rapyd::js('datepicker/bootstrap-datepicker.js');
             if ($this->language != "en") {
                 Rapyd::js('datepicker/locales/bootstrap-datepicker.' . $this->language . '.js');
             }
             unset($this->attributes['id']);
             //$this->attributes['class'] = "form-control";
             $from = Form::text($this->name . '[from]', @$this->values[0], $this->attributes);
             $to = Form::text($this->name . '[to]', @$this->values[1], $this->attributes);
             $output = '
                         <div id="range_' . $this->name . '_container">
                             <div class="input-daterange">
                                <div class="input-group">
                                    <div class="input-group-addon">&ge;</div>
                                    ' . $from . '
                                </div>
                                <div class="input-group">
                                     <div class="input-group-addon">&le;</div>
                                     ' . $to . '
                                </div>
                             </div>
                         </div>';
             Rapyd::pop_script();
             Rapyd::script("\n                        \$('#range_{$this->name}_container .input-daterange').datepicker({\n                            format: '{$this->formatToDate()}',\n                            language: '{$this->language}',\n                            todayBtn: 'linked',\n                            autoclose: true\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     Form::macro('custom', function ($type, $name, $value = "#000000", $options = []) {
         $field = $this->input($type, $name, $value, $options);
         return $field;
     });
     view()->composer('Ticketit::*', function ($view) {
         $master = config('ticketit.master_template');
         $view->with(compact('master'));
     });
     $this->loadViewsFrom(__DIR__ . '/views', 'Ticketit');
     $this->publishes([__DIR__ . '/views' => base_path('resources/views/vendor/ticketit')], 'views');
     $this->publishes([__DIR__ . '/config/ticketit.php' => config_path('ticketit.php')], 'config');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // Adding HTML5 color picker to form elements
     Form::macro('custom', function ($type, $name, $value = "#000000", $options = []) {
         $field = $this->input($type, $name, $value, $options);
         return $field;
     });
     // Passing to views the master view value from the setting file
     view()->composer('ticketit::*', function ($view) {
         $master = config('ticketit.master_template');
         $view->with(compact('master'));
     });
     // Send notification when new comment is added
     Comment::creating(function ($comment) {
         if (config('ticketit.comment_notification') == 'yes') {
             $notification = new NotificationsController();
             $notification->newComment($comment);
         }
     });
     // Send notification when ticket status is modified
     Ticket::updating(function ($modified_ticket) {
         if (config('ticketit.status_notification') == 'yes') {
             $original_ticket = Ticket::find($modified_ticket->id);
             if ($original_ticket->status->id != $modified_ticket->status->id) {
                 $notification = new NotificationsController();
                 $notification->ticketStatusUpdated($modified_ticket, $original_ticket);
             }
         }
         if (config('ticketit.assigned_notification') == 'yes') {
             $original_ticket = Ticket::find($modified_ticket->id);
             if ($original_ticket->agent->id != $modified_ticket->agent->id) {
                 $notification = new NotificationsController();
                 $notification->ticketAgentUpdated($modified_ticket, $original_ticket);
             }
         }
         return true;
     });
     // Send notification when ticket status is modified
     Ticket::created(function ($ticket) {
         if (config('ticketit.assigned_notification') == 'yes') {
             $notification = new NotificationsController();
             $notification->newTicketNotifyAgent($ticket);
         }
         return true;
     });
     $this->loadViewsFrom(__DIR__ . '/views', 'ticketit');
     $this->publishes([__DIR__ . '/views' => base_path('resources/views/vendor/ticketit')], 'views');
     $this->publishes([__DIR__ . '/config/ticketit.php' => config_path('ticketit.php')], 'config');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->loadViewsFrom(__DIR__ . '/views', 'larastrap');
     Form::component('fhOpen', 'larastrap::form-horizontal.open', ['attributes' => []]);
     Form::component('fhClose', 'larastrap::form-horizontal.close', []);
     Form::component('fhText', 'larastrap::form-horizontal.text', ['name', 'label', 'value' => null, 'attributes' => [], 'size' => [4, 6]]);
     Form::component('fhPassword', 'larastrap::form-horizontal.password', ['name', 'label', 'attributes' => [], 'size' => [4, 6]]);
     Form::component('fhSelect', 'larastrap::form-horizontal.select', ['name', 'label', 'value' => [], 'selected' => null, 'attributes' => [], 'size' => [4, 6]]);
     Form::component('fhSubmit', 'larastrap::form-horizontal.submit', ['text' => 'Submit', 'class' => 'default', 'icon' => 'check', 'size' => [4, 6]]);
     Form::component('fhDateTime', 'larastrap::form-horizontal.datetime', ['name', 'label', 'id' => null, 'value' => null, 'attributes' => [], 'size' => [4, 6]]);
     /*
      * Custom components...
      */
     Html::component('customPageTitle', 'larastrap::custom.page-title', ['title' => 'Page title']);
 }
Example #17
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             break;
         case "create":
         case "modify":
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #18
0
 public function build()
 {
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->value;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             $lower = Form::number($this->name . '[]', @$this->values[0], $this->attributes);
             $upper = Form::number($this->name . '[]', @$this->values[1], $this->attributes);
             $output = '
                         <div id="range_' . $this->name . '_container">
                                <div class="input-group">
                                    <div class="input-group-addon">&ge;</div>
                                    ' . $lower . '
                                </div>
                                <div class="input-group">
                                     <div class="input-group-addon">&le;</div>
                                     ' . $upper . '
                                </div>
                         </div>';
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #19
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $label = $this->getLabel();
     $cssClass = 'file';
     $attrs['id'] = $id;
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     $value = $this->value;
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= view('dynamicfield::admin.dynamicfield.media-link', compact('name', 'id', 'value'))->render();
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
Example #20
0
 /**
  * Render html of field.
  *
  * @return string
  */
 public function render()
 {
     $attrs = array();
     $id = $this->getHtmlId();
     $name = $this->getHtmlName();
     $value = $this->getValue();
     $label = $this->getLabel();
     $cssClass = 'number form-control';
     $errorMessage = '';
     $attrs['id'] = $id;
     if (!$this->isValid) {
         $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage());
         $cssClass .= ' error';
     }
     $defaultValue = $this->getOption('default_value');
     if (!strlen($value)) {
         $value = $defaultValue;
     }
     if ($this->getOption('required') == 'true') {
         $cssClass .= ' required';
     }
     if ($this->getOption('placeholder')) {
         $attrs['placeholder'] = $this->getOption('placeholder');
     }
     if ($this->getOption('min_value')) {
         $attrs['min'] = $this->getOption('min_value');
     }
     if ($this->getOption('max_value')) {
         $attrs['max'] = $this->getOption('max_value');
     }
     $attrs['class'] = $cssClass;
     $html = '';
     if (!empty($label)) {
         $html .= FormFacade::label($label);
     }
     $html .= FormFacade::number($name, $value, $attrs) . $errorMessage;
     $html = sprintf($this->htmlItemTemplate, $html);
     return $html;
 }
 public function build()
 {
     $output = "";
     if (!isset($this->style)) {
         $this->style = "margin:0 2px 0 0; vertical-align: middle";
     }
     unset($this->attributes['id']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = $this->description;
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             //dd($this->options, $this->values);
             foreach ($this->options as $val => $label) {
                 $this->checked = in_array($val, $this->values);
                 //echo ((int)$this->checked)."<br />";
                 $output .= sprintf($this->format, Form::checkbox($this->name . '[]', $val, $this->checked) . $label) . $this->separator;
             }
             $output .= $this->extra_output;
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
Example #22
0
    public function build()
    {
        $output = "";
        //typeahead
        Rapyd::css('autocomplete/autocomplete.css');
        Rapyd::js('autocomplete/typeahead.bundle.min.js');
        Rapyd::js('template/handlebars.js');
        //tagsinput
        Rapyd::css('autocomplete/bootstrap-tagsinput.css');
        Rapyd::js('autocomplete/bootstrap-tagsinput.min.js');
        unset($this->attributes['type']);
        if (parent::build() === false) {
            return;
        }
        switch ($this->status) {
            case "disabled":
            case "show":
                if (!isset($this->value)) {
                    $output = $this->layout['null_label'];
                } else {
                    $output = $this->description;
                }
                $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
                break;
            case "create":
            case "modify":
                $output = Form::text($this->name, '', array_merge($this->attributes, array('id' => "" . $this->name))) . "\n";
                if ($this->remote) {
                    $script = <<<acp

                    \$('#{$this->name}').tagsinput({
                      itemValue: '{$this->record_id}',
                      itemText: '{$this->record_label}'
                    });
                    {$this->fill_tags}

                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('{$this->name}'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: '{$this->remote}?q=%QUERY'
                    });
                    blod_{$this->name}.initialize();

                    \$('#{$this->name}').tagsinput('input').typeahead(null, {
                        name: '{$this->name}',
                        displayKey: '{$this->record_label}',
                        highlight: true,
                        minLength: {$this->min_chars},
                        source: blod_{$this->name}.ttAdapter()
                    }).bind('typeahead:selected', \$.proxy(function (obj, data) {
                        this.tagsinput('add', data);
                        this.tagsinput('input').typeahead('val', '');
                    }, \$('#{$this->name}')));


acp;
                    Rapyd::script($script);
                } elseif (count($this->options)) {
                    $options = json_encode($this->local_options);
                    //options
                    $script = <<<acp

                    var {$this->name}_options = {$options};


                    \$('#{$this->name}').tagsinput({
                      itemValue: 'key',
                      itemText: 'value'
                    });
                    {$this->fill_tags}


                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        local: {$this->name}_options
                    });


                    blod_{$this->name}.initialize();
                    \$('#{$this->name}').tagsinput('input').typeahead({
                         hint: true,
                         highlight: true,
                         minLength: {$this->min_chars}
                    },
                    {
                        name: '{$this->name}',
                        displayKey: 'value',
                        source: blod_{$this->name}.ttAdapter()
                    }).bind('typeahead:selected', \$.proxy(function (obj, data) {
                        this.tagsinput('add', data);
                        this.tagsinput('input').typeahead('val', '');
                    }, \$('#{$this->name}')));

acp;
                    Rapyd::script($script);
                }
                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:
        }
        $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
    }
Example #23
0
 public function build()
 {
     $output = "";
     $this->attributes["class"] = "form-control";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = "<img border=\"0\" src=\"//maps.googleapis.com/maps/api/staticmap?center={$this->value['lat']},{$this->value['lon']}&zoom={$this->zoom}&size=500x500\">";
             }
             $output = "<div class='help-block'>" . $output . "</div>";
             break;
         case "create":
         case "modify":
             $output = Form::hidden($this->lat, $this->value['lat'], ['id' => $this->lat]);
             $output .= Form::hidden($this->lon, $this->value['lon'], ['id' => $this->lon]);
             $output .= '<div id="map_' . $this->name . '" style="width:500px; height:500px"></div>';
             $output .= '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>';
             \Rapyd::script("\n        \n            function initialize()\n            {\n                var latitude = document.getElementById('{$this->lat}');\n                var longitude = document.getElementById('{$this->lon}');\n                var zoom = {$this->zoom};\n        \n                var LatLng = new google.maps.LatLng(latitude.value, longitude.value);\n        \n\n                var mapOptions = {\n                    zoom: zoom,\n                    center: LatLng,\n                    panControl: false,\n                    zoomControl: true,\n                    scaleControl: true,\n                    mapTypeId: google.maps.MapTypeId.ROADMAP\n                }\n        \n                var map = new google.maps.Map(document.getElementById('map_{$this->name}'),mapOptions);\n\n                var marker = new google.maps.Marker({\n                    position: LatLng,\n                    map: map,\n                    title: 'Drag Me!',\n                    draggable: true\n                });\n\n                var update_hidden_fields = function () {\n                    latitude.value = marker.getPosition().lat();\n                    longitude.value = marker.getPosition().lng();\n                }\n                google.maps.event.addListener(marker, 'dragend', update_hidden_fields);\n\n                \$(document.getElementById('map_{$this->name}')).data('map', map);\n                \$(document.getElementById('map_{$this->name}')).data('marker', marker);\n                \$(document.getElementById('map_{$this->name}')).data('update_hidden_fields', update_hidden_fields);\n            }\n            initialize();\n        ");
             break;
         case "hidden":
             $output = '';
             //Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #24
0
 public function prepareForm()
 {
     $form_attr = array('url' => $this->process_url, 'class' => "form-horizontal", 'role' => "form", 'method' => $this->method);
     $form_attr = array_merge($form_attr, $this->attributes);
     // See if we need a multipart form
     foreach ($this->fields as $field_obj) {
         if (in_array($field_obj->type, array('file', 'image'))) {
             $form_attr['files'] = 'true';
             break;
         }
     }
     // Set the form open and close
     if ($this->status == 'show') {
         $this->open = '<div class="form">';
         $this->close = '</div>';
     } else {
         $this->open = Form::open($form_attr);
         $this->close = Form::hidden('save', 1) . Form::close();
         if ($this->method == "GET") {
             $this->close = Form::hidden('search', 1) . Form::close();
         }
     }
     if (isset($this->validator)) {
         $this->errors = $this->validator->messages();
         $this->error .= implode('<br />', $this->errors->all());
     }
 }
Example #25
0
 /**
  * Add a submit button to allow saving the current order of the nodes
  *
  * @param string $name
  * @param string $position
  * @param array $options
  *
  * @return $this
  */
 public function submit($name, $position = "BL", $options = array())
 {
     $options = array_merge(array("class" => "btn btn-primary"), $options);
     $this->button_container[$position][] = Form::submit($name, $options);
     return $this;
 }
Example #26
0
    public function build()
    {
        $output = "";
        Rapyd::css('autocomplete/autocomplete.css');
        Rapyd::js('autocomplete/typeahead.bundle.min.js');
        Rapyd::js('template/handlebars.js');
        unset($this->attributes['type']);
        if (parent::build() === false) {
            return;
        }
        switch ($this->status) {
            case "disabled":
            case "show":
                if (!isset($this->value)) {
                    $output = $this->layout['null_label'];
                } elseif ($this->value == "") {
                    $output = "";
                } else {
                    if ($this->relation != null) {
                        $name = $this->rel_field;
                        $value = @$this->relation->get()->first()->{$name};
                    } else {
                        $value = $this->value;
                    }
                    $output = nl2br(htmlspecialchars($value));
                }
                $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
                break;
            case "create":
            case "modify":
                if (Input::get("auto_" . $this->name)) {
                    $autocomplete = Input::get("auto_" . $this->name);
                } elseif ($this->relation != null) {
                    $name = $this->rel_field;
                    $autocomplete = @$this->relation->get()->first()->{$name};
                } elseif (count($this->local_options)) {
                    $autocomplete = $this->description;
                } else {
                    $autocomplete = $this->value;
                }
                $output = Form::text("auto_" . $this->name, $autocomplete, array_merge($this->attributes, array('id' => "auto_" . $this->name))) . "\n";
                $output .= Form::hidden($this->name, $this->value, array('id' => $this->name));
                $output = '<span id="th_' . $this->name . '">' . $output . '</span>';
                if ($this->remote) {
                    $script = <<<acp

                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('auto_{$this->name}'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        remote: {
                            url: '{$this->remote}?q=%QUERY',
                            ajax: {
                                complete: function(response){
                                    response.responseJSON.forEach(function (item) {
                                        blod_{$this->name}.valueCache[item.{$this->record_label}] = item.{$this->record_id};
                                    });
                                }
                            }
                        }
                    });
                    blod_{$this->name}.valueCache = {};
                    blod_{$this->name}.initialize();

                    \$('#th_{$this->name} .typeahead').typeahead({
                        highlight: true,
                        minLength: {$this->min_chars},
                    }, {
                        displayKey: '{$this->record_label}',
                        name: '{$this->name}',
                        source: blod_{$this->name}.ttAdapter(),
                        templates: {
                            suggestion: Handlebars.compile('{{{$this->record_label}}}')
                        }
                    }).on("typeahead:selected typeahead:autocompleted",
                        function (e,data) {
                            \$('#{$this->name}').val(data.{$this->record_id});
                    }).on("typeahead:closed,typeahead:change",
                        function (e,data) {
                            if ('{$this->must_match}') {
                                var _label = \$.trim(\$(this).val());
                                if ( !(_label in blod_{$this->name}.valueCache) ) {
                                    \$('#{$this->name}').val('');
                                    \$(this).val('');
                                } else {
                                    //Fill data to hidden input, when direct copy data to input without choose from auto-complete results.
                                    \$('#{$this->name}').val(blod_{$this->name}.valueCache[_label]);
                                }
                            } else {
                                if (\$(this).val() == '') {
                                    \$('#{$this->name}').val('');
                                }
                            }
                    });
                    \$('#th_{$this->name} .typeahead').keypress(function (e) {
                        if (e.which == 13) {
                            e.preventDefault();
                        }
                    });
                    
                    
acp;
                    Rapyd::script($script);
                } elseif (count($this->options)) {
                    $options = json_encode($this->local_options);
                    //options
                    $script = <<<acp

                    var {$this->name}_options = {$options};
                    var blod_{$this->name} = new Bloodhound({
                        datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
                        queryTokenizer: Bloodhound.tokenizers.whitespace,
                        local: {$this->name}_options
                    });


                    blod_{$this->name}.initialize();

                    \$('#th_{$this->name} .typeahead').typeahead({
                         hint: true,
                         highlight: true,
                         minLength: {$this->min_chars}
                    },
                    {
                        name: '{$this->name}',
                        displayKey: 'value',
                        source: blod_{$this->name}.ttAdapter()
                    }).on("typeahead:selected typeahead:autocompleted",
                        function (e,data) {
                            \$('#{$this->name}').val(data.key);
                    }).on("typeahead:closed",
                        function (e,data) {
                            if (\$(this).val() == '') {
                                \$('#{$this->name}').val('');
                            }
                    });
acp;
                    Rapyd::script($script);
                }
                break;
            case "hidden":
                $output = Form::hidden($this->db_name, $this->value);
                break;
            default:
        }
        $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
    }
Example #27
0
 public function build()
 {
     $output = "";
     unset($this->attributes['type']);
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "show":
             if (!isset($this->value)) {
                 $value = $this->layout['null_label'];
             } else {
                 $value = $this->isodatetimeToHuman($this->value);
             }
             $output = $value;
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->value != "") {
                 if (!$this->is_refill) {
                     $this->value = $this->isodatetimeToHuman($this->value);
                 }
             }
             Rapyd::css('datetimepicker/datetimepicker3.css');
             Rapyd::js('datetimepicker/bootstrap-datetimepicker.js');
             if ($this->language != "en") {
                 Rapyd::js('datetimepicker/locales/bootstrap-datetimepicker.' . $this->language . '.js');
             }
             $output = Form::text($this->name, $this->value, $this->attributes);
             Rapyd::script("\n                        \$('#" . $this->name . "').datetimepicker({\n                            format: '{$this->formatTodatetime()}',\n                            language: '{$this->language}',\n                            todayBtn: 'linked',\n                            autoclose: true\n                        });");
             break;
         case "hidden":
             $output = Form::hidden($this->db_name, $this->value);
             break;
         default:
     }
     $this->output = $output;
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     $installer = new InstallController();
     // if a migration is missing scape to the installation
     if (empty($installer->inactiveMigrations()) && DB::table('ticketit_settings')->count() != 0) {
         // Send the Agent User model to the view under $u
         view()->composer('*', function ($view) {
             if (auth()->check()) {
                 $u = Agent::find(auth()->user()->id);
                 $view->with('u', $u);
             }
             $setting = new Setting();
             $view->with('setting', $setting);
         });
         // Adding HTML5 color picker to form elements
         CollectiveForm::macro('custom', function ($type, $name, $value = "#000000", $options = []) {
             $field = $this->input($type, $name, $value, $options);
             return $field;
         });
         // Passing to views the master view value from the setting file
         view()->composer('ticketit::*', function ($view) {
             $tools = new ToolsController();
             $master = Setting::grab('master_template');
             $email = Setting::grab('email.template');
             $view->with(compact('master', 'email', 'tools'));
         });
         // Send notification when new comment is added
         Comment::creating(function ($comment) {
             if (Setting::grab('comment_notification')) {
                 $notification = new NotificationsController();
                 $notification->newComment($comment);
             }
         });
         // Send notification when ticket status is modified
         Ticket::updating(function ($modified_ticket) {
             if (Setting::grab('status_notification')) {
                 $original_ticket = Ticket::find($modified_ticket->id);
                 if ($original_ticket->status_id != $modified_ticket->status_id || $original_ticket->completed_at != $modified_ticket->completed_at) {
                     $notification = new NotificationsController();
                     $notification->ticketStatusUpdated($modified_ticket, $original_ticket);
                 }
             }
             if (Setting::grab('assigned_notification')) {
                 $original_ticket = Ticket::find($modified_ticket->id);
                 if ($original_ticket->agent->id != $modified_ticket->agent->id) {
                     $notification = new NotificationsController();
                     $notification->ticketAgentUpdated($modified_ticket, $original_ticket);
                 }
             }
             return true;
         });
         // Send notification when ticket status is modified
         Ticket::created(function ($ticket) {
             if (Setting::grab('assigned_notification')) {
                 $notification = new NotificationsController();
                 $notification->newTicketNotifyAgent($ticket);
             }
             return true;
         });
         $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit');
         $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit');
         $this->publishes([__DIR__ . '/Views' => base_path('resources/views/vendor/ticketit')], 'views');
         $this->publishes([__DIR__ . '/Translations' => base_path('resources/lang/vendor/ticketit')], 'lang');
         $this->publishes([__DIR__ . '/Public' => public_path('vendor/ticketit')], 'public');
         $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db');
         // Check public assets are present, publish them if not
         //            $installer->publicAssets();
         $main_route = Setting::grab('main_route');
         $admin_route = Setting::grab('admin_route');
         include __DIR__ . '/routes.php';
     } elseif (Request::path() == 'tickets-install') {
         $this->loadTranslationsFrom(__DIR__ . '/Translations', 'ticketit');
         $this->loadViewsFrom(__DIR__ . '/Views', 'ticketit');
         $this->publishes([__DIR__ . '/Migrations' => base_path('database/migrations')], 'db');
         Route::get('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@index']);
         Route::post('/tickets-install', ['middleware' => 'auth', 'uses' => 'Kordy\\Ticketit\\Controllers\\InstallController@setup']);
     }
 }
Example #29
0
 public function build()
 {
     $this->path = $this->parseString($this->path);
     $this->web_path = $this->parseString($this->web_path);
     $output = "";
     if (parent::build() === false) {
         return;
     }
     switch ($this->status) {
         case "disabled":
         case "show":
             if ($this->type == 'hidden' || $this->value == "") {
                 $output = "";
             } elseif (!isset($this->value)) {
                 $output = $this->layout['null_label'];
             } else {
                 $output = nl2br(htmlspecialchars($this->value));
             }
             $output = "<div class='help-block'>" . $output . "&nbsp;</div>";
             break;
         case "create":
         case "modify":
             if ($this->old_value) {
                 $output .= '<div class="clearfix">';
                 $output .= link_to($this->web_path . $this->value, $this->value) . "&nbsp;";
                 $output .= Form::checkbox($this->name . '_remove', 1, (bool) Input::get($this->name . '_remove')) . " " . trans('rapyd::rapyd.delete') . " <br/>\n";
                 $output .= '</div>';
             }
             $output .= Form::file($this->name, $this->attributes);
             break;
         case "hidden":
             $output = Form::hidden($this->name, $this->value);
             break;
         default:
     }
     $this->output = "\n" . $output . "\n" . $this->extra_output . "\n";
 }
Example #30
0
 /**
  * Страница редактирования организации
  * @param Organization $organization
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function editPage(Organization $organization)
 {
     FormFacade::model($organization);
     return view('admin.organization.create', ['statuses' => Status::lists('name', 'id'), 'opfs' => Opf::lists('name', 'id'), 'cities' => City::lists('name', 'id'), 'type' => $organization->type_id, 'parent' => $organization->parent, 'organization' => $organization, 'phone' => $organization->phone, 'email' => $organization->email, 'menu' => 'edit']);
 }