@extends('coaching.layout.master')

@section('content')

<div class="app-content  my-3 my-md-5">
				<div class="side-app">
          <!-- MAIN BODY CONTENT -->
          <div class="card">
            <div class="banner">
              <div class="owl-carousel owl-theme coachingBanner">
                @if(count($banners)>0)
                  @foreach($banners as $banner)
                    <div class="item">
                      <img src="{{asset('storage/coaching_banner/'.$banner->banner)}}" alt="">
                    </div>
                  @endforeach
                @else
                  <div class="item">
                    <img src="{{asset('admin/images/banner-img.jpg')}}" alt="">
                  </div>
                @endif 
              </div>
              <button class="btn edit-btn bannerUploadModalShow"><i class="fa fa-pencil"></i> Edit</button>
            </div>
            <div class="banner-content">
              <div class="banner-content-top">
                <div class="inst-logo coaching_logo">
                  @if($coachingDetails->logo)
                  <span class="avatar cover-image avatar-xxl brround" style="background-image: url('{{asset('storage/coaching_logo/'.$coachingDetails->logo)}}')"></span>
                  @else
                  <span class="avatar cover-image avatar-xxl brround" style="background-image: url('{{asset('admin/images/institute.jpg')}}')"></span>
                  @endif
                  <label for="profile_pic" class="edit-photo-overlay">
                    <i class="fa fa-camera"></i>
                    <span>Edit Photo</span>
                  </label>
                </div>
                <div class="inst-info">
                  <div class="inst-title-info">
                    <h2>{{$coachingDetails->coaching_name}}
                      <span class="varify">
                        @if($coachingDetails->coaching_verification == 0)
                        <svg xmlns="http://www.w3.org/2000/svg" width="17.446" height="22" viewBox="0 0 17.446 22">
                          <path
                            d="M205.293,106.783c0-.475.019-.956,0-1.432v-.016a.552.552,0,0,0-.395-.518l-2.791-.967q-2.2-.762-4.4-1.526c-.325-.113-.647-.242-.978-.338a.619.619,0,0,0-.419.038c-.167.059-.336.116-.5.175l-4.212,1.459-3.293,1.142c-.019.005-.035.013-.054.019a.555.555,0,0,0-.395.518v4.978c0,1.048,0,2.1,0,3.143a8,8,0,0,0,.454,2.622,11.8,11.8,0,0,0,3.011,4.51,16.664,16.664,0,0,0,4.427,3.062q.278.129.556.25l.035.016h0c.027.011.056.021.083.03a.642.642,0,0,0,.414-.043.009.009,0,0,0,.005,0,16.614,16.614,0,0,0,4.491-2.858,12.391,12.391,0,0,0,3.237-4.3,8.7,8.7,0,0,0,.688-2.673c.043-.5.027-1,.027-1.5v-5.792Zm-3.949,3.3-.669.669-2.9,2.9-1.832,1.832a.816.816,0,0,1-1.139,0l-.371-.371-2.6-2.6a.805.805,0,1,1,1.139-1.139l.371.373c.674.674,1.348,1.354,2.023,2.028l.1-.1,2.9-2.9,1.832-1.832a.807.807,0,0,1,1.142,1.142Z"
                            transform="translate(-187.855 -101.963)" fill="" />
                        </svg>
                        @else
                          <img src="{{asset('admin/images/verified.svg')}}" alt="">
                        @endif
                      </span>
                    </h2>
                    <p class="rating">
                      <i class="fa fa-star"></i>
                      <strong>{{number_format($coachingDetails->rating, 1)}}</strong>
                      <span>({{$coachingDetails->total_rating_count}} Ratings)</span>
                    </p>
                    <div class="flw-group">
                      @if($coachingDetails->total_followers > 1000)
                        @php
                          $total_followers = ($coachingDetails->total_followers / 1000).' K';
                        @endphp
                      @else 
                        @php
                          $total_followers = $coachingDetails->total_followers;
                        @endphp
                      @endif
                      @if($coachingDetails->total_following > 1000)
                        @php
                          $total_following = ($coachingDetails->total_following / 1000).' K';
                        @endphp
                      @else 
                        @php
                          $total_following = $coachingDetails->total_following;
                        @endphp
                      @endif
                      <span>{{$total_followers}} Followers</span>
                      <span>{{$total_following}} Following</span>
                    </div>
                  </div>
                  <div class="inst-btn-group">
                    <button class="btn edit-btn btn-streach-md disable-btn">Follow</button>
                    <button class="btn btn-primary btn-streach-md fs-13 disable-btn">Buy Pass</button>
                  </div>

                </div>
              </div>
              <div class="banner-content-bottom">
                <div class="info-detail">
                  <ul>
                    <li>
                      <p>
                        <img src="{{asset('admin/images/total-students.svg')}}" alt="">
                        @php
                          $total_students = 0;
                        @endphp
                        @if(isset($coachingDetails->coachingEngagement))
                          @php
                            $total_students = count($coachingDetails->coachingEngagement->groupBy('student_id'));
                          @endphp
                        @endif
                        @if($total_students > 1000)
                          {{(($total_students/1000) - 1)}} K+
                        @elseif($total_students > 1)
                          {{($total_students - 1)}}+
                        @else
                          {{$total_students}}+
                        @endif
                      </p>
                      <span>Total Students</span>
                    </li>
                    <li>
                      <p>
                        <img src="{{asset('admin/images/test-series.svg')}}" alt="">
                        @php
                          $total_test_series = 0;
                        @endphp
                        @if(isset($coachingDetails->coachingTestSeries))
                          @php
                            $total_test_series = count($coachingDetails->coachingTestSeries->where('status', 5));
                          @endphp
                        @endif
                        @if($total_test_series > 1000)
                          {{(($total_test_series/1000) - 1)}} K+
                        @elseif($total_test_series > 1)
                          {{($total_test_series - 1)}}+
                        @else
                          {{$total_test_series}}+
                        @endif
                      </p>
                      <span>Test Series</span>
                    </li>
                    <li>
                      <p>
                        <img src="{{asset('admin/images/practice-chapter.svg')}}" alt="">
                        @php
                          $total_chapters = 0;
                        @endphp
                        @if(isset($coachingDetails->coachingPracticeSet))
                          @if(count($coachingDetails->coachingPracticeSet->where('status', 5)) > 0)
                            @foreach($coachingDetails->coachingPracticeSet->where('status', 5) as $sets)
                              @php
                                  $total_chapters += count($sets->chapters);
                              @endphp
                            @endforeach
                          @endif
                        @endif
                        @if($total_chapters > 1000)
                          {{(($total_chapters/1000) - 1)}} K+
                        @elseif($total_chapters > 1)
                          {{($total_chapters - 1)}}+
                        @else
                          {{$total_chapters}}+
                        @endif
                      </p>
                      <span>Practice Chapter</span>
                    </li>
                    <li>
                      <p>
                        <img src="{{asset('admin/images/quizz.svg')}}" alt="">
                        @php
                          $total_quiz = 0;
                        @endphp
                        @if(isset($coachingDetails->coachingQuiz))
                          @php
                            $total_quiz = count($coachingDetails->coachingQuiz->where('status', 5));
                          @endphp
                        @endif
                        @if($total_quiz > 1000)
                          {{(($total_quiz/1000) - 1)}} K+
                        @elseif($total_quiz > 1)
                          {{($total_quiz - 1)}}+
                        @else
                          {{$total_quiz}}+
                        @endif
                      </p>
                      <span>Quizzes</span>
                    </li>
                  </ul>
                </div>
                <div class="social-links-items">
                  <p>Share with your Friends</p>
                  <ul>
                    <li>
                      <a href="javascript:void(0)">
                        <img src="{{asset('admin/images/whatsapp.svg')}}" alt="">
                      </a>
                    </li>
                    <li>
                      <a href="javascript:void(0)">
                        <img src="{{asset('admin/images/telegram.svg')}}" alt="">
                      </a>
                    </li>
                    <li>
                      <a href="javascript:void(0)">
                        <img src="{{asset('admin/images/facebook.svg')}}" alt="">
                      </a>
                    </li>
                    <li>
                      <a href="javascript:void(0)">
                        <img src="{{asset('admin/images/gmail.svg')}}" alt="">
                      </a>
                    </li>
                    <li>
                      <a href="javascript:void(0)">
                        <img src="{{asset('admin/images/social-logo1.svg')}}" alt="">
                      </a>
                    </li>
                  </ul>
                </div>
              </div>

              <div class="banner-footer">
                <ul class="tab-items">
                  <li class="main_tab active main_home_tab" data-id="1"><a href="javascript:void(0)">Home</a></li>
                  <li class="main_tab" data-id="2"><a href="javascript:void(0)">Test Series</a></li>
                  <li class="main_tab" data-id="3"><a href="javascript:void(0)">Practice Sets</a></li>
                  <li class="main_tab" data-id="4"><a href="javascript:void(0)">Quizzes</a></li>
                  <li class="main_tab about_tab" data-id="5"><a href="javascript:void(0)">About</a></li>
                </ul>
                <button class="btn btn-primary btn-streach-md sectionAdd" data-id="1" data-total-section="{{count($sections)}}">Add New Section</button>
              </div>

            </div>
          </div>
          <!-- coaching body  -->
          <!-- Home  -->
          
            <div class="home-coaching">
              <div class="select-choices">
                <ul>
                  <li class="active home_tab" data-id="1"><a href="javascript:void(0)">Trending</a></li>
                  <li class="home_tab" data-id="2"><a href="javascript:void(0)">Highest Rated</a></li>
                  <li class="home_tab" data-id="3"><a href="javascript:void(0)">Most Attempted</a></li>
                </ul>
                <div class="filter-group">
                  <p>Filter By </p>
                  <select name="" id="filter_exam" class="form-control input-sm">
                    <option value="">Select All</option>
                    @if($coachingExamTypes)
                      @foreach($coachingExamTypes as $examtypes)
                        <option value="{{$examtypes->exam_type_id}}">@if(isset($examtypes->examTypeName)){{$examtypes->examTypeName->exam_type}}@endif</option>
                      @endforeach
                    @endif
                  </select>
                </div>
              </div>
              <div class="owl-carousel owl-theme choices">
                  @if(isset($trendingPackages))
                    @foreach($trendingPackages as $series)
                    <div class="item">
                      <div class="preview-container">
                        <div class="preview-header">
                          <i class="fa fa-heart-o"></i>
                          <img src="{{asset('storage/test_package_image/'.$series->package_image)}}" alt="">
                        </div>
                        <div class="preview-body">
                          <div class="preview-body-top">
                            <h6>{{$series->package_name}}</h6>
                            <div class="preview-avatar">
                              @if($coachingDetails->logo)
                              <span class="avatar cover-image avatar-lg brround" style="background-image: url('{{asset('storage/coaching_logo/'.$coachingDetails->logo)}}')"></span>
                              @else
                              <span class="avatar cover-image avatar-lg brround" style="background-image: url('{{asset('admin/images/institute.jpg')}}')"></span>
                              @endif

                              <p class="star"><i class="fa fa-star"></i> @if($series->rating > 0){{number_format(($series->rating),1)}} @else{{'0.0'}} @endif</p>
                              <span class="rating">({{$series->rating_count}} Ratings)</span>
                            </div>
                          </div>
                          <div class="preview-body-content">
                            <p class="label-name">
                              <img src="{{asset('admin/images/institute.svg')}}" alt="">
                              <span>{{$coachingDetails->coaching_name}}</span>
                            </p>
                            <p class="fs-9 font-bold my-4">{{$series->exam_type}}</p>
                            <ul class="preview-list">
                              <li>No of Tests : {{$series->no_of_test}}</li>
                              @php $test_type_name = ''; @endphp
                              @if(isset($series->testByTestType))
                                @foreach($series->testByTestType as $test_type_key=>$test_types)
                                  @if(isset($test_types->testTypeByTest) && $test_type_key < 2)
                                    @php $test_type_name .= $test_types->count.' '.$test_types->testTypeByTest->test_type_name.' + '; @endphp
                                  @endif
                                @endforeach
                                @if(count($series->testByTestType)>0)<li>{{trim($test_type_name, ' + ')}}</li>@else<li>N/A</li>@endif
                              @endif
                              

                              @php $test_language = ''; @endphp
                              @if(isset($series->PackageLanguage))
                                @foreach($series->PackageLanguage as $lang)
                                  @if($lang->language_id == 1)
                                    @php $test_language .= 'English | '; @endphp
                                  @else
                                    @php $test_language .= 'Hindi | '; @endphp
                                  @endif
                                @endforeach
                              @endif
                              <li>{{trim($test_language, ' | ')}}</li>
                              <li>Validity {{($series->validity_type ==0) ? $series->validity : date('d-m-Y', strtotime($series->expire_date))}}</li>
                            </ul>
                            @if($series->sale_type < 4)
                              @if($series->discount_price > 0)
                                @php
                                  $show_btn = ($series->share_unlock_discount_price ? 'Share & Unlock' : 'Buy Now') ;
                                  $show_price = $series->discount_price." <strike>".$series->product_price."</strike>" ;
                                @endphp
                              @else
                                @php
                                  $show_btn = 'Buy Now' ;
                                  $show_price = $series->product_price;
                                @endphp
                              @endif
                            @else
                              @php
                                $show_btn = 'Unlock Free' ;
                                $show_price = 0 ;
                              @endphp
                            @endif
                            <p class="preview-price"><i class="fa fa-rupee"></i> {!!$show_price!!} /-</p>
                            <button class="btn btn-preview-outline disable-btn">{!!$show_btn!!}</button>
                          </div>
                        </div>
                      </div>
                    </div>
                    @endforeach
                    @else
                     {{'No Test Series found...'}}
                  @endif
                
              </div>
            </div>
            <!-- Home End -->
          <div class="main_tab_area">
            <!-- Practice Sets -->
            <div class="practice-coaching dragSectionContainer" id="sortable">
              @if(count($sections)>0)
                @foreach($sections as $section)
                  <div class="dragSection">

                    <div class="select-choices">
                      <h2>
                        {{$section->section_name}}
                        <span class="action">
                         <a href="javascript:void(0)" class="update_section"  data-id="{{base64_encode($section->id)}}"><img src="{{asset('admin/images/pencil.svg')}}" alt=""></a>
                         <a href="javascript:void(0)" class="remove_section"  data-id="{{base64_encode($section->id)}}"><img src="{{asset('admin/images/recycle-bin.svg')}}" alt=""></a>
                        </span>
                      </h2>
                      <div class="filter-group">
                        <button class="btn btn-primary btn-streach-md sectionAddNewProduct" data-section-id="{{$section->id}}" data-section-product-type="{{$section->product_type}}" data-total-product="{{count($section->packages)}}">Add New Product</button>
                      </div>
                    </div>
                    <div  class="dragItemContainer">
                      @if(count($section->packages)>0)
                        @foreach($section->packages as $key=>$package)
                          @php $color = ''; @endphp
                          @if($package->product_type != 1)
                            @if(fmod($key,4) == 0)
                              @php $color = 'orange'; @endphp
                            @elseif(fmod($key,4) == 1)
                              @php $color = 'light-blue'; @endphp
                            @elseif(fmod($key,4) == 2)
                              @php $color = 'dark-blue'; @endphp
                            @else
                              @php $color = 'green'; @endphp
                            @endif
                          @endif
                          <div class="drag-item {{$color}}" id="item-{{$package->product_main_id}}">
                            <span class="drag-section-icon"><img src="{{asset('admin/images/drag-v.svg')}}" alt=""></span>
                            <span class="delete-icon remove_product" data-id="{{base64_encode($package->product_id)}}" data-section-id="{{base64_encode($package->section_id)}}"><img src="{{asset('admin/images/recycle-bin.svg')}}" alt=""></span>
                              @if($package->product_type == 1)
                                <div class="preview-container ml-0 mb-5">
                                  <div class="preview-header">
                                    <i class="fa fa-heart-o"></i>
                                    <img src="{{asset('storage/test_package_image/'.$package->package_image)}}" alt="">
                                  </div>
                                  <div class="preview-body">
                                    <div class="preview-body-top">
                                      <h6>{{$package->package_name}}</h6>
                                      <div class="preview-avatar">
                                        @if($coachingDetails->logo)
                                        <span class="avatar cover-image avatar-lg brround" style="background-image: url('{{asset('storage/coaching_logo/'.$coachingDetails->logo)}}')"></span>
                                        @else
                                        <span class="avatar cover-image avatar-lg brround" style="background-image: url('{{asset('admin/images/institute.jpg')}}')"></span>
                                        @endif
                                        <p class="star"><i class="fa fa-star"></i> @if($package->rating > 0){{number_format(($package->rating),1)}} @else{{'0.0'}} @endif</p>
                                        <span class="rating">({{$package->rating_count}} Ratings)</span>
                                      </div>
                                    </div>
                                    <div class="preview-body-content">
                                      <p class="label-name">
                                        <img src="{{asset('admin/images/map-location-line.svg')}}" alt="">
                                        <span>{{$coachingDetails->coaching_name}}</span>
                                      </p>
                                      <p class="fs-9 font-bold my-4">{{$package->exam_type}}</p>
                                      <ul class="preview-list">
                                        <li>No of Tests : {{$package->no_of_test}}</li>
                                        @php $test_type_name = '';  @endphp
                                        @if(isset($package->testByTestType))
                                          @foreach($package->testByTestType as $test_type_key=>$test_types)
                                            @if(isset($test_types->testTypeByTest) && $test_type_key < 2)
                                              @php $test_type_name .= $test_types->count.' '.$test_types->testTypeByTest->test_type_name.' + '; @endphp
                                            @endif
                                          @endforeach
                                          @if(count($package->testByTestType)>0)<li>{{trim($test_type_name, ' + ')}}</li>@else<li>N/A</li>@endif
                                        @endif
                                        @php $test_language = ''; $languages = explode(' & ',$package->languages);  @endphp
                                        @if(count($languages)>0)
                                          @foreach($languages as $lang)
                                            @if($lang == 1)
                                              @php $test_language .= 'English | '; @endphp
                                            @else
                                              @php $test_language .= 'Hindi | '; @endphp
                                            @endif
                                          @endforeach
                                        @endif
                                        <li>{{trim($test_language, ' | ')}}</li>
                                        <li>Validity {{($package->validity_type ==0) ? $package->validity : date('d-m-Y', strtotime($package->expire_date))}}</li>
                                      </ul>
                                      @if($package->sale_type < 4)
                                        @if($package->discount_price > 0)
                                          @php
                                            $show_btn = ($package->share_unlock_discount_price ? 'Share & Unlock' : 'Buy Now') ;
                                            $show_price = $package->discount_price." <strike>".$package->product_price."</strike>" ;
                                          @endphp
                                        @else
                                          @php
                                            $show_btn = 'Buy Now' ;
                                            $show_price = $package->product_price;
                                          @endphp
                                        @endif
                                      @else
                                        @php
                                          $show_btn = 'Unlock Free' ;
                                          $show_price = 0 ;
                                        @endphp
                                      @endif
                                      <p class="preview-price"><i class="fa fa-rupee"></i> {!!$show_price!!} /-</p>
                                      <button class="btn btn-preview-outline disable-btn">{!!$show_btn!!}</button>
                                    </div>
                                  </div>
                                </div>
                              @else 
                                <div class="preview-container ml-0 mb-5">
                                  <div class="preview-header">
                                    <div class="header-content">
                                      <h3>{{(($package->product_type == 2) ? $package->set_name : $package->quiz_name)}}</h3>
                                      <p>Attempted by {{$package->total_attempt}}</p>
                                    </div>
                                    <i class="fa fa-heart-o"></i>
                                    <img src="{{asset('admin/images/students.jpg')}}" alt="">
                                  </div>
                                  <div class="preview-body">
                                    <div class="preview-body-top">
                                      <h6>{{$coachingDetails->coaching_name}}</h6>
                                      <div class="preview-avatar">
                                        @if($coachingDetails->logo)
                                        <span class="avatar cover-image avatar-lg brround" style="background-image: url('{{asset('storage/coaching_logo/'.$coachingDetails->logo)}}')"></span>
                                        @else
                                        <span class="avatar cover-image avatar-lg brround" style="background-image: url('{{asset('admin/images/institute.jpg')}}')"></span>
                                        @endif
                                        <p class="star"><i class="fa fa-star"></i> @if($package->rating > 0){{number_format(($package->rating),1)}} @else{{'0.0'}} @endif</p>
                                        <span class="rating">({{$package->rating_count}} Ratings)</span>
                                      </div>
                                    </div>
                                    <div class="preview-body-content">
                                      <p class="label-name">
                                        <img src="{{asset('admin/images/map-location-line.svg')}}" alt="">
                                        <span>{{$coachingDetails->city.', '.$coachingDetails->name}}</span>
                                      </p>
                                      <p class="fs-9 font-bold my-4">{{$package->exam_type}}</p>
                                      @if($package->product_type == 2)
                                        <ul class="preview-list">
                                          <li>Total Chapters : @if(isset($package->chapters)){{count($package->chapters)}}@else{{0}}@endif</li>
                                          <li>Total Questions : @if(isset($package->questions)){{count($package->questions)}}@else{{0}}@endif</li>
                                          <li>{{(($package->language_id == 1) ? 'English' : 'Hindi')}}</li>
                                        </ul>
                                      @else
                                        <ul class="preview-list">
                                          <li>Questions : @if(isset($package->questions)){{count($package->questions)}}@else{{0}}@endif</li>
                                          <li>Time : {{$package->duration}}</li>
                                          <li>{{(($package->language_id == 1) ? 'English' : 'Hindi')}}</li>
                                        </ul>
                                      @endif
                                      <button class="btn btn-preview-outline disable-btn">{{(($package->product_type == 2) ? 'Start Practice' : 'Start Quiz')}}</button>
                                    </div>
                                    </div>
                                </div>
                              @endif
                            </div>
                        @endforeach
                      @else
                        No products found..
                      @endif
                    </div>
                    @if($section->total_packages >2)
                    <div class="view-more"><a href="javascript:void(0)" class="section_view_more" data-section-id="{{$section->id}}" data-offset="4" data-total="{{$section->total_packages}}">View More <i class="fa fa-angle-down"></i></a></div>
                    @endif
                  </div>
                @endforeach
              @else
                  No products found..
              @endif
            </div>
          </div>
          <!-- About End-->
          <!-- //Coaching body -->
          <!--// MAIN BODY CONTENT -->
        </div>
			</div>
@endsection
@section('scripts')
<script type="text/javascript" src="{{asset('js/coaching/my_coaching.js?v='.time())}}"></script>
<link href="{{asset('admin/plugins/drag-drop-upload/drag-drop-upload.css?v='.time())}}" rel="stylesheet" />
@endsection
