Merge branch 'boutique-cocotte' into 'develop'

Tying up loose ends, targeting incoming live deployment

See merge request service-web-lab/boutique-cnc-sable!3
This commit is contained in:
Olivier Legat 2022-09-26 10:50:43 +00:00
commit 02f25638ad
37 changed files with 9252 additions and 98953 deletions

View file

@ -34,6 +34,16 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
MAIL_ADMIN=equipe.web@ldc.fr
MAIL_LIST_SERVICEWEB=equipe.web@ldc.fr
MAIL_LIST_INVALIDINCO=equipe.web@ldc.fr,vincent.pierre@ldc.fr,christelle.manceau@ldc.fr
# CRM
CRM_ENDPOINT=https://ldcldccrm:K5cJmTsG@dev.ldc-crm.fr
# service boutique
CRM_TOKEN=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1

View file

@ -0,0 +1,37 @@
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* This is an enumeration class,
* the following methods are its possible values
*
* @method static self none()
* @method static self loue()
* @method static self legaulois()
* @method static self marie()
* @method static self tregalette()
* @method static self esprirestauration()
*
*/
class ProductBrand extends BaseEnumRoutable
{
/**
* Enum labels
*
* @return array
*/
public static function labels()
{
return [
'none' => 'Sans marque',
'loue' => 'Loué',
'legaulois' => 'Le Gaulois',
'marie' => 'Marie',
'tregalette' => 'Tregalette',
'esprirestauration' => 'Espri Restauration',
];
}
}

57
app/Enums/SalarieSite.php Normal file
View file

@ -0,0 +1,57 @@
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* This is an enumeration class,
* the following methods are its possible values
*
* @method static self slhp()
* @method static self ldcser()
* @method static self ldcvol()
* @method static self ldcter()
* @method static self ldctra()
* @method static self ldccav()
* @method static self ldchol()
*
*/
class SalarieSite extends BaseEnumRoutable
{
/**
* Enum values
*
* @return array
*/
protected static function values(): array
{
return [
'slhp' => 'SLHP',
'ldcser' => 'LDCSER',
'ldcvol' => 'LDCVOL',
'ldcter' => 'LDCTER',
'ldctra' => 'LDCTRA',
'ldccav' => 'LDCCAV',
'ldchol' => 'LDCHOL',
];
}
/**
* Enum labels
*
* @return array
*/
public static function labels()
{
return [
'slhp' => 'Holdings',
'ldcser' => 'LDC Services',
'ldcvol' => 'LDC Sablé',
'ldcter' => 'LDC Intenational',
'ldctra' => 'LDC Traiteur',
'ldccav' => 'Cavol',
'ldchol' => 'LDC Holding',
];
}
}

View file

