<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use common\models\Newsletter;
use yii\widgets\ActiveForm;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model common\models\Newsletter */

$this->title = $model->id_newsletter;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/newsletter', 'Hírlevelek'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="newsletter-view">
	
	<h1>Hírlevél részletei</h1>


	<?php if ( $model->sent != Newsletter::$SENT_TRUE){?>
		<p>
	        <?= Html::a("Módosítás", ['update', 'id' => $model->id_newsletter], ['class' => 'btn btn-primary']) ?>
	        <?= Html::a("Törlés", ['delete', 'id' => $model->id_newsletter], [
	            'class' => 'btn btn-danger',
	            'data' => [
	                'confirm' => Yii::t('common/log', 'Are you sure you want to delete this item?'),
	                'method' => 'post',
	            ],
	        ]) ?>
	    </p>
	<?php }?>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id_newsletter',
        	[
      		'attribute' => 'status',
        	'value' => $model->statusName
    ],
        		[
        			'attribute' => 'sent',
        			'value' => $model->sent == Newsletter::$SENT_NOT ? "Küldésre vár" : "Elküldve"
    			],
            'sent_at:datetime',
            'created_at:datetime',
            'updated_at:datetime',
        ],
    ]) ?>
</div>

<p><b>Tárgy:</b></p>
<div style='border: 1px solid #000; padding: 6px; background-color: #fff;'>
	<p>
		<?php echo $model->subject?>
	</p>
</div>
<p><b >Üzenet</b></p>
<div style='border: 1px solid #000; padding: 6px; background-color: #fff;'>
	<?php echo $model->body ?>
</div>

<h3>
Teszt üzenet küldése
</h3>
<p>
	A küldés gombra kattintva úgy küldünk ki egy darab e-mailt,
	<ul>
		<li>
			mintha a megadott vendég lenne a fogadó
		</li>
		<li>
			viszont a vendég e-mail címe helyett a megadott e-mail címre küldjük
		</li>
	</ul>
</p>

<div class="newsletter-form">

    <?php $form = ActiveForm::begin(
    			['action' => Url::current()]
    		); ?>

	<?= $form->field($testModel, 'customer_name') ?>
	<?= $form->field($testModel, 'email') ?>


    <div class="form-group">
        <?= Html::submitButton(  'Teszt email küldése'   , ['class' =>  [ 'btn btn-primary' ]]) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>