Retour 02

This commit is contained in:
Thibault Richy 2019-02-26 16:31:42 +01:00
parent 985ab1edc3
commit fe2a7b62c8
19 changed files with 224 additions and 61 deletions

View file

@ -391,6 +391,25 @@ class AjaxController extends Controller
$siteId = $campagne->camp_siteId;
$demoContact = Contact::where(['contact_siteId' => $siteId, 'contact_ref' => 'DEMO'])->first();
if(!isset($demoContact)){
$req = new \Illuminate\Http\Request();
$req->setMethod('POST');
$req->request->add([
'refsite' => $siteId,
'refadherent' => 'DEMO',
'prenom' => 'Compte',
'nom' => 'Démonstration',
'email' => 'demo@demo.fr',
'code_postal' => '72000',
'commune' => 'Le Mans',
'pays' => 250
]);
$contact = new Controllers\ContactController;
$res = $contact->updateContact($req);
$demoContact = Contact::where(['contact_siteId' => $siteId, 'contact_ref' => 'DEMO'])->first();
}
if($campagne->camp_type == 0 || $campagne->camp_type == 2){
// ---- DEMONSTRATION POUR LES MURS
$myRequest = new \Illuminate\Http\Request();

View file

@ -49,6 +49,7 @@ class CampagneController extends Controller
*/
public function store(Request $request)
{
$campagne = new Campagne();
$campagne->camp_name = $request->input('camp_name');
$campagne->camp_type = $request->input('camp_type');
@ -138,7 +139,7 @@ class CampagneController extends Controller
{
$campagne->camp_published = 0;
$campagne->save();
File::deleteDirectory(public_path('/landings/' . $campagne->camp_id));
//File::deleteDirectory(public_path('/landings/' . $campagne->camp_id));
if ($campagne->delete()) {
return redirect(route('campagne.index'));
} else {

View file

@ -46,7 +46,15 @@ class ContactController extends Controller
->searchVille($ville)
->searchCountry($country)
->paginate(2,['*'],'page',$page);
return view('contact.index')->with('contacts', $contacts)->with('search', true);
$searchData = array(
'name' => $name,
'firstname' => $firstname,
'email' => $email,
'cp' => $cp,
'ville' => $ville,
'pays' => $country
);
return view('contact.index')->with('contacts', $contacts)->with('search', true)->with('searchData', $searchData);
} else {
$contacts = Contact::where('contact_siteId', session()->get('site')->site_id)->orderBy('contact_createdate', 'DESC')->take(10)->get();

View file

@ -14,6 +14,7 @@ use App\Calendrier;
use Illuminate\Support\Facades\Storage;
use App\Traits\GenerateBR;
use App\Traits\CouponTrait;
use Validator;
class CouponController extends Controller
{
@ -66,19 +67,31 @@ class CouponController extends Controller
*/
public function store(Request $request)
{
$request->validate([
$data = $request->all();
$v = Validator::make($data, [
'coupon_validity_text' => 'required',
'coupon_legal_mentions' => 'required',
'coupon_decoration_image' => 'required',
'coupon_logo_image' => 'required',
'coupon_decoration_image' => 'required|image|mimes:jpeg,png',
'coupon_logo_image' => 'required|image|mimes:jpeg,png',
'coupon_rcs' => 'required',
'coupon_site_contact' => 'required'
'coupon_site_contact' => 'required',
]);
$v->sometimes('coupon_gs1code', 'required|image|mimes:jpeg', function ($input) {
return isset($input->coupon_norme);
});
if ($v->fails()) {
return redirect('bo/coupon/'.$coupon->coupon_id.'/edit')
->withErrors($v)
->withInput();
}
$datas = $this->saveImg($request);
\Debugbar::info($datas);
$coupon = new Coupon();
$coupon->coupon_code = $datas['coupon_code'];
@ -192,6 +205,24 @@ class CouponController extends Controller
*/
public function update(Request $request, Coupon $coupon)
{
$data = $request->all();
$v = Validator::make($data, [
'coupon_decoration_image' => 'image|mimes:jpeg,png',
'coupon_logo_image' => 'image|mimes:jpeg,png',
]);
$v->sometimes('coupon_gs1code', 'required|image|mimes:jpeg', function ($input) {
return isset($input->coupon_norme);
});
if ($v->fails()) {
return redirect('bo/coupon/'.$coupon->coupon_id.'/edit')
->withErrors($v)
->withInput();
}
if(!isset($request->coupon_enablelimitquantity)){
$coupon->coupon_enablelimitquantity = 0;
}
@ -217,6 +248,15 @@ class CouponController extends Controller
$coupon->mouvements()->save($mouvement);
}
}
if(isset($datas['startdate'])){
$coupon->calendriers()->delete();
foreach($datas['startdate'] as $key => $value){
$calendar = new Calendrier();
$calendar->calendrier_startdate = $value;
$calendar->calendrier_enddate = $datas['enddate'][$key];
$coupon->calendriers()->save($calendar);
}
}
session()->flash('update_ok', 'Mise à jour du coupon réussie !');
return view('coupon.edit', ['coupon' => $coupon]);

View file

@ -52,6 +52,13 @@ class MaintenanceController extends Controller
}
public function userstore(Request $request){
$validatedData = $request->validate([
'email' => 'required|unique:users|email',
'name' => 'required',
'password' => 'required'
]);
$nom = $request->name;
$email = $request->email;
$password = $request->password;
@ -65,9 +72,12 @@ class MaintenanceController extends Controller
$user->save();
//MAJ des sites liés
$siteids = $request->site;
$sites = Site::whereIn('site_id', $siteids)->get()->pluck('id')->toArray();
$user->sites()->sync($sites);
if(isset($request->site)){
$siteids = $request->site;
$sites = Site::whereIn('site_id', $siteids)->get()->pluck('id')->toArray();
$user->sites()->sync($sites);
}
$sites = Site::all();
$usersites = $user->sites()->get()->pluck('site_id')->toArray();

View file

@ -28,7 +28,7 @@ class MurController extends Controller
$ref = $campagne->camp_id;
}
if($campagne->camp_published == 0){
if(!isset($campagne) || $campagne->camp_published == 0){
abort(404);
}

View file

@ -39,7 +39,7 @@ class SiteController extends Controller
public function store(Request $request)
{
$request->validate([
'site_id' => 'required',
'site_id' => 'required|unique:site',
'site_nom' => 'required',
'site_contact' => 'required',
'site_logo' => 'required',

View file

@ -5,6 +5,7 @@ namespace App\Traits;
use App\Campagne;
use app\Coupon;
use App\Contact;
use App\Calendrier;
use App\Mur;
use App\Panier;
@ -57,6 +58,18 @@ trait CouponTrait {
}
}
// ----- Controle le calendrier de diffusion
// $calendars = Calendrier::where(['calendrier_couponId' => $coupon->coupon_id])->get();
// if(isset($calendars)){
// $available = false;
// foreach ($calendars as $calendar) {
// if(date('Y-m-d H:i:s') > $calendar->startdate && date('Y-m-d H:i:s') < $calendar->enddate){
// $available = true;
// }
// }
// }
return $available;
}

View file

@ -123,17 +123,36 @@ trait GenerateBR {
imagecopy($mask, $ImageFond, 360, 170, 0, 0, imagesx($ImageFond), imagesy($ImageFond));
// ---- Copie le produit dans le mask
$pdt = imagecreatefromjpeg($product_image);
imagecopy($mask, $pdt, 45, 26, 0, 0, imagesx($pdt), imagesy($pdt));
imagealphablending( $mask, false );
$size = getimagesize($product_image);
switch ($size['mime']) {
case 'image/jpeg':
$pdt = imagecreatefromjpeg($product_image);
break;
case 'image/png':
$pdt = imagecreatefrompng($product_image);
break;
}
imagealphablending( $mask, true );
imagesavealpha( $mask, true );
imagecopy($mask, $pdt, 45, 26, 0, 0, imagesx($pdt), imagesy($pdt));
// ---- Copie le logo dans le mask
$logo = imagecreatefromjpeg($logo_display);
imagecopy($mask, $logo, 767, 220, 0, 0, imagesx($logo), imagesy($logo));
imagealphablending( $mask, false );
imagesavealpha( $mask, true );
$size_logo = getimagesize($logo_display);
switch ($size_logo['mime']) {
case 'image/jpeg':
$logo = imagecreatefromjpeg($logo_display);
break;
case 'image/png':
$logo = imagecreatefrompng($logo_display);
break;
}
imagealphablending( $mask, true );
imagesavealpha( $mask, true );
imagecopy($mask, $logo, 767, 220, 0, 0, imagesx($logo), imagesy($logo));
// ---- Créer le fichier final
imagepng($mask, public_path('generation')."/".$coupon->coupon_code.".png", 9);

17
public/css/app.css vendored
View file

@ -5846,9 +5846,20 @@ main section .content-wrapper .form-wrapper .form-field .title span {
main section .content-wrapper .form-wrapper .form-field.submit {
width: 100%;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
margin-top: 20px;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-align: end;
-ms-flex-align: end;
align-items: flex-end;
}
main section .content-wrapper .form-wrapper .form-field.submit span {
font-style: italic;
font-size: 0.8em;
margin-right: 20px;
}
main section .content-wrapper .form-wrapper .form-field.submit input {

View file

@ -83,7 +83,14 @@ select {
&.submit {
width:100%;
justify-content: flex-end;
margin-top:20px;
flex-direction:column;
align-items: flex-end;
span {
font-style:italic;
font-size:0.8em;
margin-right:20px;
}
input {
min-width:26%;
}

View file

@ -14,7 +14,7 @@
<input type="hidden" name="token" value="{{ $token }}">
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>
<p class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</p>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email ?? old('email') }}" required autofocus>
@ -28,7 +28,7 @@
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<p class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</p>
<div class="col-md-6">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
@ -42,7 +42,7 @@
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<p class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</p>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>

View file

@ -6,31 +6,31 @@
{!! Form::open(['route' => 'contact.store', 'enctype' => 'multipart/form-data']) !!}
<div class="form-split">
<div class="form-field">
{!! Form::label('contact_ref', 'Ref') !!}
{!! Form::label('contact_ref', 'Ref *') !!}
{!! Form::input('text', 'contact_ref', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('contact_email', 'Email') !!}
{!! Form::label('contact_email', 'Email *') !!}
{!! Form::email('contact_email', null, ['required']) !!}
</div>
</div>
<div class="form-split">
<div class="form-field">
{!! Form::label('contact_nom', 'Nom') !!}
{!! Form::label('contact_nom', 'Nom *') !!}
{!! Form::input('text','contact_nom', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('contact_prenom', 'Prénom') !!}
{!! Form::label('contact_prenom', 'Prénom *') !!}
{!! Form::input('text','contact_prenom', null, ['required']) !!}
</div>
</div>
<div class="form-split">
<div class="form-field">
{!! Form::label('contact_cp', 'Code Postal') !!}
{!! Form::label('contact_cp', 'Code Postal *') !!}
{!! Form::input('text','contact_cp', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('contact_ville', 'Ville') !!}
{!! Form::label('contact_ville', 'Ville *') !!}
{!! Form::input('text','contact_ville', null, ['required']) !!}
</div>
</div>
@ -39,7 +39,6 @@
<div class="form-field">
<label for="contact_country">Pays</label>
<select name="contact_country" id="contact_country">
<option value="" >Tous</option>
<option value="250">France</option>
<option value="056">Belgique</option>
<option value="442">Luxembourg</option>
@ -48,6 +47,7 @@
</div>
<div class="form-field submit">
<span>Les champs avec un * sont obligatoires</span>
{!! Form::submit('Enregistrer') !!}
</div>
{!! Form::close() !!}

View file

@ -8,35 +8,35 @@
<div class="form-split">
<div class="form-field">
<label for="searchName">Nom</label>
<input type="text" name="searchName" id="searchName">
<input type="text" name="searchName" id="searchName" value="@if(isset($searchData['name'])) {{$searchData['name']}} @endif">
</div>
<div class="form-field">
<label for="searchFirstname">Prénom</label>
<input type="text" name="searchFirstname" id="searchFirstname">
<input type="text" name="searchFirstname" id="searchFirstname" value="@if(isset($searchData['firstname'])) {{$searchData['firstname']}} @endif">
</div>
</div>
<div class="form-split">
<div class="form-field">
<label for="searchEmail">Email</label>
<input type="email" name="searchEmail" id="searchEmail">
<input type="email" name="searchEmail" id="searchEmail" value="@if(isset($searchData['email'])) {{$searchData['email']}} @endif">
</div>
<div class="form-field">
<label for="searchCp">Code Postal</label>
<input type="text" maxlength="6" name="searchCp" id="searchCp">
<input type="text" maxlength="6" name="searchCp" id="searchCp" value="@if(isset($searchData['cp'])) {{$searchData['cp']}} @endif">
</div>
</div>
<div class="form-split">
<div class="form-field">
<label for="searchVille">Ville</label>
<input type="text" name="searchVille" id="searchVille">
<input type="text" name="searchVille" id="searchVille" value="@if(isset($searchData['ville'])) {{$searchData['ville']}} @endif">
</div>
<div class="form-field">
<label for="searchCountry">Pays</label>
<select name="searchCountry" id="searchCountry">
<option value="">Tous</option>
<option value="250">France</option>
<option value="056">Belgique</option>
<option value="442">Luxembourg</option>
<option value="250" @if(isset($searchData['pays']) && $searchData['pays'] == 250) selected @endif>France</option>
<option value="056" @if(isset($searchData['pays']) && $searchData['pays'] == 056) selected @endif>Belgique</option>
<option value="442" @if(isset($searchData['pays']) && $searchData['pays'] == 442) selected @endif>Luxembourg</option>
</select>
</div>
</div>

View file

@ -134,11 +134,17 @@
</div>
<div class="form-split">
<div class="form-field">
{!! Form::label('coupon_decoration_image', 'Image de décoration') !!}
{!! Form::file('coupon_decoration_image', ['class' => 'input-file', 'required']) !!}
<div class="title">
{!! Form::label('coupon_decoration_image', 'Image de décoration') !!}
<span>(310x280px ou 310x160px si GS1)</span>
</div>
{!! Form::file('coupon_decoration_image', ['class' => 'input-file', 'required', 'accept' => '.jpg,.jpeg,.png']) !!}
</div>
<div class="form-field">
{!! Form::label('coupon_logo_image', 'Logo à afficher') !!}
<div class="title">
{!! Form::label('coupon_logo_image', 'Logo à afficher') !!}
<span>135x70px</span>
</div>
{!! Form::file('coupon_logo_image', ['class' => 'input-file', 'required']) !!}
</div>
</div>

View file

@ -1,6 +1,15 @@
@extends('layouts.main')
@section('content')
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="form-wrapper">
<h2><i class="fas fa-ticket-alt"></i> Editer le Coupon</h2>
{!! Form::model($coupon, ['route' => ['coupon.update', $coupon], 'enctype' => 'multipart/form-data']) !!}
@ -173,10 +182,11 @@
<div class="form-field">
<div class="title">
{!! Form::label('coupon_decoration_image', 'Image de décoration') !!}
<span>(310x280px ou 310x160px si GS1)</span>
<span>310x280px ou 310x160px si GS1</span>
<span>Formats : JPG ou PNG</span>
</div>
{!! Form::file('coupon_decoration_image', ['class' => 'input-file']) !!}
{!! Form::file('coupon_decoration_image', ['class' => 'input-file', 'accept' => '.jpg,.jpeg,.png']) !!}
@if($coupon->coupon_decoration_image != "")
<figure class="figure-desktop">
<img src="{{ asset($coupon->coupon_decoration_image) }}" alt="{{ $coupon->coupon_name }}">
@ -188,6 +198,7 @@
<div class="title">
{!! Form::label('coupon_logo_image', 'Logo à afficher') !!}
<span>135x70px</span>
<span>Formats : JPG ou PNG</span>
</div>
{!! Form::file('coupon_logo_image', ['class' => 'input-file']) !!}
@if($coupon->coupon_logo_image != "")
@ -210,7 +221,10 @@
</div>
<div class="form-split">
<div class="form-field gs1code">
{!! Form::label('coupon_gs1code', 'Image du code barre GS1') !!}
<div class="title">
{!! Form::label('coupon_gs1code', 'Image du code barre GS1') !!}
<span>Formats : JPG</span>
</div>
{!! Form::file('coupon_gs1code', ['class' => 'input-file']) !!}
@if($coupon->coupon_gs1code != "")
<figure class="figure-mobile">

View file

@ -15,36 +15,40 @@
{!! Form::open(['route' => 'site.store', 'enctype' => 'multipart/form-data']) !!}
<div class="form-split">
<div class="form-field">
{!! Form::label('site_id', 'Ref') !!}
{!! Form::label('site_id', 'Ref *') !!}
{!! Form::input('text', 'site_id', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('site_nom', 'Nom') !!}
{!! Form::label('site_nom', 'Nom *') !!}
{!! Form::input('text', 'site_nom', null, ['required']) !!}
</div>
</div>
<div class="form-split">
<div class="form-field">
{!! Form::label('site_logo', 'Logo') !!}
<div class="title">
{!! Form::label('site_logo', 'Logo *') !!}
<span>150x60px</span>
</div>
{!! Form::file('site_logo', ['class' => 'input-file', 'required']) !!}
</div>
<div class="form-field">
{!! Form::label('site_contact', 'Contact') !!}
{!! Form::label('site_contact', 'Contact *') !!}
{!! Form::email('site_contact', null, ['required']) !!}
</div>
</div>
<h4>Informations pour génération des BR :</h4>
<div class="form-split">
<div class="form-field">
{!! Form::label('site_libelle', 'Libellé du site') !!}
{!! Form::label('site_libelle', 'Libellé du site *') !!}
{!! Form::input('text', 'site_libelle', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('site_rcs', 'RCS du site') !!}
{!! Form::label('site_rcs', 'RCS du site *') !!}
{!! Form::input('text', 'site_rcs', null, ['required']) !!}
</div>
</div>
<div class="form-field submit">
<span>Les champs avec un * sont obligatoires</span>
{!! Form::submit('Enregistrer') !!}
</div>
{!! Form::close() !!}

View file

@ -18,7 +18,10 @@
</div>
<div class="form-split">
<div class="form-field">
{!! Form::label('site_logo', 'Logo') !!}
<div class="title">
{!! Form::label('site_logo', 'Logo') !!}
<span>150x60px</span>
</div>
{!! Form::file('site_logo', null, ['required']) !!}
{!! Form::input('hidden', 'site_logo_hidden', $site->site_logo) !!}
</div>
@ -52,16 +55,14 @@
<th>{{__('Ref') }}</th>
<th>{{__('Création') }}</th>
<th>{{__('Nom') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($site->campagnes as $c)
<tr>
<td>{{ $c->camp_id }}</td>
<td><a href="{{ route('campagne.edit', $c) }}">{{ $c->camp_name }}</a></td>
<td>{{ $c->camp_name }}</td>
<td>{{ $c->camp_createdate }}</td>
<td><a href="{{ route('campagne.destroy', $c) }}"><i class="fas fa-times"></i></a></td>
</tr>
@endforeach
</tbody>

View file

@ -2,22 +2,31 @@
@section('content')
<h2><i class="fas fa-users-cog"></i> Nouvel utilisateur</h2>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="form-wrapper">
{!! Form::open(['route' => 'maintenance.user.create', 'enctype' => 'multipart/form-data', 'autocomplete' => 'off']) !!}
<div class="form-split">
<div class="form-field">
{!! Form::label('name', 'Nom') !!}
{!! Form::label('name', 'Nom *') !!}
{!! Form::text('name', null, ['required']) !!}
</div>
<div class="form-field">
{!! Form::label('email', 'Email') !!}
{!! Form::label('email', 'Email *') !!}
{!! Form::input('text', 'email', null, ['required']) !!}
</div>
</div>
<div class="form-split">
<div class="form-field">
{!! Form::label('password', 'Mot de passe') !!}
{!! Form::password('password', $attributes = ['autocomplete' => 'new-password']) !!}
{!! Form::label('password', 'Mot de passe *') !!}
{!! Form::password('password', $attributes = ['autocomplete' => 'new-password', 'required' => 'required', 'minlength' => 6]) !!}
</div>
<div class="form-field">
{!! Form::label('roles', 'Rôle') !!}
@ -35,6 +44,7 @@
@endforeach
</div>
<div class="form-field submit">
<span>Les champs avec un * sont obligatoires</span>
{!! Form::submit('Enregistrer') !!}
</div>
{!! Form::close() !!}