diff --git a/.gitignore b/.gitignore index 4519587..ddbff90 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ public/uploads/* /public/medias/* !public/medias/.gitkeep +/storage/export_arcadia/* +!storage/export_arcadia/.gitkeep + /storage/*.key /vendor .env diff --git a/app/Article.php b/app/Article.php new file mode 100644 index 0000000..11528e1 --- /dev/null +++ b/app/Article.php @@ -0,0 +1,16 @@ +belongsToMany('App\Media', 'medias_articles', 'article_id', 'media_id'); + } +} diff --git a/app/Console/Commands/DeleteMediaArchive.php b/app/Console/Commands/DeleteMediaArchive.php new file mode 100644 index 0000000..380557d --- /dev/null +++ b/app/Console/Commands/DeleteMediaArchive.php @@ -0,0 +1,99 @@ +info('Vous allez supprimer définitivement tous les médias (et leurs fichiers) qui ont été supprimés (en soft delete).'); + + $choice = $this->choice('Etes-vous sûr de vouloir lancer ce traitement ?' , ['y', 'n'], 'y'); + + if($choice != "y"){ + $this->error('Choix incorrect'); + die(); + } + + $sujets = Sujet::where('sujet_dam', 1)->get(); + + $this->line(""); + $this->line("Liste des sujets disponibles"); + $this->line("----------------------------"); + foreach ($sujets as $key => $sujet) { + $this->line("[".$sujet->codeSujet."] ". $sujet->libelle); + } + $this->line("[0] Tous les sujets"); + + $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?' ); + + if($sujetId == ""){ + $this->error('Id de sujet incorrect'); + die(); + } + + if($sujetId == 0){ + $medias = Media::onlyTrashed()->with('Sujet.formats')->get(); + }else{ + $medias = Media::onlyTrashed()->where('sujet_id', $sujetId)->with('Sujet.formats')->get(); + } + + if($medias->count() == 0){ + $this->error('Aucun média a supprimer'); + die(); + } + + $this->info($medias->count().' média(s) trouvé(s) - Début du traitement'); + $bar = $this->output->createProgressBar(count($medias)); + $bar->start(); + + foreach ($medias as $media) { + // supprime les fichiers médias stockés sur disque + $files = Storage::files($media->folder."/"); + $filepath = preg_quote($media->folder.$media->uid, '/'); + $matchingFiles = preg_grep('/^'.$filepath.'/', $files); + Storage::delete($matchingFiles); + // supprime le media en bdd + $media->forceDelete(); + $bar->advance(); + } + + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); + } +} diff --git a/app/Console/Commands/ImportArcadiaFiles.php b/app/Console/Commands/ImportArcadiaFiles.php new file mode 100644 index 0000000..302db55 --- /dev/null +++ b/app/Console/Commands/ImportArcadiaFiles.php @@ -0,0 +1,185 @@ +info('Démarrage du traitement'); + $files = Storage::disk('arcadia')->files(); + $bar = $this->output->createProgressBar(count($files)-1); + $bar->start(); + + // ---- Pour chaque fichier + foreach ($files as $filename) { + + if($filename == ".gitignore") continue; + + // ---- Récupération du contenu + $files = Storage::disk('arcadia')->get($filename); + $fileContent = simplexml_load_string($files); + + // ---- traitement du fichier + if(substr($filename, 0, 11) == "DAM_ARTICLE"){ + foreach ($fileContent->dam as $row) { + $record = Article::where('noArt', $row->noArt)->first(); + if($record){ // Update record + $record->libCcial = $row->libCcial; + $record->codMarq = $row->codMarq; + $record->libMarq = $row->libMarq; + $record->codFamVte = $row->codFamVte; + $record->libFamVte = $row->libFamVte; + $record->codGencodAdm = $row->codGencodAdm; + $record->codGencodSymb = $row->codGencodSymb; + $record->codGencodPds = $row->codGencodPds; + $record->save(); + }else{ // Insert new record + $record = new Article(); + $record->noArt = $row->noArt; + $record->libCcial = $row->libCcial; + $record->codMarq = $row->codMarq; + $record->libMarq = $row->libMarq; + $record->codFamVte = $row->codFamVte; + $record->libFamVte = $row->libFamVte; + $record->codGencodAdm = $row->codGencodAdm; + $record->codGencodSymb = $row->codGencodSymb; + $record->codGencodPds = $row->codGencodPds; + $record->save(); + } + } + }elseif (substr($filename, 0, 10) == "DAM_MARQUE") { + foreach ($fileContent->dam as $row) { + $record = Marque::where('codMarq', $row->codMarq)->first(); + if($record){ // Update record + $record->libMarq = $row->libMarq; + $record->save(); + }else{ // Insert new record + $record = new Marque(); + $record->codMarq = $row->codMarq; + $record->libMarq = $row->libMarq; + $record->save(); + } + } + }elseif (substr($filename, 0, 15) == "DAM_MEDIA_SUJET") { + foreach ($fileContent->mediaSujet as $row) { + $record = Sujet::where('codeSujet', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->save(); + }else{ // Insert new record + $record = new Sujet(); + $record->codeSujet = $row->code; + $record->libelle = $row->libelle; + $record->save(); + } + } + }elseif (substr($filename, 0, 20) == "DAM_MEDIA_TYPE_MEDIA") { + foreach ($fileContent->mediatypemedia as $row) { + $record = Typemedia::where('codeTypemedia', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->save(); + }else{ // Insert new record + $record = new Typemedia(); + $record->codeTypemedia = $row->code; + $record->libelle = $row->libelle; + $record->save(); + } + } + }elseif (substr($filename, 0, 17) == "DAM_MEDIA_TYPEVUE") { + foreach ($fileContent->mediatypesvue as $row) { + $record = Typevue::where('codeTypevue', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->mediasujet->code; + $record->save(); + }else{ // Insert new record + $record = new Typevue(); + $record->codeTypevue = $row->code; + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->mediasujet->code; + $record->save(); + } + } + }elseif (substr($filename, 0, 18) == "DAM_MEDIA_VARIANTE") { + foreach ($fileContent->mediavariante as $row) { + $record = Variante::where('codeVariante', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->children()[0]->code; + $record->typevue_id = $row->CodeTypeVue->mediatypesvue->code; + $record->save(); + }else{ // Insert new record + $record = new Variante(); + $record->codeVariante = $row->code; + $record->libelle = $row->libelle; + $record->sujet_id = $row->sujet_id->children()[0]->code; + $record->typevue_id = $row->CodeTypeVue->mediatypesvue->code; + $record->save(); + } + } + }elseif (substr($filename, 0, 20) == "DAM_SITE_PROD_GROUPE") { + foreach ($fileContent->SITE_PROD_GRP as $row) { + $record = Site::where('id', $row->code)->first(); + if($record){ // Update record + $record->libelle = $row->libelle; + $record->save(); + }else{ // Insert new record + $record = new Site(); + $record->id = $row->code; + $record->libelle = $row->libelle; + $record->save(); + } + } + } + + // ---- Suppression du fichier + Storage::disk('arcadia')->delete($filename); + $bar->advance(); + } + + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); + } +} diff --git a/app/Console/Commands/RegenerateThumbnails.php b/app/Console/Commands/RegenerateThumbnails.php new file mode 100644 index 0000000..6b935d3 --- /dev/null +++ b/app/Console/Commands/RegenerateThumbnails.php @@ -0,0 +1,94 @@ +info('Vous allez regénérer toutes les miniatures des médias.'); + + $sujets = Sujet::where('sujet_dam', 1)->get(); + + $this->line(""); + $this->line("Liste des sujets disponibles"); + $this->line("----------------------------"); + foreach ($sujets as $key => $sujet) { + $this->line("[".$sujet->codeSujet."] ". $sujet->libelle); + } + $this->line("[0] Tous les sujets"); + + $sujetId = $this->ask('Pour quel sujet de média souhaitez vous executer le traitement ?' ); + + if($sujetId == ""){ + $this->error('Id de sujet incorrect'); + die(); + } + + if($sujetId == 0){ + $medias = Media::where('typemedia_id', 1)->with('Sujet.formats')->get(); + }else{ + $medias = Media::where('sujet_id', $sujetId)->where('typemedia_id', 1)->with('Sujet.formats')->get(); + } + + if($medias->count() == 0){ + $this->error('Aucun média n\'a été trouvé'); + die(); + } + + $this->info($medias->count().' média(s) trouvé(s) - Début du traitement'); + $bar = $this->output->createProgressBar(count($medias)); + $bar->start(); + + foreach ($medias as $media) { + // ---- Creation des vignettes de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); + $bar->advance(); + } + + $bar->finish(); + $this->line(""); + $this->info('Fin du traitement'); + } +} diff --git a/app/Etiquette.php b/app/Etiquette.php index 36ffe1c..486b6f1 100644 --- a/app/Etiquette.php +++ b/app/Etiquette.php @@ -12,4 +12,12 @@ class Etiquette extends Model * @var string */ protected $primaryKey = 'etiquette_id'; + + /** + * Get the medias for the etiquette. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/Format.php b/app/Format.php new file mode 100644 index 0000000..65540ff --- /dev/null +++ b/app/Format.php @@ -0,0 +1,31 @@ +belongsToMany('App\Sujet', 'sujets_formats', 'format_id', 'sujet_id'); + } + +} diff --git a/app/Http/Controllers/DossierController.php b/app/Http/Controllers/DossierController.php index 7a8d79d..d56121b 100644 --- a/app/Http/Controllers/DossierController.php +++ b/app/Http/Controllers/DossierController.php @@ -7,6 +7,8 @@ use App\Sujet; use App\Marque; use App\Media; use App\Typevue; +use App\Variante; +use App\Format; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -22,7 +24,7 @@ class DossierController extends Controller Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $dossiers = Dossier::whereNull('parent_id') ->get(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.index')->with([ 'dossiers'=> $dossiers, @@ -39,7 +41,7 @@ class DossierController extends Controller { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $marques = Marque::all(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.create')->with(['marques'=> $marques, 'sujets'=> $sujets]); } @@ -111,7 +113,7 @@ class DossierController extends Controller $dossierMarques = $dossier->marques; $marques = Marque::all(); $dossierSujets = $dossier->sujets; - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('dossiers.edit')->with(['dossier'=> $dossier, 'dossierMarques' => $dossierMarques, 'marques' => $marques, 'sujets'=> $sujets]); } @@ -186,15 +188,30 @@ class DossierController extends Controller public function loadFolder(Request $request) { $response = array(); + $userId = Auth::user()->id; $sujetId = $request->input('sujetId'); $marques = Auth::user()->marques()->pluck("marque_id"); $response['data'] = Dossier::where('sujet_id', $sujetId) - ->whereNull('parent_id') - ->whereHas("marques", function($query) use ($marques){ - $query->whereIn("marque_id", $marques); - })->get(); - $response['count'] = Media::where('sujet_id', $sujetId)->whereNull('dossier_id')->count(); + ->whereNull('parent_id') + ->whereHas("marques", function($query) use ($marques){ + $query->whereIn("marque_id", $marques); + })->get(); + $response['count'] = Media::where('sujet_id', $sujetId) + ->whereNull('dossier_id') + ->where(function ($query) use ( $userId ) { + $query->where('statut', '<>', 0) + ->orWhere('created_by', $userId); + }) + ->count(); $response['typevues'] = Typevue::where('sujet_id', $sujetId)->get(); + $response['variantes'] = Variante::where('sujet_id', $sujetId)->get(); + + + $FormatsSujet = Format::whereHas('sujets', function ($query) use ($sujetId) { + $query->where('sujet_id',$sujetId); + })->get(); + $FormatsSystem = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('system', 1)->get(); + $response['formats'] = $FormatsSujet->merge($FormatsSystem); if(Auth::user()->hasRole([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')] )){ $response['draggable'] = true; diff --git a/app/Http/Controllers/MediaController.php b/app/Http/Controllers/MediaController.php index af6f34e..b1402ca 100644 --- a/app/Http/Controllers/MediaController.php +++ b/app/Http/Controllers/MediaController.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; use App\Sujet; +use App\Format; use App\Media; use App\Typemedia; use App\Langue; @@ -13,10 +14,14 @@ use App\Copyright; use App\Etiquette; use App\Site; use App\Marque; +use App\Tag; +use App\Article; +use App\Http\Traits\MediaTools; class MediaController extends Controller { + use MediaTools; /** * Display a listing of the resource. @@ -39,7 +44,7 @@ class MediaController extends Controller 'copyrights'=> $copyrights, 'etiquettes'=> $etiquettes, 'sites'=> $sites, - 'marques'=> $marques, + 'marques'=> $marques ]); } @@ -50,6 +55,7 @@ class MediaController extends Controller public function loadMedia(Request $request) { $response = array(); + $userId = Auth::user()->id; $dossier_id = $request->input('dossier_id'); $sujet_id = $request->input('sujet_id'); $offset = $request->input('offset'); @@ -58,9 +64,29 @@ class MediaController extends Controller $order = $request->input('order'); if($dossier_id == "0"){ - $response['data'] = Media::where('sujet_id', $sujet_id)->whereNull('dossier_id')->with('Etiquette')->offset($offset)->limit($limit)->orderBy($orderField, $order)->get(); + $response['data'] = Media::where('sujet_id', $sujet_id) + ->whereNull('dossier_id') + ->where(function ($query) use ( $userId ) { + $query->where('statut', '<>', 0) + ->orWhere('created_by', $userId); + }) + ->with('Etiquette') + ->offset($offset) + ->limit($limit) + ->orderBy($orderField, $order) + ->get(); }else{ - $response['data'] = Media::where('sujet_id', $sujet_id)->where('dossier_id', $dossier_id)->with('Etiquette')->offset($offset)->limit($limit)->orderBy($orderField, $order)->get(); + $response['data'] = Media::where('sujet_id', $sujet_id) + ->where('dossier_id', $dossier_id) + ->where(function ($query) use ( $userId ) { + $query->where('statut', '<>', 0) + ->orWhere('created_by', $userId); + }) + ->with('Etiquette') + ->offset($offset) + ->limit($limit) + ->orderBy($orderField, $order) + ->get(); } if(Auth::user()->hasRole([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')] )){ $response['draggable'] = true; @@ -103,12 +129,18 @@ class MediaController extends Controller */ public function removeMedia(Request $request) { + $deletedMediasList = array(); Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR')]); - $medias = $request->input('medias'); - Media::destroy($medias); + $deleteMedias = $request->input('medias'); - return json_encode(true); + $medias = Media::whereIn('id', $deleteMedias)->whereNull('arcadia_id')->get(); + foreach ($medias as $media) { + $deletedMediasList[] = $media->id; + $media->delete(); + } + + return json_encode($deletedMediasList); } /** @@ -117,14 +149,38 @@ class MediaController extends Controller */ public function getOneMedia(Request $request) { + $host = $request->getSchemeAndHttpHost(); $response = array(); $media_id = $request->input('media_id'); - $media = Media::where('id', $media_id)->with('sujet')->with('sites')->with('marques')->with('tags:libelle')->first(); + $media = Media::where('id', $media_id)->with('sujet')->with('sites')->with('marques')->with('articles')->with('tags:libelle')->first(); if($media){ + // stock le média $response['data'] = $media; + // stock les tags foreach ($media->tags as $tag) { $response['tags'][] = $tag->libelle; } + // stock les vignettes existantes + $files = Storage::files($media->folder."/"); + $filepath = preg_quote($media->folder.$media->uid, '/'); + $matchingFiles = preg_grep('/^'.$filepath.'/', $files); + foreach ($matchingFiles as $matchingFile) { + $im = new \imagick($matchingFile); + $imageprops = $im->getImageGeometry(); + $path_parts = pathinfo($matchingFile); + + $fileInfo = array(); + $fileInfo['url'] = $host."/".$matchingFile; + $fileInfo['resolution'] = $imageprops['width']."x".$imageprops['height']."px"; + $fileInfo['extension'] = $path_parts['extension']; + $fileInfo['libelle'] = $path_parts['filename']; + if(strpos($fileInfo['libelle'], '_')){ + $fileInfo['libelle'] = "Format ".substr($fileInfo['libelle'], strpos($fileInfo['libelle'], '_')+1); + }else{ + $fileInfo['libelle'] = "Format original"; + } + $response['vignettes'][] = $fileInfo; + } } return json_encode($response); @@ -138,8 +194,71 @@ class MediaController extends Controller { Auth::user()->authorizeRoles([config('roles.const.ADMIN'), config('roles.const.REDACTEUR'), config('roles.const.CONTRIBUTEUR')]); $response = array(); + $mediaUpdate = (object) $request->input('media'); + + $media = Media::where('id', $mediaUpdate->id)->first(); + if($media){ + $media->libelle = $mediaUpdate->libelle; + $media->typevue_id = $mediaUpdate->typevue_id; + $media->variante_id = $mediaUpdate->variante_id; + $media->langue_id = $mediaUpdate->langue_id; + $media->commentaire = $mediaUpdate->commentaire; + $media->version = $mediaUpdate->version; + if( ($mediaUpdate->statut == config('services.statut.public') || $mediaUpdate->statut == config('services.statut.public_etendue')) && $media->statut == config('services.statut.brouillon')){ + $media->published_at = date("Y-m-d H:i:s"); + } + $media->statut = $mediaUpdate->statut; + $media->copyright_id = $mediaUpdate->copyright_id; + $media->etiquette_id = $mediaUpdate->etiquette_id; + $media->save(); + + // MAJ des tags + $media->tags()->detach(); + if(isset($mediaUpdate->tags)){ + foreach($mediaUpdate->tags as $tag){ + $oTag = Tag::where('libelle', $tag)->first(); + if(!$oTag){ + $oTag = new Tag(); + $oTag->libelle = $tag; + $oTag->save(); + } + $media->tags()->attach($oTag->id); + } + } + // ---- Les sites + $media->sites()->detach(); + $sSites = $mediaUpdate->sites; + if($sSites != ""){ + $sites = explode(",", $sSites); + foreach($sites as $siteId){ + $media->sites()->attach($siteId); + } + } + + // ---- Les marques + $media->marques()->detach(); + $sMarques = $mediaUpdate->marques; + if($sMarques != ""){ + $marques = explode(",", $sMarques); + foreach($marques as $marqueId){ + $media->marques()->attach($marqueId); + } + } + + // ---- Les articles + $media->articles()->detach(); + $sArticles = $mediaUpdate->articles; + if($sArticles){ + $articles = explode(",", $sArticles); + foreach($articles as $articleId){ + $media->articles()->attach($articleId); + } + } + } + + $response = true; return json_encode($response); } @@ -184,10 +303,117 @@ class MediaController extends Controller $media = Media::where('id', $media_id)->first(); if($media){ - Storage::put($media->source, base64_decode($image)); + $mediaPath = $media->folder.$media->uid.".".$media->extension; + Storage::put($mediaPath, base64_decode($image)); + + $im = new \imagick($mediaPath); + $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; + $resolutions = $im->getImageResolution(); + $im->destroy(); + $media->resolution = $resolutions['x']; + if($media->resolution != 0){ + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); + }else{ + $media->largeur_mm = ""; + $media->hauteur_mm = ""; + } + $media->taille = $this->formatBytes($this->get_file_size($mediaPath)); + $media->save(); + + // Regénération des miniatures de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); $response = $media; } return json_encode($response); } + + /** + * Applique un Id Arcadia à un média + * + */ + public function setIdArcdadia(Request $request) + { + Auth::user()->authorizeRoles([config('roles.const.ADMIN')]); + $response = false; + $media_id = $request->input('media_id'); + $arcadia_id = $request->input('arcadia_id'); + + $media = Media::where('id', $media_id)->first(); + if($media){ + $media->arcadia_id = $arcadia_id; + $media->save(); + $response = true; + } + + return json_encode($response); + } + + /** + * Renvoie un article par ID Arcadia + * + */ + public function getArticle(Request $request) + { + $response = array(); + $arcadia_id = $request->input('arcadia_id'); + + $article = Article::where('noArt', $arcadia_id)->first(); + if($article){ + $response['article'] = $article; + }else{ + $response = false; + } + return json_encode($response); + } + + /** + * Renvoie un article par ID Arcadia + * + */ + public function downloadMedia(Request $request) + { + if(!$user = Auth::user()) abort(404, 'Erreur lors du téléchargement'); + + // obtention du format + $formatId = $request->input('format'); + if($formatId != 0){ + $format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('id', $formatId)->first(); + if(!$format) abort(404, 'Erreur lors du téléchargement'); + }else{ + $format = ""; + } + + $mediasId = $request->input('medias'); + $medias = explode(",", $mediasId); + if(sizeof($medias) == 1){ + $media = Media::where('id', $mediasId)->first(); + if($media){ + $fp = $this->get_mediaPath($media, $format); + } + }else{ + // create zip archive + $zip_file = public_path() . '/uploads/DAM_'.uniqid().'_'.date("Ymd").'.zip'; + $zip = new \ZipArchive(); + $zip->open($zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE); + + // add file to archive + foreach ($medias as $mediaId) { + $media = Media::where('id', $mediaId)->first(); + if($media){ + $fp = $this->get_mediaPath($media, $format); + $zip->addFile($fp, basename($fp)); + } + } + $zip->close(); + $fp = $zip_file; + } + return response()->download($fp)->deleteFileAfterSend(true); + } + } diff --git a/app/Http/Controllers/UploadController.php b/app/Http/Controllers/UploadController.php index fc99ada..5389345 100644 --- a/app/Http/Controllers/UploadController.php +++ b/app/Http/Controllers/UploadController.php @@ -42,6 +42,7 @@ class UploadController extends Controller { } $extension = strtolower($files->getClientOriginalExtension()); + $originalName = str_replace( ".".$extension, "", $files->getClientOriginalName()); if (!in_array($extension, $acceptFileTypes)) return array("false"); if($is_chunked_upload){ @@ -95,9 +96,15 @@ class UploadController extends Controller { // on créé un média en bdd $media = new Media(); - $media->libelle = $filename; + $media->dossier_id = $dossier_id; + $media->sujet_id = $sujet_id; + $media->libelle = $originalName; $media->extension = $extension; - $media->source = $destinationPath.$filename; + $media->folder = $destinationPath; + if($user = Auth::user()){ + $media->created_by= $user->id; + } + $media->uid = $uid; $media->taille = $this->formatBytes($this->get_file_size($destinationPath.$filename)); switch ($extension) { @@ -107,26 +114,36 @@ class UploadController extends Controller { case 'jpg': case 'png': $media->typemedia_id = 1; - list($width, $height) = getimagesize($destinationPath.$filename); - $media->largeur = $width; - $media->hauteur = $height; - $media->resolution = $this->get_dpi($destinationPath.$filename); + $im = new \imagick($destinationPath.$filename); + + if($extension == "gif" ){ + $im->setIteratorIndex(0); + } + + $resolutions = $im->getImageResolution(); + $media->resolution = $resolutions['x']; + $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; + if($media->resolution != 0){ - $media->largeur_mm = ceil(($width * 2.54 / $media->resolution)*10); - $media->hauteur_mm = ceil(($height * 2.54 / $media->resolution)*10); - } - - $this->createThumbnail($destinationPath.$filename, $destinationPath.$uid.'_thumb.'.$extension, 200); - if($width >= 1500){ - $this->createThumbnail($destinationPath.$filename, $destinationPath.$uid.'_preview.'.$extension, 1500); + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); }else{ - $this->createThumbnail($destinationPath.$filename, $destinationPath.$uid.'_preview.'.$extension, $width); + $media->largeur_mm = ""; + $media->hauteur_mm = ""; } + $media->save(); + // ---- Creation des vignettes de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); break; // Illustration/Vectorielle (2) case 'svg': $media->typemedia_id = 2; + $media->save(); break; // Vidéo (3) case 'mp4': @@ -137,6 +154,7 @@ class UploadController extends Controller { $media->hauteur = $fileInfo['video']['resolution_y']; $media->duree = $fileInfo['playtime_string']; } + $media->save(); break; // Audio (4) case 'mp3': @@ -145,6 +163,7 @@ class UploadController extends Controller { if($fileInfo = $getID3->analyze($destinationPath.$filename)){ $media->duree= $fileInfo['playtime_string']; } + $media->save(); break; // Document (5) case 'ai': @@ -155,44 +174,37 @@ class UploadController extends Controller { default: $media->typemedia_id = 5; + if(in_array($extension, array("pdf", "ai", "psd")) ){ $im = new \imagick(); $im->readImage($destinationPath.$filename); - if($extension == "pdf" || $extension == "psd"){ + if($extension == "pdf" || $extension == "psd" || $extension == "ai"){ $im->setIteratorIndex(0); } - //$im->setImageFormat('jpg'); - //list($width,$height) = $im->getImageGeometry(); $imageprops = $im->getImageGeometry(); + $media->largeur = $imageprops['width']; + $media->hauteur = $imageprops['height']; + $resolutions = $im->getImageResolution(); + $media->resolution = $resolutions['x']; - $width = $imageprops['width']; - $height = $imageprops['height']; - - // create preview - $fp = $destinationPath.$uid.'_preview.png'; - if($width >= 1500){ - //$newHeight = (1500 * $height) / $width; - //$im->resizeImage(1500,$newHeight, \imagick::FILTER_LANCZOS, 0.9, true); - $im->thumbnailImage(1500, 1500 , true); + if($media->resolution != 0){ + $media->largeur_mm = ceil(($media->largeur * 2.54 / $media->resolution)*10); + $media->hauteur_mm = ceil(($media->hauteur * 2.54 / $media->resolution)*10); + }else{ + $media->largeur_mm = ""; + $media->hauteur_mm = ""; } - $im->writeImage($fp); - - // create thumb - //$newHeight = (200 * $height) / $width; - //$im->resizeImage(200, $newHeight, \imagick::FILTER_LANCZOS, 0.9, true); - $im->thumbnailImage(200, 200 , true); - $fp = $destinationPath.$uid.'_thumb.png'; - $im->writeImage($fp); + $media->save(); + $im->destroy(); + // ---- Creation des vignettes de base + $this->create_sys_thumb($media); + // ---- Creation des vignettes en lien avec le sujet du média + $this->create_thumb($media); } break; } - - - $media->dossier_id = $dossier_id; - $media->sujet_id = $sujet_id; - $media->save(); } $filest = array(); diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 1d36444..b16dd15 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -21,7 +21,7 @@ class UserController extends Controller { Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $users = User::all(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('users.index')->with(['users'=> $users, 'sujets'=> $sujets]); } @@ -35,7 +35,7 @@ class UserController extends Controller Auth::user()->authorizeRoles(config('roles.const.ADMIN')); $roles = config('roles.label'); $marques = Marque::all(); - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('users.create')->with(['roles'=> $roles, 'marques'=> $marques, 'sujets'=> $sujets]); } @@ -87,6 +87,9 @@ class UserController extends Controller foreach($sujets as $sujetId){ $user->sujets()->attach($sujetId); } + }else{ + session()->flash('error', "Vous devez ajouter au moins un sujet."); + return redirect()->route('user.create'); } session()->flash('message', "L'utilisateur à été enregistré"); @@ -160,7 +163,7 @@ class UserController extends Controller $userMarques = $user->marques; $marques = Marque::all(); $userSujets = $user->sujets; - $sujets = Sujet::all(); + $sujets = Sujet::where('sujet_dam', 1)->get(); return view('users.edit')->with(['user'=> $user, 'roles'=> $roles, 'userMarques' => $userMarques, 'marques' => $marques, 'userSujets' => $userSujets, 'sujets'=> $sujets]); } @@ -206,6 +209,9 @@ class UserController extends Controller foreach($sujets as $sujetId){ $user->sujets()->attach($sujetId); } + }else{ + session()->flash('error', "Vous devez ajouter au moins un sujet."); + return redirect()->route('user.edit', ['user' => $user]); } session()->flash('message', "L'utilisateur à été mis à jour"); diff --git a/app/Http/Traits/MediaTools.php b/app/Http/Traits/MediaTools.php index 232832e..5c4f08b 100644 --- a/app/Http/Traits/MediaTools.php +++ b/app/Http/Traits/MediaTools.php @@ -5,10 +5,85 @@ use Illuminate\Support\Facades\Storage; trait MediaTools { public function get_file_size($file_path) { - return $this->fix_integer_overflow(filesize($file_path)); } + public function create_thumb($media) { + $formats = $media->sujet->formats; + + $mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension; + $im = new \imagick($mediaPath); + $im->setImageBackgroundColor('#ffffff'); + $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE); + $im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); + $im->stripImage(); + if(in_array($media->extension, array("pdf", "ai", "psd")) ){ + $im->setIteratorIndex(0); + } + + foreach ($formats as $format) { + + $fp = public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; + $targetWidth = $format->largeur; + if($format->hauteur == 0){ + $targetHeight = floor(($media->hauteur*$format->largeur)/$media->largeur); + }else{ + $targetHeight = $format->hauteur; + } + + $im->setImageFormat($format->extension); + if($media->largeur >= $targetWidth || $media->hauteur >= $targetHeight){ + $im->thumbnailImage($targetWidth, $targetHeight , true); + } + $im->writeImage($fp); + } + $im->destroy(); + } + + + public function create_sys_thumb($media) { + $mediaPath = public_path()."/".$media->folder.$media->uid.".".$media->extension; + $im = new \imagick(); + $im->readImage($mediaPath); + + if(in_array($media->extension, array("pdf", "ai", "psd")) ){ + $extension = "png"; + $im->setIteratorIndex(0); + }else{ + $extension = $media->extension; + } + + // create preview + $fp = public_path()."/".$media->folder.$media->uid.'_preview.'.$extension; + if($media->extension == "gif" ){ + if($media->largeur >= 1500 || $media->hauteur >= 1500 || $media->largeur == ""){ + $im = $im->coalesceImages(); + foreach ($im as $frame) { + $frame->thumbnailImage(1500, 1500); + $frame->setImagePage(1500, 1500, 0, 0); + } + $im = $im->deconstructImages(); + } + $im->writeImages($fp, true); + }else{ + if($media->largeur >= 1500 || $media->hauteur >= 1500 || $media->largeur == ""){ + $im->thumbnailImage(1500, 1500 , true); + } + $im->writeImage($fp); + } + + + // create thumb + $im->setImageBackgroundColor('#ffffff'); + $im->setImageAlphaChannel(\Imagick::ALPHACHANNEL_REMOVE); + $im->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); + $im->stripImage(); + $fp = public_path()."/".$media->folder.$media->uid.'_thumb.'.$extension; + $im->thumbnailImage(200, 200 , true); + $im->writeImage($fp); + $im->destroy(); + } + public function get_mediaFolder() { $mediaPath = "medias/"; $directories = Storage::allDirectories($mediaPath ); @@ -74,149 +149,32 @@ trait MediaTools { } } - public function get_dpi($filename){ + // ---- Renvoi le chemin attendu d'un média selon le format demandé + public function get_mediaPath($media, $format = "") { - // open the file and read first 20 bytes. - $a = fopen($filename,'r'); - $string = fread($a,20); - fclose($a); + // format original + if($format == ""){ + return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; + } - // get the value of byte 14th up to 18th - $data = bin2hex(substr($string,14,4)); - $x = substr($data,0,4); - $y = substr($data,4,4); - //return array(hexdec($x),hexdec($y)); - return hexdec($x); + // format spécifique + if($format->system == 0){ + if(in_array($media->extension, array("gif", "jpeg", "jpg", "png", "pdf", "ai", "psd")) ){ + return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; + }else{ + return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; + } + } + + // format système (thumb et preview) + if($format->system == 1){ + if(in_array($media->extension, array("gif", "jpeg", "jpg", "png")) ){ + return public_path()."/".$media->folder.$media->uid.'_'.$format->libelle.'.'.$format->extension; + }elseif(in_array($media->extension, array("pdf", "ai", "psd"))){ + return public_path()."/".$media->folder.$media->uid.'.png'; + }else{ + return public_path()."/".$media->folder.$media->uid.'.'.$media->extension; + } + } } - - - /** - * @param $src - a valid file location - * @param $dest - a valid file target - * @param $targetWidth - desired output width - * @param $targetHeight - desired output height or null - */ - function createThumbnail($src, $dest, $targetWidth, $targetHeight = null) { - - - - // Link image type to correct image loader and saver - // - makes it easier to add additional types later on - // - makes the function easier to read - $IMAGETYPE_JPEG = 2; - $IMAGETYPE_PNG = 3; - $IMAGETYPE_GIF = 1; - $IMAGE_HANDLERS = [ - 2 => [ - 'load' => 'imagecreatefromjpeg', - 'save' => 'imagejpeg', - 'quality' => 50 - ], - 3 => [ - 'load' => 'imagecreatefrompng', - 'save' => 'imagepng', - 'quality' => 5 - ], - 1 => [ - 'load' => 'imagecreatefromgif', - 'save' => 'imagegif', - 'quality' => 0 - ] - ]; - - // 1. Load the image from the given $src - // - see if the file actually exists - // - check if it's of a valid image type - // - load the image resource - - // get the type of the image - // we need the type to determine the correct loader - $type = exif_imagetype($src); - - // if no valid type or no handler found -> exit - if (!$type || !$IMAGE_HANDLERS[$type]) { - return null; - } - - // load the image with the correct loader - $image = call_user_func($IMAGE_HANDLERS[$type]['load'], $src); - - // no image found at supplied location -> exit - if (!$image) { - return null; - } - - - // 2. Create a thumbnail and resize the loaded $image - // - get the image dimensions - // - define the output size appropriately - // - create a thumbnail based on that size - // - set alpha transparency for GIFs and PNGs - // - draw the final thumbnail - - // get original image width and height - $width = imagesx($image); - $height = imagesy($image); - - // maintain aspect ratio when no height set - if ($targetHeight == null) { - - // get width to height ratio - $ratio = $width / $height; - - // if is portrait - // use ratio to scale height to fit in square - if ($width > $height) { - $targetHeight = floor($targetWidth / $ratio); - } - // if is landscape - // use ratio to scale width to fit in square - else { - $targetHeight = $targetWidth; - $targetWidth = floor($targetWidth * $ratio); - } - } - - // create duplicate image based on calculated target size - $thumbnail = imagecreatetruecolor($targetWidth, $targetHeight); - - // set transparency options for GIFs and PNGs - if ($type == $IMAGETYPE_GIF || $type == $IMAGETYPE_PNG) { - - // make image transparent - imagecolortransparent( - $thumbnail, - imagecolorallocate($thumbnail, 0, 0, 0) - ); - - // additional settings for PNGs - if ($type == $IMAGETYPE_PNG) { - imagealphablending($thumbnail, false); - imagesavealpha($thumbnail, true); - } - } - - // copy entire source image to duplicate image and resize - imagecopyresampled( - $thumbnail, - $image, - 0, 0, 0, 0, - $targetWidth, $targetHeight, - $width, $height - ); - - - // 3. Save the $thumbnail to disk - // - call the correct save method - // - set the correct quality level - - // save the duplicate version of the image to disk - return call_user_func( - $IMAGE_HANDLERS[$type]['save'], - $thumbnail, - $dest, - $IMAGE_HANDLERS[$type]['quality'] - ); - } - } diff --git a/app/Marque.php b/app/Marque.php index a49eaf7..e32f368 100644 --- a/app/Marque.php +++ b/app/Marque.php @@ -12,7 +12,7 @@ class Marque extends Model * * @var string */ - protected $primaryKey = 'COD_MARQUE'; + protected $primaryKey = 'codMarq'; /** * The users that belong to the marque. diff --git a/app/Media.php b/app/Media.php index 22c46d9..4da7058 100644 --- a/app/Media.php +++ b/app/Media.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class Media extends Model { use SoftDeletes; + protected $with = "owner"; protected $table = "medias"; /** @@ -74,6 +75,14 @@ class Media extends Model return $this->belongsToMany('App\Tag', 'medias_tags', 'media_id', 'tag_id'); } + /** + * The articles that belong to the media. + */ + public function articles() + { + return $this->belongsToMany('App\Article', 'medias_articles', 'media_id', 'article_id'); + } + /** * The sites that belong to the media. */ @@ -89,4 +98,12 @@ class Media extends Model { return $this->belongsToMany('App\Marque', 'medias_marques', 'media_id', 'marque_id'); } + + /** + * Get the user that owns the media. + */ + public function owner() + { + return $this->belongsTo('App\User', 'created_by'); + } } diff --git a/app/Scopes/SystemScope.php b/app/Scopes/SystemScope.php new file mode 100644 index 0000000..967050d --- /dev/null +++ b/app/Scopes/SystemScope.php @@ -0,0 +1,21 @@ +where('system', 0); + } +} \ No newline at end of file diff --git a/app/Sujet.php b/app/Sujet.php index ee05d1a..6760dd2 100644 --- a/app/Sujet.php +++ b/app/Sujet.php @@ -6,14 +6,13 @@ use Illuminate\Database\Eloquent\Model; class Sujet extends Model { - - + /** * The primary key associated with the table. * * @var string */ - protected $primaryKey = 'CODE_SUJET'; + protected $primaryKey = 'codeSujet'; /** * The users that belong to the sujet. @@ -31,6 +30,22 @@ class Sujet extends Model return $this->hasMany('App\Dossier'); } + /** + * Get the variantes for the sujet. + */ + public function variantes() + { + return $this->hasMany('App\Variante'); + } + + /** + * Get the typeVue for the sujet. + */ + public function typeVues() + { + return $this->hasMany('App\Typevue'); + } + /** * Get the medias for the sujet. */ @@ -38,4 +53,12 @@ class Sujet extends Model { return $this->hasMany('App\Media'); } + + /** + * The formats that belong to the sujet. + */ + public function formats() + { + return $this->belongsToMany('App\Format', 'sujets_formats', 'sujet_id', 'format_id'); + } } diff --git a/app/Tag.php b/app/Tag.php index a985c4d..8bff813 100644 --- a/app/Tag.php +++ b/app/Tag.php @@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model; class Tag extends Model { + public $timestamps = false; /** * The media that belong to the tags. */ @@ -14,4 +15,5 @@ class Tag extends Model { return $this->belongsToMany('App\Media', 'medias_tags', 'tag_id', 'media_id'); } + } diff --git a/app/Typemedia.php b/app/Typemedia.php index 7b8a584..3770a31 100644 --- a/app/Typemedia.php +++ b/app/Typemedia.php @@ -13,5 +13,13 @@ class Typemedia extends Model * * @var string */ - protected $primaryKey = 'CODE_TYPEMEDIA'; + protected $primaryKey = 'codeTypemedia'; + + /** + * Get the media for the Typemedia. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/Typevue.php b/app/Typevue.php index 3d646dd..4178697 100644 --- a/app/Typevue.php +++ b/app/Typevue.php @@ -11,5 +11,29 @@ class Typevue extends Model * * @var string */ - protected $primaryKey = 'CODE_TYPEVUE'; + protected $primaryKey = 'codeTypevue'; + + /** + * Get the variantes for the Typevue. + */ + public function variantes() + { + return $this->hasMany('App\Variante'); + } + + /** + * Get the sujet that owns the Typevue. + */ + public function sujet() + { + return $this->belongsTo('App\Sujet', 'sujet_id'); + } + + /** + * Get the medias for the Typevue. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/User.php b/app/User.php index fa38dcd..09eb1b2 100644 --- a/app/User.php +++ b/app/User.php @@ -91,4 +91,12 @@ class User extends Authenticatable { return $this->belongsToMany('App\Sujet', 'sujets_users', 'user_id', 'sujet_id'); } + + /** + * Get the medias for the user. + */ + public function medias() + { + return $this->hasMany('App\Media'); + } } diff --git a/app/Variante.php b/app/Variante.php new file mode 100644 index 0000000..bab2a4e --- /dev/null +++ b/app/Variante.php @@ -0,0 +1,32 @@ +belongsTo('App\Sujet', 'sujet_id'); + } + + /** + * Get the typeVue that owns the variante. + */ + public function typeVue() + { + return $this->belongsTo('App\Typevue', 'typevue_id'); + } +} diff --git a/config/filesystems.php b/config/filesystems.php index 910571a..607760d 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -55,6 +55,11 @@ return [ 'visibility' => 'public', ], + 'arcadia' => [ + 'driver' => 'local', + 'root' => storage_path('export_arcadia'), + ], + 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), diff --git a/config/services.php b/config/services.php index f026b2c..32d22af 100644 --- a/config/services.php +++ b/config/services.php @@ -44,4 +44,9 @@ return [ ], ], + 'statut' => [ + 'brouillon' => 0, + 'public' => 1, + 'public_etendue' => 2, + ], ]; diff --git a/public/css/app.css b/public/css/app.css index 69f09ab..597d958 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -123,7 +123,6 @@ body { color: #aaaaaa; background-size: 6.1px 5.3px; height: 100%; - overflow: hidden; } ol, @@ -13006,6 +13005,28 @@ readers do not read off random characters that represent icons */ right: -22px; } +#form_download { + padding: 30px; + min-width: 300px; +} + +#form_download h3 { + font-size: 14px; + margin-bottom: 12px; + font-weight: bold; + color: #ffffff; +} + +#form_download hr { + color: #24272e; + border-bottom: 1px solid #2c2f36; + margin-bottom: 20px; +} + +#form_download p { + margin-bottom: 40px; +} + /****************************************** TEMPLATE ******************************************/ @@ -13256,6 +13277,7 @@ p { } input[type=text], +input[type=number], input[type=password], input[type=email], input[type=url], @@ -13266,6 +13288,7 @@ select { } input[type=text].is-invalid, +input[type=number].is-invalid, input[type=password].is-invalid, input[type=email].is-invalid, input[type=url].is-invalid, @@ -13693,6 +13716,7 @@ table tfoot tr:hover { .media_manager .main_content header .action_wrapper .order select { padding: 5px 0px; + color: #3b3b3b; } .media_manager .main_content .scrollLoader { @@ -14105,7 +14129,7 @@ table tfoot tr:hover { height: 100%; background-color: #333333; position: absolute; - z-index: 999999999999; + z-index: 99990; left: 0; top: 0; } @@ -14134,6 +14158,7 @@ table tfoot tr:hover { font-size: 18px; position: relative; padding: 12px; + border: none; } #form_media header .form_media_close:after { @@ -14163,6 +14188,19 @@ table tfoot tr:hover { z-index: 1; } +#form_media header .form_media_download { + float: right; + font-size: 18px; + position: relative; + padding: 12px; + border: none; +} + +#form_media header .form_media_download:hover { + background-color: transparent; + color: #ffffff; +} + #form_media .main_content { height: calc(100% - 43px); } @@ -14216,6 +14254,10 @@ table tfoot tr:hover { background-color: #272626; } +#form_media .main_content .tab.tab_edit .button_bar a { + display: inline-block; +} + #form_media .main_content .tab.tab_edit .cloud_tag_plugin { position: relative; } @@ -14294,6 +14336,10 @@ table tfoot tr:hover { width: 100%; } +#form_media .main_content .tab .wrapper .article_selector .remove_article { + color: #aaaaaa; +} + /****************************************** PAGE LOGIN ******************************************/ diff --git a/public/js/app.js b/public/js/app.js index 37b4347..db2afe6 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -10825,7 +10825,7 @@ window.initSelector = function ($selector) { }); $($selector + " .selector_dataValues").val(datavalue.join()); // Recherche d'un élément - $($selector + " .selector_filter").on('keyup', function (event) { + $($selector + " .selector_filter").off().on('keyup', function (event) { var options = $(this).parent($selector).find(".selector_choices li"); var search = $(this).val(); $(options).each(function () { @@ -10837,7 +10837,7 @@ window.initSelector = function ($selector) { }); }); // Ajout d'un élément - $($selector + " .selector_choices").on("click", "li", function () { + $($selector + " .selector_choices").off().on("click", "li", function () { if (!$(this).hasClass('selected')) { var id = $(this).attr("data-value"); var text = $(this).html(); @@ -10848,7 +10848,7 @@ window.initSelector = function ($selector) { } }); // Suppression d'un élément - $($selector + " .selector_values").on("click", "li", function () { + $($selector + " .selector_values").off().on("click", "li", function () { var id = $(this).attr("data-value"); var text = $(this).html(); $(this).parent().parent().find('.selector_choices li[data-value="' + id + '"]').removeClass('selected'); @@ -11462,6 +11462,12 @@ $(document).ready(function () { $(this).attr("aria-grabbed", "true"); event.originalEvent.dataTransfer.setData('Text', $(this).attr("data-id")); } + }); // ---- Restreint le Drag aux images + + $("html").on("dragstart", function (event) { + if (!$(event.target).hasClass('imageItem')) { + return false; + } }); // ---- déselectionne les éléments si on clique en dehors $(".main_content .media_container").on("click", function (event) { @@ -11488,7 +11494,20 @@ $(document).ready(function () { if ($target.hasClass('editItem')) { // Editer un média $(this).dblclick(); - } else if ($target.hasClass('downloadItem')) {// Télécharger le média + } else if ($target.hasClass('downloadItem')) { + // Télécharger le média + var medias = []; + medias.push($(this).attr("data-id")); + $("#form_download").fancybox({ + type: 'inline', + opts: { + animationDuration: 350, + animationEffect: 'material' + }, + beforeShow: function beforeShow() { + $("#form_download .medias").val(medias.join()); + } + }).trigger("click"); } else if ($target.hasClass('addBasket')) {// ajouter le média au panier } else if ($target.hasClass('deleteItem')) { // supprimer le média @@ -11628,69 +11647,92 @@ $(document).ready(function () { $("#form_media .form_media_retouch").show(); // on active l'onglet retouche $("#form_media .form_media_preview").show(); // on active l'onglet aperçu - // charge l'image de preview - $(".tab_preview").html('
'); - $("#openseadragon").css('width', '100%'); - $("#openseadragon").css('height', minHeight); - viewer = OpenSeadragon({ - id: "openseadragon", - tileSources: { - type: "image", - url: imgPreview - } - }); // charge l'image pour la retouche + if ($(this).attr('data-ext') == 'gif') { + // charge le gif + $(".tab_preview").html(''); + $(".tab_preview img").attr("src", $(this).attr('data-src')); + } else { + // charge l'image de preview + $(".tab_preview").html('
'); + $("#openseadragon").css('width', '100%'); + $("#openseadragon").css('height', minHeight); + viewer = OpenSeadragon({ + id: "openseadragon", + tileSources: { + type: "image", + url: imgPreview + } + }); + } - $("#form_media .tab_retouch").html(''); - $("#drTarget").attr("src", $(this).attr('data-src')); - drPlugin = new Darkroom('#drTarget', { - minWidth: 200, - minHeight: 200, - maxWidth: minWidth, - maxHeight: minHeight, - plugins: { - save: { - callback: function callback() { - // récupère la nouvelle image - var newImage = this.darkroom.sourceCanvas.toDataURL(); // sauvegarde de l'image en base + if ($(this).attr('data-ext') == 'gif') { + // masque l'onglet retouche + $("#form_media .form_media_retouch").hide(); + } else { + // charge l'image pour la retouche + $("#form_media .tab_retouch").html(''); + $("#drTarget").attr("src", $(this).attr('data-src')); + drPlugin = new Darkroom('#drTarget', { + minWidth: 200, + minHeight: 200, + maxWidth: minWidth, + maxHeight: minHeight, + plugins: { + save: { + callback: function callback() { + var dr = this.darkroom; + $.fancyConfirm({ + title: "Retouche de l\'image", + message: "Êtes-vous sûr de vouloir modifier cette image ? (cette opération sera irréversible)", + okButton: 'Modifier l\'image', + noButton: 'Annuler', + callback: function callback(value) { + if (value) { + // récupère la nouvelle image + var newImage = dr.sourceCanvas.toDataURL(); // sauvegarde de l'image en base - $.ajax({ - url: '/ajax/edit-photo', - method: 'POST', - dataType: 'json', - data: { - media_id: $(window).data('current_edit_media'), - image: newImage - }, - success: function success(result) { - // MAJ de l'aperçu - viewer.destroy(); - viewer = null; - viewer = OpenSeadragon({ - id: "openseadragon", - tileSources: { - type: "image", - url: newImage + $.ajax({ + url: '/ajax/edit-photo', + method: 'POST', + dataType: 'json', + data: { + media_id: $(window).data('current_edit_media'), + image: newImage + }, + success: function success(result) { + // MAJ de l'aperçu + viewer.destroy(); + viewer = null; + viewer = OpenSeadragon({ + id: "openseadragon", + tileSources: { + type: "image", + url: newImage + } + }); // MAJ du visuel dans la Liste + + var mediaId = $(window).data('current_edit_media'); + var $media = $(".media_container .imageItem[data-id='" + mediaId + "'] .media"); + var mediaBg = $media.css('background-image', 'url(' + result.folder + result.uid + "." + result.extension + '?t=' + new Date().getTime() + ')'); + }, + error: function error(jqXHR, textStatus, errorThrown) { + $.fancybox.close(); + $.fancyMessage({ + title: "Attention", + message: "Erreur lors de la sauvegarde de l'image, merci d'actualiser la page.", + type: "error" + }); + } + }); } - }); // MAJ du visuel dans la Liste - - var mediaId = $(window).data('current_edit_media'); - var $media = $(".media_container .imageItem[data-id='" + mediaId + "'] .media"); - var mediaBg = $media.css('background-image', 'url(' + result.source + new Date().getTime() + ')'); - }, - error: function error(jqXHR, textStatus, errorThrown) { - $.fancybox.close(); - $.fancyMessage({ - title: "Attention", - message: "Erreur lors de la sauvegarde de l'image, merci d'actualiser la page.", - type: "error" - }); - } - }); + } + }); + } } } - } - }); + }); + } } else if ($(this).attr('data-typemedia') == 2) { // média svg $("#form_media .form_media_retouch").hide(); // masque l'onglet retouche @@ -11762,21 +11804,46 @@ $(document).ready(function () { // chargement des données $(".tab_edit #arcadia_id").val(result.data.arcadia_id); $(".tab_edit #libelle").val(result.data.libelle); - $(".tab_edit #sujetLibelle").val(result.data.sujet.LIBELLE); + $(".tab_edit #sujetLibelle").val(result.data.sujet.libelle); $(".tab_edit #typevues").val(result.data.typevue_id); - $(".tab_edit #typemedias").val(result.data.typemedia_id); //$(".tab_edit #variantes").val(result.data.etiquette_id); - + $(".tab_edit #variantes option").each(function () { + if ($(this).attr('data-typevue') == result.data.typevue_id) { + $(this).show(); + } else { + $(this).hide(); + } + }); + $(".tab_edit #typemedias").val(result.data.typemedia_id); + $(".tab_edit #variantes").val(result.data.variante_id); $(".tab_edit #langues").val(result.data.langue_id); $(".tab_edit #commentaire").val(result.data.commentaire); $(".tab_edit #version").val(result.data.version); $(".tab_edit #created_at").val(result.data.created_at); + $(".tab_edit #created_by").val(result.data.owner.firstname + " " + result.data.owner.lastname); $(".tab_edit #updated_at").val(result.data.updated_at); - $(".tab_edit #published_at").val(result.data.published_at); // liste des produits liés - // marque lié + $(".tab_edit #published_at").val(result.data.published_at); + $(".tab_edit #statut").val(result.data.statut); // articles lié + + $(".tab_edit .article_selector table tbody").html(''); + $(".tab_edit #articles").val(''); + var elems = []; + $.each(result.data.articles, function (index, article) { + $articleItem = $(".tab_edit .hidden_row tr").clone(); + $articleItem.find('.col_lib').html(article.noArt + " : " + article.libCcial); + $articleItem.find('.col_famVente').html(article.codFamVte + " : " + article.libFamVte); + $articleItem.find('.col_marque').html(article.codMarq + " : " + article.libMarq); + $articleItem.find('.col_gencodAdm').html(article.codGencodAdm); + $articleItem.find('.col_gencodSymb').html(article.codGencodSymb); + $articleItem.find('.col_gencodPds').html(article.codGencodPds); + $articleItem.find('.remove_article').attr('data-id', article.id); + $(".tab_edit .article_selector table tbody").append($articleItem); + elems.push(article.id); + }); + $(".tab_edit #articles").val(elems.join()); // marque lié $(".tab_edit .selector_marques .selector_values").html(''); $.each(result.data.marques, function (index, marque) { - $(".tab_edit .selector_marques .selector_values").append('
  • ' + marque.LIBELLE + '
  • '); + $(".tab_edit .selector_marques .selector_values").append('
  • ' + marque.libMarq + '
  • '); }); initSelector(".selector_marques"); // site lié @@ -11799,29 +11866,42 @@ $(document).ready(function () { $(".tab_edit #largeur_mm").val(result.data.largeur_mm); $(".tab_edit #hauteur_mm").val(result.data.hauteur_mm); // Config de la fiche d'édition - var sujetId = $("#sujet_selector").val(); + if (result.data.sujet.sujet_arcadia == 0) { + $(".tab_edit .arcadia_fields").hide(); + } else { + $(".tab_edit .arcadia_fields").show(); + } + $(".tab_edit .article_form, .tab_edit .marque_form, .tab_edit .site_form").hide(); - switch (sujetId) { - case '1': + switch (result.data.sujet_id) { + case 1: // Visuel Article $(".tab_edit .article_form").show(); break; - case '2': + case 2: // Marque $(".tab_edit .marque_form").show(); break; - case '3': + case 4: // Sociétés $(".tab_edit .site_form").show(); break; default: - } // affiche la popin + } // Config de la liste des vignettes + $(".tab_links .table_links tbody").html(''); + $.each(result.vignettes, function (index, vignette) { + $linkItem = $(".tab_links .row_copy_hidden table tr").clone(); + $linkItem.find('.link_libelle').html(vignette.libelle + " " + vignette.extension + " " + vignette.resolution); + $linkItem.find('.link_input input').val(vignette.url); + $(".tab_links .table_links tbody").append($linkItem); + }); // affiche la popin + $("#form_media").fadeIn('fast'); }, error: function error(jqXHR, textStatus, errorThrown) { @@ -11876,6 +11956,118 @@ $(document).ready(function () { if ($(".tab_preview audio").length) { $(".tab_preview audio").get(0).pause(); } + }); // ---- Copie d'un lien dans le clipboard + + $('.tab_links').on('click', '.fa-copy', function (event) { + $(this).prev().select(); + document.execCommand("copy"); + }); // ---- Bouton Arcadia + + $('.tab_edit .btn-arcadia-link').on('click', function (event) { + event.preventDefault(); + var arcadia_id = $("#arcadia_id").val(); + arcadia_id = prompt("Indiquez le code Arcadia de ce média", arcadia_id); + $.ajax({ + url: '/ajax/set-id-arcadia', + method: 'POST', + dataType: 'json', + data: { + arcadia_id: arcadia_id, + media_id: $(window).data('current_edit_media') + }, + success: function success(result) { + if (result == true) { + $.fancybox.close(); + $.fancyMessage({ + title: "Lier un média à Arcadia", + message: "Le code Arcadia a bien été ajouté au média", + type: "info" + }); + $("#arcadia_id").val(arcadia_id); + } else { + $.fancybox.close(); + $.fancyMessage({ + title: "Attention", + message: "Erreur lors de l'opération, merci d'actualiser la page.", + type: "error" + }); + } + }, + error: function error(jqXHR, textStatus, errorThrown) { + $.fancybox.close(); + $.fancyMessage({ + title: "Attention", + message: "Erreur lors de l'opération, merci d'actualiser la page.", + type: "error" + }); + } + }); + }); // ---- Bouton de suppression d'un article + + $('.tab_edit .article_selector').on('click', ".remove_article", function (event) { + event.preventDefault(); + var elems = $(".tab_edit #articles").val().split(','); + var id = $(this).attr('data-id'); + var index = elems.indexOf(id); + elems = jQuery.grep(elems, function (value) { + return value != id; + }); + $(".tab_edit #articles").val(elems.join()); + $(this).parents("tr").remove(); + }); // ---- Bouton d'ajout d'un article à un média + + $('.tab_edit .add_article').on('click', function (event) { + event.preventDefault(); + var arcadia_id = prompt("Indiquez le code Arcadia de l'article.", arcadia_id); + $.ajax({ + url: '/ajax/get-article', + method: 'POST', + dataType: 'json', + data: { + arcadia_id: arcadia_id + }, + success: function success(result) { + if (result) { + var article = result.article; + var elems = $(".tab_edit #articles").val().split(','); + + if (jQuery.inArray(article.id, elems) == -1) { + // maj de la valeur du champ hidden + elems.push(article.id); + $(".tab_edit #articles").val(elems.join()); // maj du tableau html + + $articleItem = $(".tab_edit .hidden_row tr").clone(); + $articleItem.find('.col_lib').html(article.noArt + " : " + article.libCcial); + $articleItem.find('.col_famVente').html(article.codFamVte + " : " + article.libFamVte); + $articleItem.find('.col_marque').html(article.codMarq + " : " + article.libMarq); + $articleItem.find('.col_gencodAdm').html(article.codGencodAdm); + $articleItem.find('.col_gencodSymb').html(article.codGencodSymb); + $articleItem.find('.col_gencodPds').html(article.codGencodPds); + $articleItem.find('.remove_article').attr('data-id', article.id); + $(".tab_edit .article_selector table tbody").append($articleItem); + } else { + $.fancyMessage({ + title: "Impossible d'ajouter l'article", + message: "Cet article est déjà présent dans la liste.", + type: "error" + }); + } + } else { + $.fancyMessage({ + title: "Impossible d'ajouter l'article", + message: "La référence de cet article n'a pas été trouvé.", + type: "error" + }); + } + }, + error: function error(jqXHR, textStatus, errorThrown) { + $.fancyMessage({ + title: "Attention", + message: "Erreur lors de l'opération, merci d'actualiser la page.", + type: "error" + }); + } + }); }); // ---- Suppression de média en masse $('.action_delete_media').on('click', function (event) { @@ -11927,6 +12119,47 @@ $(document).ready(function () { $('#form_etiquette .etiquette').on('click', function (event) { event.preventDefault(); $(this).addClass('selected'); + $.fancybox.close(); + }); // ---- Popup pour télécharger des médias en masse + + $('.action_download_media, .form_media_download').on('click', function (event) { + event.preventDefault(); + var medias = []; + + if ($(this).hasClass('form_media_download')) { + medias.push($(window).data('current_edit_media')); + } else { + $('.media_container .imageItem').each(function (index) { + if ($(this).attr("aria-grabbed") == "true") { + medias.push($(this).attr("data-id")); + } + }); + } + + if (medias.length == 0) { + $.fancyMessage({ + title: "Télécharger des médias", + message: "Veuillez sélectionner au moins un média.", + type: "info" + }); + } else { + $("#form_download").fancybox({ + type: 'inline', + opts: { + animationDuration: 350, + animationEffect: 'material' + }, + beforeShow: function beforeShow() { + $("#form_download .medias").val(medias.join()); + } + }).trigger("click"); + } + }); // ---- Bouton pour lancer le téléchargement d'un ou plusieurs médias + + $('#form_download .btn_form_download').on('click', function (event) { + event.preventDefault(); + $("#form_download #the_form_download").submit(); // ferme la popup + $.fancybox.close(); }); // ---- gestion des onglets de la popup d'édition @@ -11951,9 +12184,63 @@ $(document).ready(function () { }); // ---- sauvegarde de la popup d'édition $(".btn_tab_edit_save").on("click", function (event) { - // recupère les tags - $('#tag-editor').tagEditor('getTags')[0].tags; // ferme la popin - //$(".form_media_close, .btn_tab_edit_cancel").trigger('click'); + if (!$(".form_edit_media")[0].checkValidity()) { + $.fancyMessage({ + title: "Sauvegarde d'un média", + message: "Le formulaire a mal été renseigné. merci de corriger.", + type: "error" + }); + } + + var media = { + id: $(window).data('current_edit_media'), + libelle: $(".tab_edit #libelle").val(), + typevue_id: $(".tab_edit #typevues").val(), + variante_id: $(".tab_edit #variantes").val(), + langue_id: $(".tab_edit #langues").val(), + commentaire: $(".tab_edit #commentaire").val(), + version: $(".tab_edit #version").val(), + statut: $(".tab_edit #statut").val(), + copyright_id: $(".tab_edit #copyrights").val(), + etiquette_id: $(".tab_edit #etiquettes").val(), + tags: $('#tag-editor').tagEditor('getTags')[0].tags, + sites: $(".tab_edit .selector_sites .selector_dataValues").val(), + marques: $(".tab_edit .selector_marques .selector_dataValues").val(), + articles: $(".tab_edit #articles").val() + }; + $.ajax({ + url: '/ajax/save-media', + method: 'POST', + dataType: 'json', + data: { + media: media + }, + success: function success(result) { + $.fancyMessage({ + title: "Sauvegarde d'un média", + message: "Les données ont bien été enregistrées", + type: "info" + }); + }, + error: function error(jqXHR, textStatus, errorThrown) { + $.fancyMessage({ + title: "Sauvegarde d'un média", + message: "Erreur lors de l'enregistrement. Merci d'actualiser la page.", + type: "error" + }); + } + }); + }); // ---- Chargement de la liste des vairantes lors du changement de type de vue + + $(".tab_edit #typevues").on("change", function (event) { + var typevue_id = $(this).val(); + $(".tab_edit #variantes option").each(function () { + if ($(this).attr('data-typevue') == typevue_id) { + $(this).show(); + } else { + $(this).hide(); + } + }); }); /****************************** Upload de média @@ -11993,15 +12280,29 @@ $(document).ready(function () { $(this).stop().fadeOut("fast"); }); var currentfiles = []; + var maxFiles = 20; + var counter = 0; $('#fileupload').fileupload({ url: "/ajax/upload-media", dataType: 'json', limitMultiFileUploads: 10, maxChunkSize: 8000000, + maxNumberOfFiles: 2, dragover: function dragover(e, data) { $(".uploader-window").fadeIn("fast"); }, add: function add(e, data) { + if (counter < maxFiles) { + counter++; + } else { + $.fancyMessage({ + title: "Attention", + message: "Vous ne pouvez pas ajouter plus de " + maxFiles + " fichiers", + type: "info" + }); + return false; + } + data.files = $.map(data.files, function (file, i) { if ($.inArray(file.name, currentfiles) >= 0) { $.fancyMessage({ @@ -12077,6 +12378,7 @@ $(document).ready(function () { }, stop: function stop(e) { $(".files").html(""); + counter = 0; currentfiles = []; $('#progress .progress-bar').css('width', '0%'); $('#progress').hide(); @@ -12124,7 +12426,20 @@ function initFolderManager(sujetId) { var typevues = result.typevues; $("#typevues").find('option').remove(); $.each(typevues, function (index, typevue) { - $("#typevues").append(''); + $("#typevues").append(''); + }); // initialisation de la liste variantes + + var variantes = result.variantes; + $("#variantes").find('option').remove(); + $.each(variantes, function (index, variante) { + $("#variantes").append(''); + }); // initialisation des formats de vignette disponibles autéléchargement + + $(window).data('formats', result.formats); + $('#form_download .download_format').html(''); + $('#form_download .download_format').append(''); + $.each(result.formats, function (index, format) { + $('#form_download .download_format').append(''); }); // ajout du total à la racine var total = result.count; @@ -12256,14 +12571,14 @@ function loadMedia(dossier_id, sujet_id) { case 1: ico = ''; detail = " - " + item.largeur + "x" + item.hauteur + "px"; - thumb = item.source.split('.')[0] + "_thumb." + item.extension; - preview = item.source.split('.')[0] + "_preview." + item.extension; + thumb = item.folder + item.uid + "_thumb." + item.extension; + preview = item.folder + item.uid + "_preview." + item.extension; break; case 2: ico = ''; - thumb = item.source; - preview = item.source; + thumb = item.folder + item.uid + "." + item.extension; + preview = item.folder + item.uid + "." + item.extension; break; case 3: @@ -12282,8 +12597,8 @@ function loadMedia(dossier_id, sujet_id) { ico = ''; if (item.extension == "pdf" || item.extension == "ai" || item.extension == "psd") { - thumb = item.source.split('.')[0] + "_thumb.png"; - preview = item.source.split('.')[0] + "_preview.png"; + thumb = item.folder + item.uid + "_thumb.png"; + preview = item.folder + item.uid + "_preview.png"; } else { itemClass = "doc"; } @@ -12293,7 +12608,7 @@ function loadMedia(dossier_id, sujet_id) { default: } - output += '
    '; + output += '
    '; output += '
    ' + item.etiquette.libelle + '
    '; output += '
      '; output += ''; @@ -12345,7 +12660,7 @@ function removeMedias(medias) { medias: medias }, success: function success(result) { - $.each(medias, function (index, value) { + $.each(result, function (index, value) { $(".media_container .imageItem[data-id='" + value + "']").remove(); }); // ---- MAJ du nb de média dans le dossier @@ -12357,7 +12672,26 @@ function removeMedias(medias) { var count = $(".folder_container .dd3-item[data-id='" + currentFolder + "'] > .dd3-content .count"); } - count.html(parseInt(count.html()) - medias.length); + count.html(parseInt(count.html()) - result.length); + + if (result.length != medias.length) { + $.fancybox.close(); + console.log(medias.length); + + if (medias.length == 1) { + $.fancyMessage({ + title: "Attention", + message: "Ce média est lié à Arcadia. Suppression refusée. ", + type: "error" + }); + } else { + $.fancyMessage({ + title: "Attention", + message: "Votre sélection contient des médias liés à Arcadia. Ces médias ne seront pas supprimés.", + type: "info" + }); + } + } }, error: function error(jqXHR, textStatus, errorThrown) { $.fancybox.close(); diff --git a/public/test.php b/public/test.php deleted file mode 100644 index 968c8df..0000000 --- a/public/test.php +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/resources/js/admin.js b/resources/js/admin.js index eb81fbb..879e4a1 100644 --- a/resources/js/admin.js +++ b/resources/js/admin.js @@ -132,7 +132,7 @@ window.initSelector = function($selector){ $($selector+" .selector_dataValues").val(datavalue.join()); // Recherche d'un élément - $($selector+" .selector_filter").on('keyup', function(event) { + $($selector+" .selector_filter").off().on('keyup', function(event) { var options = $(this).parent($selector).find(".selector_choices li"); var search = $(this).val(); $(options).each(function() { @@ -146,7 +146,7 @@ window.initSelector = function($selector){ }); // Ajout d'un élément - $($selector+" .selector_choices" ).on( "click", "li", function() { + $($selector+" .selector_choices" ).off().on( "click", "li", function() { if(!$(this).hasClass('selected')){ var id = $(this).attr("data-value"); var text = $(this).html(); @@ -157,7 +157,7 @@ window.initSelector = function($selector){ } }); // Suppression d'un élément - $($selector+" .selector_values" ).on( "click", "li", function() { + $($selector+" .selector_values" ).off().on( "click", "li", function() { var id = $(this).attr("data-value"); var text = $(this).html(); $(this).parent().parent().find('.selector_choices li[data-value="'+id+'"]').removeClass('selected'); diff --git a/resources/js/media.js b/resources/js/media.js index 492a22b..e21fa40 100644 --- a/resources/js/media.js +++ b/resources/js/media.js @@ -371,6 +371,13 @@ $(document).ready(function() { } }); + // ---- Restreint le Drag aux images + $("html").on("dragstart", function(event) { + if(!$(event.target).hasClass('imageItem')){ + return false; + } + }); + // ---- déselectionne les éléments si on clique en dehors $(".main_content .media_container").on("click", function(event) { if (event.target !== this) return; @@ -397,6 +404,19 @@ $(document).ready(function() { if($target.hasClass('editItem')){ // Editer un média $(this).dblclick(); }else if ($target.hasClass('downloadItem')) { // Télécharger le média + var medias = []; + medias.push($(this).attr("data-id")); + + $("#form_download").fancybox({ + type : 'inline', + opts : { + animationDuration : 350, + animationEffect : 'material', + }, + beforeShow : function() { + $("#form_download .medias").val(medias.join()); + } + }).trigger("click"); }else if ($target.hasClass('addBasket')) { // ajouter le média au panier }else if ($target.hasClass('deleteItem')) { // supprimer le média removeMedias([$(this).attr('data-id')]); @@ -534,68 +554,90 @@ $(document).ready(function() { $("#form_media .form_media_retouch").show(); // on active l'onglet retouche $("#form_media .form_media_preview").show(); // on active l'onglet aperçu - // charge l'image de preview - $(".tab_preview").html('
      '); - $("#openseadragon").css('width', '100%'); - $("#openseadragon").css('height', minHeight); - viewer = OpenSeadragon({ - id: "openseadragon", - tileSources: { - type: "image", - url: imgPreview, - } - }); + if($(this).attr('data-ext') == 'gif'){ + // charge le gif + $(".tab_preview").html(''); + $(".tab_preview img").attr("src", $(this).attr('data-src')); + }else{ + // charge l'image de preview + $(".tab_preview").html('
      '); + $("#openseadragon").css('width', '100%'); + $("#openseadragon").css('height', minHeight); + viewer = OpenSeadragon({ + id: "openseadragon", + tileSources: { + type: "image", + url: imgPreview, + } + }); + } - // charge l'image pour la retouche - $("#form_media .tab_retouch").html(''); - $("#drTarget").attr("src", $(this).attr('data-src')); - drPlugin = new Darkroom('#drTarget', { - minWidth: 200, - minHeight: 200, - maxWidth: minWidth, - maxHeight: minHeight, - plugins: { - save: { - callback: function() { - // récupère la nouvelle image - var newImage = this.darkroom.sourceCanvas.toDataURL(); - // sauvegarde de l'image en base - $.ajax({ - url: '/ajax/edit-photo', - method: 'POST', - dataType : 'json', - data: { - media_id: $(window).data('current_edit_media'), - image : newImage - }, - success: function(result){ - // MAJ de l'aperçu - viewer.destroy(); viewer = null; - viewer = OpenSeadragon({ - id: "openseadragon", - tileSources: { - type: "image", - url: newImage, + if($(this).attr('data-ext') == 'gif'){ + // masque l'onglet retouche + $("#form_media .form_media_retouch").hide(); + }else{ + // charge l'image pour la retouche + $("#form_media .tab_retouch").html(''); + $("#drTarget").attr("src", $(this).attr('data-src')); + + drPlugin = new Darkroom('#drTarget', { + minWidth: 200, + minHeight: 200, + maxWidth: minWidth, + maxHeight: minHeight, + plugins: { + save: { + callback: function() { + var dr = this.darkroom; + $.fancyConfirm({ + title : "Retouche de l\'image", + message : "Êtes-vous sûr de vouloir modifier cette image ? (cette opération sera irréversible)", + okButton : 'Modifier l\'image', + noButton : 'Annuler', + callback : function (value) { + if (value) { + // récupère la nouvelle image + var newImage = dr.sourceCanvas.toDataURL(); + // sauvegarde de l'image en base + $.ajax({ + url: '/ajax/edit-photo', + method: 'POST', + dataType : 'json', + data: { + media_id: $(window).data('current_edit_media'), + image : newImage + }, + success: function(result){ + // MAJ de l'aperçu + viewer.destroy(); viewer = null; + viewer = OpenSeadragon({ + id: "openseadragon", + tileSources: { + type: "image", + url: newImage, + } + }); + // MAJ du visuel dans la Liste + var mediaId = $(window).data('current_edit_media') + var $media = $(".media_container .imageItem[data-id='"+mediaId+"'] .media"); + var mediaBg = $media.css('background-image', 'url('+result.folder+result.uid+"."+result.extension+'?t='+ new Date().getTime()+')'); + + }, + error: function(jqXHR, textStatus, errorThrown) { + $.fancybox.close(); + $.fancyMessage({title : "Attention", message : "Erreur lors de la sauvegarde de l'image, merci d'actualiser la page.", type : "error"}); + } + }); } - }); - // MAJ du visuel dans la Liste - var mediaId = $(window).data('current_edit_media') - var $media = $(".media_container .imageItem[data-id='"+mediaId+"'] .media"); - var mediaBg = $media.css('background-image', 'url('+result.source+ new Date().getTime()+')'); + } + }); + } + }, + } + }); + } - - - }, - error: function(jqXHR, textStatus, errorThrown) { - $.fancybox.close(); - $.fancyMessage({title : "Attention", message : "Erreur lors de la sauvegarde de l'image, merci d'actualiser la page.", type : "error"}); - } - }); - } - }, - } - }); }else if ($(this).attr('data-typemedia') == 2) { // média svg $("#form_media .form_media_retouch").hide(); // masque l'onglet retouche $("#form_media .form_media_preview").show(); // on active l'onglet aperçu @@ -660,22 +702,48 @@ $(document).ready(function() { // chargement des données $(".tab_edit #arcadia_id").val(result.data.arcadia_id); $(".tab_edit #libelle").val(result.data.libelle); - $(".tab_edit #sujetLibelle").val(result.data.sujet.LIBELLE); + $(".tab_edit #sujetLibelle").val(result.data.sujet.libelle); $(".tab_edit #typevues").val(result.data.typevue_id); + $(".tab_edit #variantes option").each(function(){ + if($(this).attr('data-typevue')== result.data.typevue_id){ + $(this).show(); + }else{ + $(this).hide(); + } + }); $(".tab_edit #typemedias").val(result.data.typemedia_id); - //$(".tab_edit #variantes").val(result.data.etiquette_id); + $(".tab_edit #variantes").val(result.data.variante_id); $(".tab_edit #langues").val(result.data.langue_id); $(".tab_edit #commentaire").val(result.data.commentaire); $(".tab_edit #version").val(result.data.version); $(".tab_edit #created_at").val(result.data.created_at); + $(".tab_edit #created_by").val(result.data.owner.firstname+" "+result.data.owner.lastname); $(".tab_edit #updated_at").val(result.data.updated_at); $(".tab_edit #published_at").val(result.data.published_at); - // liste des produits liés + $(".tab_edit #statut").val(result.data.statut); + + // articles lié + $(".tab_edit .article_selector table tbody").html(''); + $(".tab_edit #articles").val(''); + var elems = []; + $.each(result.data.articles, function (index, article) { + $articleItem = $(".tab_edit .hidden_row tr").clone(); + $articleItem.find('.col_lib').html(article.noArt+" : "+article.libCcial); + $articleItem.find('.col_famVente').html(article.codFamVte+" : "+article.libFamVte); + $articleItem.find('.col_marque').html(article.codMarq+" : "+article.libMarq); + $articleItem.find('.col_gencodAdm').html(article.codGencodAdm); + $articleItem.find('.col_gencodSymb').html(article.codGencodSymb); + $articleItem.find('.col_gencodPds').html(article.codGencodPds); + $articleItem.find('.remove_article').attr('data-id', article.id); + $(".tab_edit .article_selector table tbody").append($articleItem); + elems.push(article.id); + }); + $(".tab_edit #articles").val(elems.join()); // marque lié $(".tab_edit .selector_marques .selector_values").html(''); $.each(result.data.marques, function (index, marque) { - $(".tab_edit .selector_marques .selector_values").append('
    • '+marque.LIBELLE+'
    • '); + $(".tab_edit .selector_marques .selector_values").append('
    • '+marque.libMarq+'
    • '); }); initSelector(".selector_marques"); @@ -700,20 +768,32 @@ $(document).ready(function() { $(".tab_edit #hauteur_mm").val(result.data.hauteur_mm); // Config de la fiche d'édition - var sujetId = $("#sujet_selector").val(); + if(result.data.sujet.sujet_arcadia == 0){ + $(".tab_edit .arcadia_fields").hide(); + }else{ + $(".tab_edit .arcadia_fields").show(); + } $(".tab_edit .article_form, .tab_edit .marque_form, .tab_edit .site_form").hide(); - switch (sujetId) { - case '1': // Visuel Article + switch (result.data.sujet_id) { + case 1: // Visuel Article $(".tab_edit .article_form").show(); break; - case '2': // Marque + case 2: // Marque $(".tab_edit .marque_form").show(); break; - case '3': // Sociétés + case 4: // Sociétés $(".tab_edit .site_form").show(); break; default: } + // Config de la liste des vignettes + $(".tab_links .table_links tbody").html(''); + $.each(result.vignettes, function (index, vignette) { + $linkItem = $(".tab_links .row_copy_hidden table tr").clone(); + $linkItem.find('.link_libelle').html(vignette.libelle+" "+vignette.extension+" "+vignette.resolution); + $linkItem.find('.link_input input').val(vignette.url); + $(".tab_links .table_links tbody").append($linkItem); + }); // affiche la popin $("#form_media").fadeIn('fast'); @@ -758,6 +838,101 @@ $(document).ready(function() { } }); + // ---- Copie d'un lien dans le clipboard + $('.tab_links').on('click', '.fa-copy', function(event){ + $(this).prev().select(); + document.execCommand("copy"); + }); + + // ---- Bouton Arcadia + $('.tab_edit .btn-arcadia-link').on('click', function(event){ + event.preventDefault(); + var arcadia_id = $("#arcadia_id").val(); + arcadia_id = prompt("Indiquez le code Arcadia de ce média", arcadia_id); + + $.ajax({ + url: '/ajax/set-id-arcadia', + method: 'POST', + dataType : 'json', + data: { + arcadia_id: arcadia_id, + media_id : $(window).data('current_edit_media'), + }, + success: function(result){ + if(result == true){ + $.fancybox.close(); + $.fancyMessage({title : "Lier un média à Arcadia", message : "Le code Arcadia a bien été ajouté au média", type : "info"}); + $("#arcadia_id").val(arcadia_id); + }else{ + $.fancybox.close(); + $.fancyMessage({title : "Attention", message : "Erreur lors de l'opération, merci d'actualiser la page.", type : "error"}); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + $.fancybox.close(); + $.fancyMessage({title : "Attention", message : "Erreur lors de l'opération, merci d'actualiser la page.", type : "error"}); + } + }); + }); + + // ---- Bouton de suppression d'un article + $('.tab_edit .article_selector').on('click', ".remove_article", function(event){ + event.preventDefault(); + var elems = $(".tab_edit #articles").val().split(','); + var id = $(this).attr('data-id'); + var index = elems.indexOf(id); + elems = jQuery.grep(elems, function(value) { + return value != id; + }); + + $(".tab_edit #articles").val(elems.join()); + $(this).parents("tr").remove(); + }); + + // ---- Bouton d'ajout d'un article à un média + $('.tab_edit .add_article').on('click', function(event){ + event.preventDefault(); + var arcadia_id = prompt("Indiquez le code Arcadia de l'article.", arcadia_id); + + $.ajax({ + url: '/ajax/get-article', + method: 'POST', + dataType : 'json', + data: { + arcadia_id: arcadia_id, + }, + success: function(result){ + if(result){ + var article = result.article; + var elems = $(".tab_edit #articles").val().split(','); + if(jQuery.inArray(article.id, elems) == -1){ + // maj de la valeur du champ hidden + elems.push(article.id); + $(".tab_edit #articles").val(elems.join()); + // maj du tableau html + $articleItem = $(".tab_edit .hidden_row tr").clone(); + $articleItem.find('.col_lib').html(article.noArt+" : "+article.libCcial); + $articleItem.find('.col_famVente').html(article.codFamVte+" : "+article.libFamVte); + $articleItem.find('.col_marque').html(article.codMarq+" : "+article.libMarq); + $articleItem.find('.col_gencodAdm').html(article.codGencodAdm); + $articleItem.find('.col_gencodSymb').html(article.codGencodSymb); + $articleItem.find('.col_gencodPds').html(article.codGencodPds); + $articleItem.find('.remove_article').attr('data-id', article.id); + $(".tab_edit .article_selector table tbody").append($articleItem); + }else{ + $.fancyMessage({title : "Impossible d'ajouter l'article", message : "Cet article est déjà présent dans la liste.", type : "error"}); + } + }else{ + $.fancyMessage({title : "Impossible d'ajouter l'article", message : "La référence de cet article n'a pas été trouvé.", type : "error"}); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + $.fancyMessage({title : "Attention", message : "Erreur lors de l'opération, merci d'actualiser la page.", type : "error"}); + } + }); + }); + + // ---- Suppression de média en masse $('.action_delete_media').on('click',function(event){ event.preventDefault(); @@ -811,6 +986,49 @@ $(document).ready(function() { }); + // ---- Popup pour télécharger des médias en masse + $('.action_download_media, .form_media_download').on('click',function(event){ + event.preventDefault(); + + var medias = []; + if($(this).hasClass('form_media_download')){ + medias.push($(window).data('current_edit_media')); + }else{ + $('.media_container .imageItem').each(function (index) { + if( $(this ).attr("aria-grabbed") == "true" ){ + medias.push($(this ).attr("data-id")); + } + }); + } + + + if(medias.length == 0){ + $.fancyMessage({title : "Télécharger des médias", message : "Veuillez sélectionner au moins un média.", type : "info"}); + }else{ + $("#form_download").fancybox({ + type : 'inline', + opts : { + animationDuration : 350, + animationEffect : 'material', + }, + beforeShow : function() { + $("#form_download .medias").val(medias.join()); + } + }).trigger("click"); + } + }); + + // ---- Bouton pour lancer le téléchargement d'un ou plusieurs médias + $('#form_download .btn_form_download').on('click',function(event){ + event.preventDefault(); + $("#form_download #the_form_download").submit(); + + // ferme la popup + $.fancybox.close(); + }); + + + // ---- gestion des onglets de la popup d'édition $("#form_media .tabbtn").on("click" , function(event) { event.preventDefault(); @@ -834,11 +1052,53 @@ $(document).ready(function() { // ---- sauvegarde de la popup d'édition $(".btn_tab_edit_save").on("click" , function(event) { - // recupère les tags - $('#tag-editor').tagEditor('getTags')[0].tags - // ferme la popin - //$(".form_media_close, .btn_tab_edit_cancel").trigger('click'); + if(!$(".form_edit_media")[0].checkValidity()){ + $.fancyMessage({title : "Sauvegarde d'un média", message : "Le formulaire a mal été renseigné. merci de corriger.", type : "error"}); + } + var media = { + id : $(window).data('current_edit_media'), + libelle : $(".tab_edit #libelle").val(), + typevue_id : $(".tab_edit #typevues").val(), + variante_id : $(".tab_edit #variantes").val(), + langue_id : $(".tab_edit #langues").val(), + commentaire : $(".tab_edit #commentaire").val(), + version : $(".tab_edit #version").val(), + statut : $(".tab_edit #statut").val(), + copyright_id : $(".tab_edit #copyrights").val(), + etiquette_id : $(".tab_edit #etiquettes").val(), + tags : $('#tag-editor').tagEditor('getTags')[0].tags, + sites : $(".tab_edit .selector_sites .selector_dataValues").val(), + marques : $(".tab_edit .selector_marques .selector_dataValues").val(), + articles : $(".tab_edit #articles").val(), + } + + $.ajax({ + url: '/ajax/save-media', + method: 'POST', + dataType : 'json', + data: { + media : media, + }, + success: function(result){ + $.fancyMessage({title : "Sauvegarde d'un média", message : "Les données ont bien été enregistrées", type : "info"}); + }, + error: function(jqXHR, textStatus, errorThrown) { + $.fancyMessage({title : "Sauvegarde d'un média", message : "Erreur lors de l'enregistrement. Merci d'actualiser la page.", type : "error"}); + } + }); + }); + + // ---- Chargement de la liste des vairantes lors du changement de type de vue + $(".tab_edit #typevues").on("change" , function(event) { + var typevue_id = $(this).val(); + $(".tab_edit #variantes option").each(function(){ + if($(this).attr('data-typevue')== typevue_id){ + $(this).show(); + }else{ + $(this).hide(); + } + }); }); /****************************** @@ -888,16 +1148,26 @@ $(document).ready(function() { }); var currentfiles = []; + var maxFiles = 20; + var counter = 0; $('#fileupload').fileupload({ url: "/ajax/upload-media", dataType: 'json', limitMultiFileUploads: 10, maxChunkSize: 8000000, + maxNumberOfFiles: 2, dragover: function (e, data) { $(".uploader-window").fadeIn( "fast"); }, add: function (e, data) { + if(counter < maxFiles){ + counter++; + }else{ + $.fancyMessage({title : "Attention", message : "Vous ne pouvez pas ajouter plus de "+maxFiles+" fichiers", type : "info"}); + return false; + } + data.files = $.map(data.files, function(file,i){ if ($.inArray(file.name,currentfiles) >= 0) { $.fancyMessage({title : "Attention", message : "Nous ne pouvons pas envoyer plusieurs fichiers du même nom. Veuillez renommer vos fichiers puis essayez à nouveau.", type : "error"}); @@ -967,6 +1237,7 @@ $(document).ready(function() { }, stop: function (e,) { $(".files").html(""); + counter = 0; currentfiles = []; $('#progress .progress-bar').css('width', '0%'); $('#progress').hide(); @@ -1020,7 +1291,22 @@ function initFolderManager(sujetId){ var typevues = result.typevues; $("#typevues").find('option').remove(); $.each(typevues, function (index, typevue) { - $("#typevues").append('') + $("#typevues").append('') + }); + + // initialisation de la liste variantes + var variantes = result.variantes; + $("#variantes").find('option').remove(); + $.each(variantes, function (index, variante) { + $("#variantes").append('') + }); + + // initialisation des formats de vignette disponibles autéléchargement + $(window).data('formats', result.formats); + $('#form_download .download_format').html(''); + $('#form_download .download_format').append(''); + $.each(result.formats, function (index, format) { + $('#form_download .download_format').append(''); }); // ajout du total à la racine @@ -1133,13 +1419,13 @@ function loadMedia(dossier_id, sujet_id){ case 1: ico = ''; detail = " - "+item.largeur+"x"+item.hauteur+"px"; - thumb = item.source.split('.')[0]+"_thumb."+item.extension; - preview = item.source.split('.')[0]+"_preview."+item.extension; + thumb = item.folder+item.uid+"_thumb."+item.extension; + preview = item.folder+item.uid+"_preview."+item.extension; break; case 2: ico = ''; - thumb = item.source; - preview = item.source; + thumb = item.folder+item.uid+"."+item.extension; + preview = item.folder+item.uid+"."+item.extension; break; case 3: ico = ''; @@ -1154,8 +1440,8 @@ function loadMedia(dossier_id, sujet_id){ case 5: ico = ''; if(item.extension == "pdf" || item.extension == "ai" || item.extension == "psd"){ - thumb = item.source.split('.')[0]+"_thumb.png"; - preview = item.source.split('.')[0]+"_preview.png"; + thumb = item.folder+item.uid+"_thumb.png"; + preview = item.folder+item.uid+"_preview.png"; }else{ itemClass = "doc"; } @@ -1164,7 +1450,7 @@ function loadMedia(dossier_id, sujet_id){ } - output += '
      '; + output += '
      '; output += '
      '+item.etiquette.libelle+'
      '; output += '
        '; output += ''; @@ -1212,7 +1498,7 @@ function removeMedias(medias){ medias: medias }, success: function(result){ - $.each(medias, function (index, value) { + $.each(result, function (index, value) { $(".media_container .imageItem[data-id='"+value+"']").remove(); }); @@ -1223,7 +1509,17 @@ function removeMedias(medias){ }else{ var count = $(".folder_container .dd3-item[data-id='"+currentFolder+"'] > .dd3-content .count"); } - count.html(parseInt(count.html())-medias.length); + count.html(parseInt(count.html())-result.length); + + if(result.length != medias.length){ + $.fancybox.close(); + console.log(medias.length); + if(medias.length == 1){ + $.fancyMessage({title : "Attention", message : "Ce média est lié à Arcadia. Suppression refusée. ", type : "error"}); + }else{ + $.fancyMessage({title : "Attention", message : "Votre sélection contient des médias liés à Arcadia. Ces médias ne seront pas supprimés.", type : "info"}); + } + } }, error: function(jqXHR, textStatus, errorThrown) { $.fancybox.close(); diff --git a/resources/sass/partials/common.scss b/resources/sass/partials/common.scss index ee8ed23..6d2fdd6 100644 --- a/resources/sass/partials/common.scss +++ b/resources/sass/partials/common.scss @@ -310,7 +310,27 @@ } } } +} +#form_download{ + padding: 30px; + min-width: 300px; + + h3{ + font-size: 14px; + margin-bottom: 12px; + font-weight: bold; + color: $white; + } + + hr{ + color: #24272e; + border-bottom: 1px solid #2c2f36; + margin-bottom: 20px; + } + p{ + margin-bottom: 40px; + } } /****************************************** diff --git a/resources/sass/partials/form.scss b/resources/sass/partials/form.scss index 7170993..3609e84 100644 --- a/resources/sass/partials/form.scss +++ b/resources/sass/partials/form.scss @@ -7,7 +7,7 @@ p{ margin-bottom: 10px; } -input[type="text"], input[type="password"], , input[type="email"], input[type="url"], select{ +input[type="text"], input[type="number"], input[type="password"], , input[type="email"], input[type="url"], select{ border-radius: 3px; padding: 5px 10px; border: none; diff --git a/resources/sass/partials/media.scss b/resources/sass/partials/media.scss index 33cfcfd..ec51dc0 100644 --- a/resources/sass/partials/media.scss +++ b/resources/sass/partials/media.scss @@ -99,6 +99,7 @@ } select{ padding: 5px 0px; + color: $grey; } } } @@ -503,7 +504,7 @@ height: 100%; background-color: $grey3; position: absolute; - z-index: 999999999999; + z-index: 99990; left: 0; top: 0; @@ -529,6 +530,7 @@ font-size: 18px; position: relative; padding: 12px; + border: none; &:after{ content: ''; @@ -555,6 +557,18 @@ z-index: 1; } } + .form_media_download{ + float: right; + font-size: 18px; + position: relative; + padding: 12px; + border: none; + + &:hover{ + background-color: transparent; + color: $white; + } + } } .main_content{ height: calc(100% - 43px); @@ -602,6 +616,9 @@ padding: 8px 50px; text-align: right; background-color: $lightdark; + a{ + display: inline-block; + } } .cloud_tag_plugin{ position: relative; @@ -675,6 +692,12 @@ .row_xl{ width: 100%; } + + .article_selector{ + .remove_article{ + color: $grey2; + } + } } } diff --git a/resources/sass/partials/reset.scss b/resources/sass/partials/reset.scss index b5cc72c..ca8f321 100644 --- a/resources/sass/partials/reset.scss +++ b/resources/sass/partials/reset.scss @@ -41,7 +41,6 @@ body { color: $grey2; background-size: 6.10px 5.30px; height: 100%; - overflow: hidden; } ol, ul { list-style: none; diff --git a/resources/views/dossiers/create.blade.php b/resources/views/dossiers/create.blade.php index 8f24f1a..de55312 100644 --- a/resources/views/dossiers/create.blade.php +++ b/resources/views/dossiers/create.blade.php @@ -51,7 +51,7 @@
      {!! Form::label("", "") !!} - {!! Form::select('sujet', $sujets->pluck('LIBELLE', 'CODE_SUJET')) !!} + {!! Form::select('sujet', $sujets->pluck('libelle', 'codeSujet')) !!}
      @@ -64,7 +64,7 @@
        @foreach ($marques as $marque) -
      • {{$marque->LIBELLE}}
      • +
      • {{$marque->libMarq}}
      • @endforeach
        diff --git a/resources/views/dossiers/edit.blade.php b/resources/views/dossiers/edit.blade.php index eb2cb57..6ac7b5c 100644 --- a/resources/views/dossiers/edit.blade.php +++ b/resources/views/dossiers/edit.blade.php @@ -51,7 +51,7 @@
      {!! Form::label("", "") !!} - {!! Form::select('sujet', $sujets->pluck('LIBELLE', 'CODE_SUJET'), $dossier->sujet_id) !!} + {!! Form::select('sujet', $sujets->pluck('libelle', 'codeSujet'), $dossier->sujet_id) !!}
      {!! Form::label('marques', 'Marques associées') !!} @@ -63,12 +63,12 @@
        @foreach ($marques as $marque) -
      • {{$marque->LIBELLE}}
      • +
      • {{$marque->libMarq}}
      • @endforeach
        @foreach ($dossierMarques as $dossierMarque) -
      • {{$dossierMarque->LIBELLE}}
      • +
      • {{$dossierMarque->libMarq}}
      • @endforeach
      diff --git a/resources/views/dossiers/index.blade.php b/resources/views/dossiers/index.blade.php index f28cbad..c9564c1 100644 --- a/resources/views/dossiers/index.blade.php +++ b/resources/views/dossiers/index.blade.php @@ -17,7 +17,7 @@ Ok @@ -37,10 +37,10 @@ @foreach ($dossiers as $dossier) - + {{ $dossier->libelle }} - {{ $dossier->sujet->LIBELLE }} - {{ $dossier->marques->implode('LIBELLE', ', ') }} + {{ $dossier->sujet->libelle }} + {{ $dossier->marques->implode('libMarq', ', ') }} @endforeach diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php new file mode 100644 index 0000000..8799ae2 --- /dev/null +++ b/resources/views/errors/503.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.app') + +@section('content') + + +@endsection diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 3129bf1..ee281fb 100644 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -8,7 +8,7 @@ diff --git a/resources/views/media_manager.blade.php b/resources/views/media_manager.blade.php index d2d71e3..a394435 100644 --- a/resources/views/media_manager.blade.php +++ b/resources/views/media_manager.blade.php @@ -8,7 +8,7 @@

      Gestion des médias

      @@ -28,7 +28,7 @@ @endif
    - /racine + /racine
    @@ -113,6 +113,18 @@
    + +
    Ajouter vos médias diff --git a/resources/views/users/create.blade.php b/resources/views/users/create.blade.php index f988a2a..b85a29b 100644 --- a/resources/views/users/create.blade.php +++ b/resources/views/users/create.blade.php @@ -68,7 +68,7 @@
      @foreach ($marques as $marque) -
    • {{$marque->LIBELLE}}
    • +
    • {{$marque->libMarq}}
    • @endforeach
      @@ -88,7 +88,7 @@
        @foreach ($sujets as $sujet) -
      • {{$sujet->LIBELLE}}
      • +
      • {{$sujet->libelle}}
      • @endforeach
        diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 7a5fcae..887a56c 100644 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -39,19 +39,19 @@ {!! Form::model($user, ['route' => ['user.update', $user], 'enctype' => 'multipart/form-data', 'class' => 'dataform']) !!} @method('PUT')
        - {!! Form::label('matricule', 'Matricule') !!} + {!! Form::label('matricule', 'Matricule *') !!} {!! Form::text('matricule', $user->matricule, ['disabled']) !!}
        - {!! Form::label('firstname', 'Prénom') !!} + {!! Form::label('firstname', 'Prénom *') !!} {!! Form::text('firstname', $user->firstname, ['required']) !!}
        - {!! Form::label('lastname', 'Nom') !!} + {!! Form::label('lastname', 'Nom *') !!} {!! Form::text('lastname', $user->lastname, ['required']) !!}
        - {!! Form::label('email', 'Email') !!} + {!! Form::label('email', 'Email *') !!} {!! Form::email('email', $user->email, ['required']) !!}
        @@ -71,12 +71,12 @@
          @foreach ($marques as $marque) -
        • {{$marque->LIBELLE}}
        • +
        • {{$marque->libMarq}}
        • @endforeach
          @foreach ($userMarques as $userMarque) -
        • {{$userMarque->LIBELLE}}
        • +
        • {{$userMarque->libMarq}}
        • @endforeach
        @@ -85,7 +85,7 @@
        - {!! Form::label('sujets', 'Sujets disponibles') !!} + {!! Form::label('sujets', 'Sujets disponibles *') !!}
        {!! Form::label("", "") !!} @@ -94,12 +94,12 @@
          @foreach ($sujets as $sujet) -
        • {{$sujet->LIBELLE}}
        • +
        • {{$sujet->libelle}}
        • @endforeach
          @foreach ($userSujets as $userSujet) -
        • {{$userSujet->LIBELLE}}
        • +
        • {{$userSujet->libelle}}
        • @endforeach
        diff --git a/resources/views/users/show.blade.php b/resources/views/users/show.blade.php index db58d09..d5db720 100644 --- a/resources/views/users/show.blade.php +++ b/resources/views/users/show.blade.php @@ -42,7 +42,7 @@ {!! Form::label("", "") !!} @@ -55,7 +55,7 @@ {!! Form::label("", "") !!} diff --git a/routes/web.php b/routes/web.php index b06b62c..3b8b4c1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,6 +38,9 @@ Route::group(['middleware' => ['auth']], function(){ Route::post('/ajax/save-media', 'MediaController@saveMedia'); Route::post('/ajax/apply-sticker', 'MediaController@applySticker'); Route::post('/ajax/edit-photo', 'MediaController@editPhoto'); + Route::post('/ajax/set-id-arcadia', 'MediaController@setIdArcdadia'); + Route::post('/ajax/get-article', 'MediaController@getArticle'); + Route::post('/ajax/download-media', 'MediaController@downloadMedia')->name('downloadMedia'); // Ajax pour la gestion de l'upload de média Route::post('/ajax/upload-media', 'UploadController@storeMedia'); diff --git a/storage/export_arcadia/.gitignore b/storage/export_arcadia/.gitignore new file mode 100644 index 0000000..8f4803c --- /dev/null +++ b/storage/export_arcadia/.gitignore @@ -0,0 +1,3 @@ +* +!public/ +!.gitignore