@extends('layouts.app')

@section('content')
    <section class="page-header row">
        <h2> {{ $pageTitle }} </h2>
        <ol class="breadcrumb">
            <li><a href="{{ url('') }}"> Dashboard </a></li>
            <li><a href="{{ url('/manage/'.$pageModule) }}"> {{ $pageTitle }} </a></li>
            <li class="active"> Form</li>
        </ol>
    </section>
    <div class="page-content row">
        <div class="page-content-wrapper no-margin">

            {!! Form::open(array('url'=>'/manage/stores?return='.$return, 'class'=>'form-vertical validated','files' => true )) !!}
            <input type="hidden" name="status_type" value="{{ $pageTitle }}"/>

            <div class="sbox-title clearfix">
                <div class="sbox-tools pull-right">
                    <a href="{{ url('/manage/'.$pageModule.'?return='.$return) }}" class="tips btn btn-sm "
                       title="{{ __('core.btn_back') }}"><i class="fa  fa-times"></i></a>
                </div>
                <div class="sbox-tools1 pull-left1">
                    <button name="apply" class="btn btn-sm btn-primary  " title="{{ __('core.btn_back') }}"><i
                                class="fa  fa-check"></i> {{ __('core.sb_apply') }} </button>
                    <button name="save" class="btn btn-sm btn-success" title="{{ __('core.btn_back') }}"><i
                                class="fa  fa-paste"></i> {{ __('core.sb_save') }} </button>
                    <?php if ($frontendSlug != '') {
                        $fsconfig = explode('@', $frontendSlug);
                        if (isset($row[$fsconfig[1]]) && $row[$fsconfig[1]])
                            echo '<a  class="btn btn-sm btn-outline-primary" target="_blank"  title="FrontEnd" href="' . (config('website.cnf_appurl') . '/' . config('website.cnf_lang') . str_replace('//', '/', ('/' . $fsconfig[0] . '/' . $row[$fsconfig[1]]))) . '"><i class="fa  fa-desktop"></i> FrontEnd</a>';
                    } ?>
                </div>
            </div>
            <div class="sbox1">
                <div class="sbox-content clearfix row">
                    <div class="col-xs-12">
                        <ul class="parsley-error-list">
                            @foreach($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>

                        <?php $curTime = time();?>

                        <div class="sbox1">
                            <div class="col-md-6">
                                <fieldset class="sbox" style="border-top:0; border-radius: 5px;">
                                    <legend> stores</legend>
                                    <?php if (!isset($row['id'])) $row['id'] = null;   ?>
                                    <input type='hidden' name='id' id='id' value='{{$row['id']}}'/>

                                    <div class="form-group  depen-  wrap-name  ">
                                        <label for="ipt" class=" control-label "> Name <span class="asterix"> * </span>
                                        </label>


                                        <?php if (!isset($row['name'])) $row['name'] = null;   ?>
                                        <?php $val = is_array($row['name']) ? (object)$row['name'] : json_decode($row['name']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#name_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='name_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="name[{{$ilang}}]" id='name'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           required placeholder='Name - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-slug  ">
                                        <label for="ipt" class=" control-label "> Slug <span class="asterix"> * </span>
                                        </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Do not enter any special character or space, keep the slug unique among all the stores."><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['slug'])) $row['slug'] = null;   ?>
                                        <input type='text' name='slug' id='slug' value='{{ $row['slug'] }}'
                                               {{!empty($row['id']) ? 'readonly' : ''}}
                                               required class='form-control input-sm '/>
                                    </div>
                                    <div class="form-group  depen-  wrap-background_color  ">
                                        <label for="ipt" class=" control-label "> Background Color </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['background_color'])) $row['background_color'] = null;   ?>
                                        <input type='color' name='background_color' id='background_color'
                                               value='{{ $row['background_color'] }}'
                                               class='form-control input-sm '/>
                                    </div>
                                    <div class="form-group  depen-  wrap-text_color  ">
                                        <label for="ipt" class=" control-label "> Text Color </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['text_color'])) $row['text_color'] = null;   ?>
                                        <input type='color' name='text_color' id='text_color'
                                               value='{{ $row['text_color'] }}'
                                               class='form-control input-sm '/>
                                    </div>
                                    <div class="form-group  depen-  wrap-header_image  ">
                                        <label for="ipt" class=" control-label "> Header Image </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Preferred size 1170 X 200 px"><i class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['header_image'])) $row['header_image'] = null;   ?>
                                        <input type='hidden' name='header_image' id='header_image'
                                               value='{{ $row['header_image'] }}'
                                               class='header_image    form-control input-sm '/>


                                        <button class='btn btn-primary mr-5' data-type='mediaUpload'
                                                data-target='.header_image' type='button'>Choose file
                                        </button>
                                        <button class='btn btn-danger unUploadImage' data-type='mediaUnUpload'
                                                data-target='header_image' type='button'>Remove File
                                        </button>


                                        <div class='header_image_preview'></div>
                                        <div class='header_imagePreview'>
                                            <div class='img-preview'>
                                                {!! SiteHelpers::showUploadedFile($row['header_image'],'/uploads/images/store/') !!}

                                            </div>
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-logo  ">
                                        <label for="ipt" class=" control-label "> Logo </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Preferred size 150 X 50 px"><i class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['logo'])) $row['logo'] = null;   ?>
                                        <input type='hidden' name='logo' id='logo' value='{{ $row['logo'] }}'
                                               class='logo    form-control input-sm '/>


                                        <button class='btn btn-primary mr-5' data-type='mediaUpload' data-target='.logo'
                                                type='button'>Choose file
                                        </button>
                                        <button class='btn btn-danger unUploadImage' data-type='mediaUnUpload'
                                                data-target='logo' type='button'>Remove File
                                        </button>


                                        <div class='logo_preview'></div>
                                        <div class='logoPreview'>
                                            <div class='img-preview'>
                                                {!! SiteHelpers::showUploadedFile($row['logo'],'/uploads/images/store/') !!}

                                            </div>
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-homepage  ">
                                        <label for="ipt" class=" control-label "> Store Homepage Link </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Enter plain URL without any deeplink or sub ID."><i
                                                    class="fa fa-info-circle"></i></a>
                                        <?php if (!isset($row['homepage'])) $row['homepage'] = null;   ?>
                                        <?php $val = is_array($row['homepage']) ? (object)$row['homepage'] : json_decode($row['homepage']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#homepage_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='homepage_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="homepage[{{$ilang}}]" id='homepage'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           required placeholder='homepage - {{$ilang}}'
                                                           class='form-control input-sm '
                                                           style="direction: ltr;"/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>
                                    </div>
                                    <div class="form-group  depen-  wrap-dl_url_build  ">
                                        <label for="ipt" class=" control-label "> Deeplinking URL build
                                            Structure </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Use extra parameter 1 and enter the deeplink URL structure"><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['dl_url_build'])) $row['dl_url_build'] = null;   ?>
                                        <input type='text' name='dl_url_build' id='dl_url_build'
                                               value='{{ $row['dl_url_build'] }}'
                                               class='form-control input-sm '/>
                                    </div>
                                    <div class="form-group  depen-  wrap-app_homepage  ">
                                        <label for="ipt" class=" control-label "> App Homepage Deeplink URL </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Use extra parameter 1 and enter the deeplink URL structure"><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['app_homepage'])) $row['app_homepage'] = null;   ?>
                                        <input type='text' name='app_homepage' id='app_homepage'
                                               value='{{ $row['app_homepage'] }}'
                                               class='form-control input-sm '/>
                                    </div>
                                    <div class="form-group  depen-  wrap-dl_app_url_build  ">
                                        <label for="ipt" class=" control-label "> App Deeplink URL build
                                            Structure </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Use extra parameter 1 and enter the deeplink URL structure"><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['dl_app_url_build'])) $row['dl_app_url_build'] = null;   ?>
                                        <input type='text' name='dl_app_url_build' id='dl_app_url_build'
                                               value='{{ $row['dl_app_url_build'] }}'
                                               class='form-control input-sm '/>
                                    </div>
                                    <div class="form-group  depen-  wrap-cb_status  ">
                                        <label for="ipt" class=" control-label "> Cashback Status <span class="asterix"> * </span>
                                        </label>

                                        <?php if (!isset($row['cb_status'])) $row['cb_status'] = null;   ?>
                                        <?php if (strlen($row['cb_status']) < 1) $row['cb_status'] = '1';      ?>
                                        <div class='switch-wrap'><label class='switch'>
                                                <input type='hidden' name='cb_status' value='0'/>
                                                <input type='checkbox' name='cb_status' value='1'
                                                       @if($row['cb_status']) checked @endif
                                                /> <span class="slider round"></span></label></div>
                                    </div>
                                    <div class="form-group  depen-  wrap-cb_mobile  ">
                                        <label for="ipt" class=" control-label "> Support Mobile Cashback <span
                                                    class="asterix"> * </span> </label>

                                        <?php if (!isset($row['cb_mobile'])) $row['cb_mobile'] = null;   ?>
                                        <?php if (strlen($row['cb_mobile']) < 1) $row['cb_mobile'] = '1';      ?>
                                        <div class='switch-wrap'><label class='switch'>
                                                <input type='hidden' name='cb_mobile' value='0'/>
                                                <input type='checkbox' name='cb_mobile' value='1'
                                                       @if($row['cb_mobile']) checked @endif
                                                /> <span class="slider round"></span></label></div>
                                    </div>
                                    <div class="form-group  depen-  wrap-cb_coupon  ">
                                        <label for="ipt" class=" control-label "> Support Coupon with Cashback <span
                                                    class="asterix"> * </span> </label>

                                        <?php if (!isset($row['cb_coupon'])) $row['cb_coupon'] = null;   ?>
                                        <?php if (strlen($row['cb_coupon']) < 1) $row['cb_coupon'] = '1';      ?>
                                        <div class='switch-wrap'><label class='switch'>
                                                <input type='hidden' name='cb_coupon' value='0'/>
                                                <input type='checkbox' name='cb_coupon' value='1'
                                                       @if($row['cb_coupon']) checked @endif
                                                /> <span class="slider round"></span></label></div>
                                    </div>


                                    <div class="form-group  depen-  wrap-is_featured  ">
                                        <label for="ipt" class=" control-label "> Is Featured   </label>

                                        <?php if (strlen($row['is_featured']) < 1) $row['is_featured'] = '0';      ?>
                                        <div class='switch-wrap'>
                                            <label class='switch'>
                                                <input type='hidden' name='is_featured' value='0'/>
                                                <input type='checkbox' name='is_featured' value='1' @if($row['is_featured']) checked @endif />
                                                <span class="slider round"></span>
                                            </label>
                                        </div>
                                    </div>

                                    <div class="form-group depen- wrap-tracking_channels">
                                        <label for="tracking_channels" class="control-label"> Tracking Channels <span
                                                    class="asterix text-danger"> * </span></label>
                                        <?php if (!isset($row['tracking_channels'])) $row['tracking_channels'] = Yajny\Utils\StoreTrackingChannels::WEBSITE; ?>
                                        <select name='tracking_channels' id='tracking_channels'
                                                class='select2' data-placeholder='Tracking Channels'
                                                placeholder='Tracking Channels'>
                                            @foreach(Yajny\Utils\StoreTrackingChannels::getChannelsNames() as $key => $name)
                                                <option value="{{ $key }}"
                                                        @if($row['tracking_channels'] == $key) selected @endif>{{ $name }}</option>
                                            @endforeach
                                        </select>
                                    </div>

                                    <div class="form-group  depen-  wrap-cashback_percent  ">
                                        <label for="ipt" class=" control-label "> Cashback Percent </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="% cut you wish to pass-on to users as a cashback for this store."><i
                                                    class="fa fa-info-circle"></i></a>
                                        <?php if (!isset($row['cashback_percent'])) $row['cashback_percent'] = null;   ?>
                                        <?php if (strlen($row['cashback_percent']) < 1) $row['cashback_percent'] = '80';      ?>
                                        <input type='number' name='cashback_percent' id='cashback_percent'
                                               value='{{ $row['cashback_percent'] }}' required
                                               class='form-control is_number'/>
                                    </div> <?php if (!isset($row['current_cb'])) $row['current_cb'] = null;   ?>
                                    <input type='hidden' name='current_cb' id='current_cb'
                                           value='{{$row['current_cb']}}'/>
                                    <?php if (!isset($row['was_cb'])) $row['was_cb'] = null;   ?>
                                    <input type='hidden' name='was_cb' id='was_cb' value='{{$row['was_cb']}}'/>
                                    <?php if (!isset($row['amount_type'])) $row['amount_type'] = null;   ?>
                                    <?php if (strlen($row['amount_type']) < 1) $row['amount_type'] = 'percent';      ?>
                                    <input type='hidden' name='amount_type' id='amount_type'
                                           value='{{$row['amount_type']}}'/>
                                    <?php if (!isset($row['rate_type'])) $row['rate_type'] = null;   ?>
                                    <?php if (strlen($row['rate_type']) < 1) $row['rate_type'] = 'upto';      ?>
                                    <input type='hidden' name='rate_type' id='rate_type' value='{{$row['rate_type']}}'/>
                                    <div class="form-group  depen-  wrap-cashback_percent  ">
                                        <label for="ipt" class=" control-label "> Cashback Deal Type </label>
                                        <?php if (!isset($row['cb_deal_type'])) $row['cb_deal_type'] = null;   ?>
                                        <?php if (strlen($row['cb_deal_type']) < 1) $row['cb_deal_type'] = 'percent';      ?>
                                        <select name='cb_deal_type' rows='5' id='cb_deal_type' class='select2 '
                                                data-placeholder='Cashback Deal Type' placeholder='Cashback Deal Type'>
                                            <option value="percent"
                                                    @if($row['cb_deal_type'] == 'percent') selected @endif>percent
                                            </option>
                                            <option value="fixed" @if($row['cb_deal_type'] == 'fixed') selected @endif>
                                                fixed
                                            </option>
                                        </select>
                                    </div>


                                    <div class="form-group  depen-  wrap-cb_valid_period  ">
                                        <label for="cb_valid_period" class=" control-label "> Cashback validation
                                            period</label>
                                        <?php if (!isset($row['cb_valid_period'])) $row['cb_valid_period'] = 0;   ?>
                                        <input type='number' name='cb_valid_period' id='cb_valid_period'
                                               value='10' class='form-control is_number'/>
                                    </div>

                                    <div class="form-group  depen-  wrap-cb_deal_value  ">
                                        <label for="cb_deal_value" class=" control-label "> Cashback Deal Value </label>
                                        <?php if (!isset($row['cb_deal_value'])) $row['cb_deal_value'] = 0;   ?>
                                        <input type='number' name='cb_deal_value' id='cb_deal_value'
                                               value='{{$row['cb_deal_value']}}' class='form-control is_number'/>
                                    </div>

                                    <div class="form-group  depen-  wrap-about_store  ">
                                        <label for="ipt" class=" control-label "> About Store </label>


                                        <?php if (!isset($row['about_store'])) $row['about_store'] = null;   ?>
                                        <?php $val = is_array($row['about_store']) ? (object)$row['about_store'] : json_decode($row['about_store']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#about_store_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                                                     id='about_store_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="about_store[{{$ilang}}]" rows='5' id='about_store' class='form-control editor input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>

                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-sp_terms_title  ">
                                        <label for="ipt" class=" control-label "> Special Term Title </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Mention any special term that store has, that your user should keep in mind when doing the transaction."><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['sp_terms_title'])) $row['sp_terms_title'] = null;   ?>
                                        <?php $val = is_array($row['sp_terms_title']) ? (object)$row['sp_terms_title'] : json_decode($row['sp_terms_title']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#sp_terms_title_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='sp_terms_title_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="sp_terms_title[{{$ilang}}]"
                                                           id='sp_terms_title'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           placeholder='Special Term Title - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-sp_terms  ">
                                        <label for="ipt" class=" control-label "> Special Term Description </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Mention any special term that store has, that your user should keep in mind when doing the transaction."><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['sp_terms'])) $row['sp_terms'] = null;   ?>
                                        <?php $val = is_array($row['sp_terms']) ? (object)$row['sp_terms'] : json_decode($row['sp_terms']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#sp_terms_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                                                     id='sp_terms_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="sp_terms[{{$ilang}}]" rows='5' id='sp_terms' class='form-control editor input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>

                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-network_id  ">
                                        <label for="ipt" class=" control-label "> Affiliate Network ID </label>

                                        <?php if (!isset($row['network_id'])) $row['network_id'] = null;   ?>
                                        <?php if (strlen($row['network_id']) < 1) $row['network_id'] = '0';      ?>

                                        <?php $row['network_id'] = trim($row['network_id'], '[]'); ?>

                                        <select name='network_id' rows='5' id='network_id' class='select2 '
                                                data-placeholder='Select Affiliate Network ID'
                                                placeholder='Select Affiliate Network ID'></select>
                                    </div>
                                    <div class="form-group  depen-  wrap-store_family_id  ">
                                        <label for="ipt" class=" control-label "> Store Family ID </label>

                                        <?php if (!isset($row['store_family_id'])) $row['store_family_id'] = null;   ?>
                                        <?php if (strlen($row['store_family_id']) < 1) $row['store_family_id'] = '0';      ?>

                                        <?php $row['store_family_id'] = trim($row['store_family_id'], '[]'); ?>

                                        <select name='store_family_id' rows='5' id='store_family_id' class='select2 '
                                                data-placeholder='Select Store Family ID'
                                                placeholder='Select Store Family ID'></select>
                                    </div>



                                    <div class="form-group  depen-  wrap-region_code  ">
                                        <label for="ipt" class=" control-label "> Region *</label>

                                        <?php if (!isset($row['region_code'])) $row['region_code'] = null;   ?>
                                        <?php if (is_array($row['region_code'])) $row['region_code'] = implode($row['region_code']); ?>
                                        <?php $row['region_code'] = trim($row['region_code'], '[]'); ?>

                                        <select name='region_code[]' id='region_code' class='select2' multiple
                                                data-placeholder='Select Region' placeholder='Select Region'
                                                required></select>
                                    </div>


                                    <div class="form-group  depen-  wrap-status  ">
                                        <label for="ipt" class=" control-label "> Status </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Store status, only published stores appears in front-end."><i
                                                    class="fa fa-info-circle"></i></a>
                                        <?php if (!isset($row['status'])) $row['status'] = null;   ?>
                                        <?php if (strlen($row['status']) < 1) $row['status'] = 'draft';      ?>
                                        <?php $status = (isset($row['status'])) ? $row['status'] : null; ?>

                                        <input type='radio' name='status' value='publish'
                                               @if( $status == 'publish') checked="checked" @endif class='minimal-red'>
                                        Publish

                                        <input type='radio' name='status' value='draft'
                                               @if( $status == 'draft') checked="checked" @endif class='minimal-red'>
                                        Draft

                                        <input type='radio' name='status' value='trash'
                                               @if( $status == 'trash') checked="checked" @endif class='minimal-red'>
                                        Trash
                                    </div>

                                    <div class="form-group  depen-  wrap-more_about_store_title  ">
                                        <label for="ipt" class=" control-label "> More About Store Title </label>


                                        <?php if (!isset($row['more_about_store_title'])) $row['more_about_store_title'] = null;   ?>
                                        <?php $val = is_array($row['more_about_store_title']) ? (object)$row['more_about_store_title'] : json_decode($row['more_about_store_title']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#more_about_store_title_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='more_about_store_title_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="more_about_store_title[{{$ilang}}]"
                                                           id='more_about_store_title'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           placeholder='More About Store Title - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-more_about_store  ">
                                        <label for="ipt" class=" control-label "> More About Store </label>


                                        <?php if (!isset($row['more_about_store'])) $row['more_about_store'] = null;   ?>
                                        <?php $val = is_array($row['more_about_store']) ? (object)$row['more_about_store'] : json_decode($row['more_about_store']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#more_about_store_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                                                     id='more_about_store_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="more_about_store[{{$ilang}}]" rows='5' id='more_about_store'
                          class='form-control editor input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>

                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>

                                    <div class="form-group  depen-  wrap-domain_name  ">
                                        <label for="ipt" class=" control-label "> Domain Name <span
                                                    class="asterix"> * </span> </label>


                                        <?php if (!isset($row['domain_name'])) $row['domain_name'] = null;   ?>
                                        <input type='text' name='domain_name' id='domain_name'
                                               value='{{ $row['domain_name'] }}'
                                               required class='form-control input-sm '/>
                                    </div>

                                    <?php if (!isset($row['created_at'])) $row['created_at'] = null;   ?>
                                    <input type='hidden' name='created_at' id='created_at'
                                           value='{{ date("Y-m-d H:i:s") }}'/><?php if (!isset($row['updated_at'])) $row['updated_at'] = null;   ?>
                                    <input type='hidden' name='updated_at' id='updated_at'
                                           value='{{ date("Y-m-d H:i:s") }}'/></fieldset>
                            </div>

                            <div class="col-md-6">
                                <fieldset class="sbox" style="border-top:0; border-radius: 5px;">
                                    <legend> Additional Configurations</legend>

                                    <div class="form-group  depen-  wrap-cb_terms  ">
                                        <label for="ipt" class=" control-label "> Cashback Terms </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Side bar content"><i class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['cb_terms'])) $row['cb_terms'] = null;   ?>
                                        <?php $val = is_array($row['cb_terms']) ? (object)$row['cb_terms'] : json_decode($row['cb_terms']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#cb_terms_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                                                     id='cb_terms_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="cb_terms[{{$ilang}}]" rows='5' id='cb_terms' class='form-control editor input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>

                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-secrets  ">
                                        <label for="ipt" class=" control-label "> Cashback Secrets </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="Side bar content"><i class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['secrets'])) $row['secrets'] = null;   ?>
                                        <?php $val = is_array($row['secrets']) ? (object)$row['secrets'] : json_decode($row['secrets']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#secrets_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                                                     id='secrets_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="secrets[{{$ilang}}]" rows='5' id='secrets' class='form-control editor input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>

                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div> <?php if (!isset($row['tracking_days'])) $row['tracking_days'] = null;   ?>
                                    <?php if (strlen($row['tracking_days']) < 1) $row['tracking_days'] = '3';      ?>
                                    <input type='hidden' name='tracking_days' id='tracking_days'
                                           value='{{$row['tracking_days']}}'/>
                                    <?php if (!isset($row['claim_days'])) $row['claim_days'] = null;   ?>
                                    <?php if (strlen($row['claim_days']) < 1) $row['claim_days'] = '90';      ?>
                                    <input type='hidden' name='claim_days' id='claim_days'
                                           value='{{$row['claim_days']}}'/>

                                    <div class="form-group  depen-  wrap-categories  ">
                                        <label for="ipt" class=" control-label "> Store Categories </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="You may select multiple appropriate categories"><i
                                                    class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['categories'])) $row['categories'] = null;   ?>

                                        <?php $row['categories'] = trim($row['categories'], '[]'); ?>

                                        <select name='categories[]' multiple rows='5' id='categories' class='select2 '
                                                data-placeholder='Select Store Categories'
                                                placeholder='Select Store Categories'></select>
                                    </div>

                                    <div class="form-group  depen-  wrap-related_stores  ">
                                        <label for="ipt" class=" control-label "> Related Stores </label>
                                        <a class="adtip" data-toggle="tooltip" data-placement="bottom"
                                           title="You may select multiple stores"><i class="fa fa-info-circle"></i></a>

                                        <?php if (!isset($row['related_stores'])) $row['related_stores'] = null;   ?>

                                        <?php $row['related_stores'] = trim($row['related_stores'], '[]'); ?>

                                        <select name='related_stores[]' multiple rows='5' id='related_stores'
                                                class='select2 ' data-placeholder='Select related stores'
                                                placeholder='Select related stores'></select>
                                    </div>
                                    <div class="form-group  depen-  wrap-h1_tag  ">
                                        <label for="ipt" class=" control-label "> H1 Tag </label>


                                        <?php if (!isset($row['h1_tag'])) $row['h1_tag'] = null;   ?>
                                        <?php $val = is_array($row['h1_tag']) ? (object)$row['h1_tag'] : json_decode($row['h1_tag']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#h1_tag_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='h1_tag_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="h1_tag[{{$ilang}}]" id='h1_tag'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           placeholder='H1 Tag - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-h2_tag  ">
                                        <label for="ipt" class=" control-label "> H2 Tag </label>


                                        <?php if (!isset($row['h2_tag'])) $row['h2_tag'] = null;   ?>
                                        <?php $val = is_array($row['h2_tag']) ? (object)$row['h2_tag'] : json_decode($row['h2_tag']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#h2_tag_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='h2_tag_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="h2_tag[{{$ilang}}]" id='h2_tag'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           placeholder='H2 Tag - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-meta_title  ">
                                        <label for="ipt" class=" control-label "> Meta Title </label>


                                        <?php if (!isset($row['meta_title'])) $row['meta_title'] = null;   ?>
                                        <?php $val = is_array($row['meta_title']) ? (object)$row['meta_title'] : json_decode($row['meta_title']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#meta_title_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='meta_title_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="meta_title[{{$ilang}}]" id='meta_title'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           placeholder='Meta Title - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-meta_kw  ">
                                        <label for="ipt" class=" control-label "> Meta Keywords </label>


                                        <?php if (!isset($row['meta_kw'])) $row['meta_kw'] = null;   ?>
                                        <?php $val = is_array($row['meta_kw']) ? (object)$row['meta_kw'] : json_decode($row['meta_kw']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#meta_kw_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                                                     id='meta_kw_{{$ilang}}_{{$curTime}}'>
                                                    <input type='text' name="meta_kw[{{$ilang}}]" id='meta_kw'
                                                           value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                                           placeholder='Meta Keywords - {{$ilang}}'
                                                           class='form-control input-sm '/>
                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>
                                    <div class="form-group  depen-  wrap-meta_desc  ">
                                        <label for="ipt" class=" control-label "> Meta Description </label>


                                        <?php if (!isset($row['meta_desc'])) $row['meta_desc'] = null;   ?>
                                        <?php $val = is_array($row['meta_desc']) ? (object)$row['meta_desc'] : json_decode($row['meta_desc']); $is_first = true; ?>
                                        <ul class='editor-nav nav nav-tabs'>

                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <li class='{{$is_first ? "active" : null}} '><a
                                                            href='#meta_desc_{{$ilang}}_{{$curTime}}'
                                                            data-toggle='tab'>{{$ilang}}</a></li>
                                                <?php  $is_first = false;?>
                                            @endforeach </ul>

                                        <div class="tab-content ">
                                            <?php $is_first = true; ?>
                                            @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                                                <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                                                     id='meta_desc_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="meta_desc[{{$ilang}}]" rows='5' id='meta_desc' class='form-control input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>


                                                </div>
                                                <?php  $is_first = false;?>
                                            @endforeach
                                        </div>

                                    </div>


                                </fieldset>
                            </div>


                        </div>


                    </div>
                </div>
            </div>
            @include('/manage/'.$pageModule.'/subform')


            <div class="sbox-title clearfix">
                <div class="sbox-tools pull-right">
                    <a href="{{ url('/manage/'.$pageModule.'?return='.$return) }}" class="tips btn btn-sm "
                       title="{{ __('core.btn_back') }}"><i class="fa  fa-times"></i></a>
                </div>
                <div class="sbox-tools pull-left">
                    <button name="apply" class=" btn btn-sm btn-primary  " title="{{ __('core.btn_back') }}"><i
                                class="fa  fa-check"></i> {{ __('core.sb_apply') }} </button>
                    <button name="save" class=" btn btn-sm btn-success" title="{{ __('core.btn_back') }}"><i
                                class="fa  fa-paste"></i> {{ __('core.sb_save') }} </button>
                </div>
            </div>


            <input type="hidden" name="action_task" value="save"/>
            {!! Form::close() !!}
        </div>
    </div>


    <table class="hidden">
        <tr class="clone clonedInput dataRow hidden" id="masterClone">
            <?php $curTime = "01"; ?>
            <td>
                <?php $row['id'] = null;  ?>
                <?php if (!isset($row['id'])) $row['id'] = null;   ?>
                <input type='hidden' name='bulk_id[{{$row['id']}}]' id='id' value='{{$row['id']}}'/>
            </td>
            <td>
                <?php $row['store_id'] = null;  ?>
                <?php if (!isset($row['store_id'])) $row['store_id'] = null;   ?>
                <input type='hidden' name='bulk_store_id[{{$row['id']}}]' id='store_id' value='{{$row['store_id']}}'/>
            </td>
            <td>
                <?php $row['title'] = null;  ?>
                <?php if (!isset($row['title'])) $row['title'] = null;   ?>
                <?php $val = is_array($row['title']) ? (object)$row['title'] : json_decode($row['title']); $is_first = true; ?>
                <ul class='editor-nav nav nav-tabs'>

                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <li class='{{$is_first ? "active" : null}} '><a href='#title_{{$ilang}}_{{$curTime}}'
                                                                        data-toggle='tab'>{{$ilang}}</a></li>
                        <?php  $is_first = false;?>
                    @endforeach </ul>

                <div class="tab-content ">
                    <?php $is_first = true; ?>
                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                             id='title_{{$ilang}}_{{$curTime}}'>
                            <input type='text' name="bulk_title[{{$row['id']}}][{{$ilang}}]" id='title'
                                   value='{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}'
                                   required placeholder='Cashback Structure Title - {{$ilang}}'
                                   class='form-control input-sm '/>
                        </div>
                        <?php  $is_first = false;?>
                    @endforeach
                </div>
            </td>
            <td>
                <?php $row['image'] = null;  ?>
                <?php if (!isset($row['image'])) $row['image'] = null;   ?>
                <input type='hidden' name='bulk_image[{{$row['id']}}]' id='image' value='{{ $row['image'] }}'
                       class='image    form-control input-sm '/>


                <button class='btn btn-primary mr-5' data-type='mediaUpload' data-target='.image' type='button'>Choose
                    file
                </button>
                <button class='btn btn-danger unUploadImage' data-type='mediaUnUpload' data-target='image'
                        type='button'>Remove File
                </button>


                <div class='image_preview'></div>
                <div class='imagePreview'>
                    <div class='img-preview'>
                        {!! SiteHelpers::showUploadedFile($row['image'],'/uploads/images/store/') !!}

                    </div>
                </div>
            </td>
            <td>
                <?php $row['rate_type'] = null;  ?>
                <?php if (strlen($row['rate_type']) < 1) $row['rate_type'] = 'percent';      ?>

                <?php $rate_type = explode(',', $row['rate_type']);
                $rate_type_opt = array('fixed' => 'Fixed', 'percent' => 'Percent',); ?>
                <select name='bulk_rate_type[{{$row['id']}}]' rows='5' required placeholder='Select Rate Type'
                        data-placeholder='Select Rate Type' class='regSel form-control'>
                    <?php
                    foreach ($rate_type_opt as $key => $val) {
                        echo "<option  value ='$key' " . ($row['rate_type'] == $key ? " selected='selected' " : '') . ">$val</option>";
                    }
                    ?></select></td>
            <td>
                <?php $row['rate_amount_network'] = null;  ?>
                <?php if (!isset($row['rate_amount_network'])) $row['rate_amount_network'] = null;   ?>
                <input type='text' name='bulk_rate_amount_network[{{$row['id']}}]' id='rate_amount_network'
                       value='{{ $row['rate_amount_network'] }}'
                       data-parsley-maxlength="10" class='form-control is_decimal'
                       onkeypress='return isNumberKey(event,this)'/></td>
            <td>
                <?php $row['link'] = null;  ?>
                <?php if (!isset($row['link'])) $row['link'] = null; $is_first = true  ?>
                <ul class='editor-nav nav nav-tabs'>

                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <li class='{{$is_first ? "active" : null}} '><a href='#link_{{$ilang}}_{{$curTime}}'
                                                                        data-toggle='tab'>{{$ilang}}</a></li>
                        <?php  $is_first = false;?>
                    @endforeach </ul>

                <div class="tab-content ">
                    <?php $is_first = true; ?>
                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <div class='tab-pane tab_{{$ilang}}  {{$is_first ? "active" : null}}'
                             id='link_{{$ilang}}_{{$curTime}}'>
                            <input type='text' name="bulk_link[{{$row['id']}}][{{$ilang}}]" id='link'
                                   required placeholder='link - {{$ilang}}' class='form-control input-sm '/>
                        </div>
                        <?php  $is_first = false;?>
                    @endforeach
                </div>
            </td>
            <td>
                <?php $row['enabled'] = null;  ?>
                <?php if (strlen($row['enabled']) < 1) $row['enabled'] = '1';      ?>
                <div class='switch-wrap'><label class='switch'>
                        <input type='hidden' name='bulk_enabled[{{$row['id']}}]' value='0'/>
                        <input type='checkbox' name='bulk_enabled[{{$row['id']}}]' value='1'
                               @if($row['enabled']) checked @endif
                        /> <span class="slider round"></span></label></div>
            </td>
            <td>
                <?php $row['description'] = null;  ?>
                <?php if (!isset($row['description'])) $row['description'] = null;   ?>
                <?php $val = is_array($row['description']) ? (object)$row['description'] : json_decode($row['description']); $is_first = true; ?>
                <ul class='editor-nav nav nav-tabs'>

                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <li class='{{$is_first ? "active" : null}} '><a href='#description_{{$ilang}}_{{$curTime}}'
                                                                        data-toggle='tab'>{{$ilang}}</a></li>
                        <?php  $is_first = false;?>
                    @endforeach </ul>

                <div class="tab-content ">
                    <?php $is_first = true; ?>
                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                             id='description_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="bulk_description[{{$row['id']}}][{{$ilang}}]" rows='5' id='description'
                          class='form-control input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>


                        </div>
                        <?php  $is_first = false;?>
                    @endforeach
                </div>
            </td>
            <td>
                <?php $row['exclusion'] = null;  ?>
                <?php if (!isset($row['exclusion'])) $row['exclusion'] = null;   ?>
                <?php $val = is_array($row['exclusion']) ? (object)$row['exclusion'] : json_decode($row['exclusion']); $is_first = true; ?>
                <ul class='editor-nav nav nav-tabs'>

                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <li class='{{$is_first ? "active" : null}} '><a href='#exclusion_{{$ilang}}_{{$curTime}}'
                                                                        data-toggle='tab'>{{$ilang}}</a></li>
                        <?php  $is_first = false;?>
                    @endforeach </ul>

                <div class="tab-content ">
                    <?php $is_first = true; ?>
                    @foreach(explode(',', config('website.cnf_langs')) as $ilang )
                        <div class='tab-pane tab_{{$ilang}} {{$is_first ? "active" : null}}'
                             id='exclusion_{{$ilang}}_{{$curTime}}'>
				
				<textarea name="bulk_exclusion[{{$row['id']}}][{{$ilang}}]" rows='5' id='exclusion'
                          class='form-control input-sm '
                >{{   isset($val->{$ilang}) ? $val->{$ilang} : ''   }}</textarea>


                        </div>
                        <?php  $is_first = false;?>
                    @endforeach
                </div>
            </td>
            <td>

                <a onclick="removeClone(this)" href="javascript:void(0);" class="remove btn btn-xs btn-danger"><i
                            class="fa fa-minus" aria-hidden="true"></i></a>
                <input type="hidden" name="counter[]">
            </td>

        </tr>
    </table>

    <script type="text/javascript">
        $(document).ready(function () {


            jQuery(document).ready(function ($) {
                moveCopySrc();
            });

            $('.addC').relCopyForm({moveParent: "#addChildRows"});

            $("#network_id").select2({
                ajax: {
                    url: "{{url('/manage/stores/ajaxselect?filter=networks:id:name')}}",
                    data: function (params) {
                        return {
                            search: params.term,
                            page: params.page || 1
                        };
                    },
                    dataType: 'json',
                    processResults: function (data) {
                        data.page = data.page || 1;
                        return {
                            results: data.items.map(function (item) {
                                return {
                                    id: item.id,
                                    text: selctToJson(item, 'name')
                                };
                            }),
                            pagination: {
                                more: data.pagination
                            }
                        }
                    },
                    cache: true,
                    delay: 250
                },
                // minimumInputLength: 2,
                multiple: 0,
                width: '100%'
            });


            @if( strlen($row["network_id"]) > 0  )
            // Fetch the preselected item, and add to the control
            var network_idSelect = $('#network_id');
            $.ajax({
                type: 'GET',
                url: "{!! url('/manage/stores/ajaxselect?filter=networks:id:name&values='.urlencode($row["network_id"])) !!}",
            })
                .then(function (data) {
                // create the option and append to Select2
                data.items.map(function (item) {
                    var option = new Option(selctToJson(item, 'name'), item.id, true, true);
                    network_idSelect.append(option).trigger('change');

                });


                // manually trigger the `select2:select` event
                network_idSelect.trigger({
                    type: 'select2:select',
                    params: {
                        data: data
                    }
                });
            });

            network_idSelect.select2_sortable();
            @endif



            $("#store_family_id").select2({
                ajax: {
                    url: "{{url('/manage/stores/ajaxselect?filter=store_family:id:name')}}",
                    data: function (params) {
                        return {
                            search: params.term,
                            page: params.page || 1
                        };
                    },
                    dataType: 'json',
                    processResults: function (data) {
                        data.page = data.page || 1;
                        return {
                            results: data.items.map(function (item) {
                                return {
                                    id: item.id,
                                    text: selctToJson(item, 'name')
                                };
                            }),
                            pagination: {
                                more: data.pagination
                            }
                        }
                    },
                    cache: true,
                    delay: 250
                },
                // minimumInputLength: 2,
                multiple: 0,
                width: '100%'
            });


            @if( strlen($row["store_family_id"]) > 0  )
            // Fetch the preselected item, and add to the control
            var store_family_idSelect = $('#store_family_id');
            $.ajax({
                type: 'GET',
                url: "{!! url('/manage/stores/ajaxselect?filter=store_family:id:name&values='.urlencode($row["store_family_id"])) !!}",
            })
                .then(function (data) {
                // create the option and append to Select2
                data.items.map(function (item) {
                    var option = new Option(selctToJson(item, 'name'), item.id, true, true);
                    store_family_idSelect.append(option).trigger('change');

                });


                // manually trigger the `select2:select` event
                store_family_idSelect.trigger({
                    type: 'select2:select',
                    params: {
                        data: data
                    }
                });
            });

            store_family_idSelect.select2_sortable();
            @endif










            $("#region_code").select2({
                ajax: {
                    url: "{{url('/manage/stores/ajaxselect?filter=regions:code:name')}}",
                    data: function (params) {
                        return {
                            search: params.term,
                            page: params.page || 1
                        };
                    },
                    dataType: 'json',
                    processResults: function (data) {
                        data.page = data.page || 1;
                        return {
                            results: data.items.map(function (item) {
                                return {
                                    id: item.code,
                                    text: selctToJson(item, 'name')
                                };
                            }),
                            pagination: {
                                more: data.pagination
                            }
                        }
                    },
                    cache: true,
                    delay: 250
                },
                // minimumInputLength: 2,
                multiple: 1,
                width: '100%'
            });


            @if( strlen($row["region_code"]) > 0  )
            // Fetch the preselected item, and add to the control
            var region_codeSelect = $('#region_code');
            $.ajax({
                type: 'GET',
                url: "{!! url('/manage/stores/ajaxselect?filter=regions:code:name&values='.urlencode($row["region_code"])) !!}",
            }).then(function (data) {
                // create the option and append to Select2
                data.items.map(function (item) {
                    var option = new Option(selctToJson(item, 'name'), item.code, true, true);
                    region_codeSelect.append(option).trigger('change');

                });
                // manually trigger the `select2:select` event
                region_codeSelect.trigger({
                    type: 'select2:select',
                    params: {
                        data: data
                    }
                });
            });

            region_codeSelect.select2_sortable();
            @endif


            $("#categories").select2({
                ajax: {
                    url: "{{url('/manage/stores/ajaxselect?filter=categories:id:name')}}",
                    data: function (params) {
                        return {
                            search: params.term,
                            page: params.page || 1
                        };
                    },
                    dataType: 'json',
                    processResults: function (data) {
                        data.page = data.page || 1;
                        return {
                            results: data.items.map(function (item) {
                                return {
                                    id: item.id,
                                    text: selctToJson(item, 'name')
                                };
                            }),
                            pagination: {
                                more: data.pagination
                            }
                        }
                    },
                    cache: true,
                    delay: 250
                },
                // minimumInputLength: 2,
                multiple: 1,
                width: '100%'
            });


            @if( strlen($row["categories"]) > 0  )
            // Fetch the preselected item, and add to the control
            var categoriesSelect = $('#categories');
            $.ajax({
                type: 'GET',
                url: "{!! url('/manage/stores/ajaxselect?filter=categories:id:name&values='.urlencode($row["categories"])) !!}",
            }).then(function (data) {
                // create the option and append to Select2
                data.items.map(function (item) {
                    var option = new Option(selctToJson(item, 'name'), item.id, true, true);
                    categoriesSelect.append(option).trigger('change');

                });


                // manually trigger the `select2:select` event
                categoriesSelect.trigger({
                    type: 'select2:select',
                    params: {
                        data: data
                    }
                });
            });

            categoriesSelect.select2_sortable();
            @endif


            $("#related_stores").select2({
                ajax: {
                    url: "{{url('/manage/stores/ajaxselect?filter=stores:id:name')}}",
                    data: function (params) {
                        return {
                            search: params.term,
                            page: params.page || 1
                        };
                    },
                    dataType: 'json',
                    processResults: function (data) {
                        data.page = data.page || 1;
                        return {
                            results: data.items.map(function (item) {
                                return {
                                    id: item.id,
                                    text: selctToJson(item, 'name')
                                };
                            }),
                            pagination: {
                                more: data.pagination
                            }
                        }
                    },
                    cache: true,
                    delay: 250
                },
                // minimumInputLength: 2,
                multiple: 1,
                width: '100%'
            });


            @if( strlen($row["related_stores"]) > 0  )
            // Fetch the preselected item, and add to the control
            var related_storesSelect = $('#related_stores');
            $.ajax({
                type: 'GET',
                url: "{!! url('/manage/stores/ajaxselect?filter=stores:id:name&values='.urlencode($row["related_stores"])) !!}",
            }).then(function (data) {
                // create the option and append to Select2
                data.items.map(function (item) {
                    var option = new Option(selctToJson(item, 'name'), item.id, true, true);
                    related_storesSelect.append(option).trigger('change');

                });


                // manually trigger the `select2:select` event
                related_storesSelect.trigger({
                    type: 'select2:select',
                    params: {
                        data: data
                    }
                });
            });

            related_storesSelect.select2_sortable();
            @endif



            $('.removeMultiFiles').on('click', function () {
                var removeUrl = '{{ url("stores/removefiles?file=")}}' + $(this).attr('url');
                $(this).parent().remove();
                $.get(removeUrl, function (response) {
                });
                $(this).parent('div').empty();
                return false;
            });

        });
    </script>
@stop