MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/www/finance/themes/admin/widgets/product/product.php
<?php $v->layout("_admin"); ?>
<?php $v->start("css")?>
    <link rel="stylesheet" type="text/css" href="<?= url("admin-assets/css/gallery.css"); ?>" />
    <link rel="stylesheet" type="text/css" href="<?= url("shared/styles/bootstrap-tokenfield.min.css"); ?>" />
<?php $v->end(); ?>
<div class="mce_upload" style="z-index: 1001 !important;">
    <div class="mce_upload_box">
        <form class="app_form" action="<?= url("/admin/product/product"); ?>" method="post" enctype="multipart/form-data">
            <input type="hidden" name="upload" value="true"/>
            <label>
                <label class="legend">Selecione uma imagem JPG ou PNG:</label>
                <input accept="image/*" type="file" name="image" required class="form-control"/>
            </label>
            <button class="btn btn-danger icon-upload">Enviar Imagem</button>
        </form>
    </div>
</div>
<section class="wrapper" id="dataSet" data-url="<?= url("/admin/product/variants");?>">
    <?php if (!$product): ?>
    <div class="row">

        <div class="col-12 text-center my-4 text-sm-center">
            <h3> Novo Produto</h3>
            <p>Crie um novo Produto </p>
        </div>
        <div class="col-lg-9">
            <form class="form-horizontal tasi-form" method="post"  action="<?= url("/admin/product/product"); ?>">
            <section class="card">
                <header class="card-header infinity-bg white-text">
                    Cadastrar Produto
                </header>
                <div class="card-body" id="formAjax">
                        <input type="hidden" name="action" value="create"/>
                        <div class="form-group row" hidden>
                            <label class="col-sm-2 control-label">Capa (1920x1080px)</label>
                            <div class="col-sm-10">
                                <input type="file" name="cover" placeholder="Uma imagem de capa" class="form-control" id="j_img_preview"/>
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Título*</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="title">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Subtítulo*</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" name="subtitle">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                            <label class="col-sm-2 control-label">Código</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="sku">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Vídeo</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="video">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-sm-12">
                                <label class="control-label">Conteúdo*</label>
                                <textarea name="content" class="form-control mce"></textarea>
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                </div>
            </section>
            <section class="card">
                <div class="card-body">
                    <div class="form-group row">
                            <img src="<?=url("admin-assets/icons/multiple.png")?>" style="max-width: 80px; margin-right: 20px;">
                        <div class="col-xs-8 ">
                            <label class="col-sm-12 control-label">O Produto terá variações?</label>
                            <div class="col-sm-12">
                                <a href="" class="btn btn-success btn_confirm_variation" id="yes">Sim</a> <a href="" class="btn btn-info btn_confirm_variation" id="no">Não</a>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
            <section class="card" id="card_variations" data-id="<?= $variations ?>" style="display: none">
                <div class="card-body">
                    <div col-lg-12>
                        <h5>Largura do Rolo</h5>
                    </div>
                    <hr>
                    <div class="form-group row">
                        <div class="col-sm-12">
                            <input type="text" class="form-control mb-3 tokenfield" name="firstVariation" id="variationField1"><br>
                            <a href="" class="btn btn-block btn-success" id="addVariant">Adiciona Variantes</a>
                        </div>
                    </div>
                </div>
            </section>
            <div class="variants">

            </div>
            <input type="hidden" id="j_key" name="variations" value="">
            <section class="card">
                <div class="card-body">

                    <div class="form-group row">
                        <div class="col-md-12">
                            <label class="control-label">Categoria*</label>
                            <select name="category" class="form-control" required>
                                <?php foreach ($categories as $category): ?>
                                    <option value="<?= $category->id; ?>"><?= $category->title; ?></option>
                                <?php endforeach; ?>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-md-2 control-label">Data de publicação:</label>
                        <div class="col-md-4">
                            <input class="mask-datetime form-control" type="text" name="post_at" value="<?= date("d/m/Y H:i"); ?>"
                                   required/>
                            <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                        </div>
                        <label class="col-md-2 control-label">Status*</label>
                        <div class="col-md-4">
                            <select name="status" class="form-control" required>
                                <option value="post">Publicar</option>
                                <option value="draft">Rascunho</option>
                                <option value="trash">Lixo</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label class="col-sm-2 control-label">Galeria</label>
                        <div class="col-sm-10">
                            <input type="file" name="gallery[]" placeholder="Uma imagem de capa" class="form-control" multiple/>
                            <span class="help-block">Envie até 10 imagens por vez para não sobrecarregar o sistema</span>
                        </div>
                    </div>
                </div>
            </section>
            <div class="clear" style="margin-bottom: 50px;">
                <button class="btn btn-primary" type="submit">Publicar</button>
                <a class="btn btn-danger" href="<?= url("/admin/product/home"); ?>">Cancelar</a>
            </div>
            </form>
        </div>
        <div class="col-lg-3">
            <section class="card">
                <header class="card-header infinity-bg white-text text-center">
                    Imagem de capa
                </header>
                <img class="radius img-open" style="width: 100%;" src="<?= image($product->cover, 400); ?>" id="image-preview"/>
            </section>
        </div>
    </div>
    <?php else: ?>
    <div class="row">
        <div class="col-12 text-center my-4 text-sm-center">
            <h4> Editar Produto [<?= $product->title; ?>] #<?= $product->id; ?> </h4>
            <p><a class="icon-link btn btn-success" href="<?= url("/product/{$product->uri}"); ?>" target="_blank" title="">Ver no site</a></p>
        </div>

        <div class="col-lg-9">
            <form class="form-horizontal tasi-form" method="post"  action="<?= url("/admin/product/product/{$product->id}"); ?>">
                <section class="card">
                    <header class="card-header infinity-bg white-text">
                        Editar Produto
                    </header>
                    <div class="card-body" id="formAjax">
                        <input type="hidden" name="action" value="update"/>
                        <div class="form-group row" hidden>
                            <label class="col-sm-2 control-label">Capa (1920x1080px)</label>
                            <div class="col-sm-10">
                                <input type="file" name="cover" placeholder="Uma imagem de capa" class="form-control" id="j_img_preview"/>
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Título*</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="title" value="<?= $product->title; ?>">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Subtítulo*</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" name="subtitle" value="<?= $product->subtitle; ?>">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                            <label class="col-sm-2 control-label">Código</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" name="sku" value="<?= $product->sku; ?>">
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Vídeo</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="video" value="<?= $product->video; ?>" >
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-sm-12">
                                <label class="control-label">Conteúdo*</label>
                                <textarea name="content" class="form-control mce"><?= $product->content; ?></textarea>
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                        </div>
                    </div>
                </section>
                <section class="card">
                    <div class="card-body">
                        <div class="form-group row">
                            <img src="<?=url("admin-assets/icons/multiple.png")?>" style="max-width: 80px; margin-right: 20px;">
                            <div class="col-xs-8 ">
                                <label class="col-sm-12 control-label">O Produto terá variações?</label>
                                <div class="col-sm-12">
                                    <a href="" class="btn btn-success btn_confirm_variation" id="yes">Sim</a> <a href="" class="btn btn-info btn_confirm_variation" id="no">Não</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
                <?php if($product->variations != "" AND $product->variations != "no-variations"):?>
                <section class="card" id="card_variations" data-id="<?= $variations ?>">
                    <div class="card-body">
                        <div col-lg-12>
                            <h5>Largura do Rolo</h5>
                        </div>
                        <hr>
                        <div class="form-group row">
                            <div class="col-sm-12">

                                <input type="text" class="form-control mb-3 tokenfield" value="<?= $product->variations?>," name="firstVariation" id="variationField1"><br>
                                <a href="" class="btn btn-block btn-success" id="addVariant">Adiciona Variantes</a>
                            </div>
                        </div>
                    </div>
                </section>
                    <div class="variants">
                        <?= $v->insert("views/fragments/variants-edit", ["productVariations"=>$productVariationsEdit]); ?>
                    </div>
                <?php endif;?>
                <?php if($product->variations == "" OR $product->variations == "no-variations"):?>
                    <section class="card" id="card_variations" data-id="<?= $variations ?>" style="display: none">
                        <div class="card-body">
                            <div col-lg-12>
                                <h5>Largura do Rolo</h5>
                            </div>
                            <hr>
                            <div class="form-group row">
                                <div class="col-sm-12">
                                    <input type="text" class="form-control mb-3 tokenfield" name="firstVariation" id="variationField1"><br>
                                    <a href="" class="btn btn-block btn-success" id="addVariant">Adiciona Variantes</a>
                                </div>
                            </div>
                        </div>
                    </section>
                    <div class="variants">
                        <?= $v->insert("views/fragments/no-variants-edit", ["productVariations"=>$productVariations])?>
                    </div>
                <?php endif;?>
                <input type="hidden" id="j_key" name="variations" value="<?= $product->variations != "no-variations" ? $product->variations : ""; ?>">
                <section class="card">
                    <div class="card-body">
                        <div class="form-group row">
                            <div class="col-md-12">
                                <label class="control-label">Categoria*</label>
                                <select name="category" class="form-control" required>
                                    <?php foreach ($categories as $category):
                                        $categoryId = $product->category;
                                        $select = function ($value) use ($categoryId) {
                                            return ($categoryId == $value ? "selected" : "");
                                        };
                                        ?>
                                        <option <?= $select($category->id); ?>
                                                value="<?= $category->id; ?>"><?= $category->title; ?></option>
                                    <?php endforeach; ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-md-2 control-label">Data de publicação:</label>
                            <div class="col-md-4">
                                <input class="mask-datetime form-control" type="text" name="post_at" value="<?= date_fmt($product->post_at)?>"
                                       required/>
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
                            </div>
                            <label class="col-md-2 control-label">Status*</label>
                            <div class="col-md-4">
                                <select name="status" class="form-control" required>
                                    <?php
                                    $status = $product->status;
                                    $select = function ($value) use ($status) {
                                        return ($status == $value ? "selected" : "");
                                    };
                                    ?>
                                    <option <?= $select("post"); ?> value="post">Publicar</option>
                                    <option <?= $select("draft"); ?> value="draft">Rascunho</option>
                                    <option <?= $select("trash"); ?> value="trash">Lixo</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-sm-2 control-label">Galeria</label>
                            <div class="col-sm-10">
                                <input type="file" name="gallery[]" placeholder="Uma imagem de capa" class="form-control" multiple/>
                                <span class="help-block">Envie até 10 imagens por vez para não sobrecarregar o sistema</span>
                            </div>
                        </div>

                    </div>
                </section>
                <div class="clear" style="margin-bottom: 50px;">
                    <button class="btn btn-primary" type="submit">Publicar</button>
                    <a class="btn btn-danger" href="<?= url("/admin/product/home"); ?>">Cancelar</a>
                </div>
            </form>
        </div>
        <div class="col-lg-3">
            <section class="card">
                <header class="card-header infinity-bg white-text text-center">
                    Imagem de capa
                </header>
                <img class="radius img-open" style="width: 100%;" src="<?= image($product->cover, 400); ?>" id="image-preview"/>
            </section>
            <?php if($gallery):?>
            <section class="card">
                <header class="card-header infinity-bg white-text text-center">
                    Galeria de Imagens
                </header>
                <div class="card-body">
                    <ul class="grid cs-style-8 j-deleta">
                        <?php foreach ($gallery as $g) :?>
                            <li data-delete="<?= $g->id ?>">
                                <figure>
                                    <img src="<?= image($g->gallery, 500, 500)?>" alt="img04">
                                    <figcaption>
                                        <a class="bg-infinity" rel="group" href="" id="delete-gallery"
                                           data-id="<?= $g->id ?>"
                                           data-url="<?= url("/admin/removeimagegallery")?>">
                                            <i class="fa fa-trash-o"></i></a>
                                    </figcaption>
                                </figure>
                            </li>
                        <?php endforeach;?>
                    </ul>
                </div>
            </section>
        </div>