@ -4,24 +4,11 @@ namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\OrderLine;
use App\Models\OrdersProducts;
use App\Models\Product;
use App\Models\Timeslot;
use App\Models\Magasin;
use App\Http\Requests\SortOrders;
use Illuminate\Support\Facades\Mail;
use App\Mail\OrderStatusMail;
use App\Mail\OrderConfirmMail;
use App\Mail\OrderConfirmAdminMail;
use App\Jobs\CsvOrderWrite;
use App\Models\Customers;
use App\Models\Setting;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterval;
use Gloudemans\Shoppingcart\Facades\Cart;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
@ -58,7 +45,6 @@ class OrdersController extends Controller
$q->where('day', '=', $today->format('d/m/Y'));
});
$orders = $orders->get();
return view('bo.orders.index', compact('orders', 'today'));
}
@ -131,7 +117,6 @@ class OrdersController extends Controller
// Send confirm mail.
Mail::to($order->customer->email)->send(new OrderStatusMail($order));
Mail::mailer('smtp2')->to($order->customer->email)->send(new OrderStatusMail($order));
return back()->with('success', "Changement de status enregistré pour la commande " . $order->reference . ".");
}
@ -151,431 +136,6 @@ class OrdersController extends Controller
return back()->with('success', "La commande " . $order->reference . " à été annulée.");
}
/**
* @deprecated Supprimer cette méthode qui repose sur un modèle de donnée osolète.
* ajout de produits à la commande
*
* @param string $orderReference
* @param integer $productId
* @param integer $quantity
* @return \Illuminate\Http\RedirectResponse
*/
public function addProduct(string $orderReference, int $productId, int $quantity)
{
$product = Product::findOrFail($productId);
$order = Order::where('reference', $orderReference)->first();
$order->total = $order->total + (($product->price - $product->price_buy) * $quantity);
$orderProduct = new OrdersProducts();
$orderProduct->product_id = $product->id;
$orderProduct->order_id = $order->id;
$orderProduct->quantity = $quantity;
$orderProduct->save();
return redirect()->route('bo.orders')->with('success', "Le produit à été ajouté.");
}
/**
* front
* récap panier du tunnel de commande
*
* @return \Illuminate\Contracts\View\View
*/
public function recapOrder()
{
$activestep = 2;
Cart::instance('panier');
$cart = Cart::content();
$cartInfos = array(
"totalTTC" => Cart::total(),
// Total des taxes.
'totalTVA' => Cart::tax(),
// Total sans les taxes.
'totalHT' => Cart::subtotal(),
// Poids total des items.
'totalweight' => Cart::weight(),
// Total avant taxes et remises.
'totalHTbefore' => Cart::priceTotal(),
// Total des remises.
'totaldiscount' => Cart::discount(),
// Nb de produits dans le cart.
'countItems' => Cart::count(),
);
return view('sales.recap', compact('activestep', 'cart', 'cartInfos'));
}
/**
* front
* Storing order from sales tunnel
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store()
{
// Save.
Cart::instance('panier');
$order = new Order();
// Generate order ref.
$order->reference = $this->generateOrderRef();
$order->date = Carbon::now();
$order->status_id = 1;
$order->total = str_replace(',', '.', str_replace(' ', '', Cart::total()));
$order->customer_id = Auth::user()->id;
$order->save();
// Order_id.
Cart::instance('panier');
$cart = Cart::content();
foreach ($cart as $cartItem) {
$order_line = new OrderLine();
$order_line->order_id = $order->id;
$order_line->product_id = $cartItem->model->id;
$order_line->quantity = $cartItem->qty;
// Gross unit price.
$order_line->unit_price = $cartItem->model->priceHt;
// Discount per unit.
$order_line->unit_discount = $cartItem->model->discountAmount;
// Tax rate for this line.
$order_line->tax_rate = $cartItem->taxRate;
// Tax amount par unit.
$order_line->unit_tax = round(
(($order_line->unit_price - $order_line->unit_discount) * ($order_line->tax_rate / 100)) * 100
) / 100;
// Discount amount for the line.
$order_line->total_discount = $order_line->unit_discount * $order_line->quantity;
// Gross amount for the line.
$order_line->total_ht = ($order_line->unit_price - $order_line->unit_discount) * $order_line->quantity;
// Tax amount for the line.
$order_line->total_tax = $order_line->unit_tax * $order_line->quantity;
// Total TTC avec remises de la ligne.
$order_line->total_ttc = $order_line->total_ht + $order_line->total_tax;
$order_line->save();
}//end foreach
// Empty cart.
Cart::destroy();
// Then redirect.
return redirect()->route('sales.pick-slot', ['reference' => $order->reference]);
}
/**
* generate order Reference
* for a new order
*
* @return string
*/
public function generateOrderRef()
{
// Format : YYYYMMDDHHMM000.
$now = Carbon::now();
// Count todays orders.
$countorders = Order::whereDate('created_at', Carbon::today())->count();
// Add one.
$countorders++;
$ref = $now->isoFormat('YYYYMMDDHHmm') . str_pad($countorders, 3, "0", STR_PAD_LEFT);
return $ref;
}
/**
* front tunnel de commande étape 3 : choix de créneau
*
* @param string $reference
* @return \Illuminate\Contracts\View\View
*/
public function timeSlotPick(string $reference)
{
$activestep = 3;
if (config('theme.multi_relay')) {
$magasin = Magasin::all();
} else {
$magasin = Magasin::first();
}
$availCreneaux = array();
$order = Order::where('reference', '=', $reference)->firstOrFail();
return view('sales.pick-slot', compact('activestep', 'availCreneaux', 'order', 'magasin'));
}
/**
* add timeslot by interval between start and end hour
*
* @param array $plage
* @param integer $weekDay
* @param CarbonImmutable $current
* @param Magasin $magasin
* @param CarbonImmutable $now
* @param CarbonImmutable $today
* @param CarbonInterval $delaiPrepa
* @param CarbonInterval $interval
* @param Carbon $currentTime
* @param Carbon $endTime
* @return array
*/
private function addCreneaux(
array $plage,
int $weekDay,
CarbonImmutable $current,
Magasin $magasin,
CarbonImmutable $now,
CarbonImmutable $today,
CarbonInterval $delaiPrepa,
CarbonInterval $interval,
Carbon $currentTime,
Carbon $endTime
) {
$retArray = array();
do {
$creneau = $currentTime->format('H:i');
$nbtakens = $magasin->timeslots()
->where('day', $current->format('d/m/Y'))
->where('time', $creneau)->count();
if ($nbtakens >= $plage[$weekDay]['max_orders_per_interval']) {
$isDispo = false;
} else {
$isDispo = true;
}
if (
$current->addHours($currentTime->format('H'))->addMinutes($currentTime->format('i')) <
$now->add($delaiPrepa)
) {
$isDispo = false;
}
// Attention si la date est passée (today mais avant maintenant) : pas de créneau.
if ($current > $today || $currentTime >= $now) {
$retArray[] = array($creneau, $isDispo);
}
$currentTime->add($interval);
} while ($currentTime <= $endTime);
return $retArray;
}
/**
* give array of available crenaux
*
* @param integer $id
* @return array
*/
public function getAvailableCreneauxByShop(int $id)
{
// Setting à stocker et réutiliser.
$plage_days = Setting::where('key', 'order_withdrawal_period')->firstOrFail()->value;
$magasin = Magasin::findOrFail($id);
$timeslotSettings = $magasin->timeslotSettings;
// $timeslotSettings = TimeslotSetting::all();
// Fabriquons un tableau recap.
$plage = array();
foreach ($timeslotSettings as $day) {
$plage[$day->day_index] = array(
'morning_start' => $day->morning_start,
'morning_end' => $day->morning_end,
'afternoon_start' => $day->afternoon_start,
'afternoon_end' => $day->afternoon_end,
'interval' => $day->interval,
'min_order_preparation' => $day->min_order_preparation,
'max_orders_per_interval' => $day->max_orders_per_interval
);
}
// Génération des plages.
// Start today.
$today = CarbonImmutable::now()->startOfDay();
$weekDay = $today->weekday();
// Final boundary (permet de limiter la liste des jours d'exception).
$finalday = $today->add($plage_days, 'day');
$now = CarbonImmutable::now();
// Jours exceptions.
$noCollectDays = $magasin->collecteExceptions()
->whereDate('date', '>', $now)
->whereDate('date', '<=', $finalday)
->orderBy('date')->get();
$delaiPrepa = CarbonInterval::createFromFormat('h:i', $plage[$weekDay]['min_order_preparation'] ?? '01:00');
$availCreneaux = array();
for ($i = 0; $i < $plage_days; $i++) {
$current = $today->add($i, 'day');
$weekDay = $current->weekday();
$interval = CarbonInterval::createFromFormat('h:i', $plage[$weekDay]['interval'] ?? '00:15');
// Si c'est un jour exception skip.
$skip = false;
foreach ($noCollectDays as $not_today) {
if ($current->isSameDay($not_today->date)) {
$skip = true;
}
}
if ($skip) {
continue;
}
$availCreneaux[$current->format('d/m/Y')] = array();
// Matinée.
if (!empty($plage[$weekDay]['morning_start'])) {
$currentTime = Carbon::createFromTimeString($plage[$weekDay]['morning_start']);
$endTime = Carbon::createFromTimeString($plage[$weekDay]['morning_end']);
$morningCreneaux = $this->addCreneaux(
$plage,
$weekDay,
$current,
$magasin,
$now,
$today,
$delaiPrepa,
$interval,
$currentTime,
$endTime
);
$availCreneaux[$current->format('d/m/Y')] = array_merge(
$availCreneaux[$current->format('d/m/Y')],
$morningCreneaux
);
}//end if
// Aprem.
if (!empty($plage[$weekDay]['afternoon_start'])) {
$currentTime = Carbon::createFromTimeString($plage[$weekDay]['afternoon_start']);
$endTime = Carbon::createFromTimeString($plage[$weekDay]['afternoon_end']);
$afternoonCreneaux = $this->addCreneaux(
$plage,
$weekDay,
$current,
$magasin,
$now,
$today,
$delaiPrepa,
$interval,
$currentTime,
$endTime
);
$availCreneaux[$current->format('d/m/Y')] = array_merge(
$availCreneaux[$current->format('d/m/Y')],
$afternoonCreneaux
);
}//end if
}//end for
return $availCreneaux;
}
/**
* Call ajax pour le composant vue de timeslots.
*
* @param Request $request
* @return array
*/
public function getAvailableCreneaux(Request $request)
{
return $this->getAvailableCreneauxByShop($request->id);
}
/**
* front
* enregistrement du créneau de collect
* et validation de la commande
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function setTimeSlot(Request $request)
{
$request->validate([
'selectedmagasin' => 'required',
'selectedcreneau' => 'required',
'ok_cgv' => 'accepted',
]);
$time_slot = Carbon::createFromFormat('d/m/Y-H:i', $request->selectedcreneau);
$tsday = explode('-', $request->selectedcreneau)[0];
$tstime = explode('-', $request->selectedcreneau)[1];
$magasin_id = $request->selectedmagasin;
$reference = $request->order_ref;
$order = Order::where('reference', '=', $reference)->firstOrFail();
if ($order->status_id == 1) {
// On ne traite l'enregistrement que pour les commandes en attente venant de l'étape de récap.
// Save timeslot.
$timeslot = Timeslot::firstOrNew(['order_id' => $order->id]);
$timeslot->order_id = $order->id;
$timeslot->magasin_id = $magasin_id;
$timeslot->day = $tsday;
$timeslot->time = $tstime;
$timeslot->save();
// Save order status.
$order->status_id = 3;
$order->save();
// Send confirm mail.
Mail::to($order->customer->email)->queue(new OrderConfirmMail($order));
Mail::mailer('smtp2')->to($order->customer->email)->queue(new OrderConfirmMail($order));
// Envoi du mail de confirmation aux admins site.
$toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first();
if (empty($toMailSetting->value)) {
$toMail = config('mail.from.address');
} else {
$toMail = $toMailSetting->value;
}
Mail::to($toMail)->queue(new OrderConfirmAdminMail($order));
Mail::mailer('smtp2')->to($toMail)->queue(new OrderConfirmAdminMail($order));
// Export commande.
if (config('bosettings.regate_orders')) {
CsvOrderWrite::dispatch($order);
}
}//end if
// Redirect to final confirmation.
return redirect()->route('sales.confirm', ['reference' => $order->reference]);
}
/**
* generate Order
* Test method
*
* @param string $reference
* @return void
*/
public function generateOrder(string $reference)
{
$order = Order::where('reference', '=', $reference)->with('lines')->firstOrFail();
$job = new CsvOrderWrite($order);
$job->handle();
dd('end');
}
/**
* front
* page de confirmation de commande
*
* @param string $reference
* @return \Illuminate\Contracts\View\View
*/
public function confirmOrder(string $reference)
{
$activestep = 4;
$idcommande = Session::get('idcommande');
$order = Order::where('reference', '=', $reference)->firstOrFail();
// 1 seul magasin en base pour le moment
$magasin = Magasin::find($order->timeslot->magasin->id);
return view('sales.confirm', compact('activestep', 'order', 'magasin'));
}
/**
* bo
* ajx : affichage d'infos sur un client

View file

@ -31,6 +31,7 @@ class ProductsController extends Controller
$ranges = Range::all();
$filter_range = $request->query('filter_range');
$filter_brand = $request->query('filter_brand');
$filter_name = $request->query('filter_name');
$products = new Product();
@ -41,6 +42,9 @@ class ProductsController extends Controller
if (!empty($filter_range)) {
$products = $products->where('range_id', $filter_range);
}
if (!empty($filter_brand)) {
$products = $products->where('brand', $filter_brand);
}
$products = $products->paginate(10);
// Ici récupération des infos additionnelles pour affichage dans la liste.
@ -56,7 +60,7 @@ class ProductsController extends Controller
}
}
unset($product);
return view('bo.products.index', compact('products', 'ranges', 'filter_name', 'filter_range'));
return view('bo.products.index', compact('products', 'ranges', 'filter_name', 'filter_range', 'filter_brand'));
}
/**
@ -74,9 +78,24 @@ class ProductsController extends Controller
if (!empty($product_type)) {
$product->$product_type = new $modelClass();
}
$ranges = Range::all();
$taxes = TaxRate::all();
return view('bo.products.create', compact('product_type', 'product', 'ranges', 'taxes'));
$ranges = Range::all();
$taxes = TaxRate::all();
$existingTags = Tag::all();
$selectedtags = array();
$existingProds = Product::all();
$selectedProds = array();
return view('bo.products.create', compact(
'product_type',
'product',
'ranges',
'taxes',
'existingTags',
'selectedtags',
'existingProds',
'selectedProds'
));
}
/**
@ -89,6 +108,7 @@ class ProductsController extends Controller
{
// Products fields.
$name = $request->name;
$brand = $request->brand;
$description = $request->description;
$picture = $request->picture;
$picture_large = $request->picture_large;
@ -111,22 +131,11 @@ class ProductsController extends Controller
$rangeId = $request->range_id;
$taxRateId = $request->tax_rate_id;
// Check si le slug existe déjà dans cette gamme de produits.
$slugExist = Product::where([
['range_id', $rangeId],
['slug', $slug]
])->first();
if ($slugExist) {
return redirect()->back()
->withInput($request->input())
->withErrors("Erreur : un produit avec le slug d'accès \"" . $slug .
"\" éxiste déjà. Veuillez changer le nom du produit.");
}
$this->checkSlugExistsWithinRange($request, $rangeId, $slug);
$product = new Product();
$product->name = $name;
$product->brand = $brand;
$product->description = $description;
$product->price = $price;
$product->invoicing_unit = $invoicing_unit;
@ -146,12 +155,8 @@ class ProductsController extends Controller
$product->tax_rate_id = $taxRateId;
$product->save();
// Check si le slug existe dans la table old_slugs, auquel cas il est attribué a ce nouveau produit.
$oldSlug = OldSlug::where('slug', $slug)->first();
if ($oldSlug && $oldSlug->product_id !== $product->id) {
$oldSlug->product_id = $product->id;
$oldSlug->save();
}
// Check si le slug existe dans la table old_slugs, auquel cas il est nettoyé car ce n'est plus un old_slug.
$this->cleanOldSlug($slug);
$str_random = Str::random(5);
@ -179,6 +184,11 @@ class ProductsController extends Controller
$this->$methodName($request, $product->id);
}
// Tags associés.
$this->syncTags($request->tags, $product);
// Produits associés.
$this->syncProduitsAssocies($request->prods, $product);
// Additionnal product info (foodProduct).
return redirect()->route('bo.products.index');
@ -230,13 +240,13 @@ class ProductsController extends Controller
/**
* Check if slug already exists, if so redirect
*
* @param integer $rangeId
* @param string $slug
* @param integer $productId
* @param Request $request
* @param Request $request
* @param integer $rangeId
* @param string $slug
* @param integer|null $productId
* @return \Illuminate\Http\RedirectResponse|void
*/
private function checkSlugExistsWithinRange(int $rangeId, string $slug, int $productId, Request $request)
private function checkSlugExistsWithinRange(Request $request, int $rangeId, string $slug, int $productId = null)
{
// Check si le slug existe déjà dans cette gamme de produits.
$slugExist = Product::where([
@ -281,7 +291,7 @@ class ProductsController extends Controller
*/
private function cleanOldSlug(string $slug)
{
// Check si le slug existe dans la table old_slug, auquel cas il est attribué a ce nouveau produit.
// Check si le slug existe dans la table old_slug, auquel cas il est nettoyé.
$oldSlug = OldSlug::where('slug', $slug)->first();
if ($oldSlug) {
$oldSlug->delete();
@ -329,11 +339,11 @@ class ProductsController extends Controller
/**
* sync tags to product
*
* @param array $tags
* @param Product $product
* @param array|null $tags
* @param Product $product
* @return void
*/
private function syncTags(array $tags, Product &$product)
private function syncTags(array $tags = null, Product &$product)
{
if (!empty($tags)) {
$arTagIds = array();
@ -356,11 +366,11 @@ class ProductsController extends Controller
/**
* sync associated products to product
*
* @param string $prods
* @param Product $product
* @param string|null $prods
* @param Product $product
* @return void
*/
private function syncProduitsAssocies(string $prods, Product $product)
private function syncProduitsAssocies(string $prods = null, Product $product)
{
if (!empty($prods)) {
$productIds = explode(",", $prods);
@ -383,6 +393,7 @@ class ProductsController extends Controller
$orderable_end_time = $request->orderable_end_time === null ? "23:59" : $request->orderable_end_time;
$name = $request->name;
$brand = $request->brand;
$description = $request->description;
$price = $request->price;
$invoicing_unit = $request->invoicing_unit;
@ -403,7 +414,7 @@ class ProductsController extends Controller
$rangeId = $request->range_id;
$taxRateId = $request->tax_rate_id;
$this->checkSlugExistsWithinRange($rangeId, $slug, $product->id, $request);
$this->checkSlugExistsWithinRange($request, $rangeId, $slug, $product->id);
$this->manageProductImages($request->picture, $product, $request->picture_large);
@ -411,6 +422,7 @@ class ProductsController extends Controller
$this->saveNewSlugForProduct($product, $slug);
$product->brand = $brand;
$product->description = $description;
$product->price = $price;
$product->invoicing_unit = $invoicing_unit;
@ -430,7 +442,7 @@ class ProductsController extends Controller
$product->tax_rate_id = $taxRateId;
$product->save();
// Check si le slug existe dans la table old_slug, auquel cas il est attribué a ce nouveau produit.
// Check si le slug existe dans la table old_slug, auquel cas il est supprimé.
$this->cleanOldSlug($slug);
// Ajout des infos additionnelles.

View file

@ -48,7 +48,6 @@ class ContactController extends Controller
}
// Envoi du mail d'alerte.
Mail::to($toMail)->send(new SendContactMail($request));
Mail::mailer('smtp2')->to($toMail)->send(new SendContactMail($request));
return back()->with('status', true);
}

View file

@ -96,8 +96,6 @@ class CustomerController extends Controller
}
Mail::to($request->email)->send(new RegisterConfirmMail($customer, $request->firstname));
Mail::mailer('smtp2')->to($request->email)
->send(new RegisterConfirmMail($customer, $request->firstname));
return view('auth.register-success', ['mail' => $request->email]);
});
@ -273,9 +271,10 @@ class CustomerController extends Controller
$passwordReset->save();
Mail::to($email)->send(new PasswordResetMail($token));
Mail::mailer('smtp2')->to($email)->send(new PasswordResetMail($token));
// @phpcs:ignore Generic.Files.LineLength
return back()->with('success', __("La procédure pour changer votre mot de passe a été envoyé sur votre email."));
return back()->with(
'success',
__("La procédure pour changer votre mot de passe a été envoyé sur votre email.")
);
} else {
return back()->withErrors(__("Cette adresse email n'est pas enregistrée dans nos services."));
}
@ -523,7 +522,6 @@ class CustomerController extends Controller
}
}
Mail::to($request->email)->send(new RegisterConfirmMail($customer, null));
Mail::mailer('smtp2')->to($request->email)->send(new RegisterConfirmMail($customer, null));
return back()
->withErrors(
trans('Votre compte n\'est pas activé, vérifiez dans vos emails pour y trouver

View file

@ -0,0 +1,415 @@
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\OrderLine;
use App\Models\Timeslot;
use App\Models\Magasin;
use Illuminate\Support\Facades\Mail;
use App\Mail\OrderConfirmMail;
use App\Mail\OrderConfirmAdminMail;
use App\Jobs\CsvOrderWrite;
use App\Models\Setting;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterval;
use Gloudemans\Shoppingcart\Facades\Cart;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session;
class OrderTunnelController extends Controller
{
/**
* front
* récap panier du tunnel de commande
*
* @return \Illuminate\Contracts\View\View
*/
public function recapOrder()
{
$activestep = 2;
Cart::instance('panier');
$cart = Cart::content();
$cartInfos = array(
"totalTTC" => Cart::total(),
// Total des taxes.
'totalTVA' => Cart::tax(),
// Total sans les taxes.
'totalHT' => Cart::subtotal(),
// Poids total des items.
'totalweight' => Cart::weight(),
// Total avant taxes et remises.
'totalHTbefore' => Cart::priceTotal(),
// Total des remises.
'totaldiscount' => Cart::discount(),
// Nb de produits dans le cart.
'countItems' => Cart::count(),
);
return view('sales.recap', compact('activestep', 'cart', 'cartInfos'));
}
/**
* front
* Storing order from sales tunnel
*
* @return \Illuminate\Http\RedirectResponse
*/
public function store()
{
// Save.
Cart::instance('panier');
$order = new Order();
// Generate order ref.
$order->reference = $this->generateOrderRef();
$order->date = Carbon::now();
$order->status_id = 1;
$order->total = str_replace(',', '.', str_replace(' ', '', Cart::total()));
$order->customer_id = Auth::user()->id;
$order->save();
// Order_id.
Cart::instance('panier');
$cart = Cart::content();
foreach ($cart as $cartItem) {
$order_line = new OrderLine();
$order_line->order_id = $order->id;
$order_line->product_id = $cartItem->model->id;
$order_line->quantity = $cartItem->qty;
// Gross unit price.
$order_line->unit_price = $cartItem->model->priceHt;
// Discount per unit.
$order_line->unit_discount = $cartItem->model->discountAmount;
// Tax rate for this line.
$order_line->tax_rate = $cartItem->taxRate;
// Tax amount par unit.
$order_line->unit_tax = round(
(($order_line->unit_price - $order_line->unit_discount) * ($order_line->tax_rate / 100)) * 100
) / 100;
// Discount amount for the line.
$order_line->total_discount = $order_line->unit_discount * $order_line->quantity;
// Gross amount for the line.
$order_line->total_ht = ($order_line->unit_price - $order_line->unit_discount) * $order_line->quantity;
// Tax amount for the line.
$order_line->total_tax = $order_line->unit_tax * $order_line->quantity;
// Total TTC avec remises de la ligne.
$order_line->total_ttc = $order_line->total_ht + $order_line->total_tax;
$order_line->save();
} //end foreach
// Empty cart.
Cart::destroy();
// Then redirect.
return redirect()->route('sales.pick-slot', ['reference' => $order->reference]);
}
/**
* generate order Reference
* for a new order
*
* @return string
*/
public function generateOrderRef()
{
// Format : YYYYMMDDHHMM000.
$now = Carbon::now();
// Count todays orders.
$countorders = Order::whereDate('created_at', Carbon::today())->count();
// Add one.
$countorders++;
$ref = $now->isoFormat('YYYYMMDDHHmm') . str_pad($countorders, 3, "0", STR_PAD_LEFT);
return $ref;
}
/**
* front tunnel de commande étape 3 : choix de créneau
*
* @param string $reference
* @return \Illuminate\Contracts\View\View
*/
public function timeSlotPick(string $reference)
{
$activestep = 3;
/*
* Il faut diriger les salariés vers le bon magasin sans leur
* laisser le choix
* Dans la gestion des thèmes antérieure il était possible d'avoir 2 cas :
* theme.multi_relay : on ou off, ici cela ne sera plus le cas
* (thème non interchangeable pour cette boutique spécifique)
*/
// Si Magasin n'est pas référencé, on ne sait pas ou va le salarié.
if (Auth::user()->salarie->magasin) {
$magasin = Auth::user()->salarie->magasin;
}
$availCreneaux = array();
$order = Order::where('reference', '=', $reference)->firstOrFail();
return view('sales.pick-slot', compact('activestep', 'availCreneaux', 'order', 'magasin'));
}
/**
* add timeslot by interval between start and end hour
*
* @param array $plage
* @param integer $weekDay
* @param CarbonImmutable $current
* @param Magasin $magasin
* @param CarbonImmutable $now
* @param CarbonImmutable $today
* @param CarbonInterval $delaiPrepa
* @param CarbonInterval $interval
* @param Carbon $currentTime
* @param Carbon $endTime
* @return array
*/
private function addCreneaux(
array $plage,
int $weekDay,
CarbonImmutable $current,
Magasin $magasin,
CarbonImmutable $now,
CarbonImmutable $today,
CarbonInterval $delaiPrepa,
CarbonInterval $interval,
Carbon $currentTime,
Carbon $endTime
) {
$retArray = array();
do {
$creneau = $currentTime->format('H:i');
$nbtakens = $magasin->timeslots()
->where('day', $current->format('d/m/Y'))
->where('time', $creneau)->count();
if ($nbtakens >= $plage[$weekDay]['max_orders_per_interval']) {
$isDispo = false;
} else {
$isDispo = true;
}
if (
$current->addHours($currentTime->format('H'))->addMinutes($currentTime->format('i')) <
$now->add($delaiPrepa)
) {
$isDispo = false;
}
// Attention si la date est passée (today mais avant maintenant) : pas de créneau.
if ($current > $today || $currentTime >= $now) {
$retArray[] = array($creneau, $isDispo);
}
$currentTime->add($interval);
} while ($currentTime <= $endTime);
return $retArray;
}
/**
* give array of available crenaux
*
* @param integer $id
* @return array
*/
public function getAvailableCreneauxByShop(int $id)
{
// Setting à stocker et réutiliser.
$plage_days = Setting::where('key', 'order_withdrawal_period')->firstOrFail()->value;
$magasin = Magasin::findOrFail($id);
$timeslotSettings = $magasin->timeslotSettings;
// $timeslotSettings = TimeslotSetting::all();
// Fabriquons un tableau recap.
$plage = array();
foreach ($timeslotSettings as $day) {
$plage[$day->day_index] = array(
'morning_start' => $day->morning_start,
'morning_end' => $day->morning_end,
'afternoon_start' => $day->afternoon_start,
'afternoon_end' => $day->afternoon_end,
'interval' => $day->interval,
'min_order_preparation' => $day->min_order_preparation,
'max_orders_per_interval' => $day->max_orders_per_interval
);
}
// Génération des plages.
// Start today.
$today = CarbonImmutable::now()->startOfDay();
$weekDay = $today->weekday();
// Final boundary (permet de limiter la liste des jours d'exception).
$finalday = $today->add($plage_days, 'day');
$now = CarbonImmutable::now();
// Jours exceptions.
$noCollectDays = $magasin->collecteExceptions()
->whereDate('date', '>', $now)
->whereDate('date', '<=', $finalday)
->orderBy('date')->get();
$delaiPrepa = CarbonInterval::createFromFormat('h:i', $plage[$weekDay]['min_order_preparation'] ?? '01:00');
$availCreneaux = array();
for ($i = 0; $i < $plage_days; $i++) {
$current = $today->add($i, 'day');
$weekDay = $current->weekday();
$interval = CarbonInterval::createFromFormat('h:i', $plage[$weekDay]['interval'] ?? '00:15');
// Si c'est un jour exception skip.
$skip = false;
foreach ($noCollectDays as $not_today) {
if ($current->isSameDay($not_today->date)) {
$skip = true;
}
}
if ($skip) {
continue;
}
$availCreneaux[$current->format('d/m/Y')] = array();
// Matinée.
if (!empty($plage[$weekDay]['morning_start'])) {
$currentTime = Carbon::createFromTimeString($plage[$weekDay]['morning_start']);
$endTime = Carbon::createFromTimeString($plage[$weekDay]['morning_end']);
$morningCreneaux = $this->addCreneaux(
$plage,
$weekDay,
$current,
$magasin,
$now,
$today,
$delaiPrepa,
$interval,
$currentTime,
$endTime
);
$availCreneaux[$current->format('d/m/Y')] = array_merge(
$availCreneaux[$current->format('d/m/Y')],
$morningCreneaux
);
} //end if
// Aprem.
if (!empty($plage[$weekDay]['afternoon_start'])) {
$currentTime = Carbon::createFromTimeString($plage[$weekDay]['afternoon_start']);
$endTime = Carbon::createFromTimeString($plage[$weekDay]['afternoon_end']);
$afternoonCreneaux = $this->addCreneaux(
$plage,
$weekDay,
$current,
$magasin,
$now,
$today,
$delaiPrepa,
$interval,
$currentTime,
$endTime
);
$availCreneaux[$current->format('d/m/Y')] = array_merge(
$availCreneaux[$current->format('d/m/Y')],
$afternoonCreneaux
);
} //end if
} //end for
return $availCreneaux;
}
/**
* Call ajax pour le composant vue de timeslots.
*
* @param Request $request
* @return array
*/
public function getAvailableCreneaux(Request $request)
{
return $this->getAvailableCreneauxByShop($request->id);
}
/**
* front
* enregistrement du créneau de collect
* et validation de la commande
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function setTimeSlot(Request $request)
{
$request->validate([
'selectedmagasin' => 'required',
'selectedcreneau' => 'required',
'ok_cgv' => 'accepted',
]);
$time_slot = Carbon::createFromFormat('d/m/Y-H:i', $request->selectedcreneau);
$tsday = explode('-', $request->selectedcreneau)[0];
$tstime = explode('-', $request->selectedcreneau)[1];
$magasin_id = $request->selectedmagasin;
$reference = $request->order_ref;
$order = Order::where('reference', '=', $reference)->firstOrFail();
if ($order->status_id == 1) {
// On ne traite l'enregistrement que pour les commandes en attente venant de l'étape de récap.
// Save timeslot.
$timeslot = Timeslot::firstOrNew(['order_id' => $order->id]);
$timeslot->order_id = $order->id;
$timeslot->magasin_id = $magasin_id;
$timeslot->day = $tsday;
$timeslot->time = $tstime;
$timeslot->save();
// Save order status.
$order->status_id = 3;
$order->save();
// Send confirm mail.
Mail::to($order->customer->email)->queue(new OrderConfirmMail($order));
// Envoi du mail de confirmation aux admins site.
$toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first();
if (empty($toMailSetting->value)) {
$toMail = config('mail.from.address');
} else {
$toMail = $toMailSetting->value;
}
Mail::to($toMail)->queue(new OrderConfirmAdminMail($order));
// Export commande.
if (config('bosettings.regate_orders')) {
CsvOrderWrite::dispatch($order);
}
} //end if
// Redirect to final confirmation.
return redirect()->route('sales.confirm', ['reference' => $order->reference]);
}
/**
* front
* page de confirmation de commande
*
* @param string $reference
* @return \Illuminate\Contracts\View\View
*/
public function confirmOrder(string $reference)
{
$activestep = 4;
$idcommande = Session::get('idcommande');
$order = Order::where('reference', '=', $reference)->firstOrFail();
// 1 seul magasin en base pour le moment
$magasin = Magasin::find($order->timeslot->magasin->id);
return view('sales.confirm', compact('activestep', 'order', 'magasin'));
}
}

View file

@ -118,8 +118,8 @@ class CsvOrderWrite extends CsvJobs
$this->order->reference . "_" .
$code_client . "_" .
$customer->salarie->nom . "_" .
$customer->salarie->prenom . "_" .
str_pad($customer->salarie->code_societe, 3, "0", STR_PAD_LEFT) . ".csv";
$customer->salarie->prenom .
"_001.csv";
$disk->put($outputfilename, $data);

View file

@ -3,12 +3,15 @@
namespace App\Jobs;
use App\Enums\LogType;
use App\Enums\SalarieSite;
use App\Models\Salarie;
use ErrorException;
use TypeError;
use Illuminate\Database\QueryException;
use App\Exceptions\AbortCsvImportException;
use Illuminate\Support\Str;
use App\Lib\Utils;
use App\Models\Magasin;
use Carbon\Carbon;
class CsvSalariesReader extends CsvJobs
{
@ -65,20 +68,7 @@ class CsvSalariesReader extends CsvJobs
$filepath = $disk->path($filename);
try {
$data = $this->parseCsv($filepath);
// First line is header (mandatory).
$header = array_flip(array_shift($data));
foreach ($data as $line) {
$matricule = $line[$header['matricule']];
$prenom = $line[$header['prenom']];
$nom = $line[$header['nom']];
$salarie = Salarie::firstOrNew(['matricule' => $matricule ]);
$salarie->matricule = $matricule;
$salarie->nom = $nom;
$salarie->prenom = $prenom;
$salarie->code = $salarie->code ?? $this->generateCode();
$salarie->save();
}
$this->processFile($filepath);
} catch (ErrorException | TypeError | QueryException $e) {
$message = $e->getMessage();
if (get_class($e) === QueryException::class) {
@ -93,8 +83,8 @@ class CsvSalariesReader extends CsvJobs
),
LogType::critical()
);
// Ignore the file.
continue;
// Ignore the file.
} catch (AbortCsvImportException $e) {
$this->log(
sprintf(
@ -105,8 +95,8 @@ class CsvSalariesReader extends CsvJobs
),
LogType::error()
);
// Ignore the file.
continue;
// Ignore the file.
}//end try
$this->moveToArchives($filename);
}//end foreach
@ -115,6 +105,50 @@ class CsvSalariesReader extends CsvJobs
$this->clearOldArchives();
}
/**
* Read one file and save salarie for each line
*
* @param string $filepath
* @return void
*/
private function processFile(string $filepath)
{
$data = $this->parseCsv($filepath);
// First line is header (mandatory).
$header = array_flip(array_shift($data));
foreach ($data as $line) {
$matricule = $line[$header['Matricule']];
$prenom = $line[$header['Prénom']];
$nom = $line[$header['Nom']];
$start_date = Carbon::createFromFormat('d/m/Y', $line[$header['Date début']]);
$end_date = $line[$header['Date fin']] ?
$line[$header['Date fin']] : $line[$header['Date fin prévue']];
$etablissement = $line[$header['Etablissement']];
$site = $line[$header['Site']];
$service = $line[$header['Service']];
if ($end_date != '') {
$end_date = Carbon::createFromFormat('d/m/Y', $end_date);
} else {
$end_date = null;
}
$salarie = Salarie::firstOrNew(['matricule' => $matricule]);
$salarie->matricule = $matricule;
$salarie->nom = $nom;
$salarie->prenom = $prenom;
$salarie->start_date = $start_date;
$salarie->end_date = $end_date;
$salarie->etablissement = $etablissement;
$salarie->site = $site;
$salarie->service = $service;
$salarie->code = $salarie->code ?? $this->generateCode();
$salarie->save();
$this->setMagasin($salarie);
} //end foreach
}
/**
* Génère un code d'inscription
*
@ -122,6 +156,31 @@ class CsvSalariesReader extends CsvJobs
*/
protected function generateCode()
{
return Str::random(5);
return Utils::generateRandomString(8);
}
/**
* Sets the fixed collection point for a salarie.
* For now all we now is that site LDCCAV goes to magasin Cavol.
*
* @param \App\Models\Salarie $salarie
* @return void
*/
protected function setMagasin(Salarie $salarie)
{
/*
* Pour le moment, avec cette première phase de déploiement,
* seuls les salariés du site LDCCAV vont au magasin 3.
* Les autres au magasin 1.
*/
if ($salarie->site == SalarieSite::ldccav()) {
$magasin = Magasin::find(3);
$salarie->magasin()->associate($magasin);
} else {
$magasin = Magasin::find(1);
$salarie->magasin()->associate($magasin);
}
$salarie->save();
}
}

