<?php
use App\Classes\jDate;
use App\Classes\jDateTime;
$jDate	= new jDate();
$jDateTime	= new jDateTime();



//
//echo date("Y-m-d h:i:sa");
////echo $zp->jdate("d");
//echo $jDate->jdate("d");

$date = $jDate::forge('2023-07-08 08:40:50')->format('date'); // 1391-07-24
//print_r( $time::forge('d'));

$date2 = $jDate::forge()->format('date');
$datej = $jDate::forge()->format('j');

//echo $date;

$persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
$english = [ 0 ,  1 ,  2 ,  3 ,  4 ,  5 ,  6 ,  7 ,  8 ,  9 ];
$today = substr(str_replace($persian,$english , $jDate::forge(time())->format('date')),-2);
$today --;
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'شنبه'){$dayofweek = 1;}
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'یکشنبه'){$dayofweek = 2;}
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'دوشنبه'){$dayofweek = 3;}
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'سه شنبه'){$dayofweek = 4;}
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'چهارشنبه'){$dayofweek = 5;}
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'پنجشنبه'){$dayofweek = 6;}
if ($jDate::forge(strtotime("-$today days"))->format('l') == 'جمعه'){$dayofweek = 7;}

$datejnormall = str_replace($persian,$english , $datej);
$datenormall = str_replace($persian,$english , $date2);
//        $datejnormall = 21;  /*دستی وارد کردن روز*/
$weeknum = intval($datejnormall+$dayofweek)/7;
$weeknumMainez = $weeknum-1;

//echo $jDate::forge(strtotime("-$today days"))->format('l');


?>

        <!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>calendar mob</title>

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@400;500&display=swap" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">    <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
    <script src="//code.jquery.com/jquery-1.11.1.min.js"></script>



    <style>
        * {
            font-family: 'Baloo Bhaijaan 2', cursive;
            font-size: 100%;
        }
        *:before,
        *:after {
            box-sizing: border-box;
        }
        body {
            margin: 0.5em;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
            width: 100%;
            height: 100%;
            min-width: 800px;
        }
        @media (max-width: 800px) {
            table .time {
                display: none;
            }
        }
        summary {
            padding-bottom: 0.25em;
            font-size: 1.5em;
            font-weight: 100;
            text-align: right;
        }
        tr {
            position: relative;
        }
        th {
            text-align: right;
            color: #999;
            font-weight: normal;
            font-size: 0.85em;
        }
        td {
            width: 14.285714286%;
        }
        .date {
            text-align: right;
            display: block;
            height: 0;
            font-size: 0.8em;
            padding: 0.25em;
            padding-bottom: 73%;
            position: relative;
            border-bottom: 1px solid #dedbdb;
            margin-left: 0.25em;
            margin-right: 0.25em;
        }
        tr:first-child:not(.current-week) .date {
            border-top: 1px solid #dedbdb;
        }
        .date ul,
        .date li {
            margin: 0;
            padding: 0;
            list-style: none;
            color: #333;
        }
        .date ul {
            text-align: left;
            font-size: 0.9em;
            width: 100%;
            overflow: hidden;
            position: absolute;
            font-weight: normal;
        }
        .date li {
            color: #222;
            width: 100%;

            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            position: relative;
        }
        .date li:before {
            content: '\2022';
            color: inherit;
            display: inline-block;
            padding-right: 0.25em;
        }
        .time {
            float: right;
            text-align: right;
            color: #999;
        }
        .event {
            color: #333;
        }
        .previous-week .date {
            border: none;
        }
        .current-week {
            border-top: 4px solid #fed6d7;
        }
        .current-day {
            background: #fed6d7;
            border-top: 4px solid #cb6c6b;
        }
        .current-day .date {
            font-weight: bold;
            color: #cb6c6b;
        }
        .weekend {
            background-clop: padding-box;
            background: #f5f5f5;
        }
        .date .different-calendar {
            color: #00c800;
        }




        .active {
            color: black !important;

        }
        .necessary{
            color: red !important;

        }
        .late{
            color: gray !important;

        }
        .disabled{

        }
        .deleted{

        }
        .done{
            color: #00ff00 !important;

        }

    </style>
</head>
<body>

