<?php

use App\Models\subTicket;
use App\Classes\jDate;

error_reporting(1);
$explode = explode('/', $_SERVER['REQUEST_URI']);

$jDate = new jDate();
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$english = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
$today = str_replace($persian, $english, $jDate::forge(time())->format('Y-m-d'));

?>
@extends('index')

@section('content')
    {{--    <form action="saveProject" method="post">@csrf--}}
    {{--        admin--}}
    {{--        <input type="text" name="admin" required/><hr>--}}
    {{--        title--}}
    {{--        <input type="text" name="title" required/><hr>--}}
    {{--        body--}}
    {{--        <input type="text" name="body" ><hr>--}}
    {{--        admins--}}
    {{--        <input type="text" name="admins" placeholder="mobin.hamed"><hr>--}}
    {{--        <input type="submit">--}}

    {{--    </form>--}}

    {{--<link href="https://admin.borjeweb.com/gg/assets/libs/summernote/summernote-bs4.min.css" rel="stylesheet" type="text/css">--}}

    <div class="page-content">

        <!-- start page title -->
        <div class="row">
            <div class="col-12">
                <div class="page-title-box d-flex align-items-center justify-content-between">
                    <h4 class="page-title mb-0 font-size-18">عناصر فرم</h4>

                    <div class="page-title-right">
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="javascript:%20void(0);">فرم ها</a></li>
                            <li class="breadcrumb-item active">عناصر فرم</li>
                        </ol>
                    </div>

                </div>
            </div>
        </div>
        <!-- end page title -->

        <div class="row">
            <div class="col-12">
                <div class="card">
                    <h2 style="text-align: center"> {{$ticket->title}} </h2>
                </div>
            </div>
        </div>

        @foreach($ticket->subTiket as $subTicket)
            @if($subTicket->ticket_id == $ticket->id)
            @endif
            <div class="row">
                <div class="col-9" style="float: right">
                    <div class="card">
                        <label>{{str_replace($persian,$english , $jDate::forge($subTicket->updated_at)->format('Y-m-d'))}}
                            --{{$subTicket->status}}--{{$subTicket->file}}</label>
                        <h5 style="text-align: center"> {!! $subTicket->text !!} </h5>
                    </div>
                </div>
            </div>
        @endforeach
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <hr>
                    <div class="card-body">

                        <form action="{{url('saveSubTicket')}}" method="post">@csrf
                            ارسال تیکت
                            <input type="hidden" name="ticket_id" value="{{$ticket->id}}">
                            <input type="hidden" name="maker" value="{{$user->id}}">

                            <div class="form-group row">
                                <div class="col">
                                    <textarea id="elm1" name="text"></textarea>
                                    <hr>
                                </div>
                            </div>
                            <input type="submit"
                                   class="btn btn-success  btn-lg btn-block waves-effect waves-light mb-1">
                        </form>

                        <form action="{{url('saveSubTicketFile')}}" method="post" enctype="multipart/form-data">@csrf
                            ارسال فایل
                            <input type="hidden" name="ticket_id" value="{{$ticket->id}}">
                            <input type="hidden" name="maker" value="{{$user->id}}">


                                <hr style=" margin: 0px;color: black">
                               <br>
                                <h6 style="color: red;"> حد اکثر حجم  (2) مگابایت میباشد </h6>
                           

                            <input style="padding-left: 20%" type="file" name="image" id="image" value="upload">
                            <input type="hidden" name="imagename" value="mobin123">
                            <br>
                            <input class="btn btn-success" type="submit" value="upload image">
                            <hr style=" margin: 0px;color: black">
                        </form>

                    </div>
                </div>
            </div>
        </div>
        <!-- end row -->

    </div>

@endsection
@section('script')
    <script src="https://v3dboy.ir/previews/html/qovex/qovex/Vertical/assets/libs/tinymce/tinymce.min.js"></script>
    <script src="https://v3dboy.ir/previews/html/qovex/qovex/Vertical/assets/libs/tinymce/langs/fa_IR.js"></script>



    <!-- init js -->
    <script src="https://v3dboy.ir/previews/html/qovex/qovex/Vertical/assets/js/pages/form-editor.init.js"></script>
@endsection