<?php

include("../include/config.php");
include_once("../include/functions.php"); 
include("../include/simpleimage.php");
include("session.php");
include("sessionmsg.php");
$sql=$obj->query("SELECT * FROM sl_users WHERE uid='$loged_userid'");
$rec=$obj->fetchNextObject($sql);
$storeid=getFieldWhere('storeid', 'stores', 'uid', $loged_userid);
session_start();

include("top-head.php");
if(isset($_POST['btnAddSchedule']))
{
    $prodreference_id=$_POST['id'];
    $schedule_date=$_POST['schedule_date'];
    $schedule_time=$_POST['schedule_time'];
    $info=$obj->query("select * from  tbl_order_itmes where section='quicklly-puja' AND id='".$prodreference_id."'"); 
    $inforow=$obj->fetchNextObject($info);
   
     $infoe=$obj->query("select * from  tbl_puja_schedule where sc_id='".$_POST['sc_id']."'"); 
    $inforowe=$obj->fetchNextObject($infoe);
    $schedule='';
    if($inforowe->schedule_date==0000-00-00)
    {
       
        $schedule='schedule';
    }
    else
    {
        $schedule='reschedule';
     
    }
     $sql="update tbl_puja_schedule set prodreference_id='$prodreference_id',schedule_date='$schedule_date',to_schedule_date='".$_POST['to_schedule_date']."',schedule_time='$schedule_time',current_status='Video call Scheduled',updated_at='".date('Y-m-d h:i:s')."' where sc_id='".$_POST['sc_id']."'";
      $obj->query($sql);
         echo "<script>alert('Puja Scheduled Successfully')</script>";
      $results = callAPI('POST','https://ormwebapi.quicklly.com/digitalpuja/chat-email-notification',array("emailtype"=>$schedule,'userid'=>$inforowe->user_id,'statusid'=>$_POST['sc_id'],'pid'=>$inforowe->pid));
		
       echo "<script>window.location='puja-all-order-list.php'</script>";
}

if(isset($_GET['cmpid']))
{
     $sql="update tbl_puja_schedule set current_status='complete',updated_at='".date('Y-m-d h:i:s')."',order_complete_date='".date('Y-m-d H:i:s')."' where prodreference_id='".$_GET['cmpid']."'";
      $obj->query($sql);
         echo "<script>alert('Order Completed Updated Successfully')</script>";
         echo "<script>window.location='puja-all-order-list.php'</script>";
}

if(isset($_POST['btnOrderStatus']))
{
    $sql="update tbl_puja_schedule set current_status='".$_POST['order_status']."',order_status_comment='".$_POST['puja_cancelled']."',updated_at='".date('Y-m-d H:i:s')."',order_complete_date='".date('Y-m-d H:i:s')."' where sc_id='".$_POST['sc_id']."'";
      $obj->query($sql);
      
      if($_POST['order_status']=='cancel')
      {
           $infoe=$obj->query("select * from  tbl_puja_schedule where sc_id='".$_POST['sc_id']."'"); 
    $inforowe=$obj->fetchNextObject($infoe);
         // $results = callAPI('POST','https://ormwebapi.quicklly.com/digitalpuja/chat-email-notification',array("emailtype"=>'cancel','userid'=>$inforowe->user_id,'statusid'=>$_POST['sc_id'],'pid'=>$inforowe->pid));
	
       $slotid=$_POST['slotid'];
      	if($slotid!='' || $slotid!=null)
           {
             $slotquery=$obj->query("select id,avaibility_date,from_time,to_time,timegap from tbl_puja_avaibility_date_time  where id='".$slotid."'");
			 $getslot=$obj->fetchNextObject($slotquery);
			 //$obj->query("update tbl_puja_schedule set booked_date='".$getslot->avaibility_date."',to_booked_date='".$getslot->avaibility_date."',booked_slot='".$getslot->from_time."',schedule_time='".$getslot->from_time."',schedule_date='".$getslot->avaibility_date."',to_schedule_date='".$getslot->avaibility_date."',current_status='Video call Scheduled',chat_status=1 where sc_id='$pujaid'");
             $obj->query("update tbl_puja_avaibility_date_time set booking_status=0 where id='$slotid'");
			 if($getslot->timegap==20)
            {
             $pricequeryp=$obj->query("select size from tbl_productprice  where wholesale_min=0 and product_id='272098' order by display_order asc");
			  	
              while($productp=$obj->fetchNextObject($pricequeryp)){
				  $begin = new DateTime($getslot->from_time);
                  $end = new DateTime($getslot->to_time);
				      while($begin < $end) {
    $gap=$productp->size;
    $output1 = $begin->format('Y-m-d H:i:s');
    $begin->modify('+5 minutes');          
   $output = $begin->format('Y-m-d H:i:s');
                $obj->query("update tbl_puja_avaibility_date_time set booking_status=0,status=1,updated_at=now() where avaibility_date='".$getslot->avaibility_date."' and (from_time<='".$output1."' AND to_time >='".$output."') and timegap='".$gap."'");
   
					  }
              
              }			  
			}  else {
			  $obj->query("update tbl_puja_avaibility_date_time set booking_status=0 WHERE avaibility_date='".$getslot->avaibility_date."' and (from_time<='".$getslot->from_time."' and to_time >= '".$getslot->to_time."' or (from_time>='".$getslot->from_time."' and to_time <= '".$getslot->to_time."'))");
           }
           }
      }
         echo "<script>alert('Order Status Updated Successfully')</script>";
         echo "<script>window.location='puja-all-order-list.php'</script>";
}

