<?php session_start(); ob_start(); ?>

<?php  include 'header.php'; ?>

<?php

if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}


include("user.php");





?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>SP Meeting SMS</title>
    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">
    <!-- Styles -->
     <link href="assets/css/lib/data-table/buttons.bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/owl.carousel.min.css" rel="stylesheet" />
    <link href="assets/css/lib/owl.theme.default.min.css" rel="stylesheet" />
    <link href="assets/css/lib/weather-icons.css" rel="stylesheet" />
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/unix.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
	   <link href="assets/css/lib/select2/select2.min.css" rel="stylesheet">
</head>

<body>

    
	
	  <?php include("sidebar.php"); ?>
	
	
    <!-- /# sidebar -->
     <?php include("top.php"); ?>
	<!-- /# topebar --> 
	
	
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-8 p-r-0 title-margin-right">
                        <div class="page-header">
                            <div class="page-title">
                                <h1>Hello, <span>Welcome Here</span></h1>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                    <div class="col-lg-4 p-l-0 title-margin-left">
                        <div class="page-header">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li>
                                    <li class="active">Home</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                </div>
                <!-- /# row -->
				
					<?php if ($user_type==1){ ?>
				
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">SP Meeting SMS</div>
                                            <div class="panel-body">
											
											<?php
	$edit_id = $_GET["id"];

	?>
<?php

	if (isset($_POST['submit_sms'])) {
		
		$numbers=$_POST['numbers'];
		$numbersArray = explode(',', $numbers);
		$sms=$_POST['sms'];
		$smsContent=urlencode($sms);
		   $settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='sms_api' ");
           $settingsSQL = mysqli_fetch_object($settingsSQL);
           $sms_api = $settingsSQL->value;
		   
		   
		 
		foreach ($numbersArray as $number) {
        $fullNumber = '880' . substr(preg_replace('/\D/', '', $number), -10);
		  $orginal_text = ["%text%", "%number%"];
		  $replace_text = [$smsContent, $fullNumber];
		   $curl_url = str_replace($orginal_text, $replace_text, $sms_api);
		    $curl = curl_init();
		  curl_setopt_array($curl, array(
   CURLOPT_CONNECTTIMEOUT => 20,
  CURLOPT_TIMEOUT => 520,
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL =>$curl_url,
   CURLOPT_USERAGENT =>'jadukor IT Browser'
 ));
 
$resp = curl_exec($curl);
curl_close($curl);
        }
		
		
		
		
		  
           
			
		 
		
		 echo "<div>
 </br>
 </div>";
 include_once('updated.html');
	
		
	}

?>	

<?php

$settingsSQL = mysqli_query($connection, "SELECT * FROM `settings` where name='sp_no' ");
$settingsSQL = mysqli_fetch_object($settingsSQL);
$sp_no = $settingsSQL->value;

$eventSQL = mysqli_query($connection, "SELECT v1.* , GROUP_CONCAT(v2.name ORDER BY v2.id) as vd_names,GROUP_CONCAT(v2.mobile ORDER BY v2.id) as vd_mobile FROM (SELECT p1.* , GROUP_CONCAT(p2.name ORDER BY p2.id) as ph_names,GROUP_CONCAT(p2.mobile ORDER BY p2.id) as ph_mobile FROM (select a1.* , a2.name as event_type from (SELECT t1.*, t2.name as client_name, t2.booking_id,t2.booking_name, t2.cell_1,t2.cell_2 FROM `events` as t1 left join bookings as t2 on t1.temp_id=t2.id order by t1.date) as a1 left join event_types as a2 on a1.type=a2.id) as p1 left join artists as p2 ON FIND_IN_SET(p2.id, p1.photographers) group by p1.id) as v1 left join artists as v2 ON FIND_IN_SET(v2.id, v1.videographers) WHERE v1.id='$edit_id' group by v1.id ");
$eventSQL = mysqli_fetch_object($eventSQL);
									
                                    $idn = $eventSQL->id;
									$temp_id = $eventSQL->temp_id;
								    $date = $eventSQL->date;
									$date = date("d.m.y", strtotime($date));
									$name = $eventSQL->client_name;
									$diary_of = $eventSQL->booking_name;
									$booking_id = $eventSQL->booking_id;
									$cell_1 = $eventSQL->cell_1;
									$cell_2 = $eventSQL->cell_2;
									$event_type = $eventSQL->event_type;
									$venue = $eventSQL->venue;
									$time = $eventSQL->time;
									$time=strtotime($time);
									$time=date("h.i A", $time);
									$ph_package = $eventSQL->ph_package;
									$pr = $eventSQL->pr;
									$sp = $eventSQL->sp;
									$vd = $eventSQL->videoincluded;
									$photographers = $eventSQL->photographers;
									$ph_names = $eventSQL->ph_names;
									$vd_package = $eventSQL->vd_package;
									$videographers = $eventSQL->videographers;
									$vd_names = $eventSQL->vd_names;
									$vd_mobile = $eventSQL->vd_mobile;
									$ph_mobile = $eventSQL->ph_mobile;
									 $asst = $eventSQL->asst;
									 $makeover = $eventSQL->makeover;
									 	$ev_notes = $eventSQL->ev_notes;
										
										$ph_namesArray = explode(',', $ph_names);
										$photographersArray = explode(',', $photographers);
										$vd_namesArray = explode(',', $vd_names);
										$videographersArray = explode(',', $videographers);
										
										if($vd=="checked") {$mobilenos=$ph_mobile.",".$vd_mobile; }
										if($vd!="checked") {$mobilenos=$ph_mobile; }
										
									$SP_meetingrs = mysqli_query($connection, "SELECT * FROM `sp_meetings` WHERE `temp_id` = '$temp_id' ");
									$SP_meeting = mysqli_fetch_object($SP_meetingrs);
									$sprowcount = mysqli_num_rows($SP_meetingrs);
									if($sprowcount>0){
                                    $meeting_date= $SP_meeting->date; $meeting_date = date("M d, Y", strtotime($meeting_date));
                                    $meeting_time= $SP_meeting->time;	 $meeting_time=date("h.i A", $meeting_time);
                                    $meeting_status= $SP_meeting->status;								
									}	
										
											?>
						
                    <div class="row">
					<div class="card alert">
                                <div class="card-body">
					  <form action="sp_meeting_sms.php?id=<?php echo $idn; ?>" method="post">
					  	
                    <div class="row">
					   <div class="col-lg-12">SP<div class="form-group">			 
												<textarea name="numbers" cols="80"><?php echo $sp_no;  ?></textarea>
                          </div>
						  </div>
						  </div>
						<div class="row">  
						 <div class="col-lg-12">	
						 
												<textarea rows="8" cols="80" name="sms" ><?php echo $meeting_date; ?>&#13;Meeting Time: <?php echo $meeting_time; ?>
&#13;Client: <?php echo $diary_of; ?>
&#13;Client Cell: <?php echo $cell_1; ?>
&#13;Event: <?php echo $event_type; ?>
</textarea>
												
												

                           
						 </div>	
						 </div>
						 <div class="row">  
						 <div class="col-lg-12"><div class="form-group">			 
												<button class="btn btn-primary" type="submit" name="submit_sms" onclick="return confirm('Are you sure you want to send this sms ??');" >Send SMS</button>
                          </div>
						  
						
						  
						 </div>	
						 </div>	
					
					 </div>	
					 
					 
					   </form> 
					 
					
					   <form action="sp_meeting_sms.php?id=<?php echo $idn; ?>" method="post">
					  	
                    <div class="row">
					   <div class="col-lg-12">Client Cell No<div class="form-group">			 
												<textarea name="numbers" cols="80"><?php echo $cell_1;  ?></textarea>
                          </div>
						  </div>
						  </div>
						<div class="row">  
						 <div class="col-lg-12">	
						 
												<textarea rows="8" cols="80" name="sms" >Meeting With Sajib Paul @ <?php echo $meeting_date; ?>  <?php echo $meeting_time; ?>
&#13;Client: <?php echo $diary_of; ?>
&#13;Event: <?php echo $event_type; ?>
&#13;Venue: <?php echo $venue; ?></textarea>
												
												

                           
						 </div>	
						 </div>
						 <div class="row">  
						 <div class="col-lg-12"><div class="form-group">			 
												<button class="btn btn-primary" type="submit" name="submit_sms" onclick="return confirm('Are you sure you want to send this sms ??');" >Send SMS</button>
                          </div>
						  
						
						  
						 </div>	
						 </div>	
					
					 </div>	
					 
					 
					   </form> 
					 
					 
					  </div>	
					
					
                                  



                                   


							 </div> </div>
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                   
				   
				   
				           <?php include("footer.php"); ?>
						   
						   
                </section>
				
				
					<?php } ?>
            </div>
        </div>
    </div>

    <div id="search">
        <button type="button" class="close">×</button>
        <form>
            <input type="search" value="" placeholder="type keyword(s) here" />
            <button type="submit" class="btn btn-primary">Search</button>
        </form>
    </div>


    </div>
    <script src="assets/js/lib/jquery.min.js"></script>
    <!-- jquery vendor -->
    <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>
    <!-- nano scroller -->
    <script src="assets/js/lib/menubar/sidebar.js"></script>
    <script src="assets/js/lib/preloader/pace.min.js"></script>
    <!-- sidebar -->
    <script src="assets/js/lib/bootstrap.min.js"></script>
    <!-- bootstrap -->
   
    <script src="assets/js/scripts.js"></script>
	
	 <script src="assets/js/lib/data-table/datatables.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.dataTables.min.js"></script>
    <script src="assets/js/lib/data-table/dataTables.buttons.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.flash.min.js"></script>
    <script src="assets/js/lib/data-table/jszip.min.js"></script>
    <script src="assets/js/lib/data-table/pdfmake.min.js"></script>
    <script src="assets/js/lib/data-table/vfs_fonts.js"></script>
    <script src="assets/js/lib/data-table/buttons.html5.min.js"></script>
    <script src="assets/js/lib/data-table/buttons.print.min.js"></script>
    <script src="assets/js/lib/data-table/datatables-init.js"></script>
	
	<script>
        $(document).ready(function() {
            $('.select2').select2();
        });
    </script>

		 <script src="assets/js/lib/select2/select2.full.min.js"></script>
		 
		 
</body>

</html>