- Fix Blandine 2

This commit is contained in:
Vincent BRIDIER 2020-10-02 09:55:33 +02:00
parent b5999b7b84
commit 4c9cf87a74
4 changed files with 117 additions and 92 deletions

View file

@ -1054,11 +1054,12 @@ class MediaController extends Controller
$deleteFileAfterSend = false;
// obtention du format
$formatId = $request->input('format');
if ($formatId != 0) {
if ($formatId != "original") {
$format = Format::withoutGlobalScope('App\Scopes\SystemScope')->where('id', $formatId)->first();
if (!$format) abort(404, 'Erreur lors du téléchargement');
} else {
$format = "";
$format = "original";
}
$mediasId = $request->input('medias');
@ -1066,10 +1067,20 @@ class MediaController extends Controller
if (sizeof($medias) == 1) {
$media = Media::where('id', $mediasId)->first();
if ($media) {
$fp = $this->get_mediaPath($media, $format);
if ($format === 'original') {
$fp = public_path() . '/' . $media->folder . $media->uid . '.' . $media->extension;
}else{
$fp = $this->get_mediaPath($media, $format);
}
if (!file_exists($fp))
abort(404, 'Fichier inconnu.');
return response()->download($fp, str_replace(' ', '_', $media->libelle)."_". $format->libelle ."_". $format->largeur ."x". $format->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend);
if ($format === 'original') {
return response()->download($fp, str_replace(' ', '_', $media->libelle)."_original_". $media->largeur ."x". $media->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend);
}else{
return response()->download($fp, str_replace(' ', '_', $media->libelle)."_". $format->libelle ."_". $format->largeur ."x". $format->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION))->deleteFileAfterSend($deleteFileAfterSend);
}
}
} else {
// create zip archive
@ -1081,13 +1092,23 @@ class MediaController extends Controller
foreach ($medias as $mediaId) {
$media = Media::where('id', $mediaId)->first();
if ($media) {
$fp = $this->get_mediaPath($media, $format);
if ($format === 'original') {
$fp = public_path() . '/' . $media->folder . $media->uid . '.' . $media->extension;
}else{
$fp = $this->get_mediaPath($media, $format);
}
if (!file_exists($fp)) {
$zip->close();
unlink($zip_file);
abort(404, 'Fichier(s) inconnu(s).');
}
$zip->addFile($fp, str_replace(' ', '_', $media->libelle)."_". $format->libelle ."_". $format->largeur ."x". $format->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION));
if ($format === 'original') {
$zip->addFile($fp, str_replace(' ', '_', $media->libelle)."_original_". $media->largeur ."x". $media->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION));
}else{
$zip->addFile($fp, str_replace(' ', '_', $media->libelle)."_". $format->libelle ."_". $format->largeur ."x". $format->hauteur ."px.".pathinfo($fp, PATHINFO_EXTENSION));
}
}
}
$deleteFileAfterSend = true;
@ -1135,13 +1156,13 @@ class MediaController extends Controller
}
$vignettes['preview'] = [
'url' => config('app.url') . "/" . $media->folder . $media->uid . "_preview" . "." . $media->extension,
'url' => config('app.url') . "/" . $media->folder . $media->uid . "_preview" . "." . $sys_extension,
'extension' => $sys_extension,
'largeur' => '1800',
'hauteur' => '1800'
];
$vignettes['thumb'] = [
'url' => config('app.url') . "/" . $media->folder . $media->uid . "_thumb" . "." . $media->extension,
'url' => config('app.url') . "/" . $media->folder . $media->uid . "_thumb" . "." . $sys_extension,
'extension' => $sys_extension,
'largeur' => '200',
'hauteur' => '200'

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View file

@ -23,17 +23,16 @@
<h3>Téléchargez</h3>
<hr/>
<p>Sélectionnez l'un des formats ci-dessous pour télécharger votre sélection.</p>
<form id="the_form_download" target="_blank" action="/ajax/download-media" method="POST">
<form ref="downloadMedias" id="the_form_download" target="_blank" action="/ajax/download-media" method="POST">
<select class="download_format" name="format">
<option value="original">Format original</option>
<option v-for="item in storeFormats" :value="item.id">{{item.libelle}}
{{item.largeur}}x{{item.hauteur}}px {{item.extension}}
</option>
</select>
<input type="hidden" name="_token" :value="csrf">
<input class="medias" type="hidden" name="medias" :value="this.storeGrabbed.map(e => e.id).join(',')">
<button type="submit" class="btn btn_form_download ml-10"><i class="fas fa-arrow-circle-down"></i>
Télécharger
</button>
<button type="submit" class="btn btn_form_download ml-10" @click="performDownload"><i class="fas fa-arrow-circle-down"></i>Télécharger</button>
</form>
</div>
@ -307,6 +306,9 @@
this.uploadedFiles = [];
this.setupResumable();
}
},
performDownload() {
this.$refs.downloadMedias.submit();
}
},
watch: {

View file

@ -81,43 +81,87 @@
</div>
</form>
</div>
<div v-if="this.oMedia.sujet_id === 1" class="row_xl article_form">
<label>Articles associées</label>
<div class="article_selector">
<table>
<thead>
<tr>
<th>No Article</th>
<th>Famille Vente</th>
<th>Marque</th>
<th>Gencod Administratif</th>
<th>Gencod Symbolise</th>
<th>Gencod Poids</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="item in oMedia.articles">
<td class="col_lib">{{item.noArt}} : {{item.libCcial}}</td>
<td class="col_famVente">{{item.codFamVte}}</td>
<td class="col_marque">{{item.codMarq}}</td>
<td class="col_gencodAdm">{{item.codGencodAdm}}</td>
<td class="col_gencodSymb">{{item.codGencodSymb}}</td>
<td class="col_gencodPds">{{item.codGencodPds}}</td>
<td><a @click="DeleteArticles(item.id)" href="#" class="remove_article"><i
class="far fa-times"></i></a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7"></td>
</tr>
</tfoot>
</table>
<br/>
<button class="add_article btn btn-black btn-square floatr" type="button" name="button"
@click="AddArticles"><i class="far fa-plus"></i> Ajouter
</button>
<div class="wrapper">
<div v-if="this.oMedia.sujet_id === 1 || this.oMedia.sujet_id === 2 || this.oMedia.sujet_id === 4"
class="wrapper arcadia_fields">
<h3>Informations liées au sujet</h3>
<div v-if="this.oMedia.sujet_id === 1" class="row_xl article_form">
<label>Articles associées</label>
<div class="article_selector">
<table>
<thead>
<tr>
<th>No Article</th>
<th>Famille Vente</th>
<th>Marque</th>
<th>Gencod Administratif</th>
<th>Gencod Symbolise</th>
<th>Gencod Poids</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="item in oMedia.articles">
<td class="col_lib">{{item.noArt}} : {{item.libCcial}}</td>
<td class="col_famVente">{{item.codFamVte}}</td>
<td class="col_marque">{{item.codMarq}}</td>
<td class="col_gencodAdm">{{item.codGencodAdm}}</td>
<td class="col_gencodSymb">{{item.codGencodSymb}}</td>
<td class="col_gencodPds">{{item.codGencodPds}}</td>
<td><a @click="DeleteArticles(item.id)" href="#" class="remove_article"><i
class="far fa-times"></i></a></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7"></td>
</tr>
</tfoot>
</table>
<br/>
<button class="add_article btn btn-black btn-square floatr" type="button" name="button"
@click="AddArticles"><i class="far fa-plus"></i> Ajouter
</button>
</div>
</div>
<div v-if="this.oMedia.sujet_id === 4" class="row societe_form dataform">
<label>Société</label>
<div class="selector_form selector_societes">
<input type="text" class="selector_filter" v-model="searchSocietes" name="search" placeholder="Rechercher..."
autocomplete="off">
<div class="selector_list">
<ul class="selector_choices">
<li v-for="item in oSocietes" :data-value="item.id"
@click="AddSocietes(item)">{{item.libelle}}
</li>
</ul>
<ul class="selector_values">
<li v-for="item in this.oMedia.societes" :data-value="item.id"
@click="DeleteSocietes(item.id)">{{item.libelle}}
</li>
</ul>
</div>
</div>
</div>
<div v-if="this.oMedia.sujet_id === 2" class="row marque_form dataform">
<label>Marque</label>
<div class="selector_form selector_marques">
<input type="text" class="selector_filter" v-model="searchMarques" name="search"
placeholder="Rechercher..." autocomplete="off">
<div class="selector_list">
<ul class="selector_choices">
<li v-for="item in oMarques" :data-value="item.codMarq"
@click="AddMarques(item)">{{item.libMarq}}
</li>
</ul>
<ul class="selector_values">
<li v-for="item in this.oMedia.marques" :data-value="item.codMarq"
@click="DeleteMarques(item.codMarq)">{{item.libMarq}}
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="wrapper">
@ -135,48 +179,6 @@
</select>
</div>
</div>
<div v-if="this.oMedia.sujet_id === 1 || this.oMedia.sujet_id === 2 || this.oMedia.sujet_id === 4"
class="wrapper arcadia_fields">
<h3>Informations liées au sujet</h3>
<div v-if="this.oMedia.sujet_id === 4" class="row societe_form dataform">
<label>Société</label>
<div class="selector_form selector_societes">
<input type="text" class="selector_filter" v-model="searchSocietes" name="search" placeholder="Rechercher..."
autocomplete="off">
<div class="selector_list">
<ul class="selector_choices">
<li v-for="item in oSocietes" :data-value="item.id"
@click="AddSocietes(item)">{{item.libelle}}
</li>
</ul>
<ul class="selector_values">
<li v-for="item in this.oMedia.societes" :data-value="item.id"
@click="DeleteSocietes(item.id)">{{item.libelle}}
</li>
</ul>
</div>
</div>
</div>
<div v-if="this.oMedia.sujet_id === 2" class="row marque_form dataform">
<label>Marque</label>
<div class="selector_form selector_marques">
<input type="text" class="selector_filter" v-model="searchMarques" name="search"
placeholder="Rechercher..." autocomplete="off">
<div class="selector_list">
<ul class="selector_choices">
<li v-for="item in oMarques" :data-value="item.codMarq"
@click="AddMarques(item)">{{item.libMarq}}
</li>
</ul>
<ul class="selector_values">
<li v-for="item in this.oMedia.marques" :data-value="item.codMarq"
@click="DeleteMarques(item.codMarq)">{{item.libMarq}}
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="wrapper">
<h3>Informations techniques</h3>
<div class="row">