From 8b4bd03e9cdadc62159220d3469b9bd5b8b142d4 Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Mon, 20 May 2019 14:53:09 +0200 Subject: [PATCH 1/6] Multiple mentions test --- app/Coupon.php | 1 + app/Traits/GenerateBR.php | 70 ++++++++++++++++++++----- resources/views/coupon/create.blade.php | 5 ++ resources/views/coupon/edit.blade.php | 5 ++ 4 files changed, 67 insertions(+), 14 deletions(-) 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/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index e2c33b4..627c520 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(415, 200); + $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') !!} +
From 3fdc90da7cee77538ad59f3f1a8ef1713cf249a8 Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Mon, 20 May 2019 14:56:48 +0200 Subject: [PATCH 2/6] Fix coupon_legal_mentions_splitted on edit and create page --- app/Http/Controllers/CouponController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/CouponController.php b/app/Http/Controllers/CouponController.php index 5c681bc..9431030 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_maxdatediffusion = $datas['coupon_maxdatediffusion']; $coupon->coupon_maxdatevalidity = $datas['coupon_maxdatevalidity']; @@ -245,6 +249,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); From dcf47aff301472a0cbaf182af6d234efefccefde Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Mon, 20 May 2019 15:05:41 +0200 Subject: [PATCH 3/6] Fix size --- app/Traits/GenerateBR.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index 627c520..452d925 100644 --- a/app/Traits/GenerateBR.php +++ b/app/Traits/GenerateBR.php @@ -262,7 +262,7 @@ trait GenerateBR { if($coupon->coupon_norme == 1 && strlen($contact->contact_cp)==4){ //BELGE $txt_mentions = $legalMentions[0]."\n\r".$legalMentions[1]." ".$coupon->coupon_rcs; - $ImageMentionFond = imagecreate(415, 200); + $ImageMentionFond = imagecreate(420, 180); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); From 96c7eff0f25d260a7ab494fcf9b3dc0eb0a60a7f Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Mon, 20 May 2019 15:06:43 +0200 Subject: [PATCH 4/6] Fix size of mentions --- app/Traits/GenerateBR.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index 452d925..c8b5578 100644 --- a/app/Traits/GenerateBR.php +++ b/app/Traits/GenerateBR.php @@ -262,7 +262,7 @@ trait GenerateBR { 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, 180); + $ImageMentionFond = imagecreate(420, 150); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); From 445c072bcc8dfaee637df4d08f5ae79cf402603a Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Mon, 20 May 2019 15:10:34 +0200 Subject: [PATCH 5/6] Fix position international mentions --- app/Traits/GenerateBR.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index c8b5578..e8e3b49 100644 --- a/app/Traits/GenerateBR.php +++ b/app/Traits/GenerateBR.php @@ -274,7 +274,7 @@ trait GenerateBR { $y = $y +9; } //imagecolortransparent($ImageMentionFond, $white); - imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); + imagecopy($mask, $ImageMentionFond, 335, 230, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); } else { //FR $txt_mentions = $legalMentions[0]." ".$coupon->coupon_rcs; From c1a23c2b07a1bc0bb0c46b3e96bcea653999ea6f Mon Sep 17 00:00:00 2001 From: Thibault Richy Date: Mon, 20 May 2019 15:11:44 +0200 Subject: [PATCH 6/6] zfd --- app/Traits/GenerateBR.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Traits/GenerateBR.php b/app/Traits/GenerateBR.php index e8e3b49..c89dd87 100644 --- a/app/Traits/GenerateBR.php +++ b/app/Traits/GenerateBR.php @@ -262,7 +262,7 @@ trait GenerateBR { 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, 150); + $ImageMentionFond = imagecreate(420, 145); $boxMentions = imagettfbbox(7, 0, $arial, $txt_mentions); $white = imagecolorallocate($ImageMentionFond, 255, 255, 255); imagefilledrectangle($ImageMentionFond, 0, 0, 414, 99, $white); @@ -274,7 +274,7 @@ trait GenerateBR { $y = $y +9; } //imagecolortransparent($ImageMentionFond, $white); - imagecopy($mask, $ImageMentionFond, 335, 230, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); + imagecopy($mask, $ImageMentionFond, 335, 235, 0, 0, imagesx($ImageMentionFond), imagesy($ImageMentionFond)); } else { //FR $txt_mentions = $legalMentions[0]." ".$coupon->coupon_rcs;