Exemple #1
0
 /**
  * Returns the specified color as an HTML label.
  *
  * @param $color
  *
  * @return string
  */
 protected static function formatColorLabel($color)
 {
     $name = ucfirst($color);
     // Cast the raw HTML to string before giving it to the
     // array due to unintentional escaping of it's HTML.
     return (string) HTML::raw("<span class='label label-{$color}'>{$name}</span>");
 }
 /**
  * Creates a new form for changing the current users avatar.
  *
  * @param User $user
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(User $user)
 {
     return $this->form->of('profile.avatar', function (FormGrid $form) use($user) {
         $form->with($user);
         $form->attributes(['url' => route('profile.avatar.change'), 'files' => true]);
         $form->submit = 'Save';
         $form->fieldset(function (Fieldset $fieldset) use($user) {
             if ($user->has_avatar) {
                 $fieldset->control('input:text', 'remove', function ($control) {
                     $control->label = 'Your Current Avatar';
                     // Generate a field for removing images from the current step.
                     $control->field = function () {
                         // Generate the url of the image.
                         $url = route('profile.avatar.download');
                         // Generate the HTML image tag
                         $photo = HTML::image($url, null, ['class' => 'img-responsive avatar']);
                         // Return the result as raw HTML.
                         return HTML::raw("<p><div class='col-xs-6 col-sm-4 col-md-2 text-center'>{$photo}</div></p>");
                     };
                 });
             }
             $fieldset->control('input:file', 'image')->label($user->has_avatar ? 'Replace Image' : 'Image')->help('Selecting an image will delete your current avatar!');
             $fieldset->control('input:checkbox', 'generate')->label('Generate me an Avatar')->help('The generated avatar will be a random color with your initials.')->attributes(['class' => 'switch-mark']);
         });
     });
 }
 /**
  * Returns a label if the current users session is open,
  * otherwise it will return the out datetime.
  *
  * @return string
  */
 public function getOutLabel()
 {
     if (is_null($this->out)) {
         return HTML::create('span', 'Open', ['class' => 'label label-success']);
     } else {
         return $this->out;
     }
 }
Exemple #4
0
 /**
  * The created at tag line accessor.
  *
  * @return string
  */
 public function getCreatedAtTagLineAttribute()
 {
     $user = $this->user->name;
     $daysAgo = $this->created_at_human;
     $created = $this->resolution ? "created resolution {$daysAgo}" : "commented {$daysAgo}";
     $line = HTML::create('span', $created, ['class' => 'hidden-xs']);
     return sprintf('<strong>%s</strong> %s', $user, $line);
 }
 /**
  * Returns a new table for all services.
  *
  * @param Service $service
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(Service $service)
 {
     $service = $service->with('records');
     return $this->table->of('services', function (TableGrid $table) use($service) {
         $table->with($service)->paginate($this->perPage);
         $table->column('name', function (Column $column) {
             $column->value = function (Service $service) {
                 return link_to_route('services.records.index', $service->name, [$service->id]);
             };
         });
         $table->column('last_record_status')->label('Current Status');
         $table->column('description', function (Column $column) {
             $column->value = function (Service $service) {
                 if ($service->description) {
                     return $service->description;
                 }
                 return HTML::create('em', 'None');
             };
         });
     });
 }
 /**
  * Returns a new table of all statuses.
  *
  * @param Status $status
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(Status $status)
 {
     return $this->table->of('work-orders.statuses', function (TableGrid $table) use($status) {
         $table->with($status)->paginate($this->perPage);
         $table->column('Status', function (Column $column) {
             $column->value = function (Status $status) {
                 return link_to_route('maintenance.work-orders.statuses.edit', $status->getLabel(), [$status->getKey()]);
             };
         });
         $table->column('created_at');
         $table->column('created_by', function (Column $column) {
             $column->value = function (Status $status) {
                 if ($status->user instanceof User) {
                     return $status->user->getRecipientName();
                 } else {
                     return HTML::create('em', 'None');
                 }
             };
         });
     });
 }
 /**
  * Returns a new form of the guide step.
  *
  * @param Guide     $guide
  * @param GuideStep $step
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function form(Guide $guide, GuideStep $step)
 {
     return $this->form->of('resources.guides.steps', function (FormGrid $form) use($guide, $step) {
         if ($step->exists) {
             $method = 'patch';
             $url = route('resources.guides.steps.update', [$guide->slug, $step->getPosition()]);
             $form->submit = 'Save';
         } else {
             $method = 'post';
             $url = route('resources.guides.steps.store', [$guide->slug]);
             $form->submit = 'Create';
         }
         $files = true;
         $form->attributes(compact('method', 'url', 'files'));
         $form->with($step);
         $form->layout('pages.resources.guides.steps._form');
         $form->fieldset(function (Fieldset $fieldset) use($guide, $step) {
             $hasImage = count($step->images) > 0;
             foreach ($step->images as $image) {
                 $fieldset->control('input:text', 'remove', function ($control) use($guide, $step, $image) {
                     $control->label = 'Image(s)';
                     // Generate a field for removing images from the current step.
                     $control->field = function () use($guide, $step, $image) {
                         // Generate the url of the image.
                         $url = route('resources.guides.steps.images.download', [$guide->slug, $step->id, $image->uuid]);
                         // Generate the HTML image tag
                         $photo = HTML::image($url, null, ['class' => 'img-responsive']);
                         // Generate the button for deleting the current image.
                         $button = HTML::link(route('resources.guides.steps.images.destroy', [$guide->slug, $step->id, $image->uuid]), 'Delete', ['class' => 'btn btn-danger', 'data-post' => 'DELETE', 'data-title' => 'Delete Image?', 'data-message' => 'Are you sure you want to delete this image?']);
                         // Return the result as raw HTML.
                         return HTML::raw("<div class='col-md-6 text-center'>{$photo} <br> {$button}</div>");
                     };
                 });
             }
             $fieldset->control('input:file', 'image')->label($hasImage ? 'Replace Image(s)' : 'Image');
             $fieldset->control('input:text', 'title')->attributes(['placeholder' => 'Enter the step title']);
             $fieldset->control('input:textarea', 'description')->attributes(['placeholder' => 'Enter the step description']);
         });
     });
 }
 /**
  * Returns a new table of all movements for the specified inventory stock.
  *
  * @param Inventory      $item
  * @param InventoryStock $stock
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function tableMovements(Inventory $item, InventoryStock $stock)
 {
     $movements = $stock->movements();
     return $this->table->of('inventory.stocks.movements', function (TableGrid $table) use($item, $movements) {
         $table->with($movements)->paginate($this->perPage);
         $table->pageName = 'stock-movements';
         $table->column('before');
         $table->column('after');
         $table->column('change');
         $table->column('cost');
         $table->column('reason');
         $table->column('Change By', function (Column $column) {
             return $column->value = function (InventoryStockMovement $movement) {
                 if ($movement->user instanceof User) {
                     return $movement->user->getRecipientName();
                 }
                 return HTML::create('em', 'Unknown');
             };
         });
         $table->column('Change On', 'created_at');
     });
 }
Exemple #9
0
 /**
  * Returns an html label with the color of the status.
  *
  * @return string
  */
 public function getLabel()
 {
     $color = $this->color;
     return HTML::create('span', $this->name, ['class' => "label label-{$color}"]);
 }