?>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<style>
.modal-open .modal {
    overflow-x: hidden;
    overflow-y: auto;
}
.modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999999;
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
    outline: 0;
}
select#reason {
    width: 70%;
    margin: 15px 0px;
    text-align: center;
    text-align-last: center;
    -moz-text-align-last: center;
}
#otherreason {
    width: 70%;
    font-weight: 400;
}
div#unsubscribemodel ul, #upgragedowndradeplan ul {
    margin: 10px auto;
}
div#unsubscribemodel ul li, #upgragedowndradeplan ul li {
    list-style: none;
    display: inline-block;
}
div#unsubscribemodel ul button, #upgragedowndradeplan ul button {
    background: transparent;
    border: 1px solid #e2e2e2;
    padding: 10px 40px;
    margin: 0px 20px;
    border-radius: 20px;
    outline: none;
    font-size: 15px;
    font-weight: 500;
}
button#yes, button#enablecta {
    background: #911D59 !important;
    color: #fff;
}
.unsubscribemodel.show {
    display: block!important;
}
.clsDialog {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 20;
}
.clsDialog.commoneventviewcancel {
    z-index: 999 !important;
}
.clsDialog-Box {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    background-color: white;
    border-radius: 4px;
    overflow-y: auto;
    max-height: 90%;
    box-shadow: 0 0 20px 0px rgb(0 0 0 / 28%);
}
.clsDialog-Box .clsContent {
    overflow-y: auto;
}
	  .bookingcontent.cancelpricebox {
    margin:10px 0px;
}
.qrwrapper {
    padding: 5px 10px;
    max-width: 70%;
    text-align: center;
    display: block;
    margin: 0 auto;
}
.bookingcontent a.cancelticketbtn {
    background: #E75E15 0% 0% no-repeat padding-box;
    border-radius: 4px;
    border: 0;
    color: #fff;
    font: normal normal 400 14px/20px Poppins;
    letter-spacing: 0px;
    /* color: #FFFFFF; */
    margin: 0;
    width: 100%;
    display: block;
    text-align: center;
    padding: 6px;
	text-decoration:none;
}
.bookingcontent.cancelpricebox ul {
    list-style: none;
    display: flex;
    margin:0;
    padding:0
}

.bookingcontent.cancelpricebox ul li {
    width: 70%;
    font: normal normal 500 13px/20px Poppins;
    letter-spacing: 0px;
    color: #000000;
}
.bookingcontent.cancelpricebox ul li.secondrow {
    width:30%;
    text-align:right;
}
	  .bookingcontent img  {
		  
		  max-width:100%;
		  padding-top: 10px;
	  }