<table>
    <summary>{{$date2}}</summary>
    <thead>
    <tr>
        <th scope="col"  style="text-align: center">شنبه</th>
        <th scope="col"  style="text-align: center">یکشنبه</th>
        <th scope="col"  style="text-align: center">دوشنبه</th>
        <th scope="col" style="text-align: center">سه شنبه</th>
        <th scope="col" style="text-align: center">چهارشنبه</th>
        <th scope="col" style="text-align: center">پنج شنبه</th>
        <th scope="col" style="text-align: center">جمعه</th>


    </tr>
    </thead>


    @php($counter = 1)
    @php($counterTableBuilder = 1)
    @php($aPlas = 0)
    @php($thisweek=0)
    @for($a = 1; $counterTableBuilder < 32; $a++)
        <?php

        if ($weeknum <= $a AND $aPlas == 0){
            $aPlas = 1;
            echo "<tr class='current-week'>";
        }
        else if ($weeknum-1 <= $a AND $aPlas == 0){
            echo "<tr class='previous-week'>";
        }
        else {
            echo "<tr>";
        }

        ?>
        <?php

        ?>

        @for($i =1; $i < 8; $i++)
            <?php
            //
            if ($counter == 1){
                $today = substr(str_replace($persian,$english , $jDate::forge(time())->format('date')),-2);

                if ($jDate::forge(strtotime("-$today days"))->format('l') == 'چهارشنبه'){
                    for ($lastMonthDays =0; $lastMonthDays < 5; $lastMonthDays++){
                        echo '<td><span class="date"><ul></ul></span></td>';
                        $counter++;
                        $i++;
                    }
                }
            }

            $classli='';
            if ($counterTableBuilder == $datejnormall){
                $classli = "different-calendar";
                echo '<td class="current-day">';
            }

            else if ($counter%7 == 0){
                echo '<td class="weekend">';

            }
            else{
                echo '<td>';
            }

            //                str_replace($persian,$english , $jDate::forge($task->d1)->format('date'))
            ?>

            <span class="date"><?php if($counterTableBuilder < 32){echo $counterTableBuilder;} ?>
                      <ul>

                          @foreach($tasks as $task)
                              {{--                              @if(str_replace($persian,$english , $jDate::forge($task->d3)->format('date') == 2)--}}
                              {{--                              @endif--}}
                              @if($task->show_just_end == 1)
                                  @if(substr(str_replace($persian,$english , $jDate::forge($task->d3)->format('date')),-2) == $counterTableBuilder)
                                      <li class="{{$classli}} {{$task->status}}" style="font-weight: 600">
                                      <span class="event {{$task->status}}">

           <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#id{{$task->id}}">
{{$task->title}}
</button>

                                          <!-- Modal -->
<div class="modal fade" id="id{{$task->id}}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Modal title2222</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                {!! $task->task !!}

            </div>

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

                                      </span>
                                      <span class="time" {{$task->status}}>
                                          @foreach($Admins as $Admin)
                                              @if($task->admin_id == $Admin->id)
                                                  {{$Admin->name}}
                                              @endif
                                          @endforeach
                                      </span>
                                  </li>
                                  @endif
                              @else
                                  {{--                                  {{substr(str_replace($persian,$english , $jDate::forge($task->d1)->format('date')),-2)}}---}}
                                  {{--                                  {{substr(str_replace($persian,$english , $jDate::forge($task->d3)->format('date')),-2)}}<br>--}}
                                  @if(substr(str_replace($persian,$english , $jDate::forge($task->d1)->format('date')),-2) <= $counterTableBuilder)
                                      @if(substr(str_replace($persian,$english , $jDate::forge($task->d3)->format('date')),-2) >= $counterTableBuilder)
                                          <li class="{{$classli}} {{$task->status}}" style="font-weight: 600">
                                      <span class="event {{$task->status}}">
           <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#id{{$task->id}}">
{{$task->title}}
</button>

                                          <!-- Modal -->
<div class="modal fade" id="id{{$task->id}}" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Modal title2222</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                {!! $task->task !!}

            </div>
            <div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-expanded="false">
    Dropdown button
  </button>
  <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="dropdownMenuButton2">
    <li><a class="dropdown-item active" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
    <li><a class="dropdown-item" href="#">Something else here</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><a class="dropdown-item" href="#">Separated link</a></li>
  </ul>
</div>
        </div>
    </div>
</div>

                                      </span>
                                      <span class="time" {{$task->status}}>
                                          @foreach($Admins as $Admin)
                                              @if($task->admin_id == $Admin->id)
                                                  {{$Admin->name}}
                                              @endif
                                          @endforeach
                                      </span>
                                      </li>
                                      @endif
                                  @endif
                              @endif


                          @endforeach

                      </ul>
                  </span>


            </td>
            @php($counter++)
            @php($counterTableBuilder++)
            @endfor
            </tr>
        @endfor

</table>

<!-- Button trigger modal -->

<!-- Button trigger modal -->

{{--<table class="table table-striped table-bordered">--}}
{{--    <thead>--}}
{{--    <tr>--}}


{{--    </tr>--}}
{{--    </thead>--}}
{{--    <tbody>--}}
{{--    @php($counter = 1)--}}
{{--    @for($a = 1; $a < 6; $a++)--}}
{{--        <tr>--}}
{{--            @for($i =1; $i < 8; $i++)--}}
{{--                <td>{{$counter++}}</td>--}}
{{--            @endfor--}}
{{--        </tr>--}}
{{--    @endfor--}}

{{--    </tbody>--}}
{{--</table>--}}

</div>


<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>


