Multiple mentions test

This commit is contained in:
Thibault Richy 2019-05-20 14:53:09 +02:00
parent 2f4fa9e6fd
commit 8b4bd03e9c
4 changed files with 67 additions and 14 deletions

View file

@ -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'
];

View file

@ -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('<nl>', $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;

View file

@ -127,6 +127,11 @@
{!! Form::label('coupon_treatment_center', 'Centre de traitement *') !!}
{!! Form::select('coupon_treatment_center', ['HighCo', 'Sogec']) !!}
</div>
<div class="form-field">
{!! 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') !!}
</div>
</div>
<div class="form-split">
<div class="form-field-textarea">

View file

@ -177,6 +177,11 @@
{!! Form::label('coupon_treatment_center', 'Centre de traitement *') !!}
{!! Form::select('coupon_treatment_center', ['HighCo', 'Sogec']) !!}
</div>
<div class="form-field">
{!! 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') !!}
</div>
</div>
<div class="form-split">
<div class="form-field-textarea">