<?php
use App\Classes\jDate;

$jDate	= new jDate();
$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$english = [ 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,  9 ];
$today = str_replace($persian,$english , $jDate::forge(time())->format('d'));
$url = explode('/',$_SERVER["SCRIPT_URL"]);
?>
{{--<form method="post" action="{{$task->id}}/doneAction">--}}
{{--    @csrf--}}
{{--    <input type="submit" value="done">--}}
{{--</form>--}}
<style>
    .bg-task0 {
        background: #ff6a00 !important;
    }
    .bg-task1 {
        background: #a2010c !important;
    }
    .bg-task2 {
        background: #a2010c !important;
    }
    .bg-task3 {
        background: #626262 !important;
    }
    .bg-task4 {
        background: #626262 !important;
    }
    .bg-task100 {
        background: #05875c !important;
    }
</style>
@extends('index')

@section('content')

    <div class="page-content">
        <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 >فرم ها</a></li>
                            <li class="breadcrumb-item active">عناصر فرم</li>
                        </ol>
                    </div>

                </div>
            </div>
        </div>
        <div class="row">
            @if($url[1]== "allTask")
                @foreach($tasks as $task)
                    @if($task->status != 4)
                        <div class="col-lg-4 " >
                            <div class="card bg-task{{$task->status}} text-white-50 class{{$task->status}}">
                                <div class="card-body">
                                    <h5 class="mt-0 mb-4 text-white"><i class="mdi mdi-bullseye-arrow mr-3"></i>{{$task->title}}</h5>
                                    <button type="button" class="btn btn-dark w-lg waves-effect waves-light" data-toggle="modal" data-target="#exampleModalScrollable{{$task->id}}">اطلاعات</button>
                                    <div class="modal fade" id="exampleModalScrollable{{$task->id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
                                        <div class="modal-dialog modal-dialog-scrollable">
                                            <div class="modal-content">
                                                <form method="post" id="taskEditGeneral{{$task->id}}">
                                                    @csrf
                                                    <div class="modal-header">
                                                        <h5 class="modal-title mt-0" id="exampleModalScrollableTitle"><input name="title" value="{{$task->title}}" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif> </h5>
                                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                            <span aria-hidden="true">×</span>
                                                        </button>
                                                    </div>
                                                    <div class="modal-body text-dark">
                                            <span class="text-success">
                                                تاریخ شروع :
                                                <input name="d1" value="{{$jDate::forge($task->d1)->format('Y/m/d')}}" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif>
                                            </span>
                                                        <hr>
                                                        <span class="text-danger ">
                                                تاریخ پایان :
                                                <input name="d3" value="{{$jDate::forge($task->d3)->format('Y/m/d')}}" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif>

                                            </span><br>
                                                        <textarea name="task" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif>
                                               {!! $task->task !!}
                                            </textarea>

                                                    </div>
                                                    <div class="modal-footer">



                                                        <select class="form-control" id="pet-select" name="status"  onclick="">
                                                            <option value="0">فعال</option>
                                                            <option value="1">مهم</option>
                                                            <option value="2">گذشته</option>
                                                            <option value="3">غیر فعال</option>
                                                            <option value="4">حذف شده</option>
                                                            <option value="100" selected>انجام شده</option>
                                                        </select>

                                                        @if( $Admin->premises == 0)
                                                            <button onmousedown="document.getElementById('taskEditGeneral{{$task->id}}').action = 'https://admin.borjeweb.com/editTask/{{$task->id}}'" onmouseup="document.getElementById('taskEditGeneral{{$task->id}}').submit()">
                                                                admin edit</button>
                                                        @else
                                                            <button onmousedown="document.getElementById('taskEditGeneral{{$task->id}}').action = 'https://admin.borjeweb.com/editTaskStatus/{{$task->id}}'" onmouseup="document.getElementById('taskEditGeneral{{$task->id}}').submit()">
                                                                done</button>
                                                        @endif

                                                    </div>
                                                </form>
                                            </div>

                                            <!-- /.modal-content -->
                                        </div>
                                        <!-- /.modal-dialog -->
                                    </div>


                                </div>

                            </div>
                        </div>
                    @endif

                @endforeach
            @else
                @foreach($tasks as $task)
                    @if($task->admin == $Admin->name or $task->maker==$Admin->name and $task->status != 4)
                    <div class="col-lg-4 " >
                        <div class="card bg-task{{$task->status}} text-white-50 class{{$task->status}}">
                            <div class="card-body">
                                <h5 class="mt-0 mb-4 text-white"><i class="mdi mdi-bullseye-arrow mr-3"></i>{{$task->title}} </h5>
                                <button type="button" class="btn btn-dark w-lg waves-effect waves-light" data-toggle="modal" data-target="#exampleModalScrollable{{$task->id}}">اطلاعات</button>
                                <div class="modal fade" id="exampleModalScrollable{{$task->id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
                                    <div class="modal-dialog modal-dialog-scrollable">
                                        <div class="modal-content">
                                            <form method="post" id="taskEditGeneral{{$task->id}}">
                                                @csrf
                                                <div class="modal-header">
                                                    <h5 class="modal-title mt-0" id="exampleModalScrollableTitle"><input name="title" value="{{$task->title}}" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif> </h5>
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">×</span>
                                                    </button>
                                                </div>
                                                <div class="modal-body text-dark">
                                            <span class="text-success">
                                                تاریخ شروع :
                                                <input name="d1" value="{{$jDate::forge($task->d1)->format('Y/m/d')}}" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif>
                                            </span>
                                                    <hr>
                                                    <span class="text-danger ">
                                                تاریخ پایان :
                                                <input name="d3" value="{{$jDate::forge($task->d3)->format('Y/m/d')}}" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif>

                                            </span><br>
                                                    <textarea name="task" style="border: none" @if($Admin->premises != 0)readonly="readonly"@endif>
                                               {!! $task->task !!}
                                            </textarea>

                                                </div>
                                                <div class="modal-footer">



                                                    <select class="form-control" id="pet-select" name="status"  onclick="">
                                                        <option value="0">فعال</option>
                                                        <option value="1">مهم</option>
                                                        <option value="2">گذشته</option>
                                                        <option value="3">غیر فعال</option>
                                                        <option value="4">حذف شده</option>
                                                        <option value="100" selected>انجام شده</option>
                                                    </select>

                                                    @if( $Admin->premises == 0)
                                                        <button onmousedown="document.getElementById('taskEditGeneral{{$task->id}}').action = 'https://admin.borjeweb.com/editTask/{{$task->id}}'" onmouseup="document.getElementById('taskEditGeneral{{$task->id}}').submit()">
                                                            admin edit</button>
                                                    @else
                                                        <button onmousedown="document.getElementById('taskEditGeneral{{$task->id}}').action = 'https://admin.borjeweb.com/editTaskStatus/{{$task->id}}'" onmouseup="document.getElementById('taskEditGeneral{{$task->id}}').submit()">
                                                            done</button>
                                                    @endif

                                                </div>
                                            </form>
                                        </div>

                                        <!-- /.modal-content -->
                                    </div>
                                    <!-- /.modal-dialog -->
                                </div>


                            </div>

                        </div>
                    </div>
                    @endif
                @endforeach
            @endif
        </div>
    </div>
@endsection
<button type="button" class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target=".bs-example-modal-center">مودال وسط</button>
