diff --git a/app/Coupon.php b/app/Coupon.php index bddac46..423eaf9 100644 --- a/app/Coupon.php +++ b/app/Coupon.php @@ -115,6 +115,7 @@ class Coupon extends Model 'coupon_validity_text', 'coupon_site_contact', 'coupon_legal_mentions', + 'coupon_legal_mentions_splitted', 'coupon_seuil_alert', 'coupon_treatment_center' ]; diff --git a/app/Http/Controllers/CouponController.php b/app/Http/Controllers/CouponController.php index 83f08dd..62612b5 100644 --- a/app/Http/Controllers/CouponController.php +++ b/app/Http/Controllers/CouponController.php @@ -129,7 +129,11 @@ class CouponController extends Controller } else { $coupon->coupon_published = 0; } - + if (isset($datas['coupon_legal_mentions_splitted'])) { + $coupon->coupon_legal_mentions_splitted = $datas['coupon_legal_mentions_splitted']; + } else { + $coupon->coupon_legal_mentions_splitted = 0; + } $coupon->coupon_validity = $datas['coupon_validity']; $coupon->coupon_mindatediffusion = $datas['coupon_mindatediffusion']; $coupon->coupon_maxdatediffusion = $datas['coupon_maxdatediffusion']; @@ -246,6 +250,9 @@ class CouponController extends Controller if(!isset($request->coupon_published)){ $coupon->coupon_published = 0; } + if(!isset($request->coupon_legal_mentions_splitted)){ + $coupon->coupon_legal_mentions_splitted = 0; + } if ($coupon->update($this->saveImg($request))) { $datas = $this->saveImg($request); $br_path = $this->generateBase($request, $coupon); diff --git a/app/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index e2c33b4..c89dd87 100644 --- a/app/Traits/GenerateBR.php +++ b/app/Traits/GenerateBR.php @@ -53,22 +53,23 @@ trait GenerateBR { // ----- Mentions légales + RCS - $txt_mentions = $coupon->coupon_legal_mentions." ".$coupon->coupon_rcs; - $ImageMentionFond = imagecreate(415, 100); - $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); - $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); - imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); - $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); - $lines_mentions = explode("\r\n", $txt_mentions); - $y = 19; - foreach ($lines_mentions as $line) { + if($coupon->coupon_legal_mentions_splitted == 0){ + $txt_mentions = $coupon->coupon_legal_mentions." ".$coupon->coupon_rcs; + $ImageMentionFond = imagecreate(415, 100); + $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); + $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); + imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); + $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); + $lines_mentions = explode("\r\n", $txt_mentions); + $y = 19; + foreach ($lines_mentions as $line) { + $this->imagettftextSp($ImageMentionFond , 7 , 0, 15, $y, $black, $arial, $line, 0.01); + $y = $y +9; + } - $this->imagettftextSp($ImageMentionFond , 7 , 0, 15, $y, $black, $arial, $line, 0.01); - $y = $y +9; + //imagecolortransparent($ImageMentionFond, $white); + imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); } - - //imagecolortransparent($ImageMentionFond, $white); - imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); // ---- Copie la main dans le mask $hand = imagecreatefrompng($hand_picture); @@ -254,6 +255,47 @@ trait GenerateBR { list($maskWidth, $maskHeight) = getimagesize($coupon->coupon_image); + + // ----- Mentions légales + RCS dépendant de l'user + if ($coupon->coupon_legal_mentions_splitted == 1) { + $legalMentions = explode('', $coupon->coupon_legal_mentions); + if($coupon->coupon_norme == 1 && strlen($contact->contact_cp)==4){ + //BELGE + $txt_mentions = $legalMentions[0]."\n\r".$legalMentions[1]." ".$coupon->coupon_rcs; + $ImageMentionFond = imagecreate(420, 145); + $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); + $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); + imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); + $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); + $lines_mentions = explode("\r\n", $txt_mentions); + $y = 19; + foreach ($lines_mentions as $line) { + $this->imagettftextSp($ImageMentionFond , 7 , 0, 15, $y, $black, $arial, $line, 0.01); + $y = $y +9; + } + //imagecolortransparent($ImageMentionFond, $white); + imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); + } else { + //FR + $txt_mentions = $legalMentions[0]." ".$coupon->coupon_rcs; + $ImageMentionFond = imagecreate(415, 100); + $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); + $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); + imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); + $black = imagecolorallocate($ImageMentionFond, 0, 0, 0); + $lines_mentions = explode("\r\n", $txt_mentions); + $y = 19; + foreach ($lines_mentions as $line) { + + $this->imagettftextSp($ImageMentionFond , 7 , 0, 15, $y, $black, $arial, $line, 0.01); + $y = $y +9; + } + //imagecolortransparent($ImageMentionFond, $white); + imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); + } + } + + // ---- Inscription de l'utilisateur et de la ville $libelle = "OFFRE RÉSERVÉE À"; $user = $contact->contact_prenom." ".$contact->contact_nom."\r\n".$contact->contact_cp. " ".$contact->contact_ville; diff --git a/resources/views/coupon/create.blade.php b/resources/views/coupon/create.blade.php index a4516ce..5ff0f60 100644 --- a/resources/views/coupon/create.blade.php +++ b/resources/views/coupon/create.blade.php @@ -127,6 +127,11 @@ {!! Form::label('coupon_treatment_center', 'Centre de traitement *') !!} {!! Form::select('coupon_treatment_center', ['HighCo', 'Sogec']) !!} +
+ {!! Form::label('coupon_legal_mentions_splitted', 'Activer les mentions internationnales') !!} + {!! Form::checkbox('coupon_legal_mentions_splitted', 1, false) !!} + {!! Form::label('coupon_legal_mentions_splitted', 'Activer') !!} +
diff --git a/resources/views/coupon/edit.blade.php b/resources/views/coupon/edit.blade.php index 1b3ef58..4dc75b9 100644 --- a/resources/views/coupon/edit.blade.php +++ b/resources/views/coupon/edit.blade.php @@ -177,6 +177,11 @@ {!! Form::label('coupon_treatment_center', 'Centre de traitement *') !!} {!! Form::select('coupon_treatment_center', ['HighCo', 'Sogec']) !!}
+
+ {!! Form::label('coupon_legal_mentions_splitted', 'Activer les mentions internationnales') !!} + {!! Form::checkbox('coupon_legal_mentions_splitted', 1, ($coupon->coupon_legal_mentions_splitted ==1?true:null)) !!} + {!! Form::label('coupon_legal_mentions_splitted', 'Activer') !!} +