Add preview from father, add new features

This commit is contained in:
Ludovic CANDELLIER
2021-04-11 00:36:41 +02:00
parent f781158e36
commit f5ca57fdf2
58 changed files with 1482 additions and 532 deletions

View File

@@ -7,23 +7,13 @@ use App\Http\Controllers\Controller;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index()
{
// return redirect('dashboard');
return view('home');
}
}

View File

@@ -2,25 +2,18 @@
namespace App\Repositories\Botanic;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Yajra\DataTables\DataTables;
use Maatwebsite\Excel\Facades\Excel;
use App\Repositories\Core\Tag;
use App\Repositories\Core\Media;
use App\Models\Botanic\Variety;
use App\Exports\Botanic\VarietiesExport;
class Varieties
{
public static function getDatatable()
{
$model = Variety::with('specie');
return Datatables::of($model)->make(true);
}
public static function getOptions()
{
return Variety::orderBy('name')->get()->pluck('name','id')->toArray();
@@ -30,8 +23,7 @@ class Varieties
{
$varieties = Variety::with('specie')->get();
$data = [];
foreach ($varieties as $variety)
{
foreach ($varieties as $variety) {
$data[$variety->id] = (isset($variety->specie->name) ? $variety->specie->name . ' ' : '') . $variety->name;
}
asort($data, SORT_NATURAL | SORT_FLAG_CASE);
@@ -45,7 +37,7 @@ class Varieties
public static function get($id)
{
return Variety::find($id);
return Variety::findOrFail($id);
}
public static function getFull($id)
@@ -58,8 +50,7 @@ class Varieties
public static function getTagsByVariety($variety)
{
$tags = $variety->tags;
return $tags ? $tags->pluck('id')->toArray() : null;
return Tag::getTagsByModel($variety);
}
@@ -89,7 +80,7 @@ class Varieties
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$variety = Variety::find($id);
$variety = self::get($id);
$ret = $variety->update($data);
return $variety;
}
@@ -101,43 +92,22 @@ class Varieties
public static function storeTags($variety, $tags)
{
if ($tags) {
$tags = collect($tags)->transform(function ($item, $key) {
return (int) $item;
})->toArray();
return $variety->syncTags($tags, true);
} else return false;
return Tag::storeTags($variety, $tags);
}
public static function storeImages($variety, $files)
{
if ($files) {
foreach ($files as $file) {
$variety->addMedia($file)->withResponsiveImages()->toMediaCollection('images');
}
}
return Media::storeImages($variety, $files);
}
public static function getImages($id)
{
$variety = self::get($id);
if ($variety) {
$variety->getMedia();
foreach ($variety->media as $key => $media) {
$variety->media[$key]['url'] = $media->getUrl();
}
return $variety->media;
} else {
return false;
}
return Media::getImages(self::get($id));
}
public static function deleteImage($id, $index)
{
$variety = self::get($id);
$variety->getMedia();
$ret = $variety->media[$index]->delete();
return "1";
return Media::deleteImage(self::get($id), $index);
}
public static function exportExcel()

View File

@@ -2,28 +2,69 @@
namespace App\Repositories\Core;
use \Carbon\Carbon;
use \League\Period\Period;
use Carbon\Carbon;
use League\Period\Period;
use League\Period\Duration;
use League\Period\Sequence;
use League\Period\Chart\Dataset;
use function League\Period\duration;
use function League\Period\interval_after;
class DateRange
{
public static function getPeriodsLastMonth($nb)
public static function getPeriodsLastMonthWithLabels($nb, $with_actual = true)
{
$end = static::lastMonth();
$begin = $end->copy()->subMonth($nb);
return static::getPeriodsbyMonth($begin, $end);
$periods = DateRange::PeriodsToCarbon(DateRange::getPeriodsLastMonth($nb, $with_actual));
$labels = DateRange::getMonthNames($periods);
foreach ($labels as $label) {
$data[$label] = $periods;
}
return $data;
}
public static function getPeriodsLastWeek($nb)
public static function getAllMonthNames()
{
$end = static::lastWeek();
return self::getMonthNames(self::PeriodsToCarbon(self::getPeriodsLastMonth(12)));
}
public static function getPeriodsLastMonth($nb = 1, $with_actual = true)
{
$end = $with_actual ? Carbon::now()->endOfMonth() : self::lastMonth();
$begin = ($nb == 1) ? $end->copy()->startOfMonth() : $end->copy()->startOfMonth()->subMonth($nb-1);
$t = self::getPeriodsbyMonth($begin, $end);
return self::getPeriodsbyMonth($begin, $end);
}
public static function getMonthNamesByPeriods($periods)
{
$months = [];
foreach ($periods as $period) {
$date = self::DatePointToCarbon($period->getStartDate());
$months[] = DateTime::getMonthName($date);
}
return $months;
}
public static function getMonthNames($periods)
{
$months = [];
foreach ($periods as $period) {
$months[] = DateTime::getMonthName($period['start']);
}
return $months;
}
public static function getPeriodsLastWeek($nb = 1, $with_actual = true)
{
$end = $with_actual ? Carbon::now()->endOfWeek() : self::lastWeek();
$begin = $end->copy()->subWeek($nb);
return static::getPeriodsbyWeek($begin, $end);
}
public static function getPeriodsLastDay($nb)
public static function getPeriodsLastDay($nb = 1, $with_actual = true)
{
$end = static::lastDay();
$end = $with_actual ? Carbon::now()->endOfDay() : static::lastDay();
$begin = $end->copy()->subDay($nb);
return static::getPeriodsbyDay($begin, $end);
}
@@ -73,42 +114,60 @@ class DateRange
public static function lastMonth()
{
$start = Carbon::parse('first day of last month');
$start->addMonth()->startOfDay();
return $start;
return Carbon::now()->subMonth()->startOfMonth();
}
public static function lastWeek()
{
return Carbon::parse('last monday');
return Carbon::now()->subWeek()->startOfWeek();
}
public static function lastDay()
{
return Carbon::parse('yesterday');
return Carbon::now()->subDay()->startOfDay();
}
public static function getPeriodsbyMonth($begin, $end)
public static function getPeriodsbyMonth($begin, $end, $interval = 1)
{
return (static::getPeriods($begin, $end, 'MONTH'));
return self::getPeriods($begin, $end, "$interval MONTH");
}
public static function getPeriodsbyWeek($begin, $end)
public static function getPeriodsbyWeek($begin, $end, $interval = 1)
{
return (static::getPeriods($begin, $end, 'WEEK'));
return self::getPeriods($begin, $end, "$interval WEEK");
}
public static function getPeriodsbyDay($begin, $end)
public static function getPeriodsbyDay($begin, $end, $interval = 1)
{
return (static::getPeriods($begin, $end, 'DAY'));
return self::getPeriods($begin, $end, "$interval DAY");
}
public static function getPeriods($begin, $end, $interval)
public static function getPeriods($begin, $end, $duration, $interval = 1)
{
$period = new Period($begin, new \DateTime($end));
foreach ($period->getDatePeriod("1 $interval") as $day) {
$daterange[] = Period::createFromDuration($day->format('Y-m-d H:i:s'), "1 $interval");
$period = new Period($begin, $end);
foreach ($period->getDatePeriod($duration) as $day) {
$daterange[] = interval_after($day, $duration);
}
return ($daterange);
return $daterange;
}
public static function PeriodsToCarbon($periods)
{
$data = [];
foreach ($periods as $period) {
$data[] = self::PeriodToCarbon($period);
}
return $data;
}
public static function PeriodToCarbon($period)
{
return ['start' => self::DatePointToCarbon($period->getStartDate()), 'end' => self::DatePointToCarbon($period->getEndDate())];
}
public static function DatePointToCarbon($date)
{
return Carbon::createFromFormat('Y-m-d H:i:s', $date->format('Y-m-d H:i:s'));
}
}

View File

@@ -2,11 +2,66 @@
namespace App\Repositories\Core;
use Illuminate\Support\Str;
use Carbon\Carbon;
use Jenssegers\Date\Date;
use App\Repositories\Languages;
class DateTime
{
public static function getMonthName($date, $short = true)
{
return $short ? self::getUltraShortMonthName($date) : $date->monthName;
}
public static function getShortMonthName($date)
{
return $date->shortMonthName;
}
public static function getUltraShortMonthName($date)
{
return strtoupper(Str::ascii(mb_substr($date->shortMonthName,0,3)));
}
public static function getDayName($date, $short = true)
{
return $short ? $date->shortDayName : $date->dayName;
}
public static function DatetoLocale($date = null)
{
$format = self::getLocaleFormatDate();
if (!is_null($date) && !empty($date)) {
$date = Carbon::parse($date)->format($format);
} elseif ($date == 'now') {
$date = Carbon::now()->format($format);
}
return $date;
}
public static function DatetimeToLocale($date = null)
{
$format = self::getLocaleFormatDatetime();
if (!is_null($date) && !empty($date)) {
$date = Carbon::parse($date)->format($format);
} elseif ($date == 'now') {
$date = Carbon::now()->format($format);
}
return $date;
}
public static function getDateTime()
{
return self::DatetimeToLocale(date('Y-m-d H:i:s'));
}
public static function getDate()
{
return self::DateToLocale(date('Y-m-d'));
}
public static function getLang()
{
return session('locale') ? session('locale') : 'fr';
@@ -14,46 +69,79 @@ class DateTime
public static function convert($date)
{
return $date ? Carbon::createFromFormat('d/m/Y', $date)->isoFormat('Y-MM-DD') : null;
$format = self::getLocaleFormatDate();
return !empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD') : null;
}
public static function convertTime($date)
{
return $date ? Carbon::createFromFormat('d/m/Y H:i', $date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
$format = self::getLocaleFormatDatetime();
return !empty($date) ? Carbon::createFromFormat($format, $date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
}
public static function toFr($date)
{
return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
return !empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y') : null;
}
public static function toFrTime($date)
{
return $date ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
return !empty($date) ? Carbon::parse($date)->isoFormat('DD/MM/Y HH:mm:ss') : null;
}
public static function FromDatetimeFr($date)
public static function getYearFromDate($date)
{
return $date ? Carbon::createFromFormat('d/m/Y H:i:s', $date) : null;
// return date_format(DateTime::convert($signature_date), 'Y');
$date = DateTime::convert($date);
$date = date_create($date);
return date_format($date, 'Y');
}
public static function DatetimeToStamp($date)
public static function getLocaleFormatDate()
{
return $date ? self::FromDatetimeFr($date)->isoFormat('Y-MM-DD HH:mm:ss') : null;
$locale = self::getLang();
switch ($locale) {
case 'fr':
case 'en':
$format = 'd/m/Y';
break;
default:
$format = 'Y-m-d';
}
return $format;
}
public static function DatetimeToDate($date)
public static function getLocaleFormatDatetime()
{
return $date ? self::FromDatetimeFr($date)->isoFormat('DD/MM/Y') : null;
$locale = self::getLang();
switch ($locale) {
case 'fr':
case 'en':
$format = 'd/m/Y H:i:s';
break;
default:
$format = 'Y-m-d H:i:s';
}
return $format;
}
public static function DatetimeToTime($date)
public static function getLocaleDateFull($date)
{
return $date ? self::FromDatetimeFr($date)->isoFormat('HH:mm') : null;
return Carbon::parse($date)->isoFormat('LLLL');
}
public static function isPast($date)
public static function getLocaleDateFullShort($date)
{
return Carbon::parse($date)->isoFormat('lll');
}
public static function getLocaleHour($date)
{
return Carbon::parse($date)->isoFormat('');
}
public static function relativeTime()
{
return self::FromDatetimeFr($date)->isPast();
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace App\Repositories\Core;
use Qoraiche\MailEclipse\MailEclipse;
use Illuminate\Support\Facades\DB;
class Mailer
{
public static function getTemplates()
{
// $mailables = MailEclipse::getMailables();
// DB::rollBack();
// dump($mailables);
/*
$mailables = (null !== $mailables) ? $mailables->sortBy('name') : collect([]);
foreach ($mailables as $mailable)
{
$templates[] = $mailable['name'];
}
*/
$templates = ['EventInscription','EventSaveTheDate','MatinalesBadge','MatinalesThanks','MatinalesReplays'];
return $templates;
}
public static function getTemplate($template_id)
{
$templates = self::getTemplates();
return $templates[$template_id];
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace App\Repositories\Core;
class Media
{
public static function getImages($model) {
if ($model) {
$model->getMedia();
foreach ($model->media as $key => $media) {
$model->media[$key]['url'] = $media->getUrl();
}
return $model->media;
} else {
return false;
}
}
public static function storeImages($model, $files)
{
if ($files) {
foreach ($files as $file) {
self::storeImage($model, $file);
}
}
}
public static function storeImage($model, $file)
{
return $model->addMedia($file)->withResponsiveImages()->toMediaCollection('images');
}
public static function deleteImage($model, $index)
{
$model->getMedia();
$ret = $model->media[$index]->delete();
return "1";
}
public static function getThumbSrc($image)
{
if (!$image) {
return null;
}
$id = $image['id'];
$images = json_decode($image['responsive_images'], true);
$urls = $images['medialibrary_original']['urls'];
$img = $urls[count($urls)-1];
$src = "storage/$id/responsive-images/$img";
return $src;
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace App\Repositories\Core;
class Tag
{
public static function getTagsByModel($model)
{
$tags = $model->tags;
return $tags ? $tags->pluck('id')->toArray() : null;
}
public static function storeTags($model, $tags)
{
if ($tags) {
$tags = collect($tags)->transform(function ($item, $key) {
return (int) $item;
})->toArray();
return $model->syncTags($tags, true);
} else return false;
}
}

View File

@@ -1,55 +0,0 @@
<?php
namespace App\Repositories\Core;
use Yajra\DataTables\DataTables;
use App\Models\Botanic\Family;
class Tags
{
public static function getDatatable()
{
$model = Family::orderBy('name');
return Datatables::of($model)->make(true);
}
public static function getOptions()
{
return Family::get()->SortBy('name')->pluck('name','id')->toArray();
}
public static function getAll()
{
return Family::orderBy('name','asc')->get();
}
public static function get($id)
{
return Family::find($id);
}
public static function store($data)
{
$id = isset($data['id']) ? $data['id'] : false;
$item = $id ? self::update($data) : self::create($data);
return $item->id;
}
public static function create($data)
{
return Family::create($data);
}
public static function update($data)
{
return Family::find($id)->update($data);
}
public static function destroy($id)
{
return Family::destroy($id);
}
}

View File

@@ -11,8 +11,9 @@ class Upload
public static function getData($file)
{
$data['filename'] = $file->getClientOriginalName();
$data['filetype'] = $file->extension();
$data['filetype'] = $file->getClientOriginalExtension();
$data['filesize'] = $file->getSize();
$data['mime'] = $file->getMimeType();
return $data;
}
@@ -21,25 +22,34 @@ class Upload
$data = (is_array($data)) ? (object) $data : $data;
$pos = strrpos($file, '/');
$uuid = substr($file, $pos+1);
$uuid = str_replace('.' . $data->filetype, '', $uuid);
$uuid = pathinfo($uuid, PATHINFO_FILENAME);
// $uuid = str_replace('.' . strtolower($data->filetype), '', $uuid);
// $uuid = str_replace('.' . $data->filetype, '', $uuid);
return $uuid;
}
public static function store($file, $filepath)
public static function storeByVar($var, $path, $public = false)
{
return $file->store($filepath);
// check if filename exists
// store
// Storage::disk('local')->put('file.txt', 'Contents');
// $path = Storage::putFile('avatars', $request->file('avatar'));
// $path = $request->file('avatar')->storeAs('avatars',$request->user()->id,'s3');
// $path = $request->file('avatar')->storePublicly('avatars', 's3');
return $request->has($var) ? basename($request->file($var)->store($path)) : false;
}
public static function store($file, $path)
{
return Storage::putFile($path, $file);
// return $file->store($filepath);
}
public static function storePublic($file, $filepath)
{
// exit;
$filepath = 'public/' . $filepath;
return $file->store($filepath);
}
public static function delete($file)
{
return Storage::delete($file);
return Storage::putFile($filepath, $file, 'public');
// $filepath = 'public/' . $filepath;
// return $file->store($filepath);
}
public static function createThumb($file, $size, $sub = false)
@@ -96,6 +106,59 @@ class Upload
public static function getName($file)
{
$file = (is_array($file)) ? (object) $file : $file;
return $file->uuid . '.' .$file->filetype;
return $file->uuid . '.' . strtolower($file->filetype);
}
/**
* [fix problem path with Storage on Windows]
* @param [type] $path [description]
* @return [type] [description]
*/
public static function fix($path)
{
if (self::isWindows()) {
return str_replace('/', '\\', $path);
} else {
return $path;
}
}
public static function move($source, $dest)
{
if (Storage::exists($dest)) {
self::delete($dest);
}
return Storage::move($source, $dest); // transfère et renomme le fichier du dossier temporaire au dossier du client
}
public static function delete($file)
{
// Storage::delete($file);
// return unlink($file);
return Storage::delete($file);
}
public static function deleteFile($path)
{
if (Storage::exists($path)) {
return Storage::delete($path);
} else {
return false;
}
}
public static function deleteRecursive($path)
{
rmdir_recursive($targetDir);
}
public function make_dir($path, $permissions = 0777)
{
return is_dir($path) || mkdir($path, $permissions, true);
}
public static function isWindows()
{
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
}
}

View File

@@ -0,0 +1,63 @@
<?php
namespace App\Repositories\Core\User;
class Basket
{
public static function first($key)
{
$data = self::get($key);
return array_shift($data);
}
public static function last($key)
{
$data = self::get($key);
return $data ? array_pop($data) : false;
}
public static function set($key, $data)
{
return session([$key => $data]);
}
public static function get($key)
{
return session($key);
}
public static function add($key, $value)
{
$data = self::isExist($key) ? self::get($key) : [];
if (array_search($value, $data) === false) {
array_push($data, $value);
self::set($key, $data);
}
return count($data);
}
public static function remove($key, $value)
{
$data = self::get($key);
if (($index = array_search($value, $data)) !== false) {
unset($data[$index]);
}
return self::set($key, $data);
}
public static function isExist($key)
{
return session()->has($key);
}
public static function reset($key)
{
return session()->forget($key);
}
public static function resetAll()
{
return session()->flush();
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace App\Repositories\Core\User\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NewUser extends Notification
{
use Queueable;
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
*
* @return string[]
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$currentUser = \Auth::user();
return (new MailMessage())
->markdown('notifications.email')
->greeting(__('notifications.greeting', ['firstname' => $notifiable->first_name]))
->subject(__('notifications.newuser.subject', ['name' => config('app.name')]))
->line(__('notifications.newuser.intro', [
'name' => $currentUser->first_name.' '.$currentUser->last_name,
]))
->action(
__('notifications.newuser.button'),
route('users.firstlogin', $notifiable->remember_token)
)
->salutation(__('notifications.salutation', [
'name' => $currentUser->first_name.' '.$currentUser->last_name,
]))
->line(__('notifications.newuser.outro'));
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
*
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Repositories\Core\User\Notifications;
use Illuminate\Notifications\Messages\MailMessage;
class ResetPassword extends \Illuminate\Auth\Notifications\ResetPassword
{
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
/*
public function toMail($notifiable)
{
return (new MailMessage())
->markdown('notifications.email')
->greeting(__('notifications.greeting', ['firstname' => $notifiable->first_name]))
->subject(__('notifications.resetpassword.subject'))
->line(__('notifications.resetpassword.intro'))
->action(
__('notifications.resetpassword.button'),
route('password.reset', $this->token)
)
->line(__('notifications.resetpassword.outro'));
}
*/
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Repositories\Core\User;
use App\Models\Core\Auth\PasswordReset;
class PasswordResets
{
public static function getTokenByEmail($email)
{
return PasswordReset::byEmail($email)->first();
}
public static function getEmailByToken($token)
{
return PasswordReset::byToken($token)->first();
}
}

View File

@@ -2,12 +2,10 @@
namespace App\Repositories\Shop;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Yajra\DataTables\DataTables;
use App\Repositories\Core\Tag;
use App\Repositories\Core\Media;
use App\Repositories\Botanic\Species;
use App\Repositories\Botanic\Varieties;
use App\Models\Shop\Article;
@@ -15,12 +13,6 @@ use App\Models\Shop\Article;
class Articles
{
public static function getDatatable()
{
$model = Article::orderBy('name');
return Datatables::of($model)->make(true);
}
public static function getAll()
{
return Article::orderBy('name','asc')->get();
@@ -28,11 +20,11 @@ class Articles
public static function getFull($id)
{
$article = Article::with('product')->findOrFail($id);
$data = $article->toArray();
$data['categories'] = self::getCategoriesByArticle($article);
$data['tags'] = self::getTagsByArticle($article);
$data['prices'] = self::getPricesByArticle($article);
$article = Article::with('product.tags')->findOrFail($id);
$data['article'] = $article->toArray();
$data['article']['categories'] = self::getCategoriesByArticle($article);
$data['article']['tags'] = self::getTagsByArticle($article);
$data['article']['prices'] = self::getPricesByArticle($article);
self::getMeta($data);
return $data;
}
@@ -53,7 +45,6 @@ class Articles
public static function getByCategory($category_id)
{
// TODO add category
return Article::with(['prices','product','image'])->get();
}
@@ -109,7 +100,7 @@ class Articles
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$article = Article::find($id);
$article = self::get($id);
$ret = $article->update($data);
return $article;
}
@@ -133,12 +124,7 @@ class Articles
public static function storeTags($article, $tags)
{
if ($tags) {
$tags = collect($tags)->transform(function ($item, $key) {
return (int) $item;
})->toArray();
return $article->syncTags($tags, true);
} else return false;
return Tag::storeTags($article, $tags);
}
public static function storePrices($article, $prices)
@@ -148,55 +134,27 @@ class Articles
public static function storeImages($article, $files)
{
if ($files) {
foreach ($files as $file) {
self::storeImage($article, $file);
}
}
return Media::storeImages($article, $files);
}
public static function storeImage($article, $file)
{
return $article->addMedia($file)->withResponsiveImages()->toMediaCollection('images');
return Media::storeImage($article, $file);
}
public static function getImages($id)
{
$article = self::get($id);
if ($article)
{
$article->getMedia();
foreach ($article->media as $key => $media) {
$article->media[$key]['url'] = $media->getUrl();
}
return $article->media;
} else {
return false;
}
return Media::getImages(self::get($id));
}
public static function getThumbSrc($image)
{
if (!$image) {
return null;
return Media::getThumbSrc($image);
}
$id = $image['id'];
$images = json_decode($image['responsive_images'], true);
$urls = $images['medialibrary_original']['urls'];
$img = $urls[count($urls)-1];
$src = "storage/$id/responsive-images/$img";
return $src;
}
public static function deleteImage($id, $index)
{
$article = self::get($id);
$article->getMedia();
$ret = $article->media[$index]->delete();
return "1";
return Media::deleteImage(self::get($id), $index);
}
}

View File

@@ -18,6 +18,7 @@
"beyondcode/laravel-comments": "^1.2",
"box/spout": "^3.1",
"browner12/helpers": "^3.0",
"cesargb/laravel-cascade-delete": "^1.2",
"coduo/php-humanizer": "^3.0",
"consoletvs/charts": "^6.5",
"cornford/googlmapper": "^2.3",
@@ -67,8 +68,8 @@
"rinvex/laravel-categories": "^3.0",
"rinvex/laravel-tags": "^3.0",
"rutorika/sortable": "^6.0",
"santigarcor/laratrust": "^5.2",
"sebastienheyd/boilerplate": "^7.1",
"santigarcor/laratrust": "^6.0",
"sebastienheyd/boilerplate": "^7.3",
"sebastienheyd/boilerplate-email-editor": "^8.0",
"sebastienheyd/boilerplate-media-manager": "^7.0",
"sensiolabs/security-checker": "^6.0",

View File

@@ -96,6 +96,7 @@
"izimodal": "^1.5.1",
"jQuery-QueryBuilder": "^2.5.2",
"jqtree": "^1.4.12",
"jquery": "^3.5.1",
"jquery-confirm": "^3.3.4",
"jquery-form": "^4.2.2",
"jquery-jeditable": "^2.0.13",

View File

@@ -7,7 +7,7 @@
@section('content')
{{ Form::open(['route' => 'Shop.Admin.Articles.store', 'id' => 'article-form', 'autocomplete' => 'off', 'files' => true]) }}
<input type="hidden" name="id" id="id" value="{{ $id }}">
<input type="hidden" name="id" id="id" value="{{ $article['id'] ?? null }}">
@include('Shop.Admin.Articles.form')
</form>

View File

@@ -4,53 +4,58 @@
<div class="row">
<div class="col-2">
{{ Form::label('ref', 'Référence') }}<br>
@include('components.input', ['name' => 'ref', 'value' => isset($ref) ? $ref : null])
@include('components.input', ['name' => 'ref', 'value' => $article['ref'] ?? null])
</div>
<div class="col-4">
{{ Form::label('model', 'Familles de produit') }}<br>
@include('components.select', ['name' => 'product_type', 'id_name' => 'product_type', 'list' => $models_options, 'value' => isset($product_type) ? $product_type : null, 'class' => 'select2 form-control'])
@include('components.select', ['name' => 'product_type', 'id_name' => 'product_type', 'list' => $models_options, 'value' => $article['product_type'] ?? null, 'class' => 'select2 form-control'])
</div>
<div class="col-6">
{{ Form::label('model_id', 'Produit') }}<br>
@include('components.select', ['name' => 'product_id', 'id_name' => 'product_id', 'list' => $products ?? [], 'value' => isset($product_id) ? $product_id : null, 'class' => 'select2 form-control'])
@include('components.select', ['name' => 'product_id', 'id_name' => 'product_id', 'list' => $products ?? [], 'value' => $article['product_id'] ?? null, 'class' => 'select2 form-control'])
</div>
</div>
<div class="row">
<div class="col-8">
{{ Form::label('name', 'Nom') }}<br>
@include('components.input', ['name' => 'name', 'value' => isset($name) ? $name : null, 'required' => true])
@include('components.input', ['name' => 'name', 'value' => $article['name'] ?? null, 'required' => true])
</div>
<div class="col-4">
{{ Form::label('family_id', 'Famille d\'articles') }}<br>
@include('components.select', ['name' => 'article_family_id', 'list' => $families_options, 'value' => isset($article_family_id) ? $article_family_id : null, 'class' => 'select2 form-control'])
@include('components.select', ['name' => 'article_family_id', 'list' => $families_options, 'value' => $article['article_family_id'] ?? null, 'class' => 'select2 form-control'])
</div>
</div>
<div class="row">
<div class="col-12">
{{ Form::label('categories', 'Rayons') }}<br>
@include('components.select', ['name' => 'categories[]', 'list' => $categories_options, 'values' => isset($categories) ? $categories : null, 'class' => 'select2 form-control', 'multiple' => true])
@include('components.select', ['name' => 'categories[]', 'list' => $categories_options, 'values' => $article['categories'] ?? null, 'class' => 'select2 form-control', 'multiple' => true])
</div>
</div>
<div class="row">
<div class="col-12">
{{ Form::label('tags', 'Tags') }}<br>
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => isset($tags) ? $tags : null, 'class' => 'select2 form-control', 'multiple' => true])
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $article['tags'] ?? null, 'class' => 'select2 form-control', 'multiple' => true])
</div>
</div>
<div class="row">
<div class="col-12">
{{ Form::label('description', 'Description') }}
@include('components.textarea', ['name' => 'description', 'value' => isset($description) ? $description : null, 'class' => 'editor', 'required' => true])
@if (!empty($article['product']['description']))
@component('components.layout.box-collapse', ['id' => 'product_description', 'title' => 'Description produit'])
{{ $article['product']['description'] }}
@endcomponent
@endif
@include('components.textarea', ['name' => 'description', 'value' => $article['description'] ?? null, 'class' => 'editor', 'required' => true])
</div>
</div>
</div>
<div class="col-md-4">
@include('components.uploader.widget', ['load_url' => route('Shop.Admin.Articles.getImages', ['id' => (isset($id)) ? $id : false]), 'delete_url' => route('Shop.Admin.Articles.deleteImage') ])
@include('components.uploader.widget', ['load_url' => route('Shop.Admin.Articles.getImages', ['id' => $article['id'] ?? false]), 'delete_url' => route('Shop.Admin.Articles.deleteImage'), 'title' => 'Photos' ])
</div>
</div>

View File

@@ -1,2 +1,2 @@
@include('Shop.Admin.Articles.partials.prices.prices', ['prices' => $prices['prices'] ?? null])
@include('Shop.Admin.Articles.partials.generic_prices.generic_prices', ['generics' => $prices['generics'] ?? null])
@include('Shop.Admin.Articles.partials.prices.prices', ['prices' => $article['prices']['prices'] ?? null])
@include('Shop.Admin.Articles.partials.generic_prices.generic_prices', ['generics' => $article['prices']['generics'] ?? null])

View File

@@ -1,9 +0,0 @@
<div class="datatable-export-buttons">
@include('components.datatables.buttons.print')
@if (isset($with_exports) && $with_exports)
@include('components.datatables.buttons.download')
@endif
</div>

View File

@@ -38,7 +38,11 @@
headers: {'X-CSRF-TOKEN': '{{ csrf_token() }}'},
success: function(){
// line.remove();
@if (isset($delete_callback))
{{ $delete_callback }}
@else
table.draw();
@endif
growl("{{ __('admin.deletesuccess') }}", 'success');
}
});

View File

@@ -1,4 +1,4 @@
@include('load.autocomplete')
@include('load.form.autocomplete')
<input type="hidden" name="{{ $name }}_id" id="{{ $name }}_id" value="{{ $data['id'] ?? null }}">
<input type="text" name="{{ $name }}_name" class="form-control autocomplete" value="{{ $data['name'] ?? ''}}" data-url="{{ $url ?? ''}}" data-field="{{ $name }}_id" autocomplete="off">

View File

@@ -1,4 +1,4 @@
@include('load.datepicker')
@include('load.form.datepicker')
<div class="input-group date" data-target-input="nearest">
@include('components.input', ['class' => 'datepicker', 'meta' => 'data-target="#'.str_slug($name).'"', 'placeholder' => App\Repositories\Core\DateTime::getLocaleFormatDate() ])

View File

@@ -7,7 +7,7 @@
@if(!defined('LOAD_EDITOR'))
@include('load.editor')
@include('load.form.editor.editor')
@push('js')
<script>
$(function() {

View File

@@ -3,7 +3,7 @@
@include('components.input', ['type' => 'number', 'meta' => "step = '.01'"])
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" aria-haspopup="true" aria-expanded="false">
<button class="btn bg-light" type="button" aria-haspopup="false" aria-expanded="false">
%
</button>
</div>

View File

@@ -15,5 +15,5 @@
</select>
@if(!defined('LOAD_SELECT2'))
@include('load.select2')
@include('load.form.select2')
@endif

View File

@@ -1,3 +1,4 @@
<input type="checkbox" name="{{ $name ?? ''}}" id="{{ $id_name ?? $name ?? '' }}" class="{{ $class ?? 'toggle'}}" value="{{ $val ?? 1}}" data-toggle="toggle" data-on="{{ $on ?? __('yes') }}" data-off="{{ $off ?? __('no') }}" data-onstyle="{{ $onstyle ?? 'outline-success'}}" data-offstyle="{{ $offstyle ?? 'outline-danger'}}" data-size="{{ $size ?? 'sm' }}" @if ( (isset($value) && isset($val) && ($value == $val)) || (!isset($val) && isset($value) && $value)) checked @endif {{ $disabled ?? ''}} {{ $meta ?? ''}} >
<input type="hidden" name="{{ $name ?? ''}}" value="0">
<input type="checkbox" name="{{ $name ?? ''}}" id="{{ $id_name ?? $name ?? '' }}" class="{{ $class ?? 'toggle'}}" value="{{ $val ?? 1}}" data-toggle="toggle" data-on="{{ $on ?? __('yes') }}" data-off="{{ $off ?? __('no') }}" data-onstyle="{{ $onstyle ?? 'outline-success'}}" data-offstyle="{{ $offstyle ?? 'outline-danger'}}" data-size="{{ $size ?? '' }}" @if ( (isset($value) && isset($val) && ($value == $val)) || (!isset($val) && isset($value) && $value)) checked @endif {{ $disabled ?? ''}} {{ $meta ?? ''}} >
@include('load.toggle')
@include('load.form.toggle')

View File

@@ -5,7 +5,7 @@
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#{{ $id }}" aria-expanded="false" aria-controls="{{ $id }}">
<i class="fa fa-chevron-right"></i>
</button>
{!! $title !!}
{!! $title ?? null !!}
@if (isset($required) && $required)
<sup>*</sup>
@endif

View File

@@ -1,10 +1,10 @@
<div class="col row-new-image row-image mt-3 mb-2">
<div class="col {{ $prefix ?? '' }}row-new-image row-image mt-3 mb-2">
<p>
<button type="button" class="btn btn-danger delete-new-image-btn"><i class="fa fa-minus-circle"></i></button>
Photo <span class="row-image-number"></span>
<button type="button" class="btn btn-danger {{ $prefix ?? '' }}delete-new-image-btn"><i class="fa fa-minus-circle"></i></button>
Photo <span class="{{ $prefix ?? '' }}row-image-number"></span>
</p>
<input name="images[]" type="file" class="file" data-show-upload="false" data-show-caption="true" data-msg-placeholder="Choisissez une photo">
<input name="{{ $prefix ?? '' }}images[]" type="file" class="file" data-show-upload="false" data-show-caption="true" data-msg-placeholder="Choisissez une photo">
</div>

View File

@@ -2,6 +2,7 @@
@foreach($images as $key => $image)
<figure class="mr-2">
<img src="{{ $image['url'] }}" class="img-thumbnail img-caption" style="max-height:92px;">
@if ($can_edit ?? true)
<figcaption class="text-center pt-2">
<button type="button" class="btn btn-xs btn-outline-secondary">
<i class="fas fa-expand-alt"></i>
@@ -10,11 +11,14 @@
<i class="fas fa-trash" data-index="{{ $key }}"></i>
</button>
</figcaption>
@endif
</figure>
@endforeach
@endif
@if ($can_edit ?? true)
<script>
handleDeleteImages();
handleEnlargeImages();
{{ $prefix ?? '' }}handleDeleteImages();
{{ $prefix ?? '' }}handleEnlargeImages();
</script>
@endif

View File

@@ -1,14 +1,14 @@
<div class="row" id="uploader-mini-gallery"></div>
<div class="row" id="{{ $prefix ?? '' }}uploader-mini-gallery"></div>
<div class="modal fade" id="mini-gallery-lightbox" tabindex="-1" role="dialog" aria-labelledby="mini-gallery-lightbox" aria-hidden="true">
<div class="modal fade" id="{{ $prefix ?? '' }}mini-gallery-lightbox" tabindex="-1" role="dialog" aria-labelledby="mini-gallery-lightbox" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="mini-gallery-title-lightbox"></h5>
<h5 class="modal-title"></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
</div>
<div class="modal-body">
<img src="" id="mini-gallery-img-lightbox" class="img-fluid" >
<img src="" class="img-fluid lightbox" >
</div>
</div>
</div>
@@ -16,8 +16,8 @@
@push('js')
<script>
function handleDeleteImages() {
$('#uploader-mini-gallery .fa-trash').click(function() {
function {{ $prefix ?? '' }}handleDeleteImages() {
$('#{{ $prefix ?? '' }}uploader-mini-gallery .fa-trash').click(function() {
id = $('#id').val();
index = $(this).data('index');
console.log(id);
@@ -35,13 +35,13 @@
})
}
function handleEnlargeImages() {
$('#uploader-mini-gallery .fa-expand-alt').click(function() {
function {{ $prefix ?? '' }}handleEnlargeImages() {
$('#{{ $prefix ?? '' }}uploader-mini-gallery .fa-expand-alt').click(function() {
$img = $(this).parents('figure').find('.img-thumbnail');
url = $img.attr('src');
console.log(url);
$('#mini-gallery-img-lightbox').attr('src', url);
$('#mini-gallery-lightbox').modal('show');
$('#{{ $prefix ?? '' }}mini-gallery-lightbox .lightbox').attr('src', url);
$('#{{ $prefix ?? '' }}mini-gallery-lightbox').modal('show');
})
}
</script>

View File

@@ -2,51 +2,57 @@
<div class="card">
<div class="card-header">
<h3 class="card-title">Photos</h3>
<h3 class="card-title">{{ $title }}</h3>
<div class="card-tools">
</div>
</div>
<div class="card-body pt-3 pb-0">
@if (isset($id))
@if (isset($article['id']))
@include('components.uploader.mini-gallery')
@endif
<div id="uploader-new-images"></div>
@if ($can_edit ?? true)
<div id="{{ $prefix ?? '' }}uploader-new-images"></div>
@include('components.uploader.block_image_new', ['name' => 'images[]', 'required' => true])
@endif
</div>
@if ($can_edit ?? true)
<div class="card-footer">
<button type="button" class="btn btn-xs btn-primary add-image pull-right">Ajout <i class="fa fa-plus"></i></button>
<button type="button" class="btn btn-xs btn-primary {{ $prefix ?? '' }}add-image pull-right">Ajout <i class="fa fa-plus"></i></button>
</div>
@endif
</div>
@push('js')
<script>
function append_image() {
$("#uploader-new-images .file").fileinput();
$("#uploader-new-images .file").focus();
function {{ $prefix ?? '' }}append_image() {
$("#{{ $prefix ?? '' }}uploader-new-images .file").fileinput();
$("#{{ $prefix ?? '' }}uploader-new-images .file").focus();
}
$("#uploader-new-images").appender({
rowSection: '.row-new-image',
type: '.row-image',
addBtn: '.add-image',
$("#{{ $prefix ?? '' }}uploader-new-images").appender({
rowSection: '.{{ $prefix ?? '' }}row-new-image',
type: '.{{ $prefix ?? '' }}row-image',
addBtn: '.{{ $prefix ?? '' }}add-image',
appendEffect: 'fade',
addClass: 'animated fadeIn',
rowNumber: '.row-image-number',
deleteBtn: '.delete-new-image-btn',
callback: append_image,
rowNumber: '.{{ $prefix ?? '' }}row-image-number',
deleteBtn: '.{{ $prefix ?? '' }}delete-new-image-btn',
callback: {{ $prefix ?? '' }}append_image,
hideSection: true
});
function loadImages()
{
$gallery = $("#uploader-mini-gallery");
$gallery = $("#{{ $prefix ?? '' }}uploader-mini-gallery");
if ($gallery) {
$gallery.load("{{ $load_url }}");
}
}
$(function() {
loadImages();
});
</script>
@endpush

View File

@@ -6,6 +6,9 @@
@section('content')
@component('components.layout.box-collapse', ['title' => __('person_in_charge'), 'id' => 'form-contact'])
TEST
@endcomponent
@endsection

View File

@@ -35,7 +35,6 @@
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('admin') }}"><i class="fa fa-cog"></i> Accès à l'administration</a>
<a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
Déconnexion

View File

@@ -0,0 +1,77 @@
@if(!defined('LOAD_APPENDER'))
@push('js')
<script>
(function ($) {
$.fn.appender = function (settings) {
let appendArea = this;
let rowHtml = $(settings.rowSection)[0].outerHTML;
settings.hideSection ? $(settings.rowSection).remove() : "";
let rowCounter = 1;
if (settings.rowNumberStart) {
rowCounter = Number(settings.rowNumberStart);
}
$(document).on('click', settings.addBtn, function (event) {
$(appendArea).append(rowHtml);
if (settings.appendEffect === 'fade') {
$(settings.rowSection).last().hide().fadeIn();
} else if (settings.appendEffect === 'slide') {
$(settings.rowSection).last().hide().slideDown(200);
}
$(settings.rowSection).last().addClass(settings.addClass);
$(settings.rowNumber).last().text(rowCounter);
type = (settings.type) ? settings.type : settings.rowSection;
$(type).each(function(rowIndex) {
$(this).find('input[name]').each(function() {
var name = $(this).attr('name');
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
$(this).attr('name',name);
});
$(this).find('select[name]').each(function() {
var name = $(this).attr('name');
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
$(this).attr('name',name);
});
$(this).find('textarea[name]').each(function() {
var name = $(this).attr('name');
name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
$(this).attr('name',name);
});
$(this).find('.appender').each(function() {
$(this).data('id',rowIndex);
});
});
rowCounter++;
if (settings.callback) {
settings.callback();
}
});
if (settings.deleteBtn) {
$(document).on('click', settings.deleteBtn, function (e) {
$(e.target).closest(settings.rowSection).remove();
if (settings.callback) {
settings.callback();
}
})
}
};
}(jQuery));
</script>
@endpush
@php(define('LOAD_APPENDER', true))
@endif

View File

@@ -0,0 +1,6 @@
@if(!defined('LOAD_FORMBUILDER'))
@push('scripts')
<script src="{{ asset('/assets/plugins/formBuilder/form-builder.min.js') }}"></script>
@endpush
@php(define('LOAD_FORMBUILDER', true))
@endif

View File

@@ -0,0 +1,9 @@
@if(!defined('LOAD_FORMIOJS'))
@push('css')
<link rel="stylesheet" href="{{ asset('/assets/plugins/formiojs/formio.full.min.css') }}">
@endpush
@push('scripts')
<script src="{{ asset('/assets/plugins/formiojs/formio.full.min.js') }}"></script>
@endpush
@php(define('LOAD_FORMIOJS', true))
@endif

View File

@@ -0,0 +1,39 @@
function checkCollapsedFields(selector)
{
var fields = selector + ' input,' + selector + ' textarea,' + selector + ' select';
console.log(fields);
var nb_fields = $(fields).length;
console.log(nb_fields);
var nb_required = $(fields).filter('[required]').length;
console.log(nb_required);
var nb_filled = 0;
var nb_necessary = 0;
$(fields).each(function(i, field){
if ($(field).val() != '')
{
nb_filled++;
}
});
$(fields).filter('[required]').each(function(i, required){
if ($(required).val() != '')
{
nb_necessary++;
}
});
var result = nb_filled + " / " + nb_fields;
result = result + " | " + nb_necessary + " / " + nb_required;
console.log(result);
var check = $(selector).parent().find('.check');
console.log(check);
// $(selector).parent().find('.check').html(result);
if (nb_necessary < nb_required) {
$(selector).collapse('show');
}
}

View File

@@ -0,0 +1,22 @@
@if(!defined('LOAD_COLOR'))
@push('scripts')
<script src="{{ asset('/assets/plugins/jquery-minicolors/jquery.minicolors.min.js') }}"></script>
<script>
function initColor(sel) {
var selector = (typeof(sel) == 'undefined') ? '.color' : sel;
var settings = {
position: 'bottom left',
theme: 'bootstrap'
};
$(selector).minicolors(settings);
}
</script>
@endpush
@push('css')
<link rel="stylesheet" href="{{ asset('/assets/plugins/jquery-minicolors/jquery.minicolors.css') }}">
@endpush
@php(define('LOAD_COLOR', true))
@endif

View File

@@ -0,0 +1,25 @@
@if(!defined('LOAD_DUALLIST'))
@push('scripts')
<script src="{{ asset('/assets/plugins/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js') }}"></script>
<script>
function initDualList(sel) {
var selector = (typeof(sel) == 'undefined') ? '.duallist' : sel;
var settings = {
nonSelectedListLabel: 'Non-selected',
selectedListLabel: 'Selected',
preserveSelectionOnMove: 'moved',
moveOnSelect: true,
nonSelectedFilter: ''
};
$(selector).bootstrapDualListbox(settings);
}
</script>
@endpush
@push('css')
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-duallistbox/bootstrap-duallistbox.min.css') }}">
@endpush
@php(define('LOAD_DUALLIST', true))
@endif

View File

@@ -0,0 +1,15 @@
@if(!defined('LOAD_EDITOR'))
@include('load.form.editor.tinymce')
@push('js')
<script>
function initEditor(selector) {
var selector = '.editor';
$(selector).tinymce({});
}
</script>
@endpush
@php(define('LOAD_EDITOR', true))
@endif

View File

@@ -0,0 +1,41 @@
@if(!defined('LOAD_TINYMCE'))
@push('js')
<script src="{!! mix('/js/tinymce/tinymce.min.js', '/assets/vendor/boilerplate') !!}"></script>
<script>
tinymce.defaultSettings = {
plugins: "autoresize fullscreen codemirror link lists table media image imagetools paste customalign stickytoolbar",
toolbar: "undo redo | styleselect | bold italic underline | customalignleft aligncenter customalignright | link media image | bullist numlist | table | code fullscreen",
contextmenu: "link image imagetools table spellchecker bold italic underline",
sticky_toolbar_container: '.tox-editor-header',
toolbar_drawer: "sliding",
sticky_offset: $('nav.main-header').outerHeight(),
codemirror: { config: { theme: 'storm' } },
menubar: false,
removed_menuitems: 'newdocument',
remove_linebreaks: false,
forced_root_block: false,
force_p_newlines: true,
relative_urls: false,
verify_html: false,
branding: false,
statusbar: false,
browser_spellcheck: true,
encoding: 'UTF-8',
image_uploadtab: false,
paste_preprocess: function(plugin, args) {
args.content = args.content.replace(/<(\/)*(\\?xml:|meta|link|span|font|del|ins|st1:|[ovwxp]:)((.|\s)*?)>/gi, ''); // Unwanted tags
args.content = args.content.replace(/\s(class|style|type|start)=("(.*?)"|(\w*))/gi, ''); // Unwanted attributes
args.content = args.content.replace(/<(p|a|div|span|strike|strong|i|u)[^>]*?>(\s|&nbsp;|<br\/>|\r|\n)*?<\/(p|a|div|span|strike|strong|i|u)>/gi, ''); // Empty tags
},
skin : "boilerplate",
language: '{{ App::getLocale() }}'
};
function initEditor(sel) {
var selector = (typeof(sel) == 'undefined') ? '.editor' : sel;
$(selector).tinymce({});
}
</script>
@endpush
@php(define('LOAD_TINYMCE', true))
@endif

View File

@@ -0,0 +1,18 @@
@if(!defined('LOAD_SELECT2'))
@push('scripts')
<script src="{!! mix('/js/select2/select2.full.min.js', '/assets/vendor/boilerplate') !!}"></script>
<script src="{!! asset('/assets/vendor/boilerplate/js/select2/i18n/'.config('boilerplate.app.locale').'.js') !!}"></script>
<script>
function initSelect2() {
$(".select2").select2({
placeholder: "{{ __('select_a_value') }}",
allowClear: false,
width: {
value: '100%'
}
});
}
</script>
@endpush
@php(define('LOAD_SELECT2', true))
@endif

View File

@@ -0,0 +1,25 @@
@if(!defined('LOAD_SET_OPTIONS'))
@push('js')
<script>
function setOptions(selector,data,selected,all) {
// console.log(data);
console.log(selector);
var $el = $(selector);
$el.empty(); // remove old options
if (all) {
$el.append($("<option></option>").attr("value",'').text('{{ __("all") }}'));
}
$.each(data, function(key, name) {
if (key != null) {
if (key == selected) {
$el.append($("<option selected='selected'></option>").attr("value", key).text(name));
} else {
$el.append($("<option></option>").attr("value", key).text(name));
}
}
});
}
</script>
@endpush
@php(define('LOAD_SET_OPTIONS', true))
@endif

View File

@@ -0,0 +1,34 @@
@if(!defined('LOAD_TOGGLE'))
@push('scripts')
<script src="{{ asset('/assets/plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js') }}"></script>
<script>
function initToggle(url, sel, data, callback) {
var selector = (typeof(sel) == 'undefined') ? '.toggle' : sel;
if (typeof(data) == 'undefined') {
var data = {};
}
$(selector).bootstrapToggle();
$('input' + selector).change(function() {
console.log($(this));
data['id'] = $(this).data('id');
data['active'] = $(this).is(':checked');
if (data['id'] && (typeof(url) != 'undefined') && (url != '')) {
var dataJson = Object.assign({}, data);
$.post(url, dataJson);
}
if (typeof(callback) != 'undefined') {
eval(callback);
}
});
}
</script>
@endpush
@push('css')
<link rel="stylesheet" href="{{ asset('/assets/plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css') }}">
@endpush
@php(define('LOAD_TOGGLE', true))
@endif

View File

@@ -0,0 +1,25 @@
@if(!defined('LOAD_FILEINPUT'))
@push('css')
<link rel="stylesheet" href="{!! mix('/js/fileinput/bootstrap-fileinput.min.css', '/assets/vendor/boilerplate') !!}">
@endpush
@push('js')
<script src="{!! mix('/js/fileinput/bootstrap-fileinput.min.js', '/assets/vendor/boilerplate') !!}"></script>
@if(App::getLocale() !== 'en')
<script src="{!! asset('/assets/vendor/boilerplate/js/fileinput/locales/'.config('boilerplate.app.locale').'.js') !!}"></script>
<script>
$.fn.fileinput.defaults.language = '{{ config('boilerplate.app.locale') }}';
</script>
@endif
@endpush
<script>
function initUpload(selector) {
var selector = '.file';
$(selector).fileinput({
showCaption: false,
dropZoneEnabled: false,
showUpload: false,
});
}
</script>
@php(define('LOAD_FILEINPUT', true))
@endif

View File

@@ -0,0 +1,29 @@
@if(!defined('LOAD_FILEINPUT'))
@push('css')
<link rel="stylesheet" href="{!! mix('/js/fileinput/bootstrap-fileinput.min.css', '/assets/vendor/boilerplate') !!}">
@endpush
@push('js')
<script src="{!! mix('/js/fileinput/bootstrap-fileinput.min.js', '/assets/vendor/boilerplate') !!}"></script>
@if(App::getLocale() !== 'en')
<script src="{!! asset('/assets/vendor/boilerplate/js/fileinput/locales/' . App::getLocale() . '.js') !!}"></script>
<script>
$.fn.fileinput.defaults.language = '{{ App::getLocale() }}';
</script>
@endif
<script>
function initUpload(sel) {
var selector = (typeof(sel) == 'undefined') ? '.file' : sel;
$(selector).fileinput({
showCaption: false,
dropZoneEnabled: false,
showUpload: false,
});
}
</script>
@endpush
@php(define('LOAD_FILEINPUT', true))
@endif

View File

@@ -0,0 +1,16 @@
@if(!defined('LOAD_URL'))
@include('load.layout.modal')
@push('js')
<script>
function initLoadUrl(sel) {
var selector = (typeof(sel) == 'undefined') ? '.btn-web' : sel;
$(selector).off().click(function() {
var url = $(this).closest('.input-group').find('.url').val();
viewModal(url);
});
}
</script>
@endpush
@php(define('LOAD_URL', true))
@endif

View File

@@ -0,0 +1,114 @@
@if(!defined('LOAD_MODAL'))
@push('js')
<script>
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm) {
var status = 0;
var dialog = bootbox.dialog({
title: title,
message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>',
size: size ? size : 'large',
scrollable: true,
onHide: function(e) {
console.log(status);
},
buttons: buildModalButtons(form_id, no_confirm)
});
/*
changeModalContent(dialog, url_open);
var callback = handlePostModal(form_id,url_save, callback);
handlePostModal(form_id,url_save, callback);
*/
dialog.init(function() {
$.get(url_open, function(data) {
dialog.find('.bootbox-body').html(data);
handlePostModal(form_id,url_save, callback);
});
});
}
function changeModalContent(dialog, url, callback) {
dialog.init(function() {
$.get(url, function(data) {
dialog.find('.bootbox-body').html(data);
});
});
}
function viewModal(url, size, title) {
var dialog = bootbox.dialog({
title: title ? title : 'Web viewer',
message: '<iframe style="border:0;" src="' + url + '" height="400" width="100%"></iframe>',
size: size ? size : 'xl',
scrollable: true,
});
}
function buildModalButtons(form_id, no_confirm) {
if (!no_confirm) {
var buttons = {
cancel: {
label: '{{ __('cancel') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('save') }}',
className: 'btn-success',
callback: function() {
submitModal(form_id);
}
},
};
} else {
buttons = '';
}
return buttons;
}
function submitModal(form_id) {
/*
var data = $(form_id).serialize();
$.post(url_save, data)
.done(function(data) {
if (callback) {
eval(callback);
}
});
*/
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
}
var oForm = 'form' + form_id;
$(oForm).submit();
status = 1;
}
function handlePostModal(form_id,url_save, callback) {
var oForm = 'form'+form_id;
$(oForm).submit(function(e) {
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url: url_save,
type: 'POST',
data: formData,
success: function (data) {
if (callback) {
eval(callback);
}
},
cache: false,
contentType: false,
processData: false
});
});
}
</script>
@endpush
@php(define('LOAD_MODAL', true))
@endif

View File

@@ -0,0 +1,29 @@
@if(!defined('LOAD_NICESCROLL'))
@push('scripts')
<script type="text/javascript" src="{{ asset('/assets/plugins/jquery.slimscroll.min.js') }}"></script>
<script>
function initScroll(selector) {
var selector = (typeof(selector) == 'undefined') ? '.nicescrollable' : selector;
$(selector).niceScroll({
horizrailenabled: false,
cursorborder: "0",
cursorwidth: "8px",
cursorcolor: "#fff",
zindex: "5555",
autohidemode: true,
bouncescroll: true,
mousescrollstep: 40,
scrollspeed: 100,
background: "#cdcdcd",
cursoropacitymin: 0.3,
cursoropacitymax: 0.7,
cursorborderradius: 0,
railpadding: {top:0,right:1,left:0,bottom:0}
});
}
</script>
@endpush
@php(define('LOAD_NICESCROLL', true))
@endif

View File

@@ -0,0 +1,6 @@
@if(!defined('LOAD_SLIMSCROLL'))
@push('scripts')
<script type="text/javascript" src="{{ asset('/assets/plugins/jquery.slimscroll.min.js') }}"></script>
@endpush
@php(define('LOAD_SLIMSCROLL', true))
@endif

View File

@@ -0,0 +1,39 @@
@if(!defined('LOAD_TABS'))
@push('scripts')
<script>
function addTab(name, id, txt, url) {
var navContainer = $('#'+name);
var tabContainer = $('#'+name + '-tab');
var newTab = name + '-' + id;
var newTabId = '#' + newTab;
// create the tab
$('<a href="'+newTabId+'" data-toggle="tab" class="nav-item nav-link" role="tab">'+txt+'</a>').appendTo(navContainer);
var url_open = url + id;
$.get(url_open, function(content) {
$('<div class="tab-pane fade pt-0 pb-0" id="'+newTab+'"><div class="card mb-0 card-outline card-info"><div class="card-body">'+content+'</div></div></div>').appendTo(tabContainer);
// make the new tab active
// console.log('#' + tabname + ' .nav-item a:last');
// $('#' + tabname + ' .nav-item a:last').tab('show');
});
}
function removeTab(name, id) {
var tabId = '#' + name + '-' + id;
// console.log('#' + name + "a[href='" + tabId + "'])");
$('#' + name + " a[href='" + tabId + "']").remove();
// console.log('remove ' + tabId);
$(tabId).remove();
}
</script>
@endpush
@php(define('LOAD_TABS', true))
@endif