<?php
$pageNum = @$_GET['page'];
if ($pageNum == NULL || $pageNum =='0') {$pageNum = 1;   }
$resultsPerPage='50';
$limit1 = $pageNum * $resultsPerPage - $resultsPerPage;
$limit2 =  $resultsPerPage;
?>

<div class="row">
  <?php 
  $sub_perform = $this->uri->segment(4);
  switch($sub_perform){
    case 'all-course': 
    if(isset($_GET['cat']) && $_GET['cat']!=''){
      $cat=str_replace('-',' ',$_GET['cat']);
      $getall_flav=$this->db->query("select * from x_cou_courses,x_cou_datav,x_cou_prov where ( cou_version=dtv_id and pr_id=cou_api) cou_cat LIKE '$cat' order by cou_id desc limit $limit1, $limit2");
    }
    else if(isset($_GET['code']) && $_GET['code']!=''){
      $code=str_replace('-',' ',$_GET['code']);
      $getall_flav=$this->db->query("select * from x_cou_courses,x_cou_datav,x_cou_prov where ( cou_version=dtv_id and pr_id=cou_api) and cou_xls_code = '$code' order by cou_id desc limit $limit1, $limit2");
    }
    else if(isset($_GET['mer']) && $_GET['mer']!=''){
      $mer=str_replace('-',' ',$_GET['mer']);
      $getall_flav=$this->db->query("select * from x_cou_courses,x_cou_datav,x_cou_prov where ( cou_version=dtv_id and pr_id=cou_api) and pr_id = '$mer' order by cou_id desc limit $limit1, $limit2");
    }
    else{
      $getall_flav=$this->db->query("select * from x_cou_courses,x_cou_datav,x_cou_prov where ( cou_version=dtv_id and cou_api=pr_id) order by cou_id desc limit $limit1, $limit2");
    }
      $theflav_data=$getall_flav->result_array();
      ?>
  <div class="col-sm-12">
    <div class="main-card mb-3 card">
        <div class="card-body"><h5 class="card-title">All Courses</h5>   
        <div class="pull-right" style="width: 130px;"><a href="<?=base_url('index.php/admin_action_custom/download_data?what=cou')?>" download><h5 class="card-title">Download Data</h5></a> </div>     
            <div class="table-responsive">
                <table class="mb-0 table">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>Course Name</th>
                        <th>Image</th>
                        <!-- <th><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>">Category Name</a></th> -->
                        <th><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>">Merchant Name</a></th>
                        <th>Price</th>
                        <th>Date</th>
                        <th>Modified On</th>
                        <th>Tags</th>
                        <th>Source<br><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>">Code</a></th>
                        <th>Status</th>
                        <th style="width: 30px;">Action </th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($theflav_data as $flav_details){ 
                      if($flav_details['cou_feat']==0){
                        $fea="Featured";
                      }
                      else {
                        $fea="Non-Featured";
                      }
                      ?>
                    <tr>
                        <th scope="row"><?=$flav_details['cou_id']?></th>                                
                        <td style="max-width:290px;">
                          <?=$flav_details['cou_name']?><br/>
                          <small>Keywords: (<?=$flav_details['cou_key']?>)</small>
                        </td>
                        <td><img src="<?=$flav_details['cou_img']?>" style="height: 40px;"></td>
                        <!-- <td><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>?cat=<?=url_smart($flav_details['cou_cat'])?>"><?=$flav_details['cou_cat']?></td> -->
                        <td><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>?mer=<?=url_smart($flav_details['pr_id'])?>">
                          <!-- <?=@$flav_details['cou_merchant_name']?> -->
                          <img src="<?=base_url('assets/avator/upload/')?><?=$flav_details['pr_image']?>" style='height: 16px;width: auto;' >
                        </a>
                        </td>
                        <td><?=@$flav_details['cou_price']?></td>
                        <td><?=date("d-m-Y",strtotime($flav_details['cou_date']));?></td>
                        <td><?=date("d-m-Y",strtotime($flav_details['cou_edit_date']));?></td>
                        <td class="text-left">
                          <?=read_me_user('cou_feat',$flav_details['cou_feat'])?></span><br/>
                          <small>
                            <?php if($flav_details['cou_cat_1'] =='1'){echo "Added to category 1 <br/>"; } ?>
                            <?php if($flav_details['cou_cat_2'] =='1'){echo "Added to category 2 <br/>"; } ?>
                            <?php if($flav_details['cou_cat_3'] =='1'){echo "Added to category 3 <br/>";} ?>
                            <?php if($flav_details['cou_cat_4'] =='1'){echo "Added to category 4 <br/>";} ?>
                            <?php if($flav_details['cou_cat_5'] =='1'){echo "Added to category 5 <br/>";} ?>
                            <?php if($flav_details['cou_cat_6'] =='1'){echo "Added to category 6 <br/>";} ?>
                          </small>
                        </td>

                        <td><?=@$flav_details['cou_source']?><br><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>?code=<?=$flav_details['cou_xls_code']?>"><?=@$flav_details['cou_xls_code']?></a> 
                        <br><small><a href="<?=base_url('index.php/admin/perform/custom/all-course')?>?ver=<?=url_smart($flav_details['cou_version'])?>"> Version: <?=$flav_details['dtv_name']?> </a></small>
                        </td>
                        <td class="text-left">
                          <?=read_me_user('cou_status',$flav_details['cou_status'])?>
                        </td>
                        <td> 
                          <div class="mr-2 btn-group">
                          <button class="btn btn-outline-secondary">View</button>
                          <button type="button" aria-haspopup="true" aria-expanded="false" data-toggle="dropdown" class="dropdown-toggle-split dropdown-toggle btn btn-outline-secondary"><span class="sr-only">Toggle Dropdown</span>
                          </button>
                        <div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu">
                              <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=<?=$fea?>"><button type="button" tabindex="0" class="dropdown-item"><?=$fea?></button></a>
                              <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=enable_cou"><button type="button" tabindex="0" class="dropdown-item">Enable</button></a>
                              <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cou"><button type="button" tabindex="0" class="dropdown-item">Disable</button></a>
                              <div tabindex="-1" class="dropdown-divider"></div>
                              <a href="<?=base_url('index.php/admin/perform/custom/edit-course?couID=')?><?=$flav_details['cou_id']?>"><button type="button" tabindex="0" class="dropdown-item">Edit Course</button></a>
                              <a href="<?=base_url('course/')?><?=$flav_details['cou_id']?>/<?=url_smart($flav_details['cou_name'])?>" target="_blank"><button type="button" tabindex="0" class="dropdown-item">View Course</button></a>                  
                              <a onclick="return confirm('are you sure you want to delete this?');" href="<?=base_url('index.php/admin_action_custom/delete')?>?id=<?=$flav_details['cou_id']?>&what=course" >
                                <button type="button" tabindex="0" class="dropdown-item">Delete</button></a>



                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cat1"><button type="button" tabindex="0" class="dropdown-item">Add to category 1</button></a>
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cat2"><button type="button" tabindex="0" class="dropdown-item">Add to category 2</button></a>
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cat3"><button type="button" tabindex="0" class="dropdown-item">Add to category 3</button></a>
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cat4"><button type="button" tabindex="0" class="dropdown-item">Add to category 4</button></a>
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cat5"><button type="button" tabindex="0" class="dropdown-item">Add to category 5</button></a>
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['cou_id']?>&what=disable_cat6"><button type="button" tabindex="0" class="dropdown-item">Add to category 6</button></a>
                                

                          </div>
                      </div>
                        </td>
                    </tr>
                      <?php }//foreach ?>
                    </tbody>
                </table>
            </div>
            <nav class="mt-4" aria-label="Page navigation example">
                <ul class="pagination">
                    <li class="page-item"><a href="javascript:void(0);" class="page-link" aria-label="Previous"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></a></li>
                    <?php
                    $pagesare=$pageNum;
                    for ($x = $pageNum-10; $x <= $pageNum+10; $x++) {
                    $addclass='';if($pageNum == $x ){$addclass='bold';}if($x > 0){
                    ?>
                    <li onclick="paging(<?=$x?>)"  class="page-item <?=$addclass?>"><a href="#" class="page-link"><?=$x?></a></li>
                    <?php } } ?>
                    <li class="page-item"><a href="javascript:void(0);" class="page-link" aria-label="Next"><span aria-hidden="true">»</span><span class="sr-only">Next</span></a></li>
                </ul>
            </nav>
        </div>
    </div>
  </div>       
    <?php
    break;
    case 'add-course':
    $redirect_crs=base_url('admin/perform/custom/add-course');
    ?>
      <div class="main-card mb-3 card" style="width:800px;">
      <div class="card-header">Upload Courses from XSL</div>
      <div class="card-body">
      <div class="row">
        <div class="col-sm-6">
          <img src="<?=base_url('assets/avator/logo.png')?>" style='width:150px;' class='mb-3'>
        </div>
      </div>      
      <form method="post" action="<?=base_url('index.php/admin_action_custom/update_courses');?>" enctype="multipart/form-data" >        
        <div class="row my-2">
          
          <div class="col-12">
            <span class="bg-info px-3 py-1 text-white">
              <i class="fa fa-angle-down mr-2"> </i><a href="<?=base_url('assets/Courslyst_Client_Onboarding_DataSheet.csv')?>" download class='text-white' > Download the template </a>
            </span>
          </div>
          <div class="col-12">
            <hr/>
          </div>
          <div class="col-sm-6">
            Course Status: 
            <select name="cou_status" class="form-control">
                <option value="1">Active</option>
                <option value="0">In-Active</option>
            </select>
          </div>

          <div class="col-sm-6">
            Select Provider
            <?php 
            $get_sliders=$this->db->query("select * from x_cou_prov order by pr_id desc limit 20");
            $allsliedsrs=$get_sliders->result_array();
            ?>
            <select name="cou_prov" class="form-control">
            <?php 
            foreach($allsliedsrs as $thede_arfsthas){ ?>
              <option value="<?=$thede_arfsthas['pr_id']?>"><?=$thede_arfsthas['pr_name']?></option>
            <?php } ?>
            </select>
          </div>


           <div class="col-sm-6">
            Select Data Version
            <?php 
            $get_sliders=$this->db->query("select * from x_cou_datav order by dtv_did desc limit 10");
            $allsliedsrs=$get_sliders->result_array();
            ?>
            <select name="cou_version" class="form-control">
            <?php 
            foreach($allsliedsrs as $thede_arfsthas){ ?>
              <option value="<?=$thede_arfsthas['dtv_id']?>"><?=$thede_arfsthas['dtv_name']?> - <?=$thede_arfsthas['dtv_did']?></option>
            <?php } ?>
            </select>
          </div>
          <div class="col-sm-6">
            <div class="col-sm-6">Upload xsls file here: <input type="file" name="file_name"><br/></div>
          </div>
          <div class="col-12">
            <hr/>
          </div>
        </div>

        <button class="btn mt-2 btn-warning px-3 pull-right py-2">Update Courses</button>
      </form>
      </div>
      <div class="card-footer">Good luck!</div>
      </div>
      <?php 
      break;
      case 'edit-course': 
      $id=$_GET['couID'];
      $getslider_details=$this->db->query("select * from x_cou_courses where cou_id='$id' ");
      $theimage_details3=$getslider_details->row_array();
      $getaction='edit_course';
      $theidval=$_GET['couID'];
      ?>
      <div class="main-card mb-3 card" style="width:800px;">
      <div class="card-header">Edit Course</div>
      <div class="card-body">
      <a href="<?=base_url('index.php/admin/perform/custom/all-course')?>"><h5 class="card-title text-right">All Courses</h5></a>
      <div class="row">
        <div class="col-sm-6">
          <img src="<?=base_url('assets/avator/logo.png')?>" style='width:150px;' class='mb-3'>
        </div>
      </div>
      <h5 class="card-title">Refresh properly to see your new Image.</h5>
      Because of cache you may not see new Image updated instant so you <br/> need to use a private mode or clear your cache to see your updated Image.<br/>

      <p> Make sure you are adding horizontal image in the size of <b>1200px width Minimum</b> and hight as per your image.<br/> <b> Also please make sure all the images are of same height</b></p>
      <form method="post" action="<?=base_url('index.php/admin_action_custom/');?><?=$getaction?>" onsubmit="return uploadandform('<?=base_url('index.php/admin_action/')?><?=$getaction?>','post',this,'image_name','progress_value_sc','prog_valie_text','Show_Errors_987','loader_post_upload','1','uni_loader_prog_status');" enctype="multipart/form-data" >
        <input type="hidden" name="couID" value="<?=$theidval?>">
        <input type="hidden" name="what" value="course">
        <div class="row my-2">
          <div class="col-sm-6"><input type="text" name="cou_cat" placeholder="Category" class="form-control col-12" value="<?=@$theimage_details3['cou_cat']?>" ></div>
          <div class="col-sm-6"><input type="text" name="cou_price" placeholder="Price" class="form-control col-12" value="<?=@$theimage_details3['cou_price']?>"><br/></div>
        </div> 
        <div class="row my-2">
          <div class="col-sm-6"><textarea name="cou_key" class="form-control" placeholder="Keywords separated with ,"><?=@$theimage_details3['cou_key']?></textarea></div>
          <div class="col-sm-6"><input type="text" name="cou_video" placeholder="Video URL" class="form-control col-12" value="<?=@$theimage_details3['cou_video']?>"><br/></div>
          <div class="col-sm-6"><input type="text" name="cou_tags" placeholder="Tags" class="form-control col-12" value="<?=@$theimage_details3['cou_tags']?>"><br/></div>
          
        </div>
        <div class="row my-2">
          <div class="col-sm-6"><input type="file" name="file_name"></div>
          <div class="col-sm-6" style="max-height:300px;overflow:hidden;" ><?php if(@$theimage_details3['cou_img']!=''){?><img src="<?=@$theimage_details3['cou_img']?>" style='max-width: 99%;' ><?php }?></div>
        </div>
        <button class="btn mt-2 btn-warning btn-block py-2">Edit Course</button>
      </form>
      </div>
      <div class="card-footer">Good luck!</div>
      </div>
      <?php 
      break;
      case 'all-keywords': 
        if(isset($_GET['cuky']) && $_GET['cuky']!=''){
          $cookie_id=str_replace('-',' ',$_GET['cuky']);
          $getall_flav=$this->db->query("SELECT t1.*, t2.*, IF(user_id='0','Guest',t2.name) as UserName
              FROM x_cou_keywords t1
                LEFT JOIN site_mem t2 ON t1.user_id = t2.mid where cookie_id='$cookie_id' and keyword !='' order by key_id desc limit $limit1, $limit2");
        }
        else {
            $getall_flav=$this->db->query("SELECT t1.*, t2.*, IF(user_id='0','Guest',t2.name) as UserName
              FROM x_cou_keywords t1
                LEFT JOIN site_mem t2 ON t1.user_id = t2.mid where keyword !='' order by key_id desc limit $limit1, $limit2");
        }
        $theflav_data=$getall_flav->result_array();
      ?>
  <div class="col-sm-12">
    <div class="main-card mb-3 card">
        <div class="card-body"><h5 class="card-title">All Keywords</h5>   
        <div class="pull-right" style="width: 130px;"><a href="<?=base_url('index.php/admin_action_custom/download_data?what=key')?>" download><h5 class="card-title">Download Data</h5></a> </div>      
            <div class="table-responsive">
                <table class="mb-0 table">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th style="width:200px;">Keyword</th>
                        <th><a href="<?=base_url('index.php/admin/perform/custom/all-keywords')?>">Cookie ID</a></th>
                        <th>User Name</th>
                        <th>IP Address</th>
                        <th>Date</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($theflav_data as $flav_details){ 
                      
                      ?>
                    <tr>
                        <th scope="row"><?=$flav_details['key_id']?></th>                                
                        <td><?=$flav_details['keyword']?></td>
                        <td><a href="<?=base_url('index.php/admin/perform/custom/all-keywords')?>?cuky=<?=url_smart($flav_details['cookie_id'])?>"><?=@$flav_details['cookie_id']?></a></td>
                        <td><?=@$flav_details['UserName']?><br><?=@$flav_details['email']?><br><?=@$flav_details['contact']?><br><?=@$flav_details['address']?></td>
                        <td><?=@$flav_details['key_ip']?></td>
                        <td><?=date("d-m-Y",strtotime($flav_details['key_time']));?></td>
                    </tr>
                      <?php }//foreach ?>
                    </tbody>
                </table>
            </div>
            <nav class="mt-4" aria-label="Page navigation example">
                <ul class="pagination">
                    <li class="page-item"><a href="javascript:void(0);" class="page-link" aria-label="Previous"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></a></li>
                    <?php
                    $pagesare=$pageNum;
                    for ($x = $pageNum-10; $x <= $pageNum+10; $x++) {
                    $addclass='';if($pageNum == $x ){$addclass='bold';}if($x > 0){
                    ?>
                    <li onclick="paging(<?=$x?>)"  class="page-item <?=$addclass?>"><a href="#" class="page-link"><?=$x?></a></li>
                    <?php } } ?>
                    <li class="page-item"><a href="javascript:void(0);" class="page-link" aria-label="Next"><span aria-hidden="true">»</span><span class="sr-only">Next</span></a></li>
                </ul>
            </nav>
        </div>
    </div>
  </div>       
    <?php
    break;
    case 'add-prov':
      $what='add_prov';
      $theidval='';
    if(isset($_GET['edit']) && $_GET['edit'] !=''){
      $id=$_GET['edit'];
      $getslider_details=$this->db->query("select * from x_cou_prov where pr_id='$id' ");
      $theimage_details3=$getslider_details->row_array();
      $what='edit_prov';
      $theidval=$_GET['edit'];
    }
    ?>
    <div class="main-card mb-3 card">
                      <div class="card-header">Add / Remove Provider</div>
                        <div class="card-body">
                          <div class="row">
                            <div class="col-sm-6">
                              <img src="<?=base_url('assets/avator/logo.png')?>" style='width:150px;' class='mb-3'>
                            </div>
                          </div>
                          <h5 class="card-title">Refresh properly to see your new Image.</h5>

                          <form method="post" action="<?=base_url('index.php/admin_action/site_prov');?>" onsubmit="return uploadandform('<?=base_url('index.php/admin_action/site_prov')?>','post',this,'image_name','progress_value_sc','prog_valie_text','Show_Errors_987','loader_post_upload','1','uni_loader_prog_status');" enctype="multipart/form-data" >
                            <input type="hidden" name="what" value="<?=$what?>">
                            <input type="hidden" name="blogid" value="<?=$theidval?>">
                            <input type="hidden" name="blog_link2" value="<?=@$theimage_details3['pr_name']?>">
                            
                          <div class="row my-2">
                            <div class="col-sm-6"><input type="text" name="blog_link" placeholder="Name" class="form-control col-12" value="<?=@$theimage_details3['pr_name']?>" ></div>
                            <div class="col-sm-6"><input type="text" name="title" placeholder="Title" class="form-control col-12" value="<?=@$theimage_details3['pr_title']?>" ></div>
                          </div>
                          <div class="col-12 my-1 px-0">
                            <textarea class="form-control" placeholder="Short Description" name="scomment"><?=@$theimage_details3['pr_desc']?></textarea>
                          </div>
                          <div class="col-12 my-1 px-0">
                            <br><input type="file" name="file_name">
                          </div>
                          <div class="col-12 my-1 px-0">
                            <br>
                            <select name="pr_priority" class="form-control">
                              <option value="">--Select Priority--</option>
                              <?php for($i=1; $i<11; $i++){?>
                              <option value="<?=$i?>" <?php if($i==@$theimage_details3['pr_priority']) echo "selected";?>><?=$i?></option>
                            <?php }?>
                            </select>
                          </div>
                            <button class="btn mt-2 btn-warning btn-block py-2">Add / Edit Provider</button>
                          </form>
                        </div>
                      <div class="card-footer">Good luck!</div>
                    </div>

                    <?php
                    $get_sliders=$this->db->query("select * from x_cou_prov order by pr_id desc limit 10");
                    $allsliedsrs=$get_sliders->result_array();
                     ?>
                  <div class="col-sm-6">
                      <div class="main-card mb-3 card">
                          <div class="card-body"><h5 class="card-title">All Providers</h5>
                              <table class="mb-0 table">
                                  <thead>
                                  <tr>
                                      <th>#</th>
                                      <th>Image</th>
                                      <th>Name</th>
                                      <th>Description</th>
                                      <th>Priority</th>
                                      <th>Action</th>
                                  </tr>
                                  </thead>
                                  <tbody>
                                    <?php 
                                    foreach($allsliedsrs as $slider2){ ?>
                                  <tr>
                                      <th scope="row"><?=$slider2['pr_id']?></th>
                                      <td><img src="<?=base_url('assets/avator/upload/')?><?=$slider2['pr_image']?>" style='height:40px;'></td>
                                      <td><b><?=$slider2['pr_name']?></b></td>
                                      <td><?=trim_text(strip_tags($slider2['pr_desc']),'90')?></td>
                                      <td><?=$slider2['pr_priority']?></td>
                                      <td style="min-width: 120px;">
                                      <a onclick="return confirm('Are you sure you want to delete this?');" href="<?=base_url('index.php/admin_action/delete')?>?id=<?=$slider2['pr_id']?>&what=provid" >
                                        <button class="mr-2 btn-icon btn-icon-only btn btn-outline-danger"><i class="pe-7s-trash btn-icon-wrapper"> </i></button></a>
                                        <a href="<?=base_url('index.php/admin/perform/custom/add-prov')?>?edit=<?=$slider2['pr_id']?>"><button class="mr-2 btn-icon btn-icon-only btn btn-outline-warning"><i class="pe-7s-pen btn-icon-pen"> </i></button></a>
                                      </td>
                                  </tr>
                                <?php } ?>
                                  </tbody>
                              </table>

                          </div>
                      </div>
                  </div>
    <?php 
    break;

    case 'all-versi':
      $what='add_versi';
      $theidval='';
    if(isset($_GET['edit']) && $_GET['edit'] !=''){
      $id=$_GET['edit'];
      $getslider_details=$this->db->query("select * from x_cou_prov where pr_id='$id' ");
      $theimage_details3=$getslider_details->row_array();
      $what='edit_prov';
      $theidval=$_GET['edit'];
    }
    ?>
    <div class="main-card mb-3 card">
                      <div class="card-header">Add / Remove Blog</div>
                        <div class="card-body">
                          <div class="row">
                            <div class="col-sm-6">
                              <img src="<?=base_url('assets/avator/logo.png')?>" style='width:150px;' class='mb-3'>
                            </div>
                          </div>
                          <h5 class="card-title">Refresh properly to see your new Image.</h5>

                          <form method="post" action="<?=base_url('index.php/admin_action/add_versi');?>" onsubmit="return uploadandform('<?=base_url('index.php/admin_action/add_versi')?>','post',this,'image_name','progress_value_sc','prog_valie_text','Show_Errors_987','loader_post_upload','1','uni_loader_prog_status');" enctype="multipart/form-data" >
                            <input type="hidden" name="what" value="<?=$what?>">
                            <input type="hidden" name="blogid" value="<?=$theidval?>">
                            
                          <div class="row my-2">
                            <div class="col-sm-6"><input type="text" name="blog_link" placeholder="Name" class="form-control col-12" value="<?=@$theimage_details3['pr_name']?>" ></div>
                            <div class="col-sm-6"><input type="text" name="title" placeholder="ID" class="form-control col-12" value="<?=@$theimage_details3['pr_title']?>" ></div>
                          </div>
                          <div class="col-12 my-1 px-0">
                            <textarea class="form-control" placeholder="Short Description" name="scomment"><?=@$theimage_details3['pr_desc']?></textarea>
                          </div>
                          
                            <button class="btn mt-2 btn-warning btn-block py-2">Add / Edit</button>
                          </form>
                        </div>
                      <div class="card-footer">Good luck!</div>
                    </div>

                    <?php
                    $get_sliders=$this->db->query("select * from x_cou_datav order by dtv_did desc limit 10");
                    $allsliedsrs=$get_sliders->result_array();
                     ?>
                  <div class="col-sm-6">
                      <div class="main-card mb-3 card">
                          <div class="card-body"><h5 class="card-title">All Versions</h5>
                              <table class="mb-0 table">
                                  <thead>
                                  <tr>
                                      <th>#</th>
                                      <th>Version</th>
                                      <th>Name</th>
                                      <th>Status</th>
                                      <th>Description</th>
                                      <th>Action</th>
                                  </tr>
                                  </thead>
                                  <tbody>
                                    <?php 
                                    foreach($allsliedsrs as $slider2){ ?>
                                  <tr>
                                      <th scope="row"><?=$slider2['dtv_id']?></th>
                                      <td>
                                        <?=$slider2['dtv_did']?>
                                      </td>
                                      <td><b><?=$slider2['dtv_name']?></b></td>
                                      <td><b><?=read_me_user('cou_status',$slider2['dtv_status'])?></b></td>
                                      <td><?=trim_text(strip_tags($slider2['dtv_desc']),'90')?></td>
                                      <td style="min-width: 120px;">
                                      
                                                <div class="mr-2 btn-group">
                                          <button class="btn btn-outline-secondary">Options</button>
                                          <button type="button" aria-haspopup="true" aria-expanded="false" data-toggle="dropdown" class="dropdown-toggle-split dropdown-toggle btn btn-outline-secondary"><span class="sr-only">Toggle Dropdown</span>
                                          </button>
                                        <div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu">

                                                <a href="<?=base_url('index.php/admin_action/user_modify')?>?id=<?=$slider2['dtv_id']?>&what=active_data_v" >
                                                <button type="button" tabindex="0" class="dropdown-item">Activate Data</button></a>

                                              <div tabindex="-1" class="dropdown-divider"></div>
                                              <a onclick="return confirm('Do you really want to delete this user, you can ban the user as well.');" href="<?=base_url('index.php/admin_action/delete')?>?id=<?=$slider2['dtv_id']?>&what=course_data" >
                                                <button type="button" tabindex="0" class="dropdown-item">Delete</button></a>
                                          </div>
                                      </div>

                                      </td>
                                  </tr>
                                <?php } ?>
                                  </tbody>
                              </table>

                          </div>
                      </div>
                  </div>
    <?php 
    break;
    case 'all-prov':
      $get_sliders=$this->db->query("select * from x_cou_prov order by pr_id desc limit 100");
      $allsliedsrs=$get_sliders->result_array();
       ?>
    <div class="col-sm-6">
        <div class="main-card mb-3 card">
            <div class="card-body"><h5 class="card-title">All Providers</h5>
                <table class="mb-0 table">
                    <thead>
                    <tr>
                        <th>#</th>
                        <th>Image</th>
                        <th>Name</th>
                        <!-- <th>Description</th> -->
                        <th>Action</th>
                    </tr>
                    </thead>
                    <tbody>
                      <?php 
                      foreach($allsliedsrs as $slider2){ ?>
                    <tr>
                        <th scope="row"><?=$slider2['pr_id']?></th>
                        <td>
                        <a href="<?=base_url('admin/perform/custom/all-course?mer=')?><?=$slider2['pr_id']?>">  <img src="<?=base_url('assets/avator/upload/')?><?=$slider2['pr_image']?>" style='height:40px;'></a>
                        </td>
                        <td><b><?=$slider2['pr_name']?></b></td>
                        <!-- <td><?=trim_text(strip_tags($slider2['pr_desc']),'90')?></td> -->
                        <td style="min-width: 120px;">
                        <a onclick="return confirm('Are you sure you want to delete this?');" href="<?=base_url('index.php/admin_action/delete')?>?id=<?=$slider2['pr_id']?>&what=provid" >
                          <button class="mr-2 btn-icon btn-icon-only btn btn-outline-danger"><i class="pe-7s-trash btn-icon-wrapper"> </i></button></a>
                          <a href="<?=base_url('index.php/admin/perform/custom/add-prov')?>?edit=<?=$slider2['pr_id']?>"><button class="mr-2 btn-icon btn-icon-only btn btn-outline-warning"><i class="pe-7s-pen btn-icon-pen"> </i></button></a>
                        </td>
                    </tr>
                  <?php } ?>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
    <?php
    break;
    case 'orders': 
                $what='view_order';
                    $theidval='';
                  if(isset($_GET['view']) && $_GET['view'] !=''){
                    $id=$_GET['view'];
                    $getslider_details=$this->db->query("select * from `x-orders` where or_order_id='$id' ");
                    $theimage_details3=$getslider_details->row_array();
                    $theidval=$_GET['view'];

                    if ($getslider_details->num_rows()>0) {
                      $Odr_Details = $getslider_details->result_array();
                      $order_chk_id = $Odr_Details[0]['checkout_order_id'];
                      ?>
                      <div class="mb-4 card col-sm-11">
                        <div class="card-body"><h5 class="card-title">Order Details</h5>
                          <div class="table-responsive">
                            <table class="table">
                              <tbody>
                                <tr>
                                  <td>Order #</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['checkout_order_id']?></td>
                                  <td>Checkout Date</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['checkout_date']?></td>
                                </tr>
                                <tr>
                                  <td>First Name</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['first_name']?></td>
                                  <td>Last Name</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['last_name']?></td>
                                </tr>
                                <tr>
                                  <td>Phone#</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['phone']?></td>
                                  <td>Email</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['email']?></td>
                                </tr>
                                <tr>
                                  <td>Address</td>
                                  <td class="font-weight-bold"><?=$Odr_Details[0]['address']?></td>
                                  <td>Total Price</td>
                                  <td class="font-weight-bold"><?=number_format($Odr_Details[0]['checkout_price'],2)?></td>
                                </tr>
                                <tr>
                                  <td>Order Status</td>
                                  <td class="font-weight-bold"><?=read_me_user('cstatus',$Odr_Details[0]['checkout_status'])?></td>
                                  <td>Payment Status</td>
                                  <td class="font-weight-bold"><?=read_me_user('cpay',$Odr_Details[0]['chk_payment_status'])?></td>
                                </tr>
                              </tbody>
                            </table>

                           


                            <div class="table-responsive">
                              <fieldset><h5>Products List</h5></fieldset>
                                    <table class="table table-borderless">
                                      <tbody>
                                        <?php 
                                        $Order_listPro = $this->db->query("SELECT * from `x-orders-detail` where checkout_order_id='$order_chk_id' ");
                                        if ($Order_listPro->num_rows()>0) {
                                          $index = 0;
                                          foreach ($Order_listPro->result_array() as $productList) {
                                            $index++;
                                            ?>
                                            <tr>
                                              <td><?=$index?></td>
                                              <td><img width="60px" style="width: 60px; border-radius: 20px;" class="ec-cart-pro-img mr-4" src="<?=base_url('assets/avator/upload/')?><?=$productList['xod_image1']?>" alt=""></td>
                                              <td><?=$productList['xod_title']?></td>
                                              <td><?=$productList['xod_name']?></td>
                                              <td><?=$productList['xod_price']?></td>
                                              <td><?=$productList['xod_qty']?></td>
                                              <td><?=$productList['xod_price']?> x <?=$productList['xod_qty']?> <br/><b>Total : <b class="text-warning"><?=number_format($productList['xod_qty']*$productList['xod_price'])?></b> </b></td>
                                            </tr>
                                            <?php
                                          }
                                        }else{
                                          echo "<div class='alert alert-info'>Empty Product List!</div>";
                                        }
                                         ?>
                                      </tbody>
                                    </table>
                            </div>
                          </div>

                        </div>
                      </div>
                      <?php
                    }else{
                      echo "<div class='alert alert-info'>Empty data!</div>";
                    }

                  }else{
                    $get_sliders=$this->db->query("select * from site_blogs order by blog_id desc limit 10");
                    $allsliedsrs=$get_sliders->result_array();
                     ?>
                  <div class="col-sm-12">
                      <div class="main-card mb-3 card">
                          <div class="card-body"><h5 class="card-title">All Orders</h5>
                              <table class="mb-0 table">
                                  <thead>
                                  <tr>
                                      <th>Order #</th>
                                      <th>Date</th>
                                      <th>Shipt to</th>
                                      <th>User Provided Date & Time</th>
                                      <th>Code</th>
                                      <th>Status</th>
                                      <th>Payment Status</th>
                                      <th>&nbsp;</th>
                                  </tr>
                                  </thead>
                                  <tbody>
                                    <?php 
                                    $ordersAll = $this->db->query("SELECT * FROM `x-orders` order by or_order_id desc limit $limit1, $limit2");
                                    if ($ordersAll->num_rows()>0) {
                                      foreach ($ordersAll->result_array() as $OrderMain) {
                                    ?>
                                  <tr>
                                      <th scope="row"><?=$OrderMain['checkout_order_id']?></th>
                                      <td>
                                        <b><?=date('jS M D Y',strtotime($OrderMain['checkout_date']))?></b>
                                      </td>
                                      <td style="min-width: 120px;">
                                        <?=$OrderMain['first_name'].' '.$OrderMain['last_name']?>
                                      </td>
                                      <td><?=$OrderMain['chk_user_date'].' '.con_24to12($OrderMain['chk_time_hour'],$OrderMain['chk_time_min'], '1')?></td>
                                      <td><?=$OrderMain['chk_code']?></td>
                                      <td><?=read_me_user('cstatus',$OrderMain['checkout_status'])?></td>
                                      <td><?=read_me_user('cpay',$OrderMain['chk_payment_status'])?></td>

                                      <td>
                                        
                                        <div class="mr-2 btn-group">
                          <button class="btn btn-outline-secondary">View</button>
                          <button type="button" aria-haspopup="true" aria-expanded="false" data-toggle="dropdown" class="dropdown-toggle-split dropdown-toggle btn btn-outline-secondary"><span class="sr-only">Toggle Dropdown</span>
                          </button>
                        <div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu">
                              <a target='_blank' href="<?=base_url('index.php/admin/perform/custom/').'orders?view='.$OrderMain['or_order_id']?>"><button type="button" tabindex="0" class="dropdown-item"  >View Order</button></a>
                                
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$OrderMain['or_order_id']?>&what=paid" ><button type="button" tabindex="0" class="dropdown-item">Paid</button></a>
                                
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$OrderMain['or_order_id']?>&what=unpaid" ><button type="button" tabindex="0" class="dropdown-item">Un-paid</button></a>
                              
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$OrderMain['or_order_id']?>&what=Confirmed" ><button type="button" tabindex="0" class="dropdown-item">Confirmed</button></a>
                                
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$OrderMain['or_order_id']?>&what=Cancelled"><button type="button" tabindex="0" class="dropdown-item">Cancelled</button></a>

                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$OrderMain['or_order_id']?>&what=Shipped" ><button type="button" tabindex="0" class="dropdown-item">Shipped</button></a>
                                
                                <a href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$OrderMain['or_order_id']?>&what=Completed"><button type="button" tabindex="0" class="dropdown-item">Completed</button></a>
                              
                              <div tabindex="-1" class="dropdown-divider"></div>
                              <!-- <a onclick="return confirm('are you sure you want to Cancel this?');" href="<?=base_url('index.php/admin_action_custom/modify')?>?id=<?=$flav_details['app_id']?>&what=cancel_appl" >
                                <button type="button" tabindex="0" class="dropdown-item">Cancel Order</button></a> -->

                              <a onclick="return confirm('are you sure you want to delete this?');" href="<?=base_url('index.php/admin_action_custom/delete')?>?id=<?=$OrderMain['or_order_id']?>&what=appl" >
                                <button type="button" tabindex="0" class="dropdown-item">Delete Order</button></a>
                          </div>
                      </div>
                                      </td>
                                  </tr>
                                <?php } 
                              }?>
                                  </tbody>
                              </table>
                              <div class="col-12">
                                            <nav class="mt-4" aria-label="Page navigation example">
                                            <ul class="pagination">
                                                <li class="page-item"><a href="javascript:void(0);" class="page-link" aria-label="Previous"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></a></li>
                                                <?php
                                                $pagesare=$pageNum;
                                                for ($x = $pageNum-10; $x <= $pageNum+10; $x++) {
                                                $addclass='';if($pageNum == $x ){$addclass='bold';}if($x > 0){
                                                ?>
                                                <li onclick="paging(<?=$x?>)"  class="page-item <?=$addclass?>"><a href="#" class="page-link"><?=$x?></a></li>
                                                <?php } } ?>
                                                <li class="page-item"><a href="javascript:void(0);" class="page-link" aria-label="Next"><span aria-hidden="true">»</span><span class="sr-only">Next</span></a></li>
                                            </ul>
                                        </nav>
                                          </div>
                              
                          </div>
                      </div>
                  </div>
                  <?php
                  }

                  ?>
                    <?php
                     
                  break;


    case 'order': 
      $getaction='order';
      $theidval='';?>
    
                <div class="card w-100">
                <div class="card-header">All Orders</div> 
                  <div class="card-body">
                  <table class="table"> 
                      <tr>
                         <th>#</th>
                         <th>Order id</th>
                         <th>Order date</th>
                         <th>Name</th>
                         <th>Email</th>
                         <th>Phone</th>
                         <th>Address</th>
                         <th>Message</th>
                         <th>status</th>
                         <th>Action</th>
                     </tr>
                <?php  
                 $getall_order=$this->db->query("select * from site_order");
                 $all_order=$getall_order->result_array();
                 $count=1;
    
                 foreach($all_order as $order){?>
                
                  
                     <tr class="bg-white">
                         <td><?=$count++;?></td>
                         <td><?php echo $order['so_order_id']?></td>
                         <td><?=date_format_1($order['so_date'], '1')?></td>
                         <td><?php echo $order['so_name']?></td>
                         <td><?php echo $order['so_email']?></td>
                         <td><?php echo $order['so_phone']?></td>
                         <td><?php echo $order['so_add']?></td>
                         <td><?php echo $order['so_message']?></td>
                       
                        
                         <td><?=read_me_user('order_status',$order['so_status'],1)?></td>
                          
                          <td class="text-left">
                                                      <div class="mr-2 btn-group">
                                                <button class="btn btn-outline-secondary">Options</button>
                                                <button type="button" aria-haspopup="true" aria-expanded="false" data-toggle="dropdown" class="dropdown-toggle-split dropdown-toggle btn btn-outline-secondary"><span class="sr-only">Toggle Dropdown</span>
                                                </button>
                                              <div tabindex="-1" role="menu" aria-hidden="true" class="dropdown-menu">
    
                                                     
                                              <a href="<?=base_url('index.php/admin_action/service_modify')?>?id=<?=$order['so_id']?>&what=ban_ord" >
                                                      <button type="button" tabindex="0" class="dropdown-item">Ban</button></a>
    
                                                      <a href="<?=base_url('index.php/admin_action/service_modify')?>?id=<?=$order['so_id']?>&what=pen_ord" >
                                                      <button type="button" tabindex="0" class="dropdown-item">Pending</button></a>

                                                      <a href="<?=base_url('index.php/admin_action/service_modify')?>?id=<?=$order['so_id']?>&what=active_ord" >
                                                      <button type="button" tabindex="0" class="dropdown-item">Active</button></a>

                                                      <a href="<?=base_url('index.php/admin_action/service_modify')?>?id=<?=$order['so_id']?>&what=del_ord" >
                                                      <button type="button" tabindex="0" class="dropdown-item">Delivered</button></a>
    
                                                      <a onclick="return confirm('Do you really want to delete this user, you can ban the user as well.');" href="<?=base_url('index.php/admin_action/delete')?>?id=<?=$order['so_id']?>&what=order" >
                                                      <button type="button" tabindex="0" class="dropdown-item">Delete</button></a>
                                                </div>
                                            </div>
                                                    </td>
                                                  
                                                </tr>
                     
                      <?php } ?>
                 </table>
                 
                 </div>
                </div>
                 <?php
                
    break;
    case 'add_gen_product':
    ?>
    <div class="main-card mb-3 card col-12">
        <div class="card-body"><h5 class="card-title">Add Product</h5>
            <div>
                <form class="form-horizontal form-label-left" action="<?=base_url('index.php/admin_action_custom/add_gen_product')?>" method="post" enctype="multipart/form-data" onsubmit="return uploadandform('<?=base_url('index.php/admin_action_custom/add_gen_product')?>','post',this,'image_name','progress_value_sc','prog_valie_text','Show_Errors_987','loader_post_upload','1','uni_loader_prog_status');" id='fomr_id_proile22w'>
                  <input type="hidden" name="edit" value="0">
                  <div class="form-group">
                  <input type="text" name="inv_order_id" placeholder="Order ID" value="" required>
                </div>
                  <?php for($i=1; $i<3; $i++){?>
                  <div class="form-group">
                    <input type="text" name="inv_prod<?=$i?>" placeholder="Product Name<?=$i?>" value="">
                    <input type="text" name="inv_prod<?=$i?>_price" placeholder="Price" value="">
                    <input type="text" name="inv_prod<?=$i?>_qty" placeholder="Qunatity" value="">
                  </div>
                <?php }?>
              
              
                  <input type="hidden" name="inv_pid" value="3" id="inv_pid">
                  
                  <div class="form-group">
                    <div class="">
                      <button type="submit" class="btn btn-success btn-block">Add Product</button>
                    </div>
                  </div>
                
                </form>

            </div>
        </div>
    </div>
    
  <?php
    break;
    case 'gen_products': 
      $getaction='order';
      $theidval='';?>
    
                <div class="card w-100">
                <div class="card-header">All General Products</div> 
                  <div class="card-body">
                  <table class="table"> 
                      <tr>
                         <th>#</th>
                         <th>Order id</th>
                         <th>Product Name / Price / Quantity</th>
                     </tr>
                <?php  
                 $getall_order=$this->db->query("select * from x_gen_products order by gpid desc");
                 $all_order=$getall_order->result_array();
                 $count=1;
    
                 foreach($all_order as $order){?>
                
                  
                     <tr class="bg-white">
                         <td><?=$count++;?></td>
                         <td><?php echo $order['gp_order_id']?></td>
                         
                         <td><?php $products=unserialize($order['gp_products']);
                         for($p=0;$p<count($products); $p++){
                         echo "<b>Name:</b>".$products[$p]['0']."\t<b>Price:</b> ".$products[$p]['1']."\t<b>Quantity:</b> ".$products[$p]['2']."<br>";}?></td>
                       
                                                  
                                                </tr>
                     
                      <?php } ?>
                 </table>
                 
                 </div>
                </div>
                 <?php
                
    break;
    default:
    echo $sub_perform;
    break;
  }
  ?>
</div>