HEX
Server: LiteSpeed
System: Linux sv4.hami.host 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64
User: armgroup (1008)
PHP: 8.2.32
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, mail, socket_create, socket_create_listen, socket_create_pair, link, dl, openlog, syslog, stream_socket_server, curl_multi_init
Upload Files
File: //home/armgroup/libs/resources/views/livewire/admin/product/edit.blade.php
<form role="form" wire:submit.prevent="update">
    <div class="card-body">
        <div class="card-header" style="background-color: #dfe6e9; color: #2d3436;">دسته اصلی:
            @foreach($category->parents as $p)
                <span>{{ $p->name }}</span>
                @if(!$loop->last)
                    <span class="fa fa-angle-left"></span>
                @endif
            @endforeach
            <a href="{{ route('admin.products.selectCategory', ['product' => $product->id]) }}" class="mr-3 text-primary">تغییر...</a>
        </div>
        <h4 class="text-center my-1" style="color: #2c3e50; text-decoration: underline;"><span class="fa fa-info-circle"></span> عمومی</h4>
        <div class="row">
            <div class="col-12 mb-3">
                <!--<div class="form-group mb-0" wire:ignore>-->
                <!--    <label for="category_id">دسته‌ها</label>-->
                <!--    <select class="form-control @error('category_id') is-invalid @enderror" id="category_id" wire:model.defer="category_id" multiple>-->
                <!--        <option></option>-->
                <!--        @foreach($categories as $category)-->
                <!--            <option value="{{ $category->id }}">{{ $category->name }}</option>-->
                <!--        @endforeach-->
                <!--    </select>-->
                <!--</div>-->
                @error('category_id')
                <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                @enderror
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="name">نام *</label>
                    <input class="form-control @error('product.name') is-invalid @enderror" id="name"
                           wire:model.defer="product.name" type="text" required>
                    @error('product.name')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="slug">اسلاگ *</label>
                    <input class="form-control @error('product.slug') is-invalid @enderror" id="slug"
                           wire:model.defer="product.slug" type="text" required>
                    @error('product.slug')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="latin_name">نام لاتین</label>
                    <input class="form-control @error('product.latin_name') is-invalid @enderror" id="latin_name"
                           wire:model.defer="product.latin_name" type="text" dir="ltr">
                    @error('product.latin_name')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6 mb-3">
                <div class="form-group mb-0" wire:ignore>
                    <label for="brand_id">برند</label>
                    <select class="form-control @error('product.brand_id') is-invalid @enderror" id="brand_id"
                            wire:model.defer="product.brand_id">
                        <option></option>
                        @foreach($brands as $brand)
                            <option value="{{ $brand->id }}">{{ $brand->name }}</option>
                        @endforeach
                    </select>
                </div>
                @error('product.brand_id')
                <span class="text-danger" role="alert">
                        <strong>{{ $message }}</strong>
                    </span>
                @enderror
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="weight">وزن (گرم)</label>
                    <input class="form-control @error('product.weight') is-invalid @enderror" dir="ltr" id="weight"
                           wire:model.defer="product.weight" type="number">
                    @error('product.weight')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="sort_order">ترتیب نمایش</label>
                    <input class="form-control @error('product.sort_order') is-invalid @enderror" dir="ltr" id="sort_order"
                           wire:model.defer="product.sort_order" type="number">
                    @error('product.sort_order')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="sending_days">مدت ارسال(روز)</label>
                    <input class="form-control @error('product.sending_days') is-invalid @enderror" dir="ltr" id="sending_days"
                           wire:model.defer="product.sending_days" type="number" min="0">
                    @error('product.sending_days')
                        <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="suggest">محصول پیشنهادی *</label>
                    <select class="form-control @error('product.suggest') is-invalid @enderror" id="suggest" required
                            wire:model.defer="product.suggest">
                        <option value="1">بله</option>
                        <option value="0">خیر</option>
                    </select>
                    @error('product.suggest')
                    <span class="text-danger" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="best_seller">پرفروش*</label>
                    <select class="form-control @error('product.best_seller') is-invalid @enderror" id="best_seller" required
                            wire:model.defer="product.best_seller">
                        <option value="1">بله</option>
                        <option value="0">خیر</option>
                    </select>
                    @error('product.best_seller')
                        <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="product.stock">موجودی</label>
                    <input class="form-control @error('product.stock') is-invalid @enderror" id="product.stock"
                           wire:model.defer="product.stock" type="number">
                    @error('product.stock')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="product.code">کد</label>
                    <input class="form-control @error('product.code') is-invalid @enderror" id="product.code"
                           wire:model.defer="product.code" type="text" dir="ltr">
                    @error('product.code')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-6">
                <div class="form-group">
                     <small id="price-mask" class="float-left text-secondary ">{{ is_numeric($product->price) ? number_format($product->price) : $product->price }}</small> 
                    <label for="product.price">قیمت (تومان)</label>
                    <input class="form-control @error('product.price') is-invalid @enderror" id="product.price"
                           wire:model.lazy="product.price" type="number" oninput="updatePriceMask()">
                    @error('product.price')
                    <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            @if($can_change_status)
                <div class="col-6">
                    <div class="form-group">
                        <label for="status">وضعیت *</label>
                        <select class="form-control @error('product.status') is-invalid @enderror" id="status" required
                                wire:model.defer="product.status">
                            <option value="1">فعال</option>
                            <option value="0">غیرفعال</option>
                        </select>
                        @error('product.status')
                        <span class="text-danger" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                </div>
            @endif
            <div class="col-6">
                    <div class="form-group">
                        <label for="status">کشور سازنده </label>
                        <select class="form-control @error('product.country_code') is-invalid @enderror" id="status" required
                                wire:model.defer="product.country_code">
                            <option value="">انتخاب کنید</option>
                            @foreach($countries as $code => $country)
                                <option value="{{$code}}">{{$country['name']}}</option>
                            @endforeach
                        </select>
                        @error('product.country_code')
                        <span class="text-danger" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
            </div>
            <!-- <div class="col-6">
                <div class="form-group">
                    <label for="video-lfm">ویدئو در اسلایدر (فرمت mp4)</label>
                    <div>
                        <a id="video-lfm" class="btn btn-primary text-white">
                            <i class="fa fa-file-video-o"></i> {{ $product->slider_video ? 'تغییر' : 'انتخاب'}} ویدئو
                        </a>
                        @if($product->slider_video)
                            <button class="btn btn-danger" wire:click.prevent="$set('product.slider_video', null)">
                                <span class="fa fa-times"></span>
                                حذف
                            </button>
                        @endif
                    </div>
                </div>
                @if($product->slider_video)
                    <a href="{{ asset($product->slider_video) }}" target="_blank" class="btn btn-success btn-sm">
                        <span class="fa fa-eye"></span>
                        مشاهده ویدئو
                    </a>
                @endif
                @error('product.slider_video')
                <span class="text-danger" role="alert">
                        <strong>{{ $message }}</strong>
                    </span>
                @enderror
            </div>
            <div class="col-6">
                <div class="form-group">
                    <label for="slider_text">متن در اسلایدر</label>
                    <textarea class="form-control @error('product.slider_text') is-invalid @enderror"
                              id="slider_text"
                              rows="5"
                              wire:model.defer="product.slider_text"></textarea>
                    @error('product.slider_text')
                        <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div> -->
            <div class="col-12">
                <div class="form-group mb-0" wire:ignore>
                    <label for="description">توضیحات کامل</label>
                    <textarea class="form-control @error('product.description') is-invalid @enderror tinymce" id="description"
                              wire:model.defer="product.description"></textarea>
                </div>
                @error('product.description')
                <span class="text-danger" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
                @enderror
            </div>
        </div>
        <h4 class="text-center mb-1 mt-3" style="color: #2c3e50; text-decoration: underline;"><span class="fa fa-search"></span> سئو</h4>
        <div class="row">
            <div class="col-12">
                <div class="form-group">
                    <label for="meta_title">عنوان صفحه</label>
                    <input class="form-control @error('product.meta_title') is-invalid @enderror" id="meta_title"
                           wire:model.defer="product.meta_title" type="text" placeholder="در صورت خالی بودن نام محصول قرار می‌گیرد">
                    @error('product.meta_title')
                        <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-12">
                <div class="form-group">
                    <label for="short_description">توضیحات کوتاه</label>
                    <textarea class="form-control @error('product.short_description') is-invalid @enderror" id="short_description"
                              wire:model.defer="product.short_description"></textarea>
                    @error('product.short_description')
                        <span class="text-danger" role="alert">
                            <strong>{{ $message }}</strong>
                        </span>
                    @enderror
                </div>
            </div>
            <div class="col-12">
                <div class="form-group mb-0" wire:ignore>
                    <label for="tag_id">تگ‌ها</label>
                    <select class="form-control @error('tag_id') is-invalid @enderror" id="tag_id" wire:model.defer="tag_id" multiple>
                        <option></option>
                        @foreach($tags as $tag)
                            <option value="{{ $tag->id }}">{{ $tag->name }}</option>
                        @endforeach
                    </select>
                </div>
                @error('tag_id')
                    <span class="text-danger" role="alert">
                        <strong>{{ $message }}</strong>
                    </span>
                @enderror
            </div>
            <div class="col-12 mt-3">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>سوال</th>
                        <th>جواب</th>
                        <th>عملیات</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($faq as $index => $f)
                        <tr>
                            <td>
                                <input type="text" class="form-control @error("faq.$index.question") is-invalid @enderror"
                                       wire:model.defer="faq.{{$index}}.question" required>
                                @error("faq.$index.question")
                                <span class="text-danger" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </td>
                            <td>
                                <input type="text" class="form-control @error("faq.$index.answer") is-invalid @enderror"
                                       wire:model.defer="faq.{{$index}}.answer" required>
                                @error("faq.$index.answer")
                                <span class="text-danger" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </td>
                            <td>
                                <button type="button" class="btn btn-danger btn-sm" wire:click="removeItem({{ $index }}, 3)">
                                    <span class="fa fa-trash"></span> حذف
                                </button>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="2"></td>
                        <td>
                            <button type="button" id="add-item" class="btn btn-success btn-sm" wire:click="addItem(3)"><span class="fa fa-plus"></span> افزودن</button>
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div>
        </div>
        <h4 class="text-center mb-1 mt-3" style="color: #2c3e50; text-decoration: underline;"><span class="fa fa-image"></span> تصاویر</h4>
        <table class="table table-hover">
            <thead>
            <tr>
                <th>تصویر</th>
                <th>ترتیب</th>
                <th>عملیات</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td class="px-5">
                    <div class="row">
                        <div id="holder" class="d-inline col-md-4">
                            @if($product->image)
                                <a href="{{ asset($product->image) }}" target="_blank">
                                    <img src="{{ asset($product->image) }}" style="width: 120px; height: 90px;" class="img-fluid">
                                </a>
                            @endif
                            @error('product.image')
                                <br>
                                <span class="text-danger" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                        <div class="input-group d-inline col-md-2">
                            <span class="input-group-btn">
                               <a data-input="thumbnail" data-preview="holder" id="lfm" class="btn btn-primary text-white">
                                  <i class="fa fa-picture-o"></i> انتخاب
                               </a>
                            </span>
                        </div>
                    </div>
                </td>
                <td><b>تصویر شاخص</b></td>
                <td><span class="badge badge-danger">الزامی است</span></td>
            </tr>
            @if(count($items))
                @foreach($items as $index => $item)
                    <tr>
                        <td class="px-5">
                            <div class="row">
                                <div id="holder{{ $index }}" class="d-inline col-md-4">
                                    @if($item['path'])
                                        <a href="{{ asset($item['path']) }}" target="_blank">
                                            <img src="{{ asset($item['path']) }}" style="width: 120px; height: 90px;" class="img-fluid">
                                        </a>
                                    @endif
                                    @error("items.$index.path")
                                        <br>
                                        <span class="text-danger" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                                <div class="input-group d-inline col-md-8">
                                       <span class="input-group-btn">
                                         <a data-input="thumbnail{{ $index }}" data-preview="holder{{ $index }}" class="btn btn-primary multiLFM text-white">
                                           <i class="fa fa-picture-o"></i> انتخاب
                                         </a>
                                       </span>
                                </div>
                            </div>
                        </td>
                        <td>
                            <input type="number" class="form-control @error("items.$index.sort_order") is-invalid @enderror" min="0" wire:model.defer="items.{{$index}}.sort_order">
                            @error("items.$index.sort_order")
                            <span class="text-danger" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </td>
                        <td>
                            <button type="button" class="btn btn-danger btn-sm" wire:click="removeItem({{ $index }}, 1)">
                                <span class="fa fa-trash"></span> حذف
                            </button>
                        </td>
                    </tr>
                @endforeach
            @endif
            </tbody>
            <tfoot>
            <tr>
                <td colspan="2"></td>
                <td>
                    <button type="button" id="add-item" class="btn btn-success btn-sm" wire:click="addItem(1)"><span class="fa fa-plus"></span> افزودن</button>
                </td>
            </tr>
            </tfoot>
        </table>
        @if(count($attributes))
            <h4 class="text-center mb-1 mt-3" style="color: #2c3e50; text-decoration: underline;"><span class="fa fa-info"></span> ویژگی‌ها</h4>
            <div class="row">
                @foreach($attributes as $attribute)
                    <div class="col-3 my-1">
                        <label for="attribute{{ $attribute->id }}">{{ $attribute->name }}</label>
                        <select class="form-control @error("selectedAttributes.{$attribute->id}") is-invalid @enderror"
                                id="attribute{{ $attribute->id }}"
                                wire:model.defer="selectedAttributes.{{ $attribute->id }}">
                            <option value="">انتخاب کنید</option>
                            @foreach($attribute->values as $value)
                                <option value="{{ $value->id }}">{{ $value->value }}</option>
                            @endforeach
                        </select>
                        @error("selectedAttributes.{$attribute->id}")
                        <span class="text-danger" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                        @enderror
                    </div>
                @endforeach
            </div>
        @endif
        <h4 class="text-center my-1" style="color: #2c3e50; text-decoration: underline;"><span class="fa fa-dollar"></span> تخفیف</h4>
        <table class="table table-hover mt-4">
            <thead>
                <tr>
                    <th>سازمان</th>
                    <!--<th>عنوان شگفت انگیز</th>-->
                    <!--<th>زیر عنوان شگفت انگیز</th>-->
                      <!--<th> درصد</th>-->
                    <th>قیمت ویژه</th>
                    <th>تاریخ شروع</th>
                    <th>تاریخ پایان</th>
                    <th>عملیات</th>
                </tr>
            </thead>
            <tbody>
                @if(count($specials))
                    @foreach($specials as $index => $item)
                        <tr>
                            <td>
                                <select class="form-control @error("specials.$index.organization_id") is-invalid @enderror" wire:model.defer="specials.{{$index}}.organization_id">
                                    <option value="">پیش‌فرض</option>
                                    @foreach($organizations as $organization)
                                        <option value="{{ $organization->id }}">{{ $organization->name }}</option>
                                    @endforeach
                                </select>
                                @error("specials.$index.organization_id")
                                <span class="text-danger" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </td>
                            
                            
                          <!--  <td>-->
                          <!--      <input type="text" class="form-control @error("specials.$index.title") is-invalid @enderror"  wire:model.defer="specials.{{$index}}.title">-->
                          <!--      @error("specials.$index.title")-->
                          <!--      <span class="text-danger" role="alert">-->
                          <!--              <strong>{{ $message }}</strong>-->
                          <!--          </span>-->
                          <!--      @enderror-->
                          <!--  </td>-->
                            
                            
                            
                          <!--<td>-->
                          <!--      <input type="text" class="form-control @error("specials.$index.sub_title") is-invalid @enderror"  wire:model.defer="specials.{{$index}}.sub_title">-->
                          <!--      @error("specials.$index.sub_title")-->
                          <!--      <span class="text-danger" role="alert">-->
                          <!--              <strong>{{ $message }}</strong>-->
                          <!--          </span>-->
                          <!--      @enderror-->
                          <!--  </td>-->
                            <!--<td>-->
                          
                            <!--    <input type="number" class="form-control @error("specials.$index.discount_percentage") is-invalid @enderror" -->
                            <!--           min="0" max="100" dir="ltr" -->
                            <!--           wire:model="specials.{{$index}}.discount_percentage"-->
                            <!--           placeholder="درصد تخفیف">-->
                            <!--    @error("specials.$index.discount_percentage")-->
                            <!--    <span class="text-danger" role="alert">-->
                            <!--        <strong>{{ $message }}</strong>-->
                            <!--    </span>-->
                            <!--    @enderror-->
                            <!--</td>-->
                            <td>
                                <input type="number" class="form-control @error("specials.$index.special") is-invalid @enderror" min="0" dir="ltr" wire:model.defer="specials.{{$index}}.special">
                                @error("specials.$index.special")
                                <span class="text-danger" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </td>
                            <td>
                                <div wire:ignore>
                                    <input id="special_started_at{{ $index }}" type="text" class="form-control" autocomplete="off">
                                    <input id="special_started_at_alt{{ $index }}" type="hidden">
                                </div>
                                @error("specials.$index.special_started_at")
                                <span class="text-danger" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </td>
                            <td>
                                <div wire:ignore>
                                    <input id="special_ended_at{{ $index }}" type="text" class="form-control" autocomplete="off">
                                    <input id="special_ended_at_alt{{ $index }}" type="hidden">
                                </div>
                                @error("specials.$index.special_ended_at")
                                <span class="text-danger" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </td>
                            <td>
                                <button type="button" class="btn btn-danger btn-sm" wire:click="removeSpecial({{ $index }})">
                                    <span class="fa fa-trash"></span> حذف
                                </button>
                            </td>
                        </tr>
                    @endforeach
                @endif
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="4"></td>
                    <td>
                        <button type="button" id="add-special" class="btn btn-success btn-sm" wire:click="addSpecial"><span class="fa fa-plus"></span> افزودن</button>
                    </td>
                </tr>
            </tfoot>
        </table>
        <div class="col-12 my-3">
            <h4 class="text-center" style="color: #2c3e50; text-decoration: underline;"><span class="fa fa-dollar"></span>گزینه ها</h4>
        </div>
        @if(count($allOptions))
            <div class="col-12 mb-4">
                <div class="row">
                    <div class="col-1 pt-2 text-center"><strong>گزینه‌ها</strong></div>
                    @foreach($allOptions as $op)
                        <div class="col-2" wire:ignore>
                            <select wire:model.defer="productSelectedOptions.{{ $op->id }}"
                                    id="op-{{ $op->id }}"
                                    multiple
                                    class="form-control">
                                @foreach($op->values as $val)
                                    <option value="{{ $val->id }}">{{ $val->name }}</option>
                                @endforeach
                            </select>
                        </div>
                    @endforeach
                    <div class="col-1">
                        <button type="button"
                                class="btn btn-info"
                                wire:click.prevent="setProductOptions">
                            انتخاب
                        </button>
                    </div>
                </div>
            </div>
        @endif
        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                <tr>
                    @foreach($options as $option)
                        <th>{{ $option->name }}</th>
                    @endforeach
                   
                    <!--<th>قیمت ویژه</th>-->
                    <!--<th>تاریخ شروع</th>-->
                    <!--<th>تاریخ پایان</th>-->
                    @if(count($options))
                         <th>موجودی</th>
                        <th>کد</th>
                        <th>قیمت</th>
                        <th>عملیات</th>
                    @endif
                </tr>
                </thead>
                <tbody>
                @foreach($items2 as $index => $item)
                    <tr>
                        @foreach($options as $option)
                            <td>
                                <select
                                    class="form-control @error("items2.$index.value_id") is-invalid @enderror"
                                    wire:model.defer="items2.{{$index}}.value_id" required>
                                    <option value="">انتخاب کنید</option>
                                    @foreach($option->values as $value)
                                        <option value="{{ $value->id }}">{{ $value->name }}</option>
                                    @endforeach
                                </select>
                                @error("items2.$index.value_id")
                                <strong class="text-danger">{{ $message }}</strong>
                                @enderror
                            </td>
                        @endforeach
                        @if(count($options))
                            <td>
                                <input type="text" class="form-control @error("items2.$index.stock") is-invalid @enderror"
                                       wire:model.defer="items2.{{$index}}.stock" dir="ltr">
                                @error("items2.$index.stock")
                                <strong class="text-danger">{{ $message }}</strong>
                                @enderror
                            </td>
                            <td>
                                <input type="text" class="form-control @error("items2.$index.code") is-invalid @enderror"
                                       wire:model.defer="items2.{{$index}}.code" dir="ltr">
                                @error("items2.$index.code")
                                <strong class="text-danger">{{ $message }}</strong>
                                @enderror
                            </td>
                            <td>
                                <input type="number" class="form-control @error("items2.$index.price") is-invalid @enderror"
                                       wire:model.defer="items2.{{$index}}.price" dir="ltr" required>
                                @error("items2.$index.price")
                                <strong class="text-danger">{{ $message }}</strong>
                                @enderror
                            </td>
                            <td>
                                @if(count($items2) >= 1)
                                    <button type="button" class="btn btn-danger btn-sm"
                                            wire:click="removeItem({{ $index }}, 2)">
                                        <span class="fa fa-trash"></span> حذف
                                    </button>
                                @endif
                            </td>
                        @endif
                    </tr>
                @endforeach
                </tbody>
                @if(count($options))
                    <tfoot>
                    <tr>
                        <!--<td colspan="{{ 6 + count($options) }}"></td>-->
                        <td colspan="4"></td>
                        <td>
                            <button type="button" id="add-item2" class="btn btn-success btn-sm" wire:click="addItem(2)">
                                <span class="fa fa-plus"></span> افزودن
                            </button>
                        </td>
                    </tr>
                    </tfoot>
                @endif
            </table>
        </div>
    </div>
    <div class="card-footer">
        <button type="submit" class="btn btn-primary">ذخیره</button>
        <a href="{{ route('admin.products.index') }}" class="btn btn-danger float-left">لغو</a>
    </div>