.bookingcontent h4.modal-title {
    text-align: left;
    font: normal normal 600 14px/30px Poppins !important;
    letter-spacing: 0px;
    color: #000000;
	margin-bottom:0px !important;
}
.bookingcontent p {
    text-align: left;
    font: normal normal normal 14px/20px Poppins;
    letter-spacing: 0px;
    color: #000000;
    margin-bottom: 5px;
}
.viewmodal .bookingcontent.bgclas p {
	 text-align: center;
    font: normal normal 400 14px/20px Poppins;
    letter-spacing: 0px;
    color: #000000;
    margin-bottom: 5px;
}
.viewmodal .bookingcontent.bgclas p span {
	color: #000000;
	font: normal normal 400 14px/20px Poppins;
}
img.topeventimgqr {
    margin-bottom: 5px;
}
.bookingcontent.ullist ul {
    display: block;
    list-style: none;
}

.bookingcontent.ullist ul li {
    width: 49%;
    display: inline-block;
	font: normal normal 400 14px/30px Poppins !important;
    letter-spacing: 0px;
    color: #000000;
}
.bookingcontent.ullist {
    border-top: 1px solid #E4E4E4;
}
.viewmodal .bookingcontent.ullist {
    border-top: 1px solid #E4E4E4;
	border-bottom: 1px solid #E4E4E4;
	margin-bottom:10px;
}
.viewmodal .bookingcontent.ullist ul {
  padding:0;
  margin:0;
}
.bookingcontent.bgclas h5 {
    text-align: left;
    font: normal normal 600 14px/20px Poppins;
    letter-spacing: 0px;
    color: #000000;
    padding: 0;
    margin: 0;
}

.bookingcontent.bgclas {
    background: #F2F2F2 0% 0% no-repeat padding-box;
    padding: 5px 5px;
}
	 .commoneventviewcancel .clsDialog-Box a.clsClose {
		  background-image: url('<?php echo SITE_URL;?>images/eventbook/cancel.svg') !important;
		  right:0;
		  top:0;
	  }
	  .clsDialog.commoneventviewcancel {
		  z-index:999 !important;
	  }
	  .commoneventviewcancel .clsFoodCustomDialog .clsContent.clsFoodStoreCard.exclude-calc {
    width: 320px;
    min-width: 320px;
    padding: 0px 10px 10px 10px;
}
.clsDialog-Box a.clsClose {
    position: absolute;
    display: block;
    width: 20px;
    height: 20px;
    background-size: 100%;
    background-repeat: no-repeat;
    border-radius: 50%;
    transition: 0.2s ease-out;
}
</style>
<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">

       <?php include("sidebar-for-puja.php");?>

        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">

            <!-- Main Content -->
            <div id="content">

               <?php include("top-bar-header-puja.php");?>

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                    <h1 class="h3 mb-2 text-gray-800">Order Info</h1>

  
<form class="user" method="post">
<div class="row">
<div class="col-lg-12">
<div class="form-group row">
                                    <div class="col-sm-4 mb-3 mb-sm-0">
                                        <input type="text" class="form-control form-control-user" id="exampleFirstName"
                                            placeholder="Order Id"  name="search_order_id" value="<?php echo $_REQUEST['search_order_id']; ?>">
                                    </div>
                                    <div class="col-sm-4">
                                        <input type="email" class="form-control form-control-user" id="exampleLastName"
                                            placeholder="Email" name="search_email" value="<?php echo $_REQUEST['search_email']; ?>">
                                    </div>
									<div class="col-sm-4 mb-3 mb-sm-0">
                                        <input type="text" class="form-control form-control-user" id="exampleFirstName"
                                            placeholder="Phone" name="search_phone" value="<?php echo $_REQUEST['search_phone']; ?>">
                                    </div>
                                </div>
								<div class="form-group row">
                                    <div  class="col-sm-4 mb-3 mb-sm-0">
                                       
											<select  class="form-control form-control-user custominput" aria-label=".form-select-lg example" name="search_order_status">

                        <option value="" selected="">Order Status</option>
                        <option value="1" <?php if($_REQUEST['search_order_status']==1){?>selected<?php } ?>>Order Accepted</option><option value="3" <?php if($_REQUEST['search_order_status']==3){?>selected<?php } ?>>Delivered</option><option value="5" <?php if($_REQUEST['search_order_status']==5){?>selected<?php } ?>>Declined</option><option value="6" <?php if($_REQUEST['search_order_status']==6){?>selected<?php } ?>>Out of stock</option> </select>