<!--        <div class="col-lg-9">-->
<!--            <section class="card">-->
<!--                <header class="card-header infinity-bg white-text">-->
<!--                    Editar Produto-->
<!--                </header>-->
<!--                <div class="card-body">-->
<!--                    <form class="form-horizontal tasi-form" method="post" action="--><?//= url("/admin/product/product/{$product->id}"); ?><!--" >-->
<!--                        <input type="hidden" name="action" value="update"/>-->
<!--                        <div class="form-group row" hidden>-->
<!--                            <label class="col-sm-2 control-label">Capa (1920x1080px)</label>-->
<!--                            <div class="col-sm-10">-->
<!--                                <input type="file" name="cover" placeholder="Uma imagem de capa" class="form-control" id="j_img_preview"/>-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!---->
<!--                        <div class="form-group row">-->
<!--                            <label class="col-sm-2 control-label">Título*</label>-->
<!--                            <div class="col-sm-10">-->
<!--                                <input type="text" class="form-control" name="title" value="--><?//= $product->title; ?><!--" >-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="form-group row">-->
<!--                            <label class="col-sm-2 control-label">Subtítulo*</label>-->
<!--                            <div class="col-sm-5">-->
<!--                                <input type="text" class="form-control" name="subtitle" value="--><?//= $product->subtitle; ?><!--">-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                            <label class="col-sm-2 control-label">Código</label>-->
<!--                            <div class="col-sm-3">-->
<!--                                <input type="text" class="form-control" name="sku" value="--><?//= $product->sku; ?><!--">-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!---->
<!--                        <div class="form-group row">-->
<!--                            <label class="col-sm-2 control-label">Vídeo</label>-->
<!--                            <div class="col-sm-10">-->
<!--                                <input type="text" class="form-control" name="video" value="--><?//= $product->video; ?><!--" >-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="form-group row">-->
<!--                            <div class="col-sm-12">-->
<!--                                <label class="control-label">Conteúdo*</label>-->
<!---->
<!--                                <textarea name="content" class="form-control mce">--><?//= $product->content; ?><!--</textarea>-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!---->
<!--                        <div class="form-group row">-->
<!---->
<!--                            <div class="col-sm-3">-->
<!--                                <label class="control-label">Altura*</label>-->
<!--                                <input type="text" class="form-control" name="height" value="--><?//= $productVariations->height; ?><!--">-->
<!--                                <span class="help-block">Em cm</span>-->
<!--                            </div>-->
<!---->
<!--                            <div class="col-sm-3">-->
<!--                                <label class="control-label">Largura*</label>-->
<!--                                <input type="text" class="form-control" name="width" value="--><?//= $productVariations->width; ?><!--">-->
<!--                                <span class="help-block">Em cm</span>-->
<!--                            </div>-->
<!---->
<!--                            <div class="col-sm-3">-->
<!--                                <label class="control-label">Profundidade*</label>-->
<!--                                <input type="text" class="form-control" name="depth" value="--><?//= $productVariations->depth; ?><!--">-->
<!--                                <span class="help-block">Em cm</span>-->
<!--                            </div>-->
<!--                            <div class="col-sm-3">-->
<!--                                <label class="control-label">Peso*</label>-->
<!---->
<!--                                <input type="text" class="form-control" name="weight" value="--><?//= $productVariations->weight; ?><!--">-->
<!--                                <span class="help-block">Em gramas</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="form-group row">-->
<!---->
<!--                            <div class="col-sm-4">-->
<!--                                <label class="control-label">Preço*</label>-->
<!--                                <input type="text" class="form-control" name="price" value="--><?//= $productVariations->price; ?><!--">-->
<!--                                <span class="help-block">ex: 10.00</span>-->
<!--                            </div>-->
<!--                            <div class="col-sm-4">-->
<!--                                <label class="control-label">Preço Promo*</label>-->
<!--                                <input type="text" class="form-control" name="promotional_price" value="--><?//= $productVariations->promotional_price; ?><!--">-->
<!--                                <span class="help-block">ex: 9.00</span>-->
<!--                            </div>-->
<!--                            <div class="col-sm-4">-->
<!--                                <label class="control-label">Estoque*</label>-->
<!--                                <input type="text" class="form-control" name="stock" value="--><?//= $productVariations->stock; ?><!--">-->
<!--                                <span class="help-block">-1 para infinito</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!---->
<!---->
<!--                        <div class="form-group row">-->
<!--                            <div class="col-md-12">-->
<!--                                <label class="control-label">Categoria*</label>-->
<!--                                <select name="category" class="form-control" required>-->
<!--                                    --><?php //foreach ($categories as $category):
//                                        $categoryId = $product->category;
//                                        $select = function ($value) use ($categoryId) {
//                                            return ($categoryId == $value ? "selected" : "");
//                                        };
//                                        ?>
<!--                                        <option --><?//= $select($category->id); ?>
<!--                                                value="--><?//= $category->id; ?><!--">--><?//= $category->title; ?><!--</option>-->
<!--                                    --><?php //endforeach; ?>
<!--                                </select>-->
<!--                            </div>-->
<!---->
<!--                        </div>-->
<!--                        <div class="form-group row">-->
<!---->
<!---->
<!--                            <label class="col-md-2 control-label">Data de publicação:</label>-->
<!--                            <div class="col-md-4">-->
<!--                                <input class="mask-datetime form-control" type="text" name="post_at" value="--><?//= date_fmt($product->post_at)?><!--"-->
<!--                                       required/>-->
                                <!-- <span class="help-block">A block of help text that breaks onto a new line and may extend beyond one line.</span>-->