25
app/Lib/Utils.php Normal file
View file

@ -0,0 +1,25 @@
<?php
namespace App\Lib;
class Utils
{
/**
* Simple Custom Random string generator
*
* @param integer $length
* @param string $characters
* @return string
*/
public static function generateRandomString(
int $length = 10,
string $characters = 'abcdefghjkmnpqrstuwxyzABCDEFGHJKMNPQRSTUWXYZ123456789'
) {
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
}

View file

@ -34,7 +34,7 @@ class RegisterConfirmMail extends Mailable implements ShouldQueue
* @param string|null $firstname
* @return void
*/
public function __construct(Customers $customer, mixed $firstname)
public function __construct(Customers $customer, string $firstname = null)
{
$this->firstname = $firstname;
$this->customer = $customer;

View file

@ -3,6 +3,7 @@
namespace App\Models;
use App\Enums\InvoicingUnit;
use App\Enums\ProductBrand;
use App\Enums\SellUnit;
use App\Enums\WeightUnit;
use Carbon\Carbon;
@ -12,12 +13,14 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Gloudemans\Shoppingcart\Contracts\Buyable;
use Gloudemans\Shoppingcart\CanBeBought;
use Illuminate\Support\Facades\Auth;
use Kwaadpepper\Enum\Traits\CastsEnums;
class Product extends Model implements Buyable
{
use HasFactory;
use SoftDeletes;
use CanBeBought;
use CastsEnums;
/**
* The attributes that should be cast to native types.
@ -29,6 +32,15 @@ class Product extends Model implements Buyable
'orderable_end' => 'datetime',
];
/**
* Map attribute names to enum classes.
*
* @var array
*/
public $enumCasts = [
'brand' => ProductBrand::class
];
/**
* Store in protected variables instead of attributes
* Because those are not set in attributes, Laravel will not try to save it to database

View file

@ -17,9 +17,9 @@ class Salarie extends Model
*/
protected $fillable = [
'matricule',
'nom',
'prenom',
'code'
'nom', 'prenom',
'code',
'start_date', 'end_date', 'etablissement', 'site', 'service'
];
/**
@ -31,4 +31,14 @@ class Salarie extends Model
{
return $this->belongsTo(Customers::class);
}
/**
* belongsTo magasin relation
*
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
*/
public function magasin()
{
return $this->belongsTo(Magasin::class);
}
}

View file

@ -3,6 +3,7 @@
namespace App\Policies;
use App\Models\Product;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Illuminate\Auth\Access\Response;
use Illuminate\Support\Carbon;
@ -12,22 +13,13 @@ class ProductPolicy
use HandlesAuthorization;
/**
* Create a new policy instance.
*
* @return void
*/
public function __construct()
{
}
/**
* @param App\Models\User|App\Models\Customers $user
* @param \App\Models\Product $product
* @param App\Models\User|App\Models\Customers|null $user
* @param \App\Models\Product $product
*
* @return \Illuminate\Auth\Access\Response
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
*/
public function addToCart($user, Product $product)
public function addtocart(?User $user, Product $product)
{
// phpcs:enable
$now = Carbon::now();

View file

@ -9,6 +9,7 @@ use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\URL;
class AppServiceProvider extends ServiceProvider
@ -38,29 +39,36 @@ class AppServiceProvider extends ServiceProvider
setlocale(LC_TIME, strtoupper(config('app.locale')) . "_" . config('app.locale') . '.utf8');
}
config([
'bosettings' => Setting::all()
->keyBy('key')
// Key every setting by its name.
->transform(function ($setting) {
return $setting->value;
// Return only the value.
})
->toArray()
// Make it an array.
]);
if (Schema::hasTable('settings')) {
// The "settings" table exists...
config([
'bosettings' => Setting::all()
->keyBy('key')
// Key every setting by its name.
->transform(function ($setting) {
return $setting->value;
// Return only the value.
})
->toArray()
// Make it an array.
]);
// On partage les ranges (gammes produit).
$ranges = Range::where('status', '1')->get();
View::share('published_ranges', $ranges);
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
// Front theme settings.
View::share('front_settings', $front_settings);
}
// On partage les tags.
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
View::share('published_tags', $tags);
if (Schema::hasTable('ranges')) {
// On partage les ranges (gammes produit).
$ranges = Range::where('status', '1')->get();
View::share('published_ranges', $ranges);
}
$front_settings = Setting::where('key', 'LIKE', 'theme_%')->get();
// Front theme settings.
View::share('front_settings', $front_settings);
if (Schema::hasTable('tags')) {
// On partage les tags.
$tags = Tag::where('status', '1')->orderBy('order', 'ASC')->get();
View::share('published_tags', $tags);
}
Blade::directive('fmt_currency', function ($expression) {
return "<?php

View file

@ -2,10 +2,21 @@
namespace App\Providers;
use App\Models\Product;
use App\Policies\ProductPolicy;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
Product::class => ProductPolicy::class,
];
/**
* Register any authentication / authorization services.
*

View file

@ -245,6 +245,7 @@ return [
'SettingRegisterMode' => \App\Enums\SettingRegisterMode::class,
'SellUnit' => \App\Enums\SellUnit::class,
'OrderUnit' => \App\Enums\OrderUnit::class,
'ProductBrand' => \App\Enums\ProductBrand::class,
'InvoicingUnit' => \App\Enums\InvoicingUnit::class,
'WeightUnit' => \App\Enums\WeightUnit::class,
'PriceShowingMode' => \App\Enums\PriceShowingMode::class,

View file

@ -45,17 +45,6 @@ return [
'auth_mode' => null,
],
'smtp2' => [
'transport' => env('MAIL_TRANSPORT2', 'array'),
'host' => env('MAIL_HOST2'),
'port' => env('MAIL_PORT2'),
'encryption' => env('MAIL_ENCRYPTION2'),
'username' => env('MAIL_USERNAME2'),
'password' => env('MAIL_PASSWORD2'),
'timeout' => null,
'auth_mode' => null,
],
'ses' => [
'transport' => 'ses',
],

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddBrandToProducts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->string('brand')->nullable()->after('name');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('brand');
});
}
}

View file

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddFieldsToSalaries extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('salaries', function (Blueprint $table) {
$table->timestamp('start_date')->nullable()->after('prenom');
$table->timestamp('end_date')->nullable()->after('start_date');
$table->string('etablissement')->after('end_date');
$table->string('site')->after('etablissement');
$table->string('service')->after('site');
// On supprime la colonne code_societe, on connectera les points de collecte à proposer via le site.
$table->dropColumn('code_societe');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('salaries', function (Blueprint $table) {
$table->dropColumn('start_date');
$table->dropColumn('end_date');
$table->dropColumn('etablissement');
$table->dropColumn('site');
$table->dropColumn('service');
$table->integer('code_societe')->nullable()->after('prenom');
});
}
}

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class LinkMagasinToSalaries extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('salaries', function (Blueprint $table) {
// Liaison à la table magasins.
$table->foreignId('magasin_id')->nullable()->after('service')->constrained('magasins');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('salaries', function (Blueprint $table) {
$table->dropForeign(['magasin_id']);
$table->dropColumn('magasin_id');
});
}
}

21970
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,12 +2,12 @@
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
"production": "mix --production"
},
"devDependencies": {
"@voerro/vue-tagsinput": "^2.7.1",
@ -15,22 +15,23 @@
"bootstrap": "^5.1.3",
"cross-env": "^7.0",
"jquery": "^3.6",
"laravel-mix": "^5.0.1",
"laravel-mix": "^6.0.49",
"lodash": "^4.17.19",
"popper.js": "^1.12",
"resolve-url-loader": "^3.1.0",
"sass-loader": "^8.0.2",
"swiper": "^6.3.4",
"toastify-js": "^1.10.0",
"vue": "^2.7.10",
"vue-loader": "^15.10.0",
"vue-smooth-dnd": "^0.8.1",
"vue-template-compiler": "^2.6.12"
"vue-template-compiler": "^2.6.12",
"vuex": "^3.6.2"
},
"dependencies": {
"@fancyapps/fancybox": "^3.5.7",
"@fortawesome/fontawesome-free": "^5.15.3",
"sass": "^1.28.0",
"tippy.js": "^6.3.1",
"vue": "^2.6.12",
"vuex": "^3.6.2"
"tippy.js": "^6.3.1"
}
}

1
public/.gitignore vendored
View file

@ -1,4 +1,3 @@
*
!.gitignore
!b-o/*
!basic/*

18434
public/b-o/css/app.css vendored

File diff suppressed because one or more lines are too long

65523
public/b-o/js/app.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,70 +0,0 @@
/*!
* Bootstrap v4.6.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
/*!
* Sizzle CSS Selector Engine v2.3.6
* https://sizzlejs.com/
*
* Copyright JS Foundation and other contributors
* Released under the MIT license
* https://js.foundation/
*
* Date: 2021-02-16
*/
/*!
* Vue.js v2.6.12
* (c) 2014-2020 Evan You
* Released under the MIT License.
*/
/*!
* jQuery JavaScript Library v3.6.0
* https://jquery.com/
*
* Includes Sizzle.js
* https://sizzlejs.com/
*
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2021-03-02T17:08Z
*/
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.16.1
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

View file

@ -1,6 +0,0 @@
{
"/b-o/js/app.js": "/b-o/js/app.js",
"/b-o/css/app.css": "/b-o/css/app.css",
"/ldc/css/app.css": "/ldc/css/app.css",
"/ldc/js/app.js": "/ldc/js/app.js"
}

3
resources/js/app.js vendored
View file

@ -1,8 +1,7 @@
//import Toastify from "toastify-js";
require('./bootstrap');
require('@fancyapps/fancybox');
//window.Toastify = Toastify;
window.Vue = require('vue');
import Vue from 'vue'
// Vuex
// import Vuex from 'vuex';

View file

@ -18,168 +18,7 @@
</ul>
</div>
@endif
<div class="form-group">
<label for="name">Nom du produit *</label>
<input type="text" id="name" name="name" class="form-control" placeholder="Nom du produit" value="{{ old('name') }}" required>
</div>
<div class="form-group">
<label>Description *</label>
<textarea class="form-control" id="description" name="description" placeholder="Description *" value="{{ old('description') }}"></textarea>
</div>
<div class="form-group">
<label for="picture">Image <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.product_image_maxwidth') }} px par {{ Config::get('theme.product_image_maxheight') }} px</small></label></br>
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
</div>
<div class="form-group">
<label for="picture_large">Image (grande) <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.product_image_large_maxwidth') }} px par {{ Config::get('theme.product_image_large_maxheight') }} px</small></label></br>
<input type="file" id="picture_large" name="picture_large" accept="image/png, image/jpeg">
</div>
<div class="row">
<div class="form-group col">
<label for="price">Prix en € *</label>
<input type="number" id="price" name="price" min="0" step=".001" class="form-control" value="{{ old('price') }}" required>
</div>
<div class="form-group col">
<label for="invoicing_unit">Unité de facturation
<span class="tipped"
data-tippy-content="Unité de base permettant d'établir le prix">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="invoicing_unit" name="invoicing_unit">
@foreach (InvoicingUnit::toArray() as $invoicingunit_type)
<option value="{{$invoicingunit_type->value}}" @if (old('invoicing_unit') == $invoicingunit_type->value)selected @endif>{{$invoicingunit_type->label}}</option>
@endforeach
</select>
</div>
{{--<div class="form-group col">
<label for="price_buy">Prix d'achat en €</label>
<input type="number" id="price_buy" name="price_buy" min="0" step=".01" class="form-control" value="{{ old('price_buy') }}">
</div>--}}
<div class="form-group col">
<label for="tax_rate_id">TVA Applicable</label>
<select class="form-select" id="tax_rate_id" name="tax_rate_id">
@foreach($taxes as $taxe)
<option value="{{$taxe->id}}">{{$taxe->label}}</option>
@endforeach
</select>
</div>
<div class="form-group col"></div>
</div>
<div class="row">
@if (config('bosettings.regate_orders'))
<div class="form-group col">
<label for="order_unit">Unité de commande
<span class="tipped"
data-tippy-content="Unité utilisée lors de la transmission de commande à Regate">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="order_unit" name="order_unit">
@foreach (OrderUnit::toArray() as $orderunit_type)
<option value="{{$orderunit_type->value}}" @if (old('order_unit') == $orderunit_type->value)selected @endif>{{$orderunit_type->label}}</option>
@endforeach
</select>
</div>
@endif
<div class="form-group col">
<label for="stock">Stock</label>
<input type="number" id="stock" name="stock" class="form-control" min="0" value="{{ old('stock') }}">
</div>
<div class="form-group col">
<label for="reference">Référence @if (config('bosettings.regate_orders')) *
<span class="tipped"
data-tippy-content="Code Article utilisé lors de la transmission de commande à Regate">
<i class="fas fa-question-circle"></i>
</span>
@else
@endif
</label>
<input type="text" id="reference" name="reference" class="form-control" value="{{ old('reference') }}" @if (config('bosettings.regate_orders')) required @endif>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
<div class="row">
<div class="form-group col">
<label for="sell_unit">Unité de vente
<span class="tipped"
data-tippy-content="Unité de vente consommateur">
<i class="fas fa-question-circle"></i>
</span>
</label>
@if (config('bosettings.sell_unit_management') == "strict")
<select class="form-select col-md-9" id="sell_unit" name="sell_unit">
@foreach (SellUnit::toArray() as $sellunit_type)
<option value="{{$sellunit_type->value}}" @if (old('sell_unit') == $sellunit_type->value)selected @endif>{{$sellunit_type->label}}</option>
@endforeach
</select>
@else
<input type="text" id="sell_unit" name="sell_unit" class="form-control" value="{{ old('sell_unit') }}">
@endif
</div>
<div class="form-group col">
<label for="weight">Poids de l'article</label>
<input type="number" id="weight" name="weight" min="0" step=".01" class="form-control" value="{{ old('weight') }}">
</div>
<div class="form-group col">
<label for="weight_unit">Unité de poids
<span class="tipped"
data-tippy-content="Unité de poids normalisée">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="weight_unit" name="weight_unit">
@foreach (WeightUnit::toArray() as $wheightunit_type)
<option value="{{$wheightunit_type->value}}" @if (old('weight_unit') == $wheightunit_type->value)selected @endif>{{$wheightunit_type->label}}</option>
@endforeach
</select>
{{--<input type="text" id="weight_unit" name="weight_unit" class="form-control" value="{{ old('weight_unit') }}">--}}
</div>
<div class="form-group col"></div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="star">
Mise en avant ?
</label>
</div>
<div class="row">
<div class="form-group col">
<label for="range_id">Gamme de produits</label>
<select class="form-select" id="range_id" name="range_id">
@foreach($ranges as $range)
<option value="{{$range->id}}">{{$range->name}}</option>
@endforeach
</select>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="status">
Publié ?
</label>
</div>
<div class="row">
<div class="form-group col">
<label for="orderable_start_date">Le produit peut être commandé à partir de :</label>
<input type="date" id="orderable_start_date" name="orderable_start_date" class="form-control" value="{{ old('orderable_start_date') }}">
<input type="time" id="orderable_start_time" name="orderable_start_time" class="form-control" value="{{ old('orderable_start_time') }}">
<small class="text-muted"> laisser vide pour que le produit puisse être commandé immédiatement </small>
</div>
<div class="form-group col">
<label for="orderable_end_date">Le produit ne pourra pas être commandé après : </label>
<input type="date" id="orderable_end_date" name="orderable_end_date" class="form-control" value="{{ old('orderable_end_date') }}">
<input type="time" id="orderable_end_time" name="orderable_end_time" class="form-control" value="{{ old('orderable_end_time') }}">
<small class="text-muted"> laisser vide pour que le produit puisse toujours être commandé </small>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
@include('bo.products.standard_form_inputs')
@if(!empty($product_type))
@include('bo.products.' . Str::snake($product_type))
@endif
@ -188,6 +27,47 @@
@section('scripts')
<script type="text/javascript">
function showPicture(id,filename) {
if ( $( id ).length ) {
$( id ).attr('href',"/images/produits/" + filename);
$( id + " img" ).attr('src',"/images/produits/" + filename);
} else {
id = id.replace("#img-","");
console.log(id);
let template = `<br/><br/>
<a data-fancybox="gallery" href="/images/produits/`+filename+`" id="#img-`+ id +`">
<img src="/images/produits/`+filename+`" alt="" style="max-height: 100px;"></a>`;
$( "#"+id ).after(template);
}
}
function setPicture(imgname) {
axios.post('/bo/ajax/set-inco-images', {
picture: imgname,
product: {{ $product->id ?? 0}}
}).then(
(response) => {
if(typeof(response.data) == "object") {
showPicture("#img-picture",response.data.picture);
showPicture("#img-picture_large",response.data.picture_large);
}
}
)
.catch(function (error) {
console.log(error);
alert('Erreur lors de la mise à jour.');
this.processing = false;
});
}
function paste(from,to) {
if(window[to+'Editor']) {
window[to+'Editor'].setData(document.getElementById(from).innerHTML);
} else {
document.getElementById(to).value = document.getElementById(from).innerHTML;
}
}
var editorConfig = {
removePlugins: ["Image", "ImageCaption", "ImageStyle", "ImageToolbar", "ImageUpload"],
toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', '|', 'blockQuote', 'insertTable', '|', 'undo', 'redo' ],
@ -213,5 +93,24 @@
.catch( error => {
console.error( error );
} );
$(document).ready(function(){
$("#prepareIncoImages").click(function(){
axios.post('/bo/ajax/get-inco-images', {
picture: @json($product->foodProduct->xmlInco->picture ?? ''),
}).then(
(response) => {
if(response.data.length) {
$('#inco_media').html(response.data);
}
}
)
.catch(function (error) {
console.log(error);
alert('Erreur lors de la vérification.');
this.processing = false;
});
});
});
</script>
@endsection

View file

@ -22,234 +22,7 @@
</ul>
</div>
@endif
<div class="form-group">
<label for="name">Nom du produit *</label>
<input type="text" id="name" name="name" class="form-control" placeholder="Nom du produit" value="{{ old('name', $product->name) }}" required>
@if ($product->product_type == "foodProduct")
@if (!empty($product->foodProduct->xmlInco))
<a class="btn btn-outline-info btn-sm" data-bs-toggle="collapse" href="#inco_nom" aria-expanded="false" aria-controls="collapseExample">Donnée inco</a>
<div class="collapse row" id="inco_nom">
<div class="input-group mb-2">
<div class="input-group-prepend">
<a class="btn btn-secondary" onclick="paste('nom','name')">Reprendre cette donnée</a>
</div>
<div class="inco_data form-control alert-info" id="nom">{{ $product->foodProduct->xmlInco->nom }}</div>
</div>
</div>
@endif
@endif
</div>
<div class="form-group">
<label for="name">Tags</label>
<auto-complete-tags
dbexistingtags='@json($existingTags)'
dbselectedtags='@json($selectedtags)'
element-id="tags"
id-field="id"
text-field="label"
></auto-complete-tags>
</div>
<div class="form-group">
<label>Description *</label>
<textarea class="form-control" id="description" name="description" placeholder="Description *">{{ old('description', $product->description) }}</textarea>
@if ($product->product_type == "foodProduct")
@if (!empty($product->foodProduct->xmlInco))
<a class="btn btn-outline-info btn-sm" data-bs-toggle="collapse" href="#inco_descriptif" aria-expanded="false" aria-controls="collapseExample">Donnée inco</a>
<div class="collapse row" id="inco_descriptif">
<div class="input-group mb-2">
<div class="input-group-prepend">
<a class="btn btn-secondary" onclick="paste('descriptif','description')">Reprendre cette donnée</a>
</div>
<div class="inco_data form-control alert-info" id="descriptif">{{ $product->foodProduct->xmlInco->descriptif }}</div>
</div>
</div>
@endif
@endif
</div>
<div class="form-group">
<label for="picture">Image <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.product_image_maxwidth') }} px par {{ Config::get('theme.product_image_maxheight') }} px</small></label></br>
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
@if ($product->picture !== null)
<br/>
<br/>
<a data-fancybox="gallery" href="/images/produits/{{$product->picture}}" id="img-picture">
<img src="/images/produits/{{$product->picture}}" alt="{{$product->name}}" style="max-height: 100px;">
</a>
@endif
{{-- variante préparation d'images --}}
@if ($product->product_type == "foodProduct")
@if (!empty($product->foodProduct->xmlInco->picture))
<a class="btn btn-outline-info btn-sm" data-bs-toggle="collapse" href="#inco_media" aria-expanded="false" aria-controls="collapseExample" id="prepareIncoImages">Images inco</a>
<div class="collapse row" id="inco_media">
<!--inco images container-->
</div>
@endif
@endif
</div>
<div class="form-group">
<label for="picture_large">Image (grande) <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.product_image_large_maxwidth') }} px par {{ Config::get('theme.product_image_large_maxheight') }} px</small></label></br>
<input type="file" id="picture_large" name="picture_large" accept="image/png, image/jpeg">
@if ($product->picture_large !== null)
<br/>
<br/>
<a data-fancybox="gallery" href="/images/produits/{{$product->picture_large}}" id="img-picture_large">
<img src="/images/produits/{{$product->picture_large}}" alt="{{$product->name}}" style="max-height: 100px;">
</a>
@endif
</div>
<div class="row">
<div class="form-group col">
<label for="price">Prix en € *</label>
<input type="number" id="price" name="price" min="0" step=".001" class="form-control" value="{{ old('price', $product->price)}}" required>
</div>
<div class="form-group col">
<label for="invoicing_unit">Unité de facturation
<span class="tipped"
data-tippy-content="Unité de base permettant d'établir le prix">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="invoicing_unit" name="invoicing_unit">
@foreach (InvoicingUnit::toArray() as $invoicingunit_type)
<option value="{{$invoicingunit_type->value}}" @if (old('invoicing_unit', $product->invoicing_unit) == $invoicingunit_type->value)selected @endif>{{$invoicingunit_type->label}}</option>
@endforeach
</select>
</div>
{{--<div class="form-group col">
<label for="price_buy">Prix d'achat en €</label>
<input type="number" id="price_buy" name="price_buy" min="0" step=".01" class="form-control" value="{{ old('price_buy', $product->price_buy)}}">
</div>--}}
<div class="form-group col">
<label for="tax_rate_id">TVA Applicable</label>
<select class="form-select" id="tax_rate_id" name="tax_rate_id">
@foreach($taxes as $taxe)
<option value="{{$taxe->id}}" @if ($taxe->id === old('tax_rate_id',$product->tax_rate_id)) selected @endif>{{$taxe->label}}</option>
@endforeach
</select>
</div>
<div class="form-group col"></div>
</div>
<div class="row">
@if (config('bosettings.regate_orders'))
<div class="form-group col">
<label for="order_unit">Unité de commande
<span class="tipped"
data-tippy-content="Unité utilisée lors de la transmission de commande à Regate">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="order_unit" name="order_unit">
@foreach (OrderUnit::toArray() as $orderunit_type)
<option value="{{$orderunit_type->value}}" @if (old('order_unit', $product->order_unit) == $orderunit_type->value)selected @endif>{{$orderunit_type->label}}</option>
@endforeach
</select>
</div>
@endif
<div class="form-group col">
<label for="stock">Stock</label>
<input type="number" id="stock" name="stock" class="form-control" min="0" value="{{ old('stock', $product->stock)}}">
</div>
<div class="form-group col">
<label for="reference">Référence @if (config('bosettings.regate_orders')) *
<span class="tipped"
data-tippy-content="Code Article utilisé lors de la transmission de commande à Regate">
<i class="fas fa-question-circle"></i>
</span>
@endif
</label>
<input type="text" id="reference" name="reference" class="form-control" value="{{ old('reference', $product->reference)}}" @if (config('bosettings.regate_orders')) required @endif>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
<div class="row">
<div class="form-group col">
<label for="sell_unit">Unité de vente
<span class="tipped"
data-tippy-content="Unité de vente consommateur">
<i class="fas fa-question-circle"></i>
</span>
</label>
@if (config('bosettings.sell_unit_management') == "strict")
<select class="form-select col-md-9" id="sell_unit" name="sell_unit">
@foreach (SellUnit::toArray() as $sellunit_type)
<option value="{{$sellunit_type->value}}" @if (old('sell_unit', $product->sell_unit) == $sellunit_type->value)selected @endif>{{$sellunit_type->label}}</option>
@endforeach
</select>
@else
<input type="text" id="sell_unit" name="sell_unit" class="form-control" value="{{ old('sell_unit', $product->sell_unit)}}">
@endif
</div>
<div class="form-group col">
<label for="weight">Poids de l'article</label>
<input type="number" id="weight" name="weight" min="0" step=".01" class="form-control" value="{{ old('weight', $product->weight)}}">
</div>
<div class="form-group col">
<label for="weight_unit">Unité de poids
<span class="tipped"
data-tippy-content="Unité de poids normalisée">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="weight_unit" name="weight_unit">
@foreach (WeightUnit::toArray() as $wheightunit_type)
<option value="{{$wheightunit_type->value}}" @if (old('weight_unit', $product->weight_unit) == $wheightunit_type->value)selected @endif>{{$wheightunit_type->label}}</option>
@endforeach
</select>
{{--<input type="text" id="weight_unit" name="weight_unit" class="form-control" value="{{ old('weight_unit', $product->weight_unit)}}">--}}
</div>
<div class="form-group col"></div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="star" @if ($product->star === 1) checked @endif>
Mise en avant ?
</label>
</div>
<div class="row">
<div class="form-group col">
<label for="range_id">Gamme de produits</label>
<select class="form-select" id="range_id" name="range_id">
@foreach($ranges as $range)
<option value="{{$range->id}}" @if ($range->id === old('range_id',$product->range_id)) selected @endif>{{$range->name}}</option>
@endforeach
</select>
</div>
<div class="form-group col">
<div class="form-group">
<label for="name">Produist associés</label>
<products-cards-dnd
dbexistingprods='@json($existingProds)'
dbselectedprods='@json($selectedProds)'
element-id="prods"
></products-cards-dnd>
</div>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="status" @if ($product->status === 1) checked @endif>
Publié ?
</label>
</div>
<div class="row">
<div class="form-group col">
<label for="orderable_start_date">Le produit peut être commandé à partir de :</label>
<input type="date" id="orderable_start_date" name="orderable_start_date" class="form-control" value="{{ old('orderable_start_date', !is_null($product->orderable_start) ? date_format($product->orderable_start, "Y-m-d") : "") }}">
<input type="time" id="orderable_start_time" name="orderable_start_time" class="form-control" value="{{ old('orderable_start_time', !is_null($product->orderable_start) ? date_format($product->orderable_start, "H:i") : "") }}">
<small class="text-muted"> laisser vide pour que le produit puisse être commandé immédiatement </small>
</div>
<div class="form-group col">
<label for="orderable_end_date">Le produit ne pourra pas être commandé après : </label>
<input type="date" id="orderable_end_date" name="orderable_end_date" class="form-control" value="{{ old('orderable_end_date', !is_null($product->orderable_end) ? date_format($product->orderable_end, "Y-m-d") : "") }}">
<input type="time" id="orderable_end_time" name="orderable_end_time" class="form-control" value="{{ old('orderable_end_time', !is_null($product->orderable_end) ? date_format($product->orderable_end, "H:i") : "") }}">
<small class="text-muted"> laisser vide pour que le produit puisse toujours être commandé </small>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
@include('bo.products.standard_form_inputs')
@if(!empty($product->product_type))
@include('bo.products.' . Str::snake($product->product_type))
@endif

View file

@ -15,6 +15,15 @@
@endforeach
</select>
</div>
<label for="filter_range" class="col-form-label">Marque</label>
<div class="col">
<select class="form-control" id="filter_brand" name="filter_brand">
<option value="" @if ($filter_brand == '') selected @endif>Toutes</option>
@foreach (ProductBrand::toArray() as $productbrand)
<option value="{{$productbrand->value}}" @if ($productbrand->value == $filter_brand) selected @endif>{{$productbrand->label}}</option>
@endforeach
</select>
</div>
<label for="filter_name" class="col-form-label">Nom</label>
<div class="col">
<input class="form-control" type="text"
@ -47,6 +56,7 @@
<th scope="col">Ref Externe</th>
<th scope="col">Image</th>
<th scope="col">Nom</th>
<th scope="col">Marque</th>
<th scope="col">Prix en €</th>
<th scope="col">Stock</th>
<th scope="col">Référence</th>
@ -76,6 +86,7 @@
@endif
</td>
<td>{{$product->name}}</td>
<td>{{$product->brand->label ?? ''}}</td>
<td>{{number_format($product->price, 2, ',', ' ')}}€</td>
<td>{{number_format($product->stock, 0, ',', ' ')}}</td>
<td>{{$product->reference}}</td>

View file

@ -0,0 +1,243 @@
<div class="form-group">
<label for="name">Nom du produit *</label>
<input type="text" id="name" name="name" class="form-control" placeholder="Nom du produit" value="{{ old('name', $product->name) }}" required>
@if ($product->product_type == "foodProduct")
@if (!empty($product->foodProduct->xmlInco))
<a class="btn btn-outline-info btn-sm" data-bs-toggle="collapse" href="#inco_nom" aria-expanded="false" aria-controls="collapseExample">Donnée inco</a>
<div class="collapse row" id="inco_nom">
<div class="input-group mb-2">
<div class="input-group-prepend">
<a class="btn btn-secondary" onclick="paste('nom','name')">Reprendre cette donnée</a>
</div>
<div class="inco_data form-control alert-info" id="nom">{{ $product->foodProduct->xmlInco->nom }}</div>
</div>
</div>
@endif
@endif
</div>
<div class="row">
<div class="form-group col-md-3">
<label for="order_unit">Marque
<span class="tipped"
data-tippy-content="Marque du produit">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select" id="brand" name="brand">
@foreach (ProductBrand::toArray() as $productbrand)
<option value="{{$productbrand->value}}" @if (old('brand', $product->brand) == $productbrand->value)selected @endif>{{$productbrand->label}}</option>
@endforeach
</select>
</div>
<div class="form-group col-md-9">
<label for="name">Tags</label>
<auto-complete-tags
dbexistingtags='@json($existingTags)'
dbselectedtags='@json($selectedtags)'
element-id="tags"
id-field="id"
text-field="label"
></auto-complete-tags>
</div>
</div>
<div class="form-group">
<label>Description *</label>
<textarea class="form-control" id="description" name="description" placeholder="Description *">{{ old('description', $product->description) }}</textarea>
@if ($product->product_type == "foodProduct")
@if (!empty($product->foodProduct->xmlInco))
<a class="btn btn-outline-info btn-sm" data-bs-toggle="collapse" href="#inco_descriptif" aria-expanded="false" aria-controls="collapseExample">Donnée inco</a>
<div class="collapse row" id="inco_descriptif">
<div class="input-group mb-2">
<div class="input-group-prepend">
<a class="btn btn-secondary" onclick="paste('descriptif','description')">Reprendre cette donnée</a>
</div>
<div class="inco_data form-control alert-info" id="descriptif">{{ $product->foodProduct->xmlInco->descriptif }}</div>
</div>
</div>
@endif
@endif
</div>
<div class="form-group">
<label for="picture">Image <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.product_image_maxwidth') }} px par {{ Config::get('theme.product_image_maxheight') }} px</small></label></br>
<input type="file" id="picture" name="picture" accept="image/png, image/jpeg">
@if ($product->picture !== null)
<br/>
<br/>
<a data-fancybox="gallery" href="/images/produits/{{$product->picture}}" id="img-picture">
<img src="/images/produits/{{$product->picture}}" alt="{{$product->name}}" style="max-height: 100px;">
</a>
@endif
{{-- variante préparation d'images --}}
@if ($product->product_type == "foodProduct")
@if (!empty($product->foodProduct->xmlInco->picture))
<a class="btn btn-outline-info btn-sm" data-bs-toggle="collapse" href="#inco_media" aria-expanded="false" aria-controls="collapseExample" id="prepareIncoImages">Images inco</a>
<div class="collapse row" id="inco_media">
<!--inco images container-->
</div>
@endif
@endif
</div>
<div class="form-group">
<label for="picture_large">Image (grande) <small class="text-muted">- JPEG/PNG, 2Mo max. Dimensions {{ Config::get('theme.product_image_large_maxwidth') }} px par {{ Config::get('theme.product_image_large_maxheight') }} px</small></label></br>
<input type="file" id="picture_large" name="picture_large" accept="image/png, image/jpeg">
@if ($product->picture_large !== null)
<br/>
<br/>
<a data-fancybox="gallery" href="/images/produits/{{$product->picture_large}}" id="img-picture_large">
<img src="/images/produits/{{$product->picture_large}}" alt="{{$product->name}}" style="max-height: 100px;">
</a>
@endif
</div>
<div class="row">
<div class="form-group col">
<label for="price">Prix en € *</label>
<input type="number" id="price" name="price" min="0" step=".001" class="form-control" value="{{ old('price', $product->price)}}" required>
</div>
<div class="form-group col">
<label for="invoicing_unit">Unité de facturation
<span class="tipped"
data-tippy-content="Unité de base permettant d'établir le prix">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="invoicing_unit" name="invoicing_unit">
@foreach (InvoicingUnit::toArray() as $invoicingunit_type)
<option value="{{$invoicingunit_type->value}}" @if (old('invoicing_unit', $product->invoicing_unit) == $invoicingunit_type->value)selected @endif>{{$invoicingunit_type->label}}</option>
@endforeach
</select>
</div>
{{--<div class="form-group col">
<label for="price_buy">Prix d'achat en €</label>
<input type="number" id="price_buy" name="price_buy" min="0" step=".01" class="form-control" value="{{ old('price_buy', $product->price_buy)}}">
</div>--}}
<div class="form-group col">
<label for="tax_rate_id">TVA Applicable</label>
<select class="form-select" id="tax_rate_id" name="tax_rate_id">
@foreach($taxes as $taxe)
<option value="{{$taxe->id}}" @if ($taxe->id === old('tax_rate_id',$product->tax_rate_id)) selected @endif>{{$taxe->label}}</option>
@endforeach
</select>
</div>
<div class="form-group col"></div>
</div>
<div class="row">
@if (config('bosettings.regate_orders'))
<div class="form-group col">
<label for="order_unit">Unité de commande
<span class="tipped"
data-tippy-content="Unité utilisée lors de la transmission de commande à Regate">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="order_unit" name="order_unit">
@foreach (OrderUnit::toArray() as $orderunit_type)
<option value="{{$orderunit_type->value}}" @if (old('order_unit', $product->order_unit) == $orderunit_type->value)selected @endif>{{$orderunit_type->label}}</option>
@endforeach
</select>
</div>
@endif
<div class="form-group col">
<label for="stock">Stock</label>
<input type="number" id="stock" name="stock" class="form-control" min="0" value="{{ old('stock', $product->stock)}}">
</div>
<div class="form-group col">
<label for="reference">Référence @if (config('bosettings.regate_orders')) *
<span class="tipped"
data-tippy-content="Code Article utilisé lors de la transmission de commande à Regate">
<i class="fas fa-question-circle"></i>
</span>
@endif
</label>
<input type="text" id="reference" name="reference" class="form-control" value="{{ old('reference', $product->reference)}}" @if (config('bosettings.regate_orders')) required @endif>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
<div class="row">
<div class="form-group col">
<label for="sell_unit">Unité de vente
<span class="tipped"
data-tippy-content="Unité de vente consommateur">
<i class="fas fa-question-circle"></i>
</span>
</label>
@if (config('bosettings.sell_unit_management') == "strict")
<select class="form-select col-md-9" id="sell_unit" name="sell_unit">
@foreach (SellUnit::toArray() as $sellunit_type)
<option value="{{$sellunit_type->value}}" @if (old('sell_unit', $product->sell_unit) == $sellunit_type->value)selected @endif>{{$sellunit_type->label}}</option>
@endforeach
</select>
@else
<input type="text" id="sell_unit" name="sell_unit" class="form-control" value="{{ old('sell_unit', $product->sell_unit)}}">
@endif
</div>
<div class="form-group col">
<label for="weight">Poids de l'article</label>
<input type="number" id="weight" name="weight" min="0" step=".01" class="form-control" value="{{ old('weight', $product->weight)}}">
</div>
<div class="form-group col">
<label for="weight_unit">Unité de poids
<span class="tipped"
data-tippy-content="Unité de poids normalisée">
<i class="fas fa-question-circle"></i>
</span>
</label>
<select class="form-select col-md-9" id="weight_unit" name="weight_unit">
@foreach (WeightUnit::toArray() as $wheightunit_type)
<option value="{{$wheightunit_type->value}}" @if (old('weight_unit', $product->weight_unit) == $wheightunit_type->value)selected @endif>{{$wheightunit_type->label}}</option>
@endforeach
</select>
{{--<input type="text" id="weight_unit" name="weight_unit" class="form-control" value="{{ old('weight_unit', $product->weight_unit)}}">--}}
</div>
<div class="form-group col"></div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="star" @if ($product->star === 1) checked @endif>
Mise en avant ?
</label>
</div>
<div class="row">
<div class="form-group col">
<label for="range_id">Gamme de produits</label>
<select class="form-select" id="range_id" name="range_id">
@foreach($ranges as $range)
<option value="{{$range->id}}" @if ($range->id === old('range_id',$product->range_id)) selected @endif>{{$range->name}}</option>
@endforeach
</select>
</div>
<div class="form-group col">
<div class="form-group">
<label for="name">Produist associés</label>
<products-cards-dnd
dbexistingprods='@json($existingProds)'
dbselectedprods='@json($selectedProds)'
element-id="prods"
></products-cards-dnd>
</div>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="status" @if ($product->status === 1) checked @endif>
Publié ?
</label>
</div>
<div class="row">
<div class="form-group col">
<label for="orderable_start_date">Le produit peut être commandé à partir de :</label>
<input type="date" id="orderable_start_date" name="orderable_start_date" class="form-control" value="{{ old('orderable_start_date', !is_null($product->orderable_start) ? date_format($product->orderable_start, "Y-m-d") : "") }}">
<input type="time" id="orderable_start_time" name="orderable_start_time" class="form-control" value="{{ old('orderable_start_time', !is_null($product->orderable_start) ? date_format($product->orderable_start, "H:i") : "") }}">
<small class="text-muted"> laisser vide pour que le produit puisse être commandé immédiatement </small>
</div>
<div class="form-group col">
<label for="orderable_end_date">Le produit ne pourra pas être commandé après : </label>
<input type="date" id="orderable_end_date" name="orderable_end_date" class="form-control" value="{{ old('orderable_end_date', !is_null($product->orderable_end) ? date_format($product->orderable_end, "Y-m-d") : "") }}">
<input type="time" id="orderable_end_time" name="orderable_end_time" class="form-control" value="{{ old('orderable_end_time', !is_null($product->orderable_end) ? date_format($product->orderable_end, "H:i") : "") }}">
<small class="text-muted"> laisser vide pour que le produit puisse toujours être commandé </small>
</div>
<div class="form-group col"></div>
<div class="form-group col"></div>
</div>

View file

@ -8,8 +8,7 @@ use App\Http\Controllers\BasketController;
use App\Http\Controllers\ProductsController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\QuickOrderController;
// BO.
use App\Http\Controllers\Bo\OrdersController;
use App\Http\Controllers\OrderTunnelController;
Route::get('/', [HomeController::class, 'index'])->name('home');
Route::get('/cgv', [IndexController::class, 'terms'])->name('terms');
@ -48,5 +47,5 @@ Route::prefix('ajax')
Route::post('/get-cart', [BasketController::class, 'getCartRequest'])->name('cart.get');
Route::post('/remove-from-cart', [BasketController::class, 'removeFromCart'])->name('cart.remove');
Route::post('/empty-cart', [BasketController::class, 'emptyCart'])->name('cart.empty');
Route::post('/get-time-slots', [OrdersController::class, 'getAvailableCreneaux'])->name('get-creneaux');
Route::post('/get-time-slots', [OrderTunnelController::class, 'getAvailableCreneaux'])->name('get-creneaux');
});

View file

@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route;
// FRONT.
use App\Http\Controllers\IndexController;
use App\Http\Controllers\CustomerController;
use App\Http\Controllers\OrderTunnelController;
// BO.
use App\Http\Controllers\Bo\DashboardController;
use App\Http\Controllers\Bo\ContentController;
@ -40,9 +41,9 @@ Route::get('/politique-de-confidentialite', [IndexController::class, 'privacy'])
Route::namespace('App\Http\Controllers\Bo')
->prefix('bo')
->name('bo.')
->middleware(['auth', 'is-admin'])
->prefix('bo')
->name('bo.')
->middleware(['auth', 'is-admin'])
->group(
function () {
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
@ -150,13 +151,18 @@ Route::namespace('App\Http\Controllers\Bo')
// Commandes.
Route::get('/orders', [OrdersController::class, 'index'])->name('orders');
Route::get('/orders/today', [OrdersController::class, 'today'])->name('orders.today');
Route::get('/orders/{reference}', [OrdersController::class, 'orderDetail'])->name('order-detail');
Route::get(
'/orders/{reference}',
[OrdersController::class, 'orderDetail']
)->name('order-detail');
Route::get(
'/orders/{reference}/advance',
[OrdersController::class, 'changeStatus']
)->name('change-order-status');
Route::get('/orders/{reference}/cancel', [OrdersController::class, 'cancelOrder'])->name('cancel-order');
Route::post('/orders/add', [OrdersController::class, 'addProduct'])->name('order-add-product');
Route::get(
'/orders/{reference}/cancel',
[OrdersController::class, 'cancelOrder']
)->name('cancel-order');
}
);
@ -209,8 +215,8 @@ Route::name('auth.')
);
Route::name('account.')
->prefix('compte')
->middleware('auth:customer')
->prefix('compte')
->middleware('auth:customer')
->group(
function () {
Route::get('/profil', [CustomerController::class, 'dashboard'])->name('dashboard');
@ -226,19 +232,16 @@ Route::name('account.')
// Tunnel de commande.
Route::prefix('commande')
->name('sales.')
->middleware('auth:customer')
->group(function () {
// Puisqu'on a le middleware on s'épargne une étape.
// Recap.
Route::get('/recap', [OrdersController::class, 'recapOrder' ])->name('recap');
Route::post('/recap', [OrdersController::class, 'store' ])->name('order-init');
// Choice timeslot.
Route::get('/collect/{reference}', [OrdersController::class, 'timeSlotPick' ])->name('pick-slot');
Route::post('/collect', [OrdersController::class, 'setTimeSlot' ])->name('order-save-slot');
// Confirm.
Route::get('/confirm/{reference}', [OrdersController::class, 'confirmOrder' ])->name('confirm');
// Test generation de commande.
Route::get('/generate/{reference}', [OrdersController::class, 'generateOrder' ])->name('generate');
});
->name('sales.')
->middleware('auth:customer')
->group(function () {
// Puisqu'on a le middleware on s'épargne une étape.
// Recap.
Route::get('/recap', [OrderTunnelController::class, 'recapOrder'])->name('recap');
Route::post('/recap', [OrderTunnelController::class, 'store'])->name('order-init');
// Choice timeslot.
Route::get('/collect/{reference}', [OrderTunnelController::class, 'timeSlotPick'])->name('pick-slot');
Route::post('/collect', [OrderTunnelController::class, 'setTimeSlot'])->name('order-save-slot');
// Confirm.
Route::get('/confirm/{reference}', [OrderTunnelController::class, 'confirmOrder'])->name('confirm');
});

9
webpack.mix.js vendored
View file

@ -21,11 +21,12 @@ const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/b-o/js')
.sass('resources/sass/app.scss', 'public/b-o/css')
mix.js("resources/js/app.js", "public/b-o/js")
.vue({ version: 2 })
.sass("resources/sass/app.scss", "public/b-o/css")
.copy(
'node_modules/@fortawesome/fontawesome-free/webfonts',
'public/webfonts'
"node_modules/@fortawesome/fontawesome-free/webfonts",
"public/webfonts"
);
//add front theme mix