</form>

@push('scripts')
    @include('livewire.admin.partials.numberFormat')
    @include('livewire.admin.partials.lfm')
    <!--@include('livewire.admin.partials.video-lfm')-->
    @include('livewire.admin.partials.tinymce', ['variable' => 'product.description'])
    @include('livewire.admin.partials.select2', ['selectId' => 'brand_id', 'selectVar' => 'product.brand_id'])
    @include('livewire.admin.partials.select2', ['selectId' => 'tag_id', 'selectVar' => 'tag_id'])
    @include('livewire.admin.partials.select2', ['selectId' => 'category_id', 'selectVar' => 'category_id', 'closeOnSelect' => true])
    @foreach($allOptions as $op)
        @include('livewire.admin.partials.select2', ['selectId' => 'op-'. $op->id, 'selectVar' => 'productSelectedOptions.'. $op->id, 'placeholder' => $op->name])
    @endforeach
    <script>
        var multiLFM = function(class_name, type, options) {
            let buttons = document.getElementsByClassName(class_name);
            for(let i = 0; i < buttons.length; i++) {
                buttons[i].addEventListener('click', function () {
                    var route_prefix = (options && options.prefix) ? options.prefix : '/laravel-filemanager';
                    var target_preview = document.getElementById(buttons[i].getAttribute('data-preview'));

                    window.open(route_prefix + '?type=' + type || 'file', 'FileManager', 'width=900,height=600');
                    window.SetUrl = function (items) {
                        var file_path = items.map(function (item) {
                            return item.url;
                        }).join(',');

                        // set or change the preview image src
                        items.forEach(function (item) {
                            target_preview.innerHTML = `<img src="${item.thumb_url}" class="img-fluid">`;
                        });

                        // trigger change event
                        target_preview.dispatchEvent(new Event('change'));

                        Livewire.emit('multiImageChanged', i, file_path);
                    };
                });
            }
        };
        multiLFM('multiLFM', 'image');

        Livewire.on('addedItem', function() {
            multiLFM('multiLFM', 'image');
        })
    </script>
    <script>
        $(document).on("click", ".calendar-btn", function () {
            var name = $(this).data('name');
            var index = $(this).data('index');
            var alt = `#${name}_${index}`;
            default_val = $(alt).val();

            var pd = $(this).persianDatepicker({
                "format": 'YYYY-MM-DD HH:mm:ss',
                "altField": `#${name}_${index}`,
                "responsive": true,
                "timePicker": {
                    "enabled": true,
                },
                "toolbox": {
                    "enabled": true,
                    "submitButton": {
                        onSubmit: (datepickerObject) => {
                            var alt = `#${name}_${index}`;
                            unix = $(alt).val() * 1;
                            if(index == 'default') {
                                @this.set(`default_${name}`, formatDate(new Date(unix)));
                            } else {
                                @this.set(`items2.${index}.${name}`, formatDate(new Date(unix)));
                            }
                        },
                        "enabled": true,
                        "text": {
                            "fa": "تایید",
                            "en": "Submit"
                        }
                    },
                },
            });

            if (default_val) {
                pd.setDate(default_val * 1)
            }

            pd.show();
        });

        function formatDate(date) {
            const year = date.getFullYear();
            const month = String(date.getMonth() + 1).padStart(2, '0');
            const day = String(date.getDate()).padStart(2, '0');
            const hours = String(date.getHours()).padStart(2, '0');
            const minutes = String(date.getMinutes()).padStart(2, '0');
            const seconds = String(date.getSeconds()).padStart(2, '0');

            return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
        }
    </script>
      <script>
        Livewire.on('addedSpecial', function(index) {
            $(`#special_started_at${index}`).MdPersianDateTimePicker({
                targetTextSelector: `#special_started_at${index}`,
                targetDateSelector: `#special_started_at_alt${index}`,
                enableTimePicker: true,
                dateFormat: 'yyyy/MM/dd HH:mm:ss'
            });
            $(`#special_started_at${index}`).on('hidden.bs.popover', function () {
            @this.set(`specials.${index}.special_started_at`, $(`#special_started_at_alt${index}`).val());
            });

            $(`#special_ended_at${index}`).MdPersianDateTimePicker({
                targetTextSelector: `#special_ended_at${index}`,
                targetDateSelector: `#special_ended_at_alt${index}`,
                enableTimePicker: true,
                dateFormat: 'yyyy/MM/dd HH:mm:ss'
            });
            $(`#special_ended_at${index}`).on('hidden.bs.popover', function () {
            @this.set(`specials.${index}.special_ended_at`, $(`#special_ended_at_alt${index}`).val());
            });
        })
        @foreach($specials as $index => $item)
            $('#special_started_at{{ $index }}').MdPersianDateTimePicker({
                targetTextSelector: '#special_started_at{{ $index }}',
                targetDateSelector: '#special_started_at_alt{{ $index }}',
                enableTimePicker: true,
                dateFormat: 'yyyy/MM/dd HH:mm:ss'
            });
            $('#special_started_at{{ $index }}').on('hidden.bs.popover', function () {
                @this.set("specials.{{ $index }}.special_started_at", $('#special_started_at_alt{{ $index }}').val());
            });
            $('#special_ended_at{{ $index }}').MdPersianDateTimePicker({
                targetTextSelector: '#special_ended_at{{ $index }}',
                targetDateSelector: '#special_ended_at_alt{{ $index }}',
                enableTimePicker: true,
                dateFormat: 'yyyy/MM/dd HH:mm:ss'
            });
            $('#special_ended_at{{ $index }}').on('hidden.bs.popover', function () {
                @this.set("specials.{{ $index }}.special_ended_at", $('#special_ended_at_alt{{ $index }}').val());
            });
        @endforeach
    </script>
    <script>
        function updatePriceMask() {
    
            const input = document.getElementById('product.price');
            const priceMask = document.getElementById('price-mask');
            
          
            if (input.value.length > 0) {
                priceMask.classList.remove('d-none');
            } else {
                priceMask.classList.add('d-none'); 
            }
    
            // Format the value with commas
            let value = parseInt(input.value);
            if (!isNaN(value)) {
                priceMask.textContent = value.toLocaleString('fa-IR'); 
            } else {
                priceMask.textContent = '';
            }
        }
    </script>
@endpush