</select>
                                    </div>
									<div  class="col-sm-4 mb-3 mb-sm-0">
                                       
											<select  class="form-control form-control-user custominput" aria-label=".form-select-lg example" name="search_payment_status">
<option value="">Payment Status</option>
                        <option value="1" <?php if($_REQUEST['search_payment_status']==1){?>selected<?php } ?>>Successful</option>
                        <option value="0" <?php if($_REQUEST['search_payment_status']==0){?>selected<?php } ?>>Unsuccessful</option>
                        
</select>
                                    </div>
                                    
                                    	<div  class="col-sm-4 mb-3 mb-sm-0">
                                       
											<select  class="form-control form-control-user custominput" aria-label=".form-select-lg example" name="search_category">
<option value="">Category</option>
                       
                       <?php
                       $category=$obj->query("SELECT  c.id, c.maincategory, ci.photo,c.slug,c.content
                            FROM    tbl_maincategory c 
                                    LEFT JOIN tbl_categoryimage ci on c.id=ci.cat_id  
                            WHERE   c.slug='online-puja' OR c.slug='astrology' AND c.status=1
                            ORDER BY c.sort_order ASC");
                             while($cate=$obj->fetchNextObject($category))
                        {
                       ?>
                       <option value="<?=$cate->id?>" <?php if($_REQUEST['search_category']==$cate->id) { echo "selected"; }?>><?=$cate->maincategory?></option>
                       <?php
                        }
                       ?>
                        
</select>
                                    </div>
									
                                   
                                </div>
								<div class="form-group row">
                                    <div  class="col-sm-4 mb-3 mb-sm-0">
                                       
										<input class="form-control form-control-user"  placeholder="Search from date" type="text" name="search_from_date" id="search_from_date" value="<?php echo $_REQUEST['search_from_date']; ?>"/>	
                                    </div>
									<div  class="col-sm-4 mb-3 mb-sm-0">
                                       
<input class="form-control form-control-user" type="text" name="search_to_date"  placeholder="Search to date" id="search_to_date" value="<?php echo $_REQUEST['search_to_date']; ?>"/>
                                    </div>
									
                                   
                                </div>
								 
								<div class="form-group col-md-3">
								<button type="submit" class="btn btn-primary btn-user btn-block">
                                    Search
                                </button>
                                
								</div>


</div>  
</div>               
</form>
                    <!-- DataTales Example -->
                    <div class="card shadow mb-4">
                        <?php
                        						$where='';

if($_REQUEST['search_order_id']!=''){

$name=$_REQUEST['search_order_id'];

$where.=" and o.id='".$name."'";	

}





if($_REQUEST['search_user_id']!=''){

$name=$_REQUEST['search_user_id'];

$where.=" and o.user_id='".$name."'";	

}

if($_REQUEST['search_email']!=''){

$name=$_REQUEST['search_email']	;

$where.=" and o.ship_email like '%$name%' ";	

}
if($_REQUEST['search_phone']!=''){

$name=$_REQUEST['search_phone']	;

$where.=" and o.ship_mobile like '%$name%' ";	

}

if($_REQUEST['search_payment_status']!=''){

$name=$_REQUEST['search_payment_status'];

$where.=" and o.payment_status ='".$name."'";		

}

if($_REQUEST['search_order_status']!=''){

$name=$_REQUEST['search_order_status']	;

$where.=" and o.order_status='".$name."'";		

}

if($_REQUEST['search_from_date']!='' && $_REQUEST['search_to_date']!=''){

$where.=" and o.order_date>='".$_REQUEST['search_from_date']."' and o.order_date<='".$_REQUEST['search_to_date']."' ";

}

if($_REQUEST['search_category']!='')
{
    $name=$_REQUEST['search_category'];
    $where.=" and p.categories='".$name."' ";
}
                        ?>
                        <div class="card-body">
						
				
                            <div class="table-responsive">
                                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th>S No.</th>
                                            <th>Customer Detail</th>
                                            <th>Payment Status</th>
                                            <th>Order Date</th>
                                            <th>Order ID</th>
                                            <th>Puja Reference Date </th>
											<th>Reference Slot / Time</th>
											<th>Puja Schedule</th>
											<th>Status</th>
                                            <th>Category</th>
                                            <th>Product</th>
                                            <th style="width:300px;">Detail</th>
                                            <th>Prasad</th>
                                            <th>QTY</th>
											<th>Amount</th>
											<th>Delivered Date</th>
											<th>Comment</th>
                                            <th>Action</th>
										
										
                                        </tr>
                                    </thead>
                                   
                                    <tbody>
                                        <?php
                                        $i=0;
                                        $orders=$obj->query("SELECT ps.*,c.maincategory,p.product_name,o.payment_status,o.ship_fname,o.ship_lname,o.ship_mobile,o.ship_full_address,o.ship_house_no,o.ship_street,o.ship_complex,o.ship_area,o.ship_city_id,o.ship_state,o.ship_pincode FROM `tbl_puja_schedule` ps inner join tbl_product p on ps.pid=p.id inner join tbl_maincategory c on c.id=p.categories inner join tbl_order o on o.id=ps.order_id $where ORDER BY `sc_id` DESC;"); 
                        while($orrow=$obj->fetchNextObject($orders))
                        {
                            $i=$i+1;
                            
                            
                            ?>
									<tr>
									    <td><?=$i?></td>
									    <td>
									         <?php 
									         
									         echo ucwords($orrow->ship_fname . " " . $orrow->ship_lname); ?><br /><?php echo $orrow->ship_mobile; ?><br />
<strong>Add:</strong> <?php 
if($orrow->ship_full_address==''){
echo $orrow->ship_house_no . ", " . $orrow->ship_street . ", " . $orrow->ship_complex . ", " . $orrow->ship_area . " " . $orrow->ship_city_id . " " . $orrow->ship_state . ", " . $orrow->ship_pincode;
} else {
echo $orrow->ship_full_address. ", ".$orrow->ship_complex .", " . $orrow->ship_pincode;
}

?>
									    </td>
									    <td><?php if($orrow->payment_status=='1'){ echo "<i class='fa fa-circle' style='color:#0acf0a'></i>"; } else { echo "<i class='fa fa-circle' style='color:red'></i>"; } ?></td>
									    <td><?=date('d M Y H:i', strtotime($orrow->created_at));?></td>
									    <td><?=$orrow->order_id?></td>
									     <td><?php 
	if($orrow->booked_date==$orrow->to_booked_date)
	{
									    if($orrow->booked_date!='' AND $orrow->booked_date!='0000-00-00'){ echo date('d M Y', strtotime($orrow->booked_date)); }
	}
	else
	{
									    ?>
									    <?php 
									    if($orrow->booked_date!='' AND $orrow->booked_date!='0000-00-00'){ echo date('d M Y', strtotime($orrow->booked_date)); }
									    if($orrow->to_booked_date!='' AND $orrow->to_booked_date!='0000-00-00'){ echo "- To -".date('d M Y', strtotime($orrow->to_booked_date)); }
	}
									    ?>
									    </td>
									    <td><?php if($orrow->booked_slot!='')
									    {
									    $arr=explode(" - ",$orrow->booked_slot);
									  //  echo date('h:i a', strtotime($arr[0]))." - ".date('h:i a', strtotime($arr[1]));
									    echo echo date('h:i a', strtotime($arr[0]));
										}
									    ?></td>
									     <td style="text-align:center;"><?php if($orrow->schedule_date!=0000-00-00)
									     {
									         if($orrow->schedule_date==$orrow->to_schedule_date)
									         {
									              $date1 = $orrow->schedule_date;
									               $time=$orrow->schedule_time; 
									               $datefrom=date('d M Y', strtotime($date1));
									               $timeto=date('h:i A', strtotime($time));
									               echo $datefrom;
									               echo "<br>";
echo $timeto;
									         }
									         else
									         {
									     $date1 = $orrow->schedule_date;
									      $date2 = $orrow->to_schedule_date;
									     $time=$orrow->schedule_time; 
									     $datefrom=date('d M Y', strtotime($date1));
									     $dateto=date('d M Y', strtotime($date2));
									     $timeto=date('h:1 A', strtotime($time));
echo $datefrom." - ".$dateto ;
echo "<br>";
echo $timeto;
}
}
									     //$inforow->schedule_date
									     ?>
									     
									     </td>
									      <td><?php
									      if($orrow->current_status=="Video call Scheduled")
									      {
									          echo "<span class='badge badge-primary'>".$orrow->current_status."</span>";
									      }
									      else if($orrow->current_status=="complete")
									      {
									          echo "<span class='badge badge-success'>".$orrow->current_status."</span>";
									      }
									      else if($orrow->current_status=="cancel")
									      {
									          echo "<span class='badge badge-danger'>".$orrow->current_status."</span>";
									      }
									      else
									      {
									           echo "<span class='badge badge-info'>Pending</span>";
									      }
									      ?></td>
									    
									    <td><?php
									   
    echo $orrow->maincategory;
									    ?></td>
									    <td>
									       <?=$orrow->product_name?>
									    </td>
									    
									     <td>
									       <?php
									      
    if($orrow->maincategory=="Astrology")
    {
        
       if($orrow->name!='')
    {
        echo "<table style='width:300px;'><tr><th>Name</th><th>Date of Birth</th><th>Birth Place</th><th>email</th><th>Birth Country</th><th>Question</th></tr>
              <tr>
              <td>".$orrow->name."</td>
              <td>".date('d M Y h:i a', strtotime($orrow->dob))."</td>
              <td>".$orrow->birthplace."</td>
              <td>".$orrow->useremailid."</td>
              <td>".$orrow->birthcountry."</td>
              <td>".$orrow->questionTodiscussion."</td>
              </tr>
        </table>";
       
    }
    
    }
    else
    {
        $priceinfo=$obj->query("select puja_info,price_detail,sell_price as price from  tbl_productprice where id='".$orrow->price_id."'"); 
    $priceinfodetail=$obj->fetchNextObject($priceinfo);
        echo $priceinfodetail->price_detail;
    }
    $priceinfo=$obj->query("select puja_info,price_detail,sell_price as price from  tbl_productprice where id='".$orrow->price_id."'"); 
    $priceinfodetail=$obj->fetchNextObject($priceinfo);
    
									       ?>
									    </td>
									    <td><?=$priceinfodetail->puja_info?></td>
									   <td>
									       <?=$orrow->qty?>
									    </td>
									    <td>$<?=number_format($priceinfodetail->price, 2);?></td>
									    <td><?=$orrow->order_complete_date?></td>
									   <td><?=$orrow->order_status_comment?></td>
									    <td>
									        <div class="dropdown">
    <button class="btn btn-success dropdown-toggle" type="button" data-toggle="dropdown">Action
    <span class="caret"></span></button>
    <ul class="dropdown-menu">
     <!-- <li style="padding:5px;"><a style="padding: 5px; cursor:pointer; font-size: 12px;" class="badge badge-danger" data-toggle="modal" onclick="getID(<?=$orrow->sc_id;?>)" data-target="#myModalCancel<?=$orrow->sc_id;?>">Cancel</a></li>-->
      <li style="padding:5px;"><a style="padding: 5px; cursor:pointer; font-size: 12px;" class="badge badge-primary" data-toggle="modal" onclick="getID(<?=$orrow->sc_id;?>)" data-target="#myModal<?=$orrow->sc_id;?>">Puja Schedule </a></li>
      <li style="padding:5px;"><a style="padding: 5px; cursor:pointer; font-size: 12px;" class="badge badge-success" onclick="return confirm('Are you sure?')" data-toggle="modal" onclick="getID(<?=$orrow->sc_id;?>)" data-target="#myModalChangeStatus<?=$orrow->sc_id;?>">Change Order Status </a></li>
    </ul>
  </div>
									    </td>
									</tr>
									<div class="modal" id="myModal<?=$orrow->sc_id;?>">
  <div class="modal-dialog">
    <div class="modal-content">

      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Puja Schedule</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>

      <!-- Modal body -->
      <div class="modal-body">
        <form method="POST">
            <div class="row">
                <div class="col-md-12">
                    <label>From Date</label>
                    <input type="date" name="schedule_date" value="<?=$orrow->schedule_date?>" required class="form-control">
                    <input type="hidden" name="id" value="<?=$orrow->id;?>">
                    <input type="hidden" name="sc_id" value="<?=$orrow->sc_id?>">
                </div>
                <div class="col-md-12">
                    <label>To Date</label>
                    <input type="date" name="to_schedule_date" value="<?=$orrow->to_schedule_date?>" required class="form-control">
                   
                </div>
                <div class="col-md-12">
                    <br>
                    <label>Select Time</label>
                    <input type="time" name="schedule_time" value="<?=$orrow->schedule_time?>" required class="form-control">
                </div>
                <div class="col-md-12" style="text-align: center;">
                    <br>
                   <button class="btn btn-success" name="btnAddSchedule">Submit</button>
                </div>
            </div>
            
        </form>
      </div>

      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>

    </div>
  </div>
</div>
<div class="modal" id="myModalChangeStatus<?=$orrow->sc_id;?>">
  <div class="modal-dialog">
    <div class="modal-content">

      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Change Order Status</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>

      <!-- Modal body -->
      <div class="modal-body">
        <form method="POST">
            <div class="row">
                <div class="col-md-12">
                    <label>Select Order Status </label>
                   <select class="form-control" required name="order_status">
                       <option value="">--Select--</option>
                        <option value="cancel">Order Cancel</option>
                        <option value="complete">Order Complete</option>
                   </select>
                </div>
                <div class="col-md-12">
                    <label>Comment </label>
                    <textarea name="puja_cancelled" value="<?=$orrow->puja_cancelled?>" required class="form-control"></textarea>
                    <input type="hidden" name="sc_id" value="<?=$orrow->sc_id?>">
                    <input type="hidden" name="slotid" value="<?=$orrow->slotid?>">
                </div>
              
                <div class="col-md-12" style="text-align: center;">
                    <br>
                   <button class="btn btn-success" name="btnOrderStatus">Submit</button>
                </div>
            </div>
            
        </form>
      </div>

      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>

    </div>
  </div>
</div>
									<?php
                            
                        }
									?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                </div>
              
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->
   <!-- Modal -->
  <!-- The Modal -->

            
<?php include("new-footer.php");?>
 		<script>
		function getID(id)
		{
		    $("#id").val(id);
		}
		$('#reason').change(function(){
	var reasoncheck= $(this).val();
	if(reasoncheck=='Other'){
		$('#otherreason').show();
	} else{
		$('#otherreason').hide()
	}
});	
$('body').on('click','#cancel',function(e){
            e.preventDefault();
            $('body').toggleClass('modal-open');
            $('#unsubscribemodel').toggleClass('show');
        });
		$('body').on('click','#nocta',function(e){
            e.preventDefault();
            $('body').toggleClass('modal-open');
            $('#upgragedowndradeplan').toggleClass('show');
        });
function cancelpopup(cancelkey,reason){
				$("#prod-loader").show();          
				          $('body').toggleClass('modal-open');
                          $('#unsubscribemodel').toggleClass('show');
						  
						  $.ajax({
        url: '<?php echo SITE_URL;?>ajax-events.php',
        type: 'POST',
        data: {
			"action": 'cancelevents',
			"cancelkey": cancelkey,
			"reason": reason

        },
		
		success: function (data) {
		var  data  = JSON.parse(data);	
	    $("#prod-loader").hide();
		if(data.success==true){	
	    location.reload();
		}
		}
		});
				
                        };
function cancelmodal() {
	$('body').toggleClass('modal-open');
    $('#unsubscribemodel').toggleClass('show');
	
}
						

$('#yes').click(function(){
	
				          var sub_id =$('#cancelkey').val();
				          var reason=$('#reason').val();
						  if(reason==''){
							 alert('Please Select a reason');
						  } else {
							if(reason=='Other'){  
							  var oreason=$('#otherreason').val();
						   if(oreason==''){
							 alert('Please Describe a reason');
							 return false;
						  } else {
							  reason=oreason;
						  }
						  }
						  cancelpopup(sub_id,reason);
				          }
                         // $('#unsubscribemodel').toggleClass('show');
						  
				
                        });
						
				
	function openDialogView(int) {
			$("#dvDialog-ViewModal").find('.bookingcontent .modal-title').text($(int).data('name'));
			$("#dvDialog-ViewModal").find('.bookingcontent .topeventaddress').text($(int).data('addr'));
			$("#dvDialog-ViewModal").find('.bookingcontent .username').text($(int).data('username'));
			$("#dvDialog-ViewModal").find('.bookingcontent .topeventdatetime').text($(int).data('datetime'));
			$("#dvDialog-ViewModal").find('.bookingcontent .viewbkid').text($(int).data('bookingid'));
			$("#dvDialog-ViewModal").find('.bookingcontent .topeventticketqty').text($(int).data('qty'));
			$("#dvDialog-ViewModal").find('.topeventimg')[0].src = $(int).data('photo');
			$("#dvDialog-ViewModal").find('.topeventimgqr')[0].src = $(int).data('qr');
			
			$("#dvDialog-ViewModal").find('.bookingcontent .ttamount').text('$'+$(int).data('payment'));
			$('#dvDialog-ViewModal').fadeIn('fast', function () {
                                                $(this).find('.clsDialog-Box').slideDown('normal');
                                                $(this).find('.clsDialog-Box').css({'pointer-events': 'auto'});
                                            });
											
											
                                            
                                        }			
		function openDialog(int) {
			$("#dvDialog-Custom").find('.bookingcontent .modal-title').text($(int).data('name'));
			$("#dvDialog-Custom").find('.bookingcontent .topeventaddress').text($(int).data('addr'));
			$("#dvDialog-Custom").find('.bookingcontent .topeventdatetime').text($(int).data('datetime'));
			$("#dvDialog-Custom").find('.bookingcontent .topeventbookingid').text($(int).data('bookingid'));
			$("#dvDialog-Custom").find('.bookingcontent .topeventticketqty').text($(int).data('qty'));
			$("#dvDialog-Custom").find('.topeventimg')[0].src = $(int).data('photo');
			$("#dvDialog-Custom").find('#cancelkey').val($(int).data('cancelkey'));
			$("#dvDialog-Custom").find('.bookingcontent .ttcamount').text('$'+$(int).data('cancelcharges'));
			$("#dvDialog-Custom").find('.bookingcontent .ttramount').text('$'+$(int).data('refundamt'));
			$("#dvDialog-Custom").find('.bookingcontent .ttamount').text('$'+$(int).data('payment'));
			$('#dvDialog-Custom').fadeIn('fast', function () {
                                                $(this).find('.clsDialog-Box').slideDown('normal');
                                                $(this).find('.clsDialog-Box').css({'pointer-events': 'auto'});
                                            });
											
											
                                            
                                        }

                                        function closeDialog(id) {
											$('#monthlysavingdata').html('');
                                            $('#' + id).find('.clsDialog-Box').slideUp('fast', function () {
                                                $('#' + id).fadeOut('fast');
                                                $('#' + id).find('.clsDialog-Box').css({'pointer-events': 'none'});
                                            });
                                        }
</script>										
<script>

	$(function() {

		$( "#search_from_date" ).datepicker({

			changeMonth: true,

			changeYear: true,

			dateFormat:'yy-mm-dd' ,

			yearRange:'2014:<?php echo date('Y');  ?>',

			onClose: function( selectedDate ) {

            $( "#search_to_date" ).val(selectedDate);

            $( "#search_to_date" ).datepicker( "option", "minDate", selectedDate );

          }



		});

		$( "#search_to_date" ).datepicker({

			changeMonth: true,

			changeYear: true,

			numberOfMonths: 2,

			dateFormat:'yy-mm-dd' ,

			yearRange:'2014:<?php echo date('Y');  ?>',

			

          })

		  $( "#search_from_date" ).datepicker({

			changeMonth: true,

			changeYear: true,

			dateFormat:'yy-mm-dd' ,

			yearRange:'2014:<?php echo date('Y');  ?>',

			onClose: function( selectedDate ) {

            $( "#visit_date_to" ).val(selectedDate);

            $( "#visit_date_to" ).datepicker( "option", "minDate", selectedDate );

          }



		});

		$( "#search_to_date" ).datepicker({

			changeMonth: true,

			changeYear: true,

			numberOfMonths: 2,

			dateFormat:'yy-mm-dd' ,

			yearRange:'2014:<?php echo date('Y');  ?>',

			

          })



		});

	

	</script>
</body>

</html>