<?php $__env->startSection('page_title'); ?>
    <?php echo e(__('admin::app.mail.compose')); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content-wrapper'); ?>
    <div class="content full-page adjacent-center">

        <?php echo view_render_event('admin.mail.compose.header.before', ['email' => $email ?? null]); ?>


        <div class="page-header">
            
            <?php echo e(Breadcrumbs::render('mail.route', request('route'))); ?>


            <div class="page-title">
                <h1><?php echo e(__('admin::app.mail.compose')); ?></h1>
            </div>
        </div>

        <?php echo view_render_event('admin.mail.compose.header.after', ['email' => $email ?? null]); ?>


        <div class="page-content">

            <email-form></email-form>

        </div>

    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script src="<?php echo e(asset('vendor/webkul/admin/assets/js/tinyMCE/tinymce.min.js')); ?>"></script>

    <script type="text/x-template" id="email-form-template">
        <form
            action="<?php echo e(isset($email) ? route('admin.mail.update', $email->id) : route('admin.mail.store')); ?>"
            method="POST"
            enctype="multipart/form-data"
            @submit.prevent="onSubmit"
        >

            <div class="form-container">

                <div class="panel">
                    <div class="panel-header">
                        <?php echo view_render_event('admin.mail.compose.form_buttons.before', ['email' => $email ?? null]); ?>


                        <button type="submit" class="btn btn-md btn-primary" @click="is_draft = 0">
                            <i class="icon email-send-icon"></i>

                            <?php echo e(__('admin::app.mail.send')); ?>

                        </button>

                        <input type="submit" value="<?php echo e(__('admin::app.mail.save-to-draft')); ?>" @click="is_draft = 1"/>

                        <a href="<?php echo e(route('admin.mail.index', ['route' => 'inbox'])); ?>"><?php echo e(__('admin::app.mail.back')); ?></a>

                        <?php echo view_render_event('admin.mail.compose.form_buttons.after', ['email' => $email ?? null]); ?>

                    </div>
    
                    <div class="panel-body">
                        <?php echo view_render_event('admin.mail.compose.form_controls.before', ['email' => $email ?? null]); ?>


                        <?php echo csrf_field(); ?>

                        <?php if(isset($email)): ?>
                            <input name="_method" type="hidden" value="PUT">
                        <?php endif; ?>

                        <input type="hidden" name="is_draft" v-model="is_draft"/>

                        <input type="hidden" name="id" value="<?php echo e(isset($email) ? $email->id : ''); ?>"/>

                        <?php echo $__env->make('admin::common.custom-attributes.edit.email-tags', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

                        <div class="form-group email-control-group" :class="[errors.has('reply_to[]') ? 'has-error' : '']">
                            <label for="to" class="required"><?php echo e(__('admin::app.leads.to')); ?></label>
    
                            <email-tags-component
                                control-name="reply_to[]"
                                control-label="<?php echo e(__('admin::app.leads.to')); ?>"
                                :validations="'required'"
                                :data='<?php echo json_encode(isset($email) ? $email->reply_to : [], 15, 512) ?>'
                            ></email-tags-component>
    
                            <span class="control-error" v-if="errors.has('reply_to[]')">
                                {{ errors.first('reply_to[]') }}
                            </span>

                            <div class="email-address-options">
                                <label @click="show_cc = ! show_cc">
                                    <?php echo e(__('admin::app.leads.cc')); ?>

                                </label>

                                <label @click="show_bcc = ! show_bcc">
                                    <?php echo e(__('admin::app.leads.bcc')); ?>

                                </label>
                            </div>
                        </div>
    
                        <div class="form-group email-control-group" :class="[errors.has('cc[]') ? 'has-error' : '']" v-if="show_cc">
                            <label for="cc"><?php echo e(__('admin::app.leads.cc')); ?></label>
    
                            <email-tags-component
                                control-name="cc[]"
                                control-label="<?php echo e(__('admin::app.leads.cc')); ?>"
                                :data='<?php echo json_encode(isset($email) ? $email->cc : [], 15, 512) ?>'
                            ></email-tags-component>
    
                            <span class="control-error" v-if="errors.has('cc[]')">
                                {{ errors.first('cc[]') }}
                            </span>
                        </div>
    
                        <div class="form-group email-control-group" :class="[errors.has('bcc[]') ? 'has-error' : '']" v-if="show_bcc">
                            <label for="bcc"><?php echo e(__('admin::app.leads.bcc')); ?></label>
    
                            <email-tags-component
                                control-name="bcc[]"
                                control-label="<?php echo e(__('admin::app.leads.bcc')); ?>"
                                :data='<?php echo json_encode(isset($email) ? $email->bcc : [], 15, 512) ?>'
                            ></email-tags-component>
    
                            <span class="control-error" v-if="errors.has('bcc[]')">
                                {{ errors.first('bcc[]') }}
                            </span>
                        </div>
                        
                        <div class="form-group" :class="[errors.has('subject') ? 'has-error' : '']">
                            <label for="subject" class="required"><?php echo e(__('admin::app.leads.subject')); ?></label>

                            <input
                                type="text"
                                name="subject"
                                class="control"
                                id="subject"
                                value="<?php echo e(isset($email) ? $email->subject : ''); ?>"
                                v-validate="'required'"
                                data-vv-as="&quot;<?php echo e(__('admin::app.leads.subject')); ?>&quot;"
                            />

                            <span class="control-error" v-if="errors.has('subject')">
                                {{ errors.first('subject') }}
                            </span>
                        </div>
                        
                        <div class="form-group" :class="[errors.has('reply') ? 'has-error' : '']">
                            <label for="reply" class="required" style="margin-bottom: 10px"><?php echo e(__('admin::app.leads.reply')); ?></label>

                            <textarea
                                name="reply"
                                class="control"
                                id="reply"
                                v-validate="'required'"
                                data-vv-as="&quot;<?php echo e(__('admin::app.leads.reply')); ?>&quot;"
                            ><?php echo e(isset($email) ? $email->reply : ''); ?></textarea>

                            <span class="control-error" v-if="errors.has('reply')">
                                {{ errors.first('reply') }}
                            </span>
                        </div>
    
                        <div class="form-group">
                            <attachment-wrapper :data='<?php echo json_encode(isset($email) ? $email->attachments : [], 15, 512) ?>'></attachment-wrapper>
                        </div>

                        <?php echo view_render_event('admin.mail.compose.form_controls.after', ['email' => $email ?? null]); ?>

                    </div>
                </div>

            </div>

        </form>
    </script>

    <script>
        Vue.component('email-form', {

            template: '#email-form-template',

            inject: ['$validator'],

            data: function () {
                return {
                    is_draft: 0,

                    show_cc: false,

                    show_bcc: false,
                }
            },

            mounted: function() {
                var self = this;

                tinymce.init({
                    selector: 'textarea#reply',
                    
                    height: 200,

                    width: "100%",

                    plugins: 'image imagetools media wordcount save fullscreen code table lists link hr',

                    toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor link hr | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent  | removeformat | code | table',
                    
                    image_advtab: true,

                    setup: function(editor) {
                        editor.on('keyUp', function() {
                            self.$validator.validate('reply', this.getContent());
                        });
                    }
                });
            },

            methods: {
                onSubmit: function(e) {
                    this.$root.onSubmit(e);
                }
            }
        });
    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('admin::layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\laravel-crm\packages\Webkul\Admin\src/resources/views/mail/compose.blade.php ENDPATH**/ ?>