Exemple #10
0
 /**
  * Creates a check mark or x icon depending if
  * bool is true or false.
  *
  * @param bool|false $bool
  * @param string     $text
  *
  * @return string
  */
 protected function createCheck($bool = false, $text = '')
 {
     if ($bool) {
         $check = HTML::create('i', '', ['class' => 'fa fa-check']);
         return HTML::raw("<span class='label label-success'>{$check} {$text}</span>");
     } else {
         $check = HTML::create('i', '', ['class' => 'fa fa-times']);
         return HTML::raw("<span class='label label-danger'>{$check} {$text}</span>");
     }
 }
Exemple #11
0
 /**
  * Returns an HTML label for the work orders completed at date.
  *
  * @return string
  */
 public function getCompletedAtLabel()
 {
     if ($this->isComplete()) {
         $class = 'label label-success';
         $icon = 'fa fa-check';
         $message = $this->completed_at;
     } else {
         $class = 'label label-danger';
         $icon = 'fa fa-times';
         $message = 'No report has been created.';
     }
     $icon = HTML::create('i', '', ['class' => $icon]);
     return HTML::raw("<span class='{$class}'>{$icon} {$message}</span>");
 }
Exemple #12
0
 /**
  * Returns an HTML string of the published state of the current guide.
  *
  * @return string
  */
 public function getPublishedLabelAttribute()
 {
     $date = $this->published_on_human;
     $published = $this->published ? "{$date}" : 'No';
     $class = 'label ' . ($this->published ? 'label-success' : 'label-danger');
     return HTML::create('span', $published, compact('class'));
 }
Exemple #13
0
 /**
  * Returns a new table of all revisions.
  *
  * @param string    $for
  * @param MorphMany $revisions
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function tableHistory($for, MorphMany $revisions)
 {
     return $this->table->of("{$for}.revisions", function (TableGrid $table) use($revisions) {
         $table->with($revisions)->paginate($this->perPage);
         $table->pageName = 'history';
         $table->column('user_responsible', function (Column $column) {
             $column->value = function (Revision $revision) {
                 $user = $revision->getUserResponsible();
                 if ($user instanceof User) {
                     return $user->getRecipientName();
                 }
                 return HTML::create('em', 'None');
             };
         });
         $table->column('changed', function (Column $column) {
             $column->value = function (Revision $revision) {
                 return $revision->getColumnName();
             };
         });
         $table->column('from', function (Column $column) {
             $column->value = function (Revision $revision) {
                 $old = $revision->getOldValue();
                 if (is_null($old)) {
                     return HTML::create('em', 'None');
                 }
                 return $old;
             };
         });
         $table->column('to', function (Column $column) {
             $column->value = function (Revision $revision) {
                 $new = $revision->getNewValue();
                 if (is_null($new)) {
                     return HTML::create('em', 'None');
                 }
                 return $new;
             };
         });
         $table->column('On', 'created_at');
     });
 }
Exemple #14
0
 /**
  * The status label accessor.
  *
  * @return string
  */
 public function getStatusLabelAttribute()
 {
     return (string) HTML::create('span', $this->title, ['class' => "label label-{$this->color}"]);
 }
Exemple #15
0
 /**
  * Returns a large variant of the users label.
  *
  * @return string
  */
 public function labelLarge()
 {
     return HTML::create('span', $this->label(), ['class' => 'label-large']);
 }