<!--                            </div>-->
<!--                            <label class="col-md-2 control-label">Status*</label>-->
<!--                            <div class="col-md-4">-->
<!--                                <select name="status" class="form-control" required>-->
<!--                                    --><?php
//                                    $status = $product->status;
//                                    $select = function ($value) use ($status) {
//                                        return ($status == $value ? "selected" : "");
//                                    };
//                                    ?>
<!--                                    <option --><?//= $select("post"); ?><!-- value="post">Publicar</option>-->
<!--                                    <option --><?//= $select("draft"); ?><!-- value="draft">Rascunho</option>-->
<!--                                    <option --><?//= $select("trash"); ?><!-- value="trash">Lixo</option>-->
<!--                                </select>-->
<!--                            </div>-->
<!--                        </div>-->
<!---->
<!---->
<!---->
<!---->
<!--                        <div class="form-group row">-->
<!--                            <label class="col-sm-2 control-label">Galeria</label>-->
<!--                            <div class="col-sm-10">-->
<!--                                <input type="file" name="gallery[]" placeholder="Uma imagem de capa" class="form-control" multiple/>-->
<!--                                <span class="help-block">Envie até 10 imagens por vez para não sobrecarregar o sistema</span>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <button class="btn btn-primary" type="submit">Publicar</button>-->
<!--                        <a class="btn btn-danger" href="--><?//= url("/admin/product/home"); ?><!--">Cancelar</a>-->
<!---->
<!--                    </form>-->
<!--                </div>-->
<!--            </section>-->
<!--        </div>-->

        <?php endif; ?>
    </div>
    <?php endif; ?>
