D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Http
/
Controllers
/
Filename :
HomeController.php
back
Copy
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Auth; use App\Orders; use App\ShceduleDay; use App\ScheduleExcept; use App\Schedule; use App\Libs\Endhour; use Carbon\Carbon; use Image; use Log; use App\Libs\Sdk\Communicator; use App\Libs\Sdk\CommunicatorConfiguration; use App\Libs\Sdk\Authentication\V1HmacAuthenticator; use App\Libs\OnlinePayments\Sdk\Client; class HomeController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); } /** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { if (isset($_GET['orderID'])) { $id = (int)$_GET['orderID']; return $this->orderGet($id); } else { $orders = Orders::where('user_id', Auth::user()->id)->orderBy('id', 'DESC')->get(); return view('home', compact('orders')); } } private function orderGet($id = null) { $status = 'false'; if (isset($_COOKIE['checkout'])) { $obj = Orders::find($id); $yourPspId = env('PAY_ID', 'americanbodyart2'); $apiKey = env('PAY_KEY', '555B97D87F9BDDCFADAF'); $apiSecret = env('PAY_SECRET', 'F5D91B23AA7C6790DC862399ABD923F9935BAC628EE8F08F0547112E95006768E4F6AFED5CB6FE4313FCC519DD6C4BB5F0E78B80D282080B264D2835EB444934'); $apiEndpoint = env('PAY_ENDPOINT', 'https://payment.direct.worldline-solutions.com/'); $integrator = 'American Body Art'; $proxyConfiguration = null; $communicatorConfiguration = new CommunicatorConfiguration( $apiKey, $apiSecret, $apiEndpoint, $integrator, $proxyConfiguration ); $authenticator = new V1HmacAuthenticator($communicatorConfiguration); $communicator = new Communicator($communicatorConfiguration, $authenticator); $client = new Client($communicator); $hostedCheckoutStatus = $client->merchant($yourPspId)->hostedCheckout()->getHostedCheckout($_COOKIE['checkout']); $status = $hostedCheckoutStatus->getCreatedPaymentOutput()->getPaymentStatusCategory(); } if($status == 'SUCCESSFUL') { if ($obj) { if ($obj->size) { $obj->status = 'payd20'; } else { if ($obj->body == 'gift card') { $obj->status = 'payed full'; } else { $obj->status = 'payd20'; } } $obj->update(); $obj_t = new Endhour(); $obj_t->orderObj($obj); $t_arr = $obj_t->arr; $dat = $obj_t->dat; $e = ShceduleDay::where('day', $dat)->where('saloon_id', $obj->saloon_id)->where('artist_id', $obj->artist_id)->first(); // dd($hh, $time, $t_arr, (int)$key, $datD, $t_day->id); if (isset($e)) { // dd($e); $e->hours = serialize($t_arr); $e->update(); } else { $enew = new ShceduleDay; $enew->saloon_id = $obj->saloon_id; $enew->artist_id = $obj->artist_id; $enew->day = $dat; $enew->hours = serialize($t_arr); $enew->status = 'except'; $enew->save(); } if ($obj->body == 'gift card') { if ($obj->user->email) { $name = $obj->id . "_" . time(); $address = 'Address'; $price = '-'; $putdate = '-'; $id = '0'; if ($obj->saloons) { $address = $obj->saloons->address; } if ($obj->price) { $price = $obj->price; } if ($obj->putdate) { $putdate = date('d/m/Y', strtotime($obj->putdate)); } if ($obj->id) { $id = $obj->id; } $img = Image::make(public_path('email.png')); $img->text($address, 185, 170, null); $img->text($price, 200, 195, function ($font) { $font->align('center'); $font->valign('top'); $font->color('#000000'); }); $img->text($putdate, 164, 234, null); $img->text($id, 285, 234, null); $img->resize(700, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save(public_path('emails/' . $name . '.png')); $pic = "<img src='" . env('APP_URL') . "/emails/" . $name . ".png' />"; $p_body = '<!doctype html> <html> <body> <p> Chère cliente, cher client,<br /> Vous trouverez ci-joint votre chèque cadeau. Pour l\'utiliser, il vous suffit de le présenter (e-mail ou imprimé) lors de votre prochain passage en salon. </p> ' . $pic . ' <p>Merci pour votre confiance.</p> <p>À très bientôt,</p> <p>L\'équipe American Body Art</p> </body> </html>'; $p_thema = "Chèque Cadeau"; $to = $obj->user->email; $headers = 'From: American Body Art <info@tattooscalculator.com> ' . "\r\n" . 'Reply-To: info@tattooscalculator.com ' . "\r\n" . 'Content-Type: text/html; charset=UTF-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $p_thema, $p_body, $headers); sleep(1); mail('contact@tattooscalculator.com', $p_thema, $p_body, $headers); } } else { $gift = ''; $putdate = $obj->putdate; if ($obj->size) { $amount = (int)$obj->prices($obj->catalogs_id, $obj->size) * 0.2; $price = (int)$obj->prices($obj->catalogs_id, $obj->size); } else { $amount = (int)$obj->price * 0.2; $price = (int)$obj->price; } if (isset($obj->saloons)) { $saloon = $obj->saloons->address; } else { $saloon = ''; } if (isset($obj->artists)) { $artists = $obj->artists->name; } else { $artists = rtrim(strip_tags($obj->body), ', '); } $p_body = "<!doctype html> <html> <body> <p> Bonjour " . $obj->user->name . ", </p> <p> Merci pour votre commande ! </p> <p> Date de la commande : " . Carbon::parse($obj->updated_at)->format('d-m-Y H:i') . " </p> <p> Bénéficiaire : SAS American Body Art </p> <p> Référence de la commande : " . $obj->id . " </p> <p> Description de la commande : " . $putdate . ", " . $saloon . ", " . $artists . " " . $gift . " </p> <p> Prix de la commande (EUR) : " . $price . " </p> <p> Montant du paiement (EUR) : " . $amount . " </p> <p> Merci pour votre confiance. <br /> À très bientôt, <br /> L'équipe American Body Art.<br /> </p> </body> </html>"; $p_thema = "Confirmation de votre commande"; $to = $obj->user->email; $headers = 'From: American Body Art <info@tattooscalculator.com> ' . "\r\n" . 'Reply-To: info@tattooscalculator.com ' . "\r\n" . 'Content-Type: text/html; charset=UTF-8' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $p_thema, $p_body, $headers); sleep(1); mail('contact@tattooscalculator.com', $p_thema, $p_body, $headers); } } }else{ Log::info('Error order_id='.$id); return redirect('cancelurl'); } return redirect('home'); } }