</section>
<?php $v->start("scripts")?>
    <script src="<?= url("admin-assets/js/toucheffects.js")?>"></script>
    <script src="<?= url("admin-assets/js/modernizr.custom.js")?>"></script>
    <script src="<?= url("admin-assets/js/form-component.js")?>"></script>
    <script src="<?= url("shared/scripts/bootstrap-tokenfield.min.js")?>"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script>
        function sendData(origin = ""){
            if(origin == ""){
                var total = $("#variationField1").val().split(',');
                var i;
                for (i = 0; i < total.length; ++i) {
                    total[i]  = total[i].trim();
                    total[i] = total[i].replace(/ /g, " ");
                    total[i] = total[i].replace(".", "_");
                    total[i] = total[i].replace(/ /g, "-");
                }
                var array1 = total;
                if ($( "#j_key" ).length) {
                    var array2 = $("#j_key").val().split(',');
                }else{
                    var array2 = [];
                }
                array1 = array1.filter(function(val) {
                    return array2.indexOf(val) == -1;
                });
                var difference = [];
                difference = array2.filter(x => !total.includes(x));
                if(!difference){
                    difference = [];
                }
                if(difference[0] != ""){
                    var i;
                    for (i = 0; i < difference.length; ++i) {
                        $("#att-"+difference[i]).remove();
                    }
                    $("#j_key").val(total);
                }
                var action = "with-variants";
            }else if(origin == "no-variants"){
                var action = "no-variants";
            }

            var urlData = $("#dataSet").data("url");
            $.ajax({
                url: urlData,
                type: "POST",
                data: {action: action, variant: array1, actual: total},
                dataType: "json",
                success: function (response) {
                    $(".variants").append(response.html);
                    $("#j_key").val(total);
                }
            });
        }

        $('.btn_confirm_variation').on("click", function (e) {
                e.preventDefault();
                var confirm = $(this).attr("id");
                if (confirm == "yes"){
                    $("#card_variations").fadeIn("fast");
                    $(".variants").html("");
                }else if(confirm == "no"){
                    $("#card_variations").fadeOut("fast");
                    $(".variants").html("");
                    $("#j_key").val("");
                    sendData("no-variants");
                }
        });

        $('.tokenfield').on('tokenfield:createtoken', function (event) {
            var existingTokens = $(this).tokenfield('getTokens');
            $.each(existingTokens, function(index, token) {
                if (token.value === event.attrs.value) {
                    event.preventDefault();
                    return false;
                }
            });
        });

        var tags = [];
        tags = $("#card_variations").data("id").split(",");
        $('.tokenfield').tokenfield({
            autocomplete:{
                source: tags,
                delay: 100
            },
            showAutocompleteOnFocus: true
        }).on('tokenfield:removedtoken', function (e) {
            e.preventDefault();
            sendData();
        });

        $("#addVariant").on("click", function (e) {
            e.preventDefault();
            sendData();
        });

        $(document).on("focus", ".mask-price", function() {
            $(this).mask('00000.00', {reverse: true, placeholder: "00.00"});
        });
    </script>
<?php $v->end